Issue building OpenCV with ccache and CUDA - opencv

Trying to build OpenCV 3.3.1 with CUDA support, using ccache:
Ubuntu 16.04 LTS
OpenCV 3.3.1
CUDA 8.0
CCACHE 3.2.4
Make fails for .cu files, giving error:
/usr/bin/ccache: invalid option -- 'E'
Usage:
ccache [options] ...
I've added the /usr/lib/ccache to PATH, which cc and which c++ outputs /usr/lib/ccache/cc and /usr/lib/ccache/c++ respectively. Manually added a symlink for nvcc in /usr/lib/ccache directory, but now OpenCV CMakeLists.txt cannot find CUDA.
But interestingly I can build this sample CUDA code, with this CMake file without any issue.
I've searched the net and read most posts on SO and other forums, but had no success. I've had this issue for previous versions of OpenCV as well, but always disabled ccache as a solution.
Can someone please explain the reason behind this error?

Trying to set
-DCUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda
seems to solve this problem for me.

Related

Why cv_bridge uses OpenCV 3.2 in ROS Melodic?

I have OpenCV 3.4 installed in Ubuntu 18. I also have installed ROS Melodic according to the website instructions. However, I keep on getting an error that libopencv_core.so.3.2 is required.
I already set my CMakeLists files to point to OpenCV 3.4.
However, I found out that in the file:
/ros/melodic/share/cv_bridge/cmake/cv_bridgeConfig.cmake
there is the following line hardcoded in opencv3.2:
set(libraries "cv_bridge;/usr/lib/x86_64-linux-gnu/libopencv_core.so.3.2.0;/usr/lib/x86_64-linux-gnu/libopencv_imgproc.so.3.2.0;/usr/lib/x86_64-linux-gnu/libopencv_imgcodecs.so.3.2.0").
I tried to change it to 3.4 but I can not rebuild it.
The error I am getting is:
/opt/ros/melodic/lib/image_view/image_view: error while loading shared libraries: libopencv_core.so.3.2: cannot open shared object file: No such file or directory
Why is OpenCV 3.2 hardcoded in cv_bridge and how can I rebuild it with OpenCV 3.4?
Update:
I eventually installed OpenCV 3.2 and it worked properly.
Because opencv development speed is much faster than ROS individual module. And a lot of ROS modules went depreciated after someone left the job.
But that's by no means the end of the day( maybe end of the day for noobs). You can build it directly with any version of opencv core function(besides imshow kind of function) others should perform just fine.
The easiest way is to do is: in the console before executing catkin_make try to execute the following
export CMAKE_PREFIX_PATH=/usr/local:$CMAKE_PREFIX_PATH
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
This should give preference to your custom OpenCV installation when doing the find_package(OpenCV 3.X.0 REQUIRED). Then compile and use the function of that version.
Well if you do have to use 3.4 then I think you have to build ros version of opencv and image transport and cvbridge to the 3.4 if that's what you are targeting.
You can find the link here https://github.com/ros-gbp/opencv3-release The highest they provide seems to be 3.3

How to build openCV 3.3.0 with GStreamer on Windows

Having Gstreamer 1.22 successfully installed I'm not able to configure the project to build OpenCV. CMake isn't able to find GStreamer on my machine. Any ideas how two address this issue?
Just found the solution:
Cmake is using FindGstreamerWindows.cmake to find GStreamer on Windows, which is using internal an environment variable called "GSTREAMER_DIR" pointing to ..\gstreamer\1.0\x86_64.
Please make sure GSTREAMER_DIR exists on your machine.
I recently compile Opencv 4.2 with GStreamer on Windows. I use settings for GStreamer as on the following pictures. Make sure you point to correct .lib and include directories. all_Library is gstapp-1.0.lib etc, when configuraing CMAKE to compile OpenCV.
I use Opencv 4.2, CMake 3.17.0 release candidate and Gstreamer 1.16.2 MSVC 64-bit (VS 2019) developer and runtime installer. The whole process is described here install OpenCV on windows GStreamer tutorial
The important part is to set up environmental variables to find Gstreamer Runtime. Into system variable path: add
xxx\1.0\x86_64\bin
xxx\1.0\x86_64\lib
xxx\1.0\x86_64\lib\gstreamer-1.0
Gstreamer pipe from c++ opencv program to the web.

Code Blocks OpenCV build failed

