-
Notifications
You must be signed in to change notification settings - Fork 13
One go at installing CV
This recipe describes one case on installing CV without using global installation locations. This recipe uses optional tools like stow and cabal-dev.
This was run on Ubuntu 10.04 LTS and a decent machine. I already had stuff installed, like the
- build-essential package & dev versions of libraries such as zlib.
- GHC 7.4.1
- cabal-install 0.10.2 using Cabal 1.10.1.0
- cabal-dev 0.9.1 (optional)
- and so on.
On my quite decent box there was 15-20 minutes worth of compiling.
Download OpenCV from http://opencv.willowgarage.com/wiki/
and follow good installation instructions at http://opencv.willowgarage.com/wiki/InstallGuide
deggis@Melchior:~$ cd temp
deggis@Melchior:~/temp$ mv /home/deggis/Downloads/OpenCV-2.3.1a.tar.bz2 .
deggis@Melchior:~/temp$ tar jxf OpenCV-2.3.1a.tar.bz2
deggis@Melchior:~/temp$ cd OpenCV-2.3.1/
deggis@Melchior:~/temp/OpenCV-2.3.1$ mkdir release && cd release
deggis@Melchior:~/temp/OpenCV-2.3.1/release$ cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/home/deggis/usr/local/ ..
It's possible to install to /usr/local as well. However, I like to keep changing things in separate place in my ~/usr/local.
After finding library & include locations CMAKE displays a thorough listing of what is going to be enabled in this build.
deggis@Melchior:~/temp/OpenCV-2.3.1/release$ time make
...
[100%] Building CXX object modules/stitching/CMakeFiles/opencv_stitching.dir/motion_estimators.o
[100%] Building CXX object modules/stitching/CMakeFiles/opencv_stitching.dir/precomp.o
Linking CXX executable ../../bin/opencv_stitching
[100%] Built target opencv_stitching
real 8m5.956s
Success.
deggis@Melchior:~/temp/OpenCV-2.3.1/release$ make install
deggis@Melchior:~/projects$ mkdir cv.smoketest && cd cv.smoketest
deggis@Melchior:~/projects/cv.smoketest$ cabal-dev
deggis@Melchior:~/projects/cv.smoketest$ time cabal-dev install CV --extra-lib-dirs=/home/deggis/usr/local/lib --extra-include-dirs=/home/deggis/usr/local/include
There's some packages depending on each other. Few minutes pass as armful of libraries are installing.
Oh bugger!
/home/deggis/projects/cv.smoketest/cabal-dev//lib/vector-0.9.1/ghc-7.4.1
cabal: The program c2hs version >=0.16.0 is required but it could not be
found.
cabal: Error: some packages failed to install:
CV-0.3.4 failed during the configure step. The exception was:
ExitFailure 1
real 3m8.857s
Here's a current issue. Compiling CV requires additional build tools, but they aren't fetched automatically. Let's install them manually.
I guess I'm going to be needing those often, so I'll install them without cabal-dev to my ~/.cabal/bin. With cabal-dev you should add current ./cabal-dev/bin to $PATH.
deggis@Melchior:~/projects/cv.smoketest$ time cabal install happy alex c2hs
[26 of 26] Compiling Main ( src/Main.hs, dist/build/c2hs/c2hs-tmp/Main.p_o )
Linking dist/build/c2hs/c2hs ...
Installing executable(s) in /home/deggis/.cabal/bin
Updating documentation index /home/deggis/.cabal/share/doc/index.html
real 2m18.676s
Let's try again.
deggis@Melchior:~/projects/cv.smoketest$ time cabal-dev install CV --extra-lib-dirs=/home/deggis/usr/local/lib --extra-include-dirs=/home/deggis/usr/local/include
c2hs: C header contains errors:
dist/build/CV/Video.chs.h:24: (column 32) [ERROR] >>> Unknown identifier!
Cannot find a definition for `CV_CAP_PROP_WHITE_BALANCE' in the header file.
cabal: Error: some packages failed to install:
CV-0.3.4 failed during the building phase. The exception was:
ExitFailure 1
real 0m6.984s
Uh, it turns out there was two things missing. Between OpenCV 2.2 and 2.3 there has been a changed #define and currently you need to specify opencv version with -fopencv23.
There's a ticket https://github.com/aleator/CV/issues/10 covering that issue now.
Also, when facing problems, cabal update (or checking out a dev version) might fix things.
deggis@Melchior:~/projects/cv.smoketest$ cabal update
Downloading the latest package list from hackage.haskell.org
Let's try one more time.
deggis@Melchior:~/projects/cv.smoketest$ time cabal-dev install CV --extra-lib-dirs=/home/deggis/usr/local/lib --extra-include-dirs=/home/deggis/usr/local/include -fopencv23
Installing library in
/home/deggis/projects/cv.smoketest/cabal-dev//lib/CV-0.3.5.3/ghc-7.4.1
Registering CV-0.3.5.3...
real 1m7.424s
Yeehaw! It seems cabal update also upgraded CV version from 0.3.4 to 0.3.5.3, which is also GHC 7.4.1 compatible.