Compile OpenCV without GPU? - opencv

I've just run cmake -D CMAKE_BUILD_TYPE=RELEASE .. from OpenCV/build, and got in my output:
-- OpenCV modules:
-- To be built: core imgproc flann highgui features2d calib3d ml video
objdetect contrib nonfree gpu legacy photo python
stitching ts videostab
-- Disabled: -
-- Disabled by dependency: -
-- Unavailable: androidcamera java world
The thing is, compilation with gpu fails, maybe because my machine doesn't have one? (It's an EC2 instance).
make fails with an odd error:
Scanning dependencies of target opencv_test_gpu
[ 72%] Building CXX object modules/gpu/CMakeFiles/opencv_test_gpu.dir/test/test_gpumat.cpp.o
[ 72%] Building CXX object modules/gpu/CMakeFiles/opencv_test_gpu.dir/test/utility.cpp.o
[ 73%] Building CXX object modules/gpu/CMakeFiles/opencv_test_gpu.dir/test/test_filters.cpp.o
[ 73%] Building CXX object modules/gpu/CMakeFiles/opencv_test_gpu.dir/test/test_copy_make_border.cpp.o
[ 73%] Building CXX object modules/gpu/CMakeFiles/opencv_test_gpu.dir/test/main.cpp.o
[ 73%] Building CXX object modules/gpu/CMakeFiles/opencv_test_gpu.dir/test/test_threshold.cpp.o
[ 73%] Building CXX object modules/gpu/CMakeFiles/opencv_test_gpu.dir/test/test_video.cpp.o
[ 73%] Building CXX object modules/gpu/CMakeFiles/opencv_test_gpu.dir/test/test_core.cpp.o
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.6/README.Bugs> for instructions.
make[2]: *** [modules/gpu/CMakeFiles/opencv_test_gpu.dir/test/test_core.cpp.o] Error 4
make[1]: *** [modules/gpu/CMakeFiles/opencv_test_gpu.dir/all] Error 2
make: *** [all] Error 2
I've tried using the flag -DOPENCV_MODULES_DISABLED_USER="gpu" but that produces weird output with gpu listed as to be built and disabled.
-- OpenCV modules:
-- To be built: core imgproc flann highgui features2d calib3d ml video objdetect contrib nonfree gpu legacy photo python stitching ts videostab
-- Disabled: gpu
-- Disabled by dependency: -
-- Unavailable: androidcamera java world
How do I compile without gpu?

To disable building a specific module, use
-D BUILD_opencv_{modulename}=OFF
In this case, use
-D BUILD_opencv_gpu=OFF

Try to add -D WITH_CUDA=OFF to your cmake command line.

For OpenCV 2.4.11 on EC2, I had to include both -D BUILD_opencv_gpu=OFF and -D WITH_CUDA=OFF. I also included -D WITH_1394=OFF to avoid a warning in python. So:
cd opencv-2.4.11/
mkdir release
cd release/
cmake -D BUILD_opencv_gpu=OFF -D WITH_CUDA=OFF -D WITH_1394=OFF -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..
make
sudo make install

This is caused by not having enough memory with your EC2 instance. I got a similar error (different module) with an EC2/Micro running Ubuntu 12.10, but it was smooth sailing on an EC2/Small.

The real question is , your device run out off memory.
This happens when gcc don't have enough memory. Trust me, since I had the same problem.

Had the same problem. It's a memory issue; increasing the swap space fixed it for me. Open a terminal and enter this:
free
dd if=/dev/zero of=/var/swap.img bs=1024k count=1000
mkswap /var/swap.img
swapon /var/swap.img
free
Then proceed with your make.
Source

I have fixed this particular problem in a most horrible way:
touch modules/gpu/CMakeFiles/opencv_test_gpu.dir/test/test_core.cpp.o
make
Compilation then completes ok. This isn't really a solution though, so I'd like to know if there's a proper fix.

Related

Make does not detect opencv_contrib even though I have it installed