Having an issue with trying to build any opencv version with code::blocks.
I've have built opencv successfully before and have no idea what the issue is.
I've tried following many different tutorials on building opencv using mingw 4.9.2 and CMake. I have also tried using mingw32 and mingw64.
But I continue to receive the errors shown in the image above.
My question is; What is the issue? How can I fix this? And, lastly, what am I doing wrong?
Found that the version of OpenCV I was using had issues with MinGW. Tested a whole bunch of OpenCV versions (3.3, 3.2, 3.1, 2.4.13, 2.4.13.3).
I found that OpenCV version 2.4.9 with the latest version of CMake and MinGW worked.
Thought I'd leave this here to help anyone else having issues with creating OpenCV to work with MinGW/Code::Blocks

Caffe with OpenCV 3 and NVIDIA Digits: OpenCV version conflict (2.4 vs 3.0)

Background:
I wish to use both Caffe and Digits such that I can use Caffe within the Digits framework or external to it.
However, for a particular project, I require that Caffe uses OpenCV 3 and not OpenCV 2.4, which Digits installs by default. This project uses Caffe external to Digits, and does not make any use of the Digits framework.
It appears that by installing Digits, my OpenCV 3 installation was "clobbered" with OpenCV 2.4, which is now causing problems within my original Caffe installation.
To make things clearer, below is a listing of the steps that I have taken.
From a fresh Ubuntu 14.04 installation:
Installed Caffe dependencies (except OpenCV) as per the Ubuntu
install guide
Installed OpenCV 3 from source to /usr/local
Tested OpenCV installation
Demos worked fine including OpenCV
3-specific code
Compiled Caffe, setting the Makefile.config to use OpenCV 3
Tested Caffe installation
All tests passed, demos worked fine
Installed Digits as per the install guide
Caffe and OpenCV 2.4 were installed by default by the installer script
OpenCV 3 clobbered by OpenCV 2.4 (?)
Carried out the steps from the Digits Getting Started guide
All steps were successful
Suspected OpenCV conflict, so tried to compile a Caffe demo
Error occurred relating to OpenCV 3.0 and 2.4 conflict -- details below.
Compilation command:
g++ classification.cpp -o classification -I/home/josh/software/caffe/include/ -L/home/josh/software/caffe/build/lib/ -lcaffe -I/usr/local/cuda/include -L/usr/local/cuda/lib64 -lcuda -lcudart -lcublas -lcurand -I/home/josh/software/cudnn/include/ -L/home/josh/software/cudnn/lib64/ -lcudnn -L/usr/lib/x86_64-linux-gnu/ -lglog -L/usr/local/lib -lboost_system -lopencv_core -lopencv_highgui -lopencv_imgproc -lopencv_imgcodecs -DUSE_OPENCV
Error message:
/usr/bin/ld: warning: libopencv_core.so.3.0, needed by /home/josh/software/caffe/build/lib//libcaffe.so, may conflict with libopencv_core.so.2.4
/usr/bin/ld: /tmp/ccHaWcOl.o: undefined reference to symbol '_ZN2cv6String10deallocateEv'
//usr/local/lib/libopencv_core.so.3.0: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
Questions:
How do I best resolve the OpenCV version conflict without breaking either Caffe/Digits installations?
Do I need to remove OpenCV and reinstall Caffe and Digits?
If so, what do I need to do differently to prevent the OpenCV version conflicts while still allowing Caffe (with OpenCV 3) and Digits to work side-by-side?
When OpenCV library is installed, the shared libraries are stored like libopencv_core.so.2.4.8, where 2.4.8 is the version number of OpenCV. libopencv_core.so file usually links to the last version of OpenCV installed in the system.
Thus, though libopencv_core.so was initially linked to libopencv_core.so.3.0, when you installed the older version, the link got updated to link to the older version.
The workaround will be to specifically call the latest OpenCV library in caffe. To do so, you will have to modify the Makefile present in caffe.
Replace all occurrences of opencv_* to :libopencv_*.so.3.0
if you install Caffe, using opencv3.0 is not a good ideal. Caffe is not very compatible with it. And if you persist in using it , please remove 2.4 version, using command sudo apt-get autoremove libopencv-dev.
The reason for this version conflict, is you install libopencv-dev (default version is 2.4) and install opencv with 3.0. So remove it, and then compile caffe.

opencv error: no GPU support

I have install Cuda 6.5 and opencv 2.4.9 with visual studio 2010, when I run gpu, I get error
Opencv Error: No GPU support(the library is compiled without PGU support) in the row_nogpu, file C:/builds/2_4_Packslave-win32-vc10-shared/opencv/modules/gpu/src/precomp.hpp line 135
I get this error, is any one can help what do I have to do?
Thanks
I believe, you have to actually build the libraries with CUDA support. I Imagine This Guide will be useful.
This can be caused because of following.
Use the flag WITH_CUDA=ON during cmake
You are trying to load the libraries which are compiled without GPU support, after you install opencv make sure you change the libraries path to that of GPU supported once.

Resources