OpenCage requires OpenCV libraries (http://opencv.willowgarage.com). By itself OpenCV can decode a limited set of video formats (http://opencv.willowgarage.com/wiki/VideoCodecs), but it can decode more video formats using FFmpeg (http://www.ffmpeg.org/), or for Mac OS X using QuickTime plug-ins such as Perian (http://perian.org/).
The GUI requires Python. Python should already be installed under Ubuntu and Mac OS X 10.6 (type "which python" at the command prompt to verify), and for Windows it can be downloaded from http://www.python.org.
The postprocessing and analysis of the behavioral data use the R software, which can be downloaded from http://www.r-project.org
To compile OpenCage from the source-code you will need a C++ compiler.
For Ubuntu, gcc should already be installed.
For Mac OS X, gcc is included with Xcode. Xcode 3.0 used
to be (and perhaps still is) free with registration from
http://developer.apple.com/xcode. Xcode 4.0 is available
for $5 from the Apple App Store. Note that Xcode is a
large download (over 4GB).
For Windows, gcc is included with MinGW (http://www.mingw.org).
Instructions for installing MinGW, including changing the
environment variable for the path, are given at
http://www.mingw.org/wiki/InstallationHOWTOforMinGW
You will also need CMake, available from
http://www.cmake.org/
See http://opencv.willowgarage.com/wiki/ for instructions
on installing OpenCV and FFmpeg from source using CMake, and
see http://www.vtk.org/Wiki/ITK/Configuring_and_Building
for instructions on installing ITK from source using CMake.
TCLAP can be downloaded from http://tclap.sourceforge.net/
You can also try using apt-get to install OpenCV, ITK and TCLAP
on Ubuntu, or MacPorts to install OpenCV, ITK and TCLAP on OS X
--- we suggest using Google to find up-to-date instructions on
the latest library versions for your operating system.
OpenCage should work with version 2.0 or later of OpenCV.
After installing OpenCV, ITK and TCLAP, OpenCage can be built using
CMake. With some methods of installation we have had problems with
CMake auto-detecting the location of the OpenCV and ITK libraries.
In this case it may be necessary to manually edit the
CMakeLists.txt file to specify the locations of the headers and
libraries. For example the line FIND_PACKAGE(ITK) may need to be
changed to FIND_PACKAGE(ITK-3.16) or FIND_PACKAGE(ITK-3.18) depending
on how ITK was installed. Also, the names of some OpenCV libraries
have changed between OpenCV2.1 and OpenCV2.2, and
they sometimes have the version number included in the
filenames and sometimes not, so these should be adjusted as
needed, for example in the line
TARGET_LINK_LIBRARIES(opencage-bin ITKCommon ITKIO ITKNumerics -L/usr/local/lib
-lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_ml -lopencv_video
-lopencv_features2d -lopencv_calib3d -lopencv_objdetect -lopencv_contrib
-lopencv_legacy)
Also, in the line
INCLUDE_DIRECTORIES( ${OPENCV_INCLUDE_DIR} /opt/local/include)
the directory /opt/local/include should be changed to whatever directory
the header tclap.h was put in during the installation of TCLAP.
Then cd to the directory containing CMakeLists.txt type
ccmake .
set BUILD_TYPE to Release, generate the makefiles, and type
make
to compile opencage-bin
A) Install Xcode and MacPorts:
============================================
1) Install the Latest Version of Xcode Developer Tools.
Make sure that the command line development ("Unix Development") are installed.
2) Install (or Reinstall) MacPorts.
Download and install dmg from www.macports.org/
3) Update the MacPorts:
$ sudo port selfupdate
Note: If you have installed packages using port before, everything may need to be reinstalled
Save a list of installed ports:
$ port installed > myports.txt
Uninstall all installed ports:
$ sudo port -f uninstall installed
Clean
$ sudo port clean --work --archive all
Browse myports.txt and reinstall
$ sudo port install portname
B) Install OpenCV
==================================================================
$ sudo port install opencv
Note: By default OpenCV is installed in /opt/local. The openCV utilities are in /opt/local/bin/ ,the dynamic libraries are in /opt/local/lib/ , and the header files are in /opt/local/include/opencv/
The fastest way to build an OpenCV program is to use pkg-config to get the dependencies:
$ g++ `pkg-config --cflags --libs opencv` -o output your_program.cpp
Note that:
$ pkg-config --cflags --libs opencv
should tell you all the dependencies. if you encounter error with PKG_CONFIG_PATH make sure that you add a line in your bashrc to set the environment variable:
$ export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
$ export PKG_CONFIG_PATH=/opt/opencv/unix-install
C) Install cmake
==================================================================
$ sudo port install cmake
D) Install ITK toolkit
===================================================================
1) obtain the latest ITK package and uncompress it on your machine for example:
at /opt/InsightToolkit-3.18.0
2) Create a binary directory and cd into it
$ sudo mkdir /opt/ITK
$ cd /opt/ITK
3) Set the environment variables for CC and CXX
$ export CC=/usr/bin/gcc
$ export CXX=/usr/bin/g++
4) Type ccmake with argument source directory:
$ sudo ccmake ../InsightToolkit-3.18.0
5) click c to configure
set the BUILD_EXAMPLES to off
set the BUILD_SHARED_LIBRARIES to off
set BUILD_TESTING to off
set the CMAKE_BUILD_TYPE to Release
6) hit c to configure and if all has been going well, g to generate.
7) make and install
$ sudo make
$ sudo make install
E) Install TCLAP
===================================================================
$ sudo port install tclap
F) Unzip the OpenCage source code
============================================================================
E.g., unzipping to your home directory ~ will create a folder ~/OpenCage and various subdirectories
G) Compile the OpenCage software
=============================================================================
1) cd into the directory where you downloaded the program, e.g.
$ cd ~/OpenCage/trunk/cpp/Release
2) Find openCV link options by typing:
$ pkg-config --libs opencv
3) Modify the provided CMakeList.txt so that the last line TARGET_LINK_LIBRARIES() has the appropriate Link options:
ITK Links: ITKCommon ITKIO ITKNumerics
## add TCLAP location, as well!
openCV Links: -L option as found above. Copy and paste those.
The line should look something like this:
TARGET_LINK_LIBRARIES(opencage-bin ITKCommon ITKIO ITKNumerics -L/usr/local/lib
-lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_ml -lopencv_video
-lopencv_features2d -lopencv_calib3d -lopencv_objdetect -lopencv_contrib
-lopencv_legacy)
4) Modify the line INCLUDE_DIRECTORIES( ${OPENCV_INCLUDE_DIR} /opt/local/include)
to include the directory in which tclap.h was installed, if it was installed
somewhere other than /opt/local/include.
5) configure using ccmake
$ ccmake .
$ set the BUILD_TYPE to Release
NOTE: ITK_DIR and openCV_DIR must have been found automatically.
5) make
$ make
=============================================================================
Miscellaneous notes:
You may also install InsightToolkits using MacPorts. This can
take rather long, so we used the debug flag -d, mainly to see
that it has not frozen entirely:
$ sudo port -d install InsightToolkit -doc -python25 +shared
Because this installed a cmake file named itk-3.16-config.cmake,
we changed the line in OpenCage's CMakeList.txt file from
FIND_PACKAGE(ITK) to FIND_PACKAGE(ITK-3.16)
To uninstall Xcode, use the commmand
$ sudo /Developer/Library/uninstall-devtools -mode=all
If your MacPort installation includes more than one
version of python and the wrong version is being used
by default, you can use python_select to toggle between them:
$ sudo port install python_select
$ sudo python_select python26
or
$ sudo python_select python27