How to install cvblob on ubuntu 12.04 - opencv

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

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

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

Docker build from Dockerfile with more memory

How to docker build from Dockerfile with more memory?
This is a different question from this Allow more memory when docker build a Dockerfile
When installing the software natively, there is enough memory to successfully build and install the marian tool
But when building the Docker image using the Dockerfile
https://github.com/marian-nmt/marian/blob/master/scripts/docker/Dockerfile.cpu , it fails with multiple memory exhausted errors
virtual memory exhausted: Cannot allocate memory
[out]:
Step : RUN cmake $MARIANPATH && make -j
---> Running in 4867d166d17a
-- The C compiler identification is GNU 5.4.0
-- The CXX compiler identification is GNU 5.4.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- 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/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CUDA_TOOLKIT_ROOT_DIR not found or specified
-- Cannot find CUDA libraries. Compiling without them.
-- Could NOT find CUDA (missing: CUDA_TOOLKIT_ROOT_DIR CUDA_NVCC_EXECUTABLE CUDA_INCLUDE_DIRS CUDA_CUDART_LIBRARY)
-- 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
-- Boost version: 1.58.0
-- Found the following Boost libraries:
-- system
-- filesystem
-- program_options
-- timer
-- iostreams
-- python
-- thread
-- chrono
-- regex
-- date_time
-- atomic
-- Found Python
-- Found PythonLibs: /usr/lib/x86_64-linux-gnu/libpython2.7.so (found suitable version "2.7.12", minimum required is "2.7")
-- Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (found version "1.2.8")
-- Found Git: /usr/bin/git (found version "2.7.4")
-- Git version: 5abc774
-- Found SparseHash: /usr/include
-- Configuring done
-- Generating done
-- Build files have been written to: /marian/build
Scanning dependencies of target fast_align
Scanning dependencies of target extract_lex
Scanning dependencies of target libcnpy
Scanning dependencies of target atools
Scanning dependencies of target libyaml-cpp-amun
[ 2%] Building CXX object src/amun/3rd_party/extract_lex/CMakeFiles/extract_lex.dir/exception.cpp.o
[ 2%] Building CXX object src/amun/3rd_party/extract_lex/CMakeFiles/extract_lex.dir/utils.cpp.o
[ 3%] Building CXX object src/amun/3rd_party/fast_align/CMakeFiles/fast_align.dir/src/ttables.cc.o
[ 6%] Building CXX object src/amun/3rd_party/fast_align/CMakeFiles/fast_align.dir/src/fast_align.cc.o
[ 7%] Building CXX object src/amun/3rd_party/extract_lex/CMakeFiles/extract_lex.dir/extract-lex-main.cpp.o
[ 10%] Building CXX object src/amun/3rd_party/CMakeFiles/libcnpy.dir/cnpy/cnpy.cpp.o
[ 10%] Building CXX object src/amun/3rd_party/fast_align/CMakeFiles/atools.dir/src/atools.cc.o
[ 10%] Building CXX object src/amun/3rd_party/fast_align/CMakeFiles/atools.dir/src/alignment_io.cc.o
[ 11%] Building CXX object src/amun/3rd_party/yaml-cpp/CMakeFiles/libyaml-cpp-amun.dir/regex_yaml.cpp.o
[ 12%] Building CXX object src/amun/3rd_party/yaml-cpp/CMakeFiles/libyaml-cpp-amun.dir/scanner.cpp.o
[ 14%] Building CXX object src/amun/3rd_party/yaml-cpp/CMakeFiles/libyaml-cpp-amun.dir/convert.cpp.o
[ 15%] Building CXX object src/amun/3rd_party/yaml-cpp/CMakeFiles/libyaml-cpp-amun.dir/stream.cpp.o
[ 16%] Building CXX object src/amun/3rd_party/yaml-cpp/CMakeFiles/libyaml-cpp-amun.dir/memory.cpp.o
[ 17%] Building CXX object src/amun/3rd_party/yaml-cpp/CMakeFiles/libyaml-cpp-amun.dir/node.cpp.o
[ 19%] Building CXX object src/amun/3rd_party/yaml-cpp/CMakeFiles/libyaml-cpp-amun.dir/directives.cpp.o
[ 20%] Building CXX object src/amun/3rd_party/yaml-cpp/CMakeFiles/libyaml-cpp-amun.dir/null.cpp.o
[ 21%] Building CXX object src/amun/3rd_party/yaml-cpp/CMakeFiles/libyaml-cpp-amun.dir/emitfromevents.cpp.o
[ 23%] Building CXX object src/amun/3rd_party/yaml-cpp/CMakeFiles/libyaml-cpp-amun.dir/singledocparser.cpp.o
[ 24%] Building CXX object src/amun/3rd_party/yaml-cpp/CMakeFiles/libyaml-cpp-amun.dir/emitterstate.cpp.o
[ 25%] Building CXX object src/amun/3rd_party/yaml-cpp/CMakeFiles/libyaml-cpp-amun.dir/scantag.cpp.o
[ 26%] Building CXX object src/amun/3rd_party/yaml-cpp/CMakeFiles/libyaml-cpp-amun.dir/simplekey.cpp.o
[ 28%] Building CXX object src/amun/3rd_party/yaml-cpp/CMakeFiles/libyaml-cpp-amun.dir/binary.cpp.o
[ 29%] Building CXX object src/amun/3rd_party/yaml-cpp/CMakeFiles/libyaml-cpp-amun.dir/parser.cpp.o
[ 30%] Building CXX object src/amun/3rd_party/yaml-cpp/CMakeFiles/libyaml-cpp-amun.dir/nodeevents.cpp.o
[ 32%] Building CXX object src/amun/3rd_party/yaml-cpp/CMakeFiles/libyaml-cpp-amun.dir/emit.cpp.o
[ 33%] Building CXX object src/amun/3rd_party/yaml-cpp/CMakeFiles/libyaml-cpp-amun.dir/exp.cpp.o
[ 35%] Building CXX object src/amun/3rd_party/yaml-cpp/CMakeFiles/libyaml-cpp-amun.dir/nodebuilder.cpp.o
[ 38%] Building CXX object src/amun/3rd_party/yaml-cpp/CMakeFiles/libyaml-cpp-amun.dir/scanscalar.cpp.o
[ 39%] Building CXX object src/amun/3rd_party/yaml-cpp/CMakeFiles/libyaml-cpp-amun.dir/emitter.cpp.o
[ 41%] Building CXX object src/amun/3rd_party/yaml-cpp/CMakeFiles/libyaml-cpp-amun.dir/tag.cpp.o
[ 42%] Building CXX object src/amun/3rd_party/yaml-cpp/CMakeFiles/libyaml-cpp-amun.dir/scantoken.cpp.o
[ 43%] Building CXX object src/amun/3rd_party/yaml-cpp/CMakeFiles/libyaml-cpp-amun.dir/ostream_wrapper.cpp.o
Scanning dependencies of target libcommon
[ 37%] Building CXX object src/amun/3rd_party/yaml-cpp/CMakeFiles/libyaml-cpp-amun.dir/node_data.cpp.o
[ 44%] Building CXX object src/amun/3rd_party/yaml-cpp/CMakeFiles/libyaml-cpp-amun.dir/contrib/graphbuilder.cpp.o
[ 46%] Building CXX object src/amun/3rd_party/yaml-cpp/CMakeFiles/libyaml-cpp-amun.dir/emitterutils.cpp.o
[ 34%] Building CXX object src/amun/3rd_party/yaml-cpp/CMakeFiles/libyaml-cpp-amun.dir/contrib/graphbuilderadapter.cpp.o
[ 47%] Building CXX object src/amun/3rd_party/yaml-cpp/CMakeFiles/libyaml-cpp-amun.dir/parse.cpp.o
[ 48%] Building CXX object src/amun/CMakeFiles/libcommon.dir/common/scorer.cpp.o
[ 50%] Building CXX object src/amun/CMakeFiles/libcommon.dir/common/git_version.cpp.o
[ 51%] Building CXX object src/amun/CMakeFiles/libcommon.dir/common/base_matrix.cpp.o
[ 52%] Building CXX object src/amun/CMakeFiles/libcommon.dir/common/sentence.cpp.o
[ 53%] Building CXX object src/amun/CMakeFiles/libcommon.dir/common/config.cpp.o
[ 55%] Building CXX object src/amun/CMakeFiles/libcommon.dir/common/utils.cpp.o
[ 56%] Building CXX object src/amun/CMakeFiles/libcommon.dir/common/vocab.cpp.o
[ 65%] Building CXX object src/amun/CMakeFiles/libcommon.dir/common/filter.cpp.o
[ 66%] Building CXX object src/amun/CMakeFiles/libcommon.dir/common/god.cpp.o
[ 67%] Building CXX object src/amun/CMakeFiles/libcommon.dir/common/exception.cpp.o
[ 69%] Building CXX object src/amun/CMakeFiles/libcommon.dir/common/search.cpp.o
[ 69%] Building CXX object src/amun/CMakeFiles/libcommon.dir/common/hypothesis.cpp.o
[ 70%] Building CXX object src/amun/CMakeFiles/libcommon.dir/common/translation_task.cpp.o
[ 70%] Building CXX object src/amun/CMakeFiles/libcommon.dir/common/printer.cpp.o
[ 70%] Building CXX object src/amun/CMakeFiles/libcommon.dir/common/sentences.cpp.o
[ 70%] Building CXX object src/amun/CMakeFiles/libcommon.dir/common/history.cpp.o
[ 70%] Building CXX object src/amun/CMakeFiles/libcommon.dir/common/logging.cpp.o
[ 70%] Building CXX object src/amun/CMakeFiles/libcommon.dir/common/processor/bpe.cpp.o
[ 71%] Building CXX object src/amun/CMakeFiles/libcommon.dir/common/output_collector.cpp.o
[ 73%] Building CXX object src/amun/CMakeFiles/libcommon.dir/common/types.cpp.o
[ 74%] Building CXX object src/amun/CMakeFiles/libcommon.dir/common/loader.cpp.o
virtual memory exhausted: Cannot allocate memory
virtual memory exhausted: Cannot allocate memory
virtual memory exhausted: Cannot allocate memory
And eventually it leads to:
src/amun/CMakeFiles/libcommon.dir/build.make:254: recipe for target 'src/amun/CMakeFiles/libcommon.dir/common/loader.cpp.o' failed
virtual memory exhausted: Cannot allocate memory
make[2]: *** [src/amun/CMakeFiles/cpumode.dir/cpu/decoder/encoder_decoder.cpp.o] Error 1
src/amun/CMakeFiles/cpumode.dir/build.make:110: recipe for target 'src/amun/CMakeFiles/cpumode.dir/cpu/decoder/encoder_decoder.cpp.o' failed
[ 79%] Built target libcnpy
virtual memory exhausted: Cannot allocate memory
src/amun/CMakeFiles/libcommon.dir/build.make:326: recipe for target 'src/amun/CMakeFiles/libcommon.dir/common/printer.cpp.o' failed
make[2]: *** [src/amun/CMakeFiles/libcommon.dir/common/printer.cpp.o] Error 1
CMakeFiles/Makefile2:340: recipe for target 'src/amun/3rd_party/yaml-cpp/CMakeFiles/libyaml-cpp-amun.dir/all' failed
make[1]: *** [src/amun/3rd_party/yaml-cpp/CMakeFiles/libyaml-cpp-amun.dir/all] Error 2
CMakeFiles/Makefile2:182: recipe for target 'src/amun/CMakeFiles/libcommon.dir/all' failed
make[1]: *** [src/amun/CMakeFiles/libcommon.dir/all] Error 2
make[1]: *** [src/amun/CMakeFiles/cpumode.dir/all] Error 2
CMakeFiles/Makefile2:110: recipe for target 'src/amun/CMakeFiles/cpumode.dir/all' failed
make: *** [all] Error 2
Looking at the docker build --help, there are options to control memory usage:
$ docker build --help
Usage: docker build [OPTIONS] PATH | URL | -
Build an image from a Dockerfile
Options:
--build-arg list Set build-time variables (default [])
--cache-from stringSlice Images to consider as cache sources
--cgroup-parent string Optional parent cgroup for the container
--compress Compress the build context using gzip
--cpu-period int Limit the CPU CFS (Completely Fair Scheduler) period
--cpu-quota int Limit the CPU CFS (Completely Fair Scheduler) quota
-c, --cpu-shares int CPU shares (relative weight)
--cpuset-cpus string CPUs in which to allow execution (0-3, 0,1)
--cpuset-mems string MEMs in which to allow execution (0-3, 0,1)
--disable-content-trust Skip image verification (default true)
-f, --file string Name of the Dockerfile (Default is 'PATH/Dockerfile')
--force-rm Always remove intermediate containers
--help Print usage
--isolation string Container isolation technology
--label list Set metadata for an image (default [])
-m, --memory string Memory limit
--memory-swap string Swap limit equal to memory plus swap: '-1' to enable unlimited swap
--network string Set the networking mode for the RUN instructions during build (default "default")
--no-cache Do not use cache when building the image
--pull Always attempt to pull a newer version of the image
-q, --quiet Suppress the build output and print image ID on success
--rm Remove intermediate containers after a successful build (default true)
--security-opt stringSlice Security options
--shm-size string Size of /dev/shm, default value is 64MB
-t, --tag list Name and optionally a tag in the 'name:tag' format (default [])
--ulimit ulimit Ulimit options (default [])
But I couldn't figure out the correct syntax of where exactly to put the -m option -_-|||
It isn't before the Dockerfile:
# Before Docker file.
$ docker build -m 4g Dockerfile.cpu -t ibot-cpu .
"docker build" requires exactly 1 argument(s).
See 'docker build --help'.
Usage: docker build [OPTIONS] PATH | URL | -
Build an image from a Dockerfile
It isn't after Dockerfile before -t
# Before -t
$ docker build Dockerfile.cpu -m 4g -t ibot-cpu .
"docker build" requires exactly 1 argument(s).
See 'docker build --help'.
Usage: docker build [OPTIONS] PATH | URL | -
Build an image from a Dockerfile
It isn't after -t before the local path
# Before local path
$ docker build Dockerfile.cpu -t ibot-cpu -m 4g .
"docker build" requires exactly 1 argument(s).
See 'docker build --help'.
Usage: docker build [OPTIONS] PATH | URL | -
Build an image from a Dockerfile
It isn't after the local path at the end too...
# At the end...
$ docker build Dockerfile.cpu -t ibot-cpu . -m 4g
"docker build" requires exactly 1 argument(s).
See 'docker build --help'.
Usage: docker build [OPTIONS] PATH | URL | -
Build an image from a Dockerfile
How to docker build from Dockerfile with more memory?
My docker version:
docker version
Client:
Version: 17.03.1-ce
API version: 1.27
Go version: go1.7.5
Git commit: c6d412e
Built: Tue Mar 28 00:40:02 2017
OS/Arch: darwin/amd64
Server:
Version: 17.04.0-ce
API version: 1.28 (minimum version 1.12)
Go version: go1.7.5
Git commit: 4845c56
Built: Wed Apr 5 18:45:47 2017
OS/Arch: linux/amd64
Experimental: false
It is not something about order. The Dockerfile must be specified with -f
docker build -f Dockerfile.cpu -t ibot-cpu -m 4g .
However, take into account that by default docker does not limit the container memory. It can take the whole free memory.
As I can see that you are on OSX, which runs docker over a Linux VM. Configure the max memory clicking the whale icon in the task bar. It's 2GB by default.
For further information please see my other answer:
How to assign more memory to docker container

