Welcome
-----------------

In this file, ">>" indicates a line to execute. The intent is that reading through this file while executing these lines provides a reasonable way to install and build SnapFind.

Notes
-----------------
-- SnapFind currently only supports ppm's and jpg's.


Building SnapFind - installing OpenCV
-----------------

Before starting you need to have built and install opencv 0.9.5.  SnapFind
requires that you build opencv with static libraries.  This can be done
at opencv configuration time by: 

  	./configure --enable-static=yes

If you want to install opencv in a non-default place, you need to specify
the option --prefix=<dir> also at configure.  This is a common option if
you don't have root access on the machine.  In this case to configure opencv
you should use:

	./configure --enable-static=yes --prefix=<writiable path>

After it configures, then run "make" and "make install".  NOTE: Compiling
SnapFind with opencv in a non-standard location will generate many warning
messages from the opencv include files.  Please ignore this.

In summary, execute:
>>(1) wget http://diamond.cs.cmu.edu/download/OpenCV-0.9.5.tar.gz
>>(2) tar xvfz OpenCV-0.9.5.tar.gz
>>(3) cd OpenCV-0.9.5
>>(4) ./configure --enable-static=yes
>>(5) make; make install



Building SnapFind
-----------------

If you are building from CVS, run autoreconf to generate the configure script.
>>(6) cd snapfind/src; autoreconf

You also need to have built the OpenDiamond Platform. The OpenDiamond
Platform does not need to be installed, but you must specify the path
when configuring SnapFind.

Then run configure 

	./configure --with-diamond=<somepath>  --with-opencv=<opencv install path>

where somepath is the top of the diamond build directory 
("somedir/diamond/target" if using the build tree).

Like the OpenDiamond Platform, SnapFind allows you to build the binaries to a directory outside the source tree. In option (b) following, we're assuming you also compiled the OpenDiamond Platform  into a different directory, named diamond-OBJS.
Thus either run:

>>(7a) cd snapfind/src
>>(7a) ./configure --with-diamond=/home/you/diamond/src/target --with-opencv=/usr/local

OR

>>(7b) cd ~; mkdir snapfind-OBJS
>>(7b) cd snapfind-OBJS
>>(7b) /home/you/snapfind/src/configure --with-diamond=/home/you/diamond-OBJS/target --with-opencv=/usr/local/lib


Once configure successfully builds, then build SnapFind 
using "make" at the top level.  If all goes well
the system should build.  The libraries, includes, and binaries
will be placed in target/{lib,include,bin}. 

>>(8) make

Running SnapFind
----------------
To run SnapFind you must have two configurations files.  The first
is called "gid_map" and the second is called "name_map".  The name_map
groups logical collections of files into one or more group numbers. 
SnapFind allows the user to select the groups id to search.  There must be
at least 1 collection defined.  The gid_map file is used to map
the each group to 1 or more OpenDiamond back-ends (IP addresses).  
If running standalone this should map the group to localhost, 
if running across a distributed set of machines, each group will 
list 1 or more machines that hold some of the data belonging to
that group.

There files are usually in ${HOME}/.diamond but can be in
other places (see OpenDiamond documentation).

>>(9) See OpenDiamond documentation (diamond/src/INSTALL) for setting up configuration files

One more configuration file needs to be added.
>>(10) cd .diamond; mkdir snapfind
>>(11) echo 'PLUGIN_DIR		/fullpath.../snapfind/src/target/lib' > snapfind/snapfindrc


To run SnapFind, you need to cd to target/bin in the build
tree and run SnapFind from there (due to current limitations in
the loading).

Running a null search will return and display all the images.

To load or save a search is a little tricky.  Searches are named by
the directory not a single config file.  So if you click load search
you will need to go into the directory of the search and click OK.
There is a sample_search in the directory called "sample_search" under
SnapFind.
	

>>(12) Start adiskd (see OpenDiamond documentation in opendiamond/src/INSTALL)
>>(11a) cd snapfind/src/target/bin; ./snapfind
OR
>>(11b) cd snapfind-OBJS/target/bin; ./snapfind



Installing OpenCV 0.9.7 Debian packages
---------------------------------------

SnapFind version 1.1.0 uses OpenCV 0.9.7, which is available in
Debian packaging.  To build or use SnapFind, the OpenCV packages
and their prerequisities must be installed.  First the prereqs:
	debhelper (>= 4.0.0), 
	quilt, 
	libjpeg62-dev, 
	zlib1g-dev, 
	libpng12-dev, 
	libtiff4-dev, 
	libraw1394-dev, 
	libdc1394-13-dev, 
	libgtk2.0-dev, 
	libavcodec-dev (>= 0.cvs20060329-1), 
	libavformat-dev, 
	python2.3-dev, 
	swig

To find some of the dev packages, make sure the package manager
checks the "Community maintained (Universe)" repository.  (In the
Synaptic package manager, go to settings->repositories->add and
check the "Community maintained (Universe) checkbox".

Now install the OpenCV packages:

	dpkg -i libcv0.9.7-0_0.9.7-2_i386.deb
	dpkg -i libcvaux0.9.7-0_0.9.7-2_i386.deb
	dpkg -i libhighgui0.9.7-0_0.9.7-2_i386.deb

These dev packages must be installed together because of circular 
dependencies:

	dpkg -i libcv-dev_0.9.7-2_i386.deb libcvaux-dev_0.9.7-2_i386.deb libhighgui-dev_0.9.7-2_i386.deb
	

Building Debian packages
------------------------

Debian packaging files are in the debian subdirectory.  To build the
debian packages from scratch, run the following from the SnapFind
source diretory, which must be named snapfind-<version>.

	cp -pr src snapfind-<version>
	cd snapfind-<version>
	fakeroot debian/rules clean

This will do a make clean.  Then build the source package.
	cd ..
	dpkg-source -b -ICVS -sn  snapfind-<version>

This will create the source package, which consists of:
	snapfind_<version>.tar.gz (source tarball)
	snapfind_<version>.dsc	(source summary)

Build the binary package:
	cd snapfind-<version>
	fakeroot debian/rules binary

This will create snapfind_<version>_<arch>.deb in the directory above.


Installing Debian packages
--------------------------
To install the binary package:
	dpkg -i snapfind_<version>_<arch>.deb

To unpack the source package:
	dpkg-source -x snapfind-<version>.dsc


Building RPMs
-------------

Use the alien package to build RPMs from debian files.
To build the binary package:
	alien -k -r snapfind_<version>_<arch>.deb

This will generate snapfind-<version>.<arch>.rpm

To build the source package:
	alien -k -r snapfind_<version>.tar.gz

This will generate snapfind_<version>.noarch.rpm