I am trying to get this running https://github.com/Katou2/Optical_Flow_GPU_Opencv3 but am facing an issue where make does not detect my opencv_contrib module. Here are the steps that I have done up till cmake.
conda create -n opticalflow python=3.6 anaconda
conda activate opticalflow
git clone https://github.com/Katou2/Optical_Flow_GPU_Opencv3
cd Optical_Flow_GPU_Opencv3
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_CUDA=ON -D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules -D BUILD_TIFF=ON ..
And this is the output that I get with no error.
-- version: 4.2.0
-- OPENCV include: /home/haziq/anaconda3/pkgs/libopencv-4.2.0-py36_3/include/opencv4
-- OPENCV libs dir:
-- OPENCV libs: opencv_calib3dopencv_coreopencv_dnnopencv_features2dopencv_flannopencv_gapiopencv_highguiopencv_imgcodecsopencv_imgprocopencv_mlopencv_objdetectopencv_photoopencv_stitchingopencv_videoopencv_videoioopencv_arucoopencv_bgsegmopencv_bioinspiredopencv_ccalibopencv_cvvopencv_datasetsopencv_dnn_objdetectopencv_dnn_superresopencv_dpmopencv_faceopencv_freetypeopencv_fuzzyopencv_hdfopencv_hfsopencv_img_hashopencv_line_descriptoropencv_optflowopencv_phase_unwrappingopencv_plotopencv_qualityopencv_regopencv_rgbdopencv_saliencyopencv_shapeopencv_stereoopencv_structured_lightopencv_superresopencv_surface_matchingopencv_textopencv_trackingopencv_videostabopencv_xfeatures2dopencv_ximgprocopencv_xobjdetectopencv_xphoto
-- Configuring done
-- Generating done
-- Build files have been written to: /home/haziq/Optical_Flow_GPU_Opencv3/build
The problem comes when I run make.
Scanning dependencies of target compute_flow_autogen
[ 25%] Automatic MOC for target compute_flow
[ 25%] Built target compute_flow_autogen
Scanning dependencies of target compute_flow
[ 50%] Building CXX object CMakeFiles/compute_flow.dir/compute_flow.o
/home/haziq/Optical_Flow_GPU_Opencv3/compute_flow.cpp:38:10: fatal error: opencv2/cudaoptflow.hpp: No such file or directory
#include "opencv2/cudaoptflow.hpp"
^~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
CMakeFiles/compute_flow.dir/build.make:62: recipe for target 'CMakeFiles/compute_flow.dir/compute_flow.o' failed
make[2]: *** [CMakeFiles/compute_flow.dir/compute_flow.o] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/compute_flow.dir/all' failed
make[1]: *** [CMakeFiles/compute_flow.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
So the error mentions that the file opencv2/cudaoptflow.hpp is not found and I read through https://github.com/open-mmlab/mmaction/issues/39 says that the error is due to the opencv_contrib module not having been installed. However, I am certain that I already have opencv_contrib installed because I have this command executed.
pip install opencv-contrib-python
and have also verified it as I am able to call the cv2.xfeatures2d method which requires opencv_contrib to run.
import cv2
help(cv2.xfeatures2d) # cv2.xfeatures2d requires opencv_contrib

How to build opencv samples

I am new to cmake though not to make. This question is different from Could not build OpenCV Android sample project since that other question is about a single project and this one is looking at the overall CMakeLists.txt.
Speaking of which: consider the CMakeLists.txt in ${OPENCVDIR}/samples :
I followed basic process for cmake:
cd "${OPENCVDIR}/samples"
mkdir build
cd build
cmake ..
But at the last step I have:
$ cmake ..
CMake Error at CMakeLists.txt:72 (find_package):
Could not find a package configuration file provided by "OpenCV" with any
of the following names:
OpenCVConfig.cmake
opencv-config.cmake
Add the installation prefix of "OpenCV" to CMAKE_PREFIX_PATH or set
"OpenCV_DIR" to a directory containing one of the above files. If "OpenCV"
provides a separate development package or SDK, be sure it has been
installed.
-- Configuring incomplete, errors occurred!
See also "/git/opencv/samples/CMakeFiles/CMakeOutput.log".
Line 72 has this: find_package(OpenCV REQUIRED PATHS "..")
I looked at the error log and it was not informative.
Compilation of the CXX compiler identification source "CMakeCXXCompilerId.cpp" produced "a.out"
The CXX compiler identification is GNU, found in "/git/opencv/samples/CMakeFiles/3.13.4/CompilerIdCXX/a.out"
Determining if the C compiler works passed with the following output:
Change Dir: /git/opencv/samples/CMakeFiles/CMakeTmp
Run Build Command:"/usr/bin/make" "cmTC_26f76/fast"
/usr/bin/make -f CMakeFiles/cmTC_26f76.dir/build.make CMakeFiles/cmTC_26f76.dir/build
make[1]: Entering directory '/git/opencv/samples/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_26f76.dir/testCCompiler.c.o
/usr/bin/cc -o CMakeFiles/cmTC_26f76.dir/testCCompiler.c.o -c /git/opencv/samples/CMakeFiles/CMakeTmp/testCCompiler.c
Linking C executable cmTC_26f76
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_26f76.dir/link.txt --verbose=1
/usr/bin/cc -rdynamic CMakeFiles/cmTC_26f76.dir/testCCompiler.c.o -o cmTC_26f76
make[1]: Leaving directory '/git/opencv/samples/CMakeFiles/CMakeTmp'
Detecting C compiler ABI info compiled with the following output:
"/git/opencv/samples/CMakeFiles/CMakeOutput.log" 706 lines, 48095 characters
Feature record: CXX_FEATURE:0cxx_defaulted_move_initializers
Feature record: CXX_FEATURE:0cxx_delegating_constructors
Feature record: CXX_FEATURE:0cxx_deleted_functions
Feature record: CXX_FEATURE:0cxx_digit_separators
Feature record: CXX_FEATURE:0cxx_enum_forward_declarations
Feature record: CXX_FEATURE:0cxx_explicit_conversions
Feature record: CXX_FEATURE:0cxx_extended_friend_declar
etc ..
What is the correct way to build these examples - hopefully using the CMakeLists.txt already provided?
It seems the installation directory of OpenCV couldn't be found by cmake. Try to provide the value through the argument:
cmake -DCMAKE_PREFIX_PATH=/home/someone/src/opencv/install ..
Ff it works, you could define this in the top-level CMakeLitst.txt:
list(APPEND CMAKE_PREFIX_PATH /home/someone/src/opencv/install)
This should provide CMake the place where it should look to.
$ opencv_version
3.4.16
$ cd OpenCV/samples/
$ cmake -B build
$ cmake --build build
JPEG display
$ build/cpp/example_cpp_image data/lena.jpg
USB camera capture
$ build/cpp/example_cpp_videocapture_basic
$ build/cpp/example_cpp_videocapture_camera
Recognition by AI
$ build/tapi/example_tapi_hog

fbthrift: No generator named 'cpp2' could be found after (seemingly) successful build

I'm trying to install crnn which requires fblualib on Ubuntu 18.04 LTS. While building TH++, an error occured (Complete build print attached below):
[ 10%] Building CXX object CMakeFiles/thpp.dir/Storage.cpp.o
In file included from /home/huiji/Downloads/thpp-master/thpp/Storage.cpp:11:0:
/home/huiji/Downloads/thpp-master/thpp/../thpp/Storage.h:22:10: fatal error: thpp/if/gen-cpp2/Tensor_types.h: no such file or directory
#include **<thpp/if/gen-cpp2/Tensor_types.h>**
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If I build thpp without using fbthrift and folly by running THPP_NOFB=1 ./build.sh in the thpp directory, the build would be successful (I have thpp files in torch/install/include and torch/install/lib). However, if I move on and build fblualib, an almost identical error occurs:
[ 20%] Building CXX object CMakeFiles/fblualib.dir/LuaUtils.cpp.o
In file included from
/home/huiji/torch/install/include/thpp/Tensor.h:20:0,
from /home/huiji/Downloads/fblualib-master/fblualib/../fblualib/LuaUtils.h:19,
from /home/huiji/Downloads/fblualib- master/fblualib/LuaUtils.cpp:11:
/home/huiji/torch/install/include/thpp/Storage.h:22:10: fatal error:
thpp/if/gen-cpp2/Tensor_types.h: no such file or directory
#include <thpp/if/gen-cpp2/Tensor_types.h>
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
I figure that there may be something wrong with my fbthrift. Then I tried the following commands under directory "thpp/if/". It seems that my fbthrift can't generate a cpp2-format file, but can generate a cpp/py file, awhile my python thrift_compiler can only generate an errored cpp2-format file.
$ thrift --gen cpp2 Tensor.thrift
[WARNING:/home/huiji/Downloads/thpp-master/thpp/if/Tensor.thrift:1] No generator named 'cpp2' could be found!
[WARNING:generation:1] Unable to get a generator for "cpp2".
# Nothing was generated in /thpp/if
$ thrift --gen cpp Tensor.thrift && ls gen-cpp
[WARNING:/home/huiji/Downloads/thpp-master/thpp/if/Tensor.thrift:3] No generator named 'cpp2' could be found!
Tensor_constants.cpp Tensor_constants.h Tensor_types.cpp Tensor_types.h
$ thrift --gen py Tensor.thrift && ls -R gen-py
[WARNING:/home/huiji/Downloads/thpp-master/thpp/if/Tensor.thrift:3] No generator named 'cpp2' could be found!
gen-py:
__init__.py Tensor
gen-py/Tensor:
constants.py __init__.py ttypes.py
$ python -m thrift_compiler.main --gen cpp2 Tensor.thrift && ls gen-cpp2
Tensor_fatal_all.h Tensor_fatal.h Tensor_fatal_types.h
Tensor_fatal_constant.h Tensor_fatal_service.h Tensor_fatal_union.h
Tensor_fatal_enum.h Tensor_fatal_struct.h
# A "gen-cpp2" directory was created, but in it there was no "Tensor_types.h"!
$ python -m thrift_compiler.main --gen cpp Tensor.thrift
('Argument Error:', ArgumentError('Language cpp not defined.',))
$ python -m thrift_compiler.main --gen py Tensor.thrift
('Argument Error:', ArgumentError('Language py not defined.',))
By the way, my fbthrift install seemed successful except the python package thrift_compiler was not installed correctly. I've followed GitHubGS's suggestion. That seem to have worked (I can now import thrift_compiler in python, below is what I did) but as you can see, it is not really working.
1.modify /thrift/compiler/CMakefile.txt by inserting these lines
set(CMAKE_CXX_FLAGS "-fPIC")
set(CMAKE_C_FLAGS "-fPIC")
2.rebuild/reinstall fbthrift(must step)
3.run your command under /fbthrift/thrift/compiler/py
g++ -I /usr/include/python2.7 -I ../../.. -std=c++14 -fpic -shared -o frontend.so compiler.cc -lboost_python -lpython2.7 -L/build/lib -lcompiler_base -lcompiler_ast -lboost_system -lboost_filesystem -lssl -lcrypto
sudo cp frontend.so /usr/local/lib/python2.7/dist-packages/thrift_py-0.9.0-py2.7.egg/thrift_compiler
Any ideas/suggestions would be greatly appreciated.
=================
Complete message of thpp build:
huiji#NoBoDy:~/Downloads/thpp-master/thpp$ ./build.sh
If you don&apos;t have folly or thrift installed, try doing
THPP_NOFB=1 ./build.sh
-- The C compiler identification is GNU 7.3.0
-- The CXX compiler identification is GNU 7.3.0
-- Check for working C compiler: /usr/local/bin/gcc
-- Check for working C compiler: /usr/local/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/local/bin/g++
-- Check for working CXX compiler: /usr/local/bin/g++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found Torch7 in /home/huiji/torch/install
-- Found Folly: /usr/local/include
-- Found Thrift: /usr/local/include
-- Performing Test HAS_NO_AS_NEEDED
-- Performing Test HAS_NO_AS_NEEDED - Success
-- Found Glog: /usr/include
-- Found PythonInterp: /usr/bin/python (found version "2.7.15")
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
-- Configuring done
-- Generating done
-- Build files have been written to: /home/huiji/Downloads/thpp-master/thpp/build
[ 5%] Generating thpp/if/gen-cpp2/Tensor_data.h, thpp/if/gen-cpp2/Tensor_types.h, thpp/if/gen-cpp2/Tensor_types.tcc, thpp/if/gen-cpp2/Tensor_constants.h, thpp/if/gen-cpp2/Tensor_data.cpp, thpp/if/gen-cpp2/Tensor_types.cpp, thpp/if/gen-cpp2/Tensor_constants.cpp
Scanning dependencies of target thpp
[ 10%] Building CXX object CMakeFiles/thpp.dir/Storage.cpp.o
In file included from /home/huiji/Downloads/thpp-master/thpp/Storage.cpp:11:0:
/home/huiji/Downloads/thpp-master/thpp/../thpp/Storage.h:22:10: fatal error: thpp/if/gen-cpp2/Tensor_types.h: no such file or directory
#include <thpp/if/gen-cpp2/Tensor_types.h>
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
CMakeFiles/thpp.dir/build.make:84: recipe for target &apos;CMakeFiles/thpp.dir/Storage.cpp.o&apos; failed
make[2]: *** [CMakeFiles/thpp.dir/Storage.cpp.o] Error 1
CMakeFiles/Makefile2:67: recipe for target &apos;CMakeFiles/thpp.dir/all&apos; failed
make[1]: *** [CMakeFiles/thpp.dir/all] Error 2
Makefile:140: recipe for target &apos;all&apos; failed
make: *** [all] Error 2
Complete message of fblualib build:
huiji#NoBoDy:~/Downloads/fblualib-master/fblualib$ ./build.sh
-- The C compiler identification is GNU 7.3.0
-- The CXX compiler identification is GNU 7.3.0
-- Check for working C compiler: /usr/local/bin/gcc
-- Check for working C compiler: /usr/local/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/local/bin/g++
-- Check for working CXX compiler: /usr/local/bin/g++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found Folly: /usr/local/include
-- Found Glog: /usr/include
-- Found Torch7 in /home/huiji/torch/install
-- Found Folly: /home/huiji/torch/install/include
-- Configuring done
WARNING: Target "fblualib" requests linking to directory "/home/huiji/torch/install/lib". Targets may link only to libraries. CMake is dropping the item.
-- Generating done
-- Build files have been written to: /home/huiji/Downloads/fblualib-master/fblualib/build
Scanning dependencies of target fblualib
[ 20%] Building CXX object CMakeFiles/fblualib.dir/LuaUtils.cpp.o
In file included from /home/huiji/torch/install/include/thpp/Tensor.h:20:0,
from /home/huiji/Downloads/fblualib-master/fblualib/../fblualib/LuaUtils.h:19,
from /home/huiji/Downloads/fblualib-master/fblualib/LuaUtils.cpp:11:
/home/huiji/torch/install/include/thpp/Storage.h:22:10: fatal error: thpp/if/gen-cpp2/Tensor_types.h: no such file or directory
#include <thpp/if/gen-cpp2/Tensor_types.h>
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
CMakeFiles/fblualib.dir/build.make:62: recipe for target &apos;CMakeFiles/fblualib.dir/LuaUtils.cpp.o&apos; failed
make[2]: *** [CMakeFiles/fblualib.dir/LuaUtils.cpp.o] Error 1
CMakeFiles/Makefile2:67: recipe for target &apos;CMakeFiles/fblualib.dir/all&apos; failed
make[1]: *** [CMakeFiles/fblualib.dir/all] Error 2
Makefile:129: recipe for target &apos;all&apos; failed
make: *** [all] Error 2
Use thrift1 and mstch_cpp2 instead. It works for me!
See https://github.com/facebook/fbthrift/issues/271 and $THRIFT_INCLUDE is /usr/local/include/thrift/ in my system.
As one of the above answer mentioned, after building fbthrift successfully, you get bin/thrift1 binary in your build folder. You can then use the output thrift1 with generator mstch_cpp2.
./build/bin/thrift1 --gen mstch_cpp2 --templates ./thrift/compiler/generate/templates --out /tmp/ ./thrift/example/if/chatroom.thrift
Ref https://github.com/facebook/fbthrift/issues/303

Unable to add extra modules to OpenCV (even with matching versions of opencv/opencv_contrib)

I'm trying to install OpenCV with extra modules on a computer running Ubuntu 14.04.2 (I need this specific version of Ubuntu as I'm using some other hardware that requires it). I was able to do it on a Raspberry Pi 3 just last week (running Ubuntu Mate 16.04.3), but now I just can't seem to get it right.
I know that the opencv_contrib-version needs to be the same as the opencv-version, and I've tried building many different versions without luck (3.4.0, 3.3.0, 3.2.0, 3.1.0).
After downloading matching versions of opencv and opencv_contrib, I'm doing the following commands from the terminal:
$ cd opencv
$ mkdir build
$ cd build
$ cmake -D OPENCV_EXTRA_MODULES_PATH = ../../opencv_contrib/modules ..
where both opencv and opencv_contrib folders are located on the Desktop, so the "../../opencv_contrib/modules"-path should be correct.
But the extra modules aren't built. Here is parts of the cmake output:
-- OpenCV modules:
-- To be built: core flann imgproc ml objdetect photo video dnn imgcodecs shape videoio highgui superres ts features2d
calib3d stitching videostab
-- Disabled: world
-- Disabled by dependency: -
-- Unavailable: cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect
cudaoptflow cudastereo cudawarping cudev java python2 python3 viz
And as you can see, it's only the standard modules that are included. I've seen many people having the same issue, but the solution has always been about having the matching opencv/opencv_contrib versions. Now that I know that the versions are correct, I have no clue as to what I'm doing wrong.
You have extra spaces around the = in your cmake call, so the path does not get set correctly. Remove the two spaces and you should be fine:
cmake -D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules ..

How to install cvblob on ubuntu 12.04

I am trying to do blob detection in OpenCV on Ubuntu 12.04 system. I need to install cvblob library for this. So, i downloaded the zip file, extracted it and tried to run cmake. But everytime i run this
cmake . -DOpenCV_DIR=<directory path>
it shows the following error
bash: syntax error near unexpected token `newline'
and also the following error:
CMake Error: The source directory "/home/arvindnarayanan/Documents/cvblob" does not appear to contain CMakeLists.txt.
What do i do?
Both of your problems are essentially CMake issues, not cvblob issues.
Here is a full example how to compile cvblob on Ubuntu 12.04 LTS. It assumes OpenCV has been installed into the system successfully.
dev#dev:~$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=12.04
DISTRIB_CODENAME=precise
DISTRIB_DESCRIPTION="Ubuntu 12.04.3 LTS"
dev#dev:~$
First get cvblob sources from http://cvblob.googlecode.com/files/cvblob-0.10.4-src.tgz (the location of latest version at the moment of writing) and untar the package:
dev#dev:~$ tar xzvf cvblob-0.10.4-src.tgz
cvblob/
cvblob/CMakeLists.txt
cvblob/CMakeScripts/
cvblob/CMakeScripts/Toolchain-mingw32.cmake
cvblob/COPYING
cvblob/COPYING.LESSER
cvblob/ChangeLog
cvblob/Doxyfile
cvblob/README
cvblob/contrib/
cvblob/contrib/cvBlobDLL/
cvblob/contrib/cvBlobDLL/README
cvblob/contrib/cvBlobDLL/TestDLL/
cvblob/contrib/cvBlobDLL/TestDLL/Debug/
cvblob/contrib/cvBlobDLL/TestDLL/ReadMe.txt
cvblob/contrib/cvBlobDLL/TestDLL/Release/
cvblob/contrib/cvBlobDLL/TestDLL/TestDLL.c
cvblob/contrib/cvBlobDLL/TestDLL/TestDLL.vcproj
cvblob/contrib/cvBlobDLL/TestDLL/imgout.png
cvblob/contrib/cvBlobDLL/TestDLL/stdafx.cpp
cvblob/contrib/cvBlobDLL/TestDLL/stdafx.h
cvblob/contrib/cvBlobDLL/TestDLL/targetver.h
cvblob/contrib/cvBlobDLL/TestDLL/test.png
cvblob/contrib/cvBlobDLL/cvblobDLL/
cvblob/contrib/cvBlobDLL/cvblobDLL/Debug/
cvblob/contrib/cvBlobDLL/cvblobDLL/Release/
cvblob/contrib/cvBlobDLL/cvblobDLL/cvblobDLL.cpp
cvblob/contrib/cvBlobDLL/cvblobDLL/cvblobDLL.h
cvblob/contrib/cvBlobDLL/cvblobDLL/cvblobDLL.sln
cvblob/contrib/cvBlobDLL/cvblobDLL/cvblobDLL.suo
cvblob/contrib/cvBlobDLL/cvblobDLL/cvblobDLL.vcproj
cvblob/contrib/cvBlobDLL/cvblobDLL/dllmain.cpp
cvblob/contrib/cvBlobDLL/cvblobDLL/stdafx.cpp
cvblob/contrib/cvBlobDLL/cvblobDLL/stdafx.h
cvblob/contrib/cvBlobDLL/cvblobDLL/targetver.h
cvblob/cvBlob/
cvblob/cvBlob/CMakeLists.txt
cvblob/cvBlob/cvaux.cpp
cvblob/cvBlob/cvblob.cpp
cvblob/cvBlob/cvblob.h
cvblob/cvBlob/cvcolor.cpp
cvblob/cvBlob/cvcontour.cpp
cvblob/cvBlob/cvlabel.cpp
cvblob/cvBlob/cvtrack.cpp
cvblob/cvBlobConfig.cmake.in
cvblob/cvblob.pc.cmake.in
cvblob/doc/
cvblob/samples/
cvblob/samples/Makefile
cvblob/samples/red_object_tracking.cpp
cvblob/samples/red_object_tracking.txt
cvblob/test/
cvblob/test/CMakeLists.txt
cvblob/test/EnterExitCrossingPaths2front_blobs.mpeg
cvblob/test/EnterExitCrossingPaths2front_blobs.txt
cvblob/test/test.cpp
cvblob/test/test.png
cvblob/test/test_random.cpp
cvblob/test/test_tracking.cpp
dev#dev:~$
As you can see there is cvblob/CMakeLists.txt that is required by CMake. You get the second error because you're saying to CMake to look from wrong directory:
dev#dev:~$ cmake .
CMake Error: The source directory "/home/dev" does not appear to contain CMakeLists.txt.
Specify --help for usage, or press the help button on the CMake GUI.
dev#dev:~$
You get the first error because you didn't realize that <directory path> is a placeholder text you're supposed to replace with a real directory path:
dev#dev:~$ cmake . -DOpenCV_DIR=<directory path>
bash: syntax error near unexpected token `newline'
dev#dev:~$
Instead you should have written:
dev#dev:~$ cmake . -DOpenCV_DIR=/usr/local/
Where /usr/local/ is a real and correct path in your system.
So how to build the library correctly ?
dev#dev:~$ cd cvblob/
dev#dev:~/cvblob$ mkdir build
dev#dev:~/cvblob$ cd build
dev#dev:~/cvblob/build$ cmake ..
-- The C compiler identification is GNU
-- The CXX compiler identification is GNU
-- Check for working C compiler: /usr/bin/gcc
-- Check for working C compiler: /usr/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
running mkdir -p "/home/dev/cvblob/build/unix-install/" 2>&1
-- Configuring done
-- Generating done
-- Build files have been written to: /home/dev/cvblob/build
dev#dev:~/cvblob/build$ make
Scanning dependencies of target cvblob
[ 11%] Building CXX object lib/CMakeFiles/cvblob.dir/cvblob.o
[ 22%] Building CXX object lib/CMakeFiles/cvblob.dir/cvlabel.o
[ 33%] Building CXX object lib/CMakeFiles/cvblob.dir/cvaux.o
[ 44%] Building CXX object lib/CMakeFiles/cvblob.dir/cvcontour.o
[ 55%] Building CXX object lib/CMakeFiles/cvblob.dir/cvtrack.o
[ 66%] Building CXX object lib/CMakeFiles/cvblob.dir/cvcolor.o
Linking CXX shared library libcvblob.so
[ 66%] Built target cvblob
Scanning dependencies of target test
[ 77%] Building CXX object test/CMakeFiles/test.dir/test.o
Linking CXX executable ../bin/test
[ 77%] Built target test
Scanning dependencies of target test_random
[ 88%] Building CXX object test/CMakeFiles/test_random.dir/test_random.o
Linking CXX executable ../bin/test_random
[ 88%] Built target test_random
Scanning dependencies of target test_tracking
[100%] Building CXX object test/CMakeFiles/test_tracking.dir/test_tracking.o
Linking CXX executable ../bin/test_tracking
[100%] Built target test_tracking
dev#dev:~/cvblob/build$ sudo make install
[sudo] password for dev:
[ 66%] Built target cvblob
[ 77%] Built target test
[ 88%] Built target test_random
[100%] Built target test_tracking
Install the project...
-- Install configuration: "Release"
-- Installing: /usr/local/share/cvblob/cvBlobConfig.cmake
-- Installing: /usr/local/lib/pkgconfig/cvblob.pc
-- Installing: /usr/local/include/cvblob.h
-- Installing: /usr/local/lib/libcvblob.so
-- Removed runtime path from "/usr/local/lib/libcvblob.so"
dev#dev:~/cvblob/build$
you can try this url to download source for installation of cvblob
http://code.google.com/p/cvblob/downloads/detail?name=cvblob-0.10.4-src.tgz&can=2&q=
you required the support of cmake & make

Resources