How to find OpenCV installed in /usr/local when building ROS node

I am using ROS Kinetic with OpenCV. I created a node that uses CUDA implemented algorithms of OpenCV (which are not available in the ros-kinetic-opencv3 package) so I compiled OpenCV from source with CUDA enabled and installed it in /usr/local.
To test if my /usr/local installation was working as expected (and if my code was correct) I created a program, outside of ROS, with the following CMakeList.txt:
cmake_minimum_required(VERSION 2.8.3)
project(stereo_algorithms_testing)
set(ENV{OpenCV_DIR} "/usr/local")
find_package(OpenCV REQUIRED)
include_directories(include ${OpenCV_INCLUDE_DIRS})
add_executable(stereo_algorithms main.cpp)
target_link_libraries(stereo_algorithms ${OpenCV_LIBS})
When I run cmake ., I get the following output:
-- The C compiler identification is GNU 5.4.0
-- The CXX compiler identification is GNU 5.4.0
-- 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
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/g++
-- Check for working CXX compiler: /usr/bin/g++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- 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
-- Found CUDA: /usr/local/cuda (found suitable exact version "8.0")
-- Found OpenCV: /usr/local (found version "3.2.0")
-- Configuring done
-- Generating done
-- Build files have been written to: /home/degraw/Opencv_testing/stereo_algorithms/test
All is well, and the code runs as expected with no runtime errors.
Now when I use the same code in a ROS node I have the following CMakeList.txt:
cmake_minimum_required(VERSION 2.8.3)
project(depth_calculator)
set(ENV{OpenCV_DIR} "/usr/local")
find_package(OpenCV REQUIRED core highgui calib3d PATHS /usr/local NO_DEFAULT_PATH)
find_package(catkin REQUIRED COMPONENTS cv_bridge image_transport)
catkin_package()
include_directories(include ${OpenCV_INCLUDE_DIRS} ${catkin_INCLUDE_DIRS})
add_executable(double_image_acq src/double_image_acquisition.cpp)
target_link_libraries(double_image_acq ${OpenCV_LIBS} ${catkin_LIBRARIES})
Notice that I explicitly tell cmake to only look for OpenCV in /usr/local.
The output of catkin_make is:
-- Using CATKIN_DEVEL_PREFIX: /home/degraw/catkin_ws/devel
-- Using CMAKE_PREFIX_PATH: /home/degraw/catkin_ws/devel;/usr/local;/opt/ros/kinetic
-- This workspace overlays: /home/degraw/catkin_ws/devel;/opt/ros/kinetic
-- Using PYTHON_EXECUTABLE: /usr/bin/python
-- Using Debian Python package layout
-- Using empy: /usr/bin/empy
-- Using CATKIN_ENABLE_TESTING: ON
-- Call enable_testing()
-- Using CATKIN_TEST_RESULTS_DIR: /home/degraw/catkin_ws/build/test_results
-- Found gtest sources under '/usr/src/gtest': gtests will be built
-- Using Python nosetests: /usr/bin/nosetests-2.7
-- catkin 0.7.6
-- BUILD_SHARED_LIBS is on
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- ~~ traversing 2 packages in topological order:
-- ~~ - depth_calculator
-- ~~ - zed_wrapper
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- +++ processing catkin package: 'depth_calculator'
-- ==> add_subdirectory(depth_calculator)
-- Found OpenCV: /opt/ros/kinetic (found version "3.2.0") found components: core highgui calib3d
...
...
...
Running command: "make -j4 -l4" in "/home/degraw/catkin_ws/build"
[ 14%] Built target zed_wrapper_gencfg
[ 28%] Linking CXX executable /home/degraw/catkin_ws/devel/lib/depth_calculator/double_image_acq
[ 57%] Built target ZEDWrapper
[ 85%] Built target zed_wrapper_node
CMakeFiles/double_image_acq.dir/src/double_image_acquisition.cpp.o: In function `OpencvDisparityCalculator::callback(boost::shared_ptr<sensor_msgs::Image_<std::allocator<void> > const> const&, boost::shared_ptr<sensor_msgs::Image_<std::allocator<void> > const> const&)':
double_image_acquisition.cpp:(.text._ZN25OpencvDisparityCalculator8callbackERKN5boost10shared_ptrIKN11sensor_msgs6Image_ISaIvEEEEES9_[_ZN25OpencvDisparityCalculator8callbackERKN5boost10shared_ptrIKN11sensor_msgs6Image_ISaIvEEEEES9_]+0x1ad): undefined reference to `cv::cuda::createStereoBM(int, int)'
collect2: error: ld returned 1 exit status
depth_calculator/CMakeFiles/double_image_acq.dir/build.make:175: recipe for target '/home/degraw/catkin_ws/devel/lib/depth_calculator/double_image_acq' failed
make[2]: *** [/home/degraw/catkin_ws/devel/lib/depth_calculator/double_image_acq] Error 1
CMakeFiles/Makefile2:353: recipe for target 'depth_calculator/CMakeFiles/double_image_acq.dir/all' failed
make[1]: *** [depth_calculator/CMakeFiles/double_image_acq.dir/all] Error 2
Makefile:138: recipe for target 'all' failed
make: *** [all] Error 2
Invoking "make -j4 -l4" failed
Obviously it's a linker issue. It finds the wrong OpenCV (the ROS OpenCV) which does not include the libraries for CUDA.
How can I tell catkin_make to find the OpenCV in /usr/local?

Compile OpenCV without GPU?

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.

Resources