Ubuntu OpenCV not compiling - c++

I'm trying to compile OpenCV 3.2 with contributions with the following commands:
1.
cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX=/usr/local/ -DOPENCV_EXTRA_MODULES_PATH=/home/matteo/Desktop/Xilinx/OpenCV/source/opencv_contrib/modules/ /home/matteo/Desktop/Xilinx/OpenCV/source/opencv-3.2.0/
2.
make -j7 # runs 7 jobs in parallel
3.
sudo make install
Can you explain why I get
...
........
...........
........................
-- VTK is not found. Please set -DVTK_DIR in CMake to VTK build directory, or to VTK install subdirectory with VTKConfig.cmake file
-- Caffe: NO
-- Protobuf: NO
-- Glog: NO
-- Downloading ...
CMake Error at cmake/OpenCVUtils.cmake:1043 (file):
file DOWNLOAD cannot open file for write.
Call Stack (most recent call first):
../opencv_contrib/modules/dnn/cmake/OpenCVFindLibProtobuf.cmake:32 (ocv_download)
../opencv_contrib/modules/dnn/CMakeLists.txt:5 (include)
CMake Error at cmake/OpenCVUtils.cmake:1047 (message):
Failed to download . Status=
Call Stack (most recent call first):
../opencv_contrib/modules/dnn/cmake/OpenCVFindLibProtobuf.cmake:32 (ocv_download)
../opencv_contrib/modules/dnn/CMakeLists.txt:5 (include)
-- Configuring incomplete, errors occurred!
I'm working with Ubuntu 16.04 . I already had OpenCV on the system: maybe I unistall it in the wrong way? I remember to compile OpenCV 3.2 with the same command used above.

You must have matching versions of the opencv_contrib and the opencv itself.
Under the opencv github, go to the OpenCV releases and download the 3.2.0 (it should be the same in the master branch).
Now, go to https://github.com/opencv/opencv_contrib/releases and download the 3.2.0. Then you will have both versions matching.
After that all the cmake commands found on the README.md at opencv_contrib master branch should work fine.

I get the same error, that exact error, around the protobuf. There's another error on the xfeatures2d module, too, if your delete the dnn modules (so they don't get configured/built). My problem is, I need the "non-free" xfeatures2d module. :(
The problem appears to be in the opencv_contrib, in the DNN and xfeatures2d modules, but I'm not sure how to fix it. the call to ocv_download seems to be having empty inputs, even though the dnn and xfeatures2d cmake files are passing in arguments. I am not even a novice with cmake, so I'm not sure how to troubleshoot further.
I get this error on both Mac configuring for XCode and on Windows configuring for Visual Studio, using the latest version of cmake-gui, 3.8.0-rc3.
EDIT: I think I've found the issue, though. I opened an issue in the opencv_contrib github. There is a call to ocv_download in the dnn and xfeatures2d cmake files that uses FILENAME as the first parameter, but should be using PACKAGE instead. When I changed the parameters to PACKAGE, CMake successfully configured opencv with the opencv_contrib modules.
Hope this helps! :)

You might not use the same version of opencv and opencv_contrib
https://github.com/opencv/opencv_contrib/archive/<version>.zip
https://github.com/opencv/opencv/archive/<version>.zip
like master or 3.2.0

SHORT
You need to have the same version in opencv and opencv_contrib (.../opencv_contrib/modules/... belongs to an independent repo).
Either the same release or the last commit in BOTH repositories.
Check which version you have and move the other. In your case, I guess you have to change the version of opencv_contrib, then move to the release with git or download it from github.
git checkout <number_opencv_version i.e. 3.2.0>
LONG
I guess as Ken Lee, that you do not have the same version in the repositories.
As Matt referenced in the opened issue, there is a problem with the call of ocv_download because the version is not the one that was used when opencv-3.1, therefore it fails because the parameter is not the expected one.
It happens to me when I was using opencv 3.1.0 and the last version of opencv_contrib. You could change the cmake files one by one, but it is easier to take the correct version in each repo.

There is a right conflict in your build folder (may result from your previous sudo make install). I don't remember how I fixed it, but you can try recursively chown to both source and build folders (or chmod to 777).

Related

CMake error in CLion after updating CMake

I am relatively new to coding in C++ and using CMake. I have been writing code using CLion IDE on ubuntu 16.04. I had written a library, with an older version of CMake (I believe it was version 3.4) which came bundled with CLion and for an unrelated reason needed to update to version 3.15. Which I assume I must have done incorrectly.
When reloading Cmake projects that previously ran fine, I get the following error message:
Found Qt4: /usr/bin/qmake (found version "4.8.7")
CMake Error at cmake-build-debug/_deps/eigen-src/cmake/language_support.cmake:33 (file):
file failed to open for writing (Permission denied):
/home/majed/CLionProjects/TwoLink_manip/cmake-build-debug/language_tests/Fortran/CMakeLists.txt
Call Stack (most recent call first):
cmake-build-debug/_deps/eigen-src/test/CMakeLists.txt:19 (workaround_9220)
I have looked through a numeber of Cmake questions which I thought could be related to my issue but none of them seemed to address this specific issue. I am not very familiar with the Cmake installation and setup and simply followed a youtube tutorial to install the latest release(cmake-3.15.5-Linux-x86_64.sh)from the cmake.org site.
I should point out that CMake does work when I run ROS packages from the terminal which is why I am apprehensive about re-installing everything. I am assuming the issue is related to where the cmake file is installed but not sure how to fix this issue with CLion. I would appreciate any and all suggestions.
I have also tried to export CMAKE_ROOT to the locaton of the new cmake folder but it doesn't really have any effect.

fail to compile simple Opencv C++ file with CMake

Hi I am trying to run a simple C++ program with Opencv to display Image file but I am getting following error.
The imported target "opencv_core" references the file
"/usr/local/lib/libopencv_core.so.3.2.0"
but this file does not exist. Possible reasons include:
The file was deleted, renamed, or moved to another location.
An install or uninstall procedure did not complete successfully.
The installation package was faulty and contained
"/usr/local/share/OpenCV/OpenCVModules.cmake"
but not all the files it references.
Call Stack (most recent call first):
/usr/local/share/OpenCV/OpenCVConfig.cmake:111 (include)
CMakeLists.txt:3 (find_package)
-- Configuring incomplete, errors occurred!
The code for which is an example given in opencv here: http://docs.opencv.org/2.4/doc/tutorials/introduction/linux_gcc_cmake/linux_gcc_cmake.html#linux-gcc-usage
I tried to use opencv 3.2 before but I uninstalled n deleted all the opencv files using sudo apt-get remove libopencv*
I found similar question here: CMake does not find OpenCV but couldnt understand the answer. I have ROS Indigo installed on ubuntu 14.04.4. Also, I tried to install Opencv 2.4.13 but when I am checking the version installed using following command
pkg-config --modversion opencv
2.4.8
I am getting 2.4.8 and the main question why its referencing the file /usr/local/lib/libopencv_core.so.3.2.0 ?
FYI I installed opencv as per the instructions given here: http://docs.opencv.org/2.4/doc/tutorials/introduction/linux_install/linux_install.html#linux-installation
Thank you
So I figured it out, apparently I had linking problem because of bad instalment. I uninstalled opencv , deleted all the files and reinstalled it. I could have solved it using symlink as well but figured its best to clear everything and reinstall it. worked perfectly.
Additional note : Its my observation that if you have ROS installed and saved the opt/ros/indigo/setup.bash in ~/.bashrc , it will give errors so better remove those lines from ~/.bashrc and then try again.
any other suggestion ??
If you have more than one OpenCV installed in your computer, you could delete your OpenCV folder or you could move your folder to your temp folder:
sudo mv /usr/local/share/OpenCV /temp/OpenCV
It worked for me!!

build opencv with extra modules error ocv_download

I try to build openCV with Extramodules. If I try to configure the projectfiles (vc14 x32 on windows 10) with cmake there's the error:
CMake Error at opencv_contrib-master/modules/xfeatures2d/cmake/download_vgg.cmake:13 (ocv_download):
Unknown CMake command "ocv_download".
Did anyone ever have this problem and knows how to solve it?
The simple answer is you are using incompatible versions of opencv and opencv_contrib, you might be installing current version of opencv_contrib on maybe opencv2.4.xx
Well, the download link for opencv contrib in CMake script https://raw.githubusercontent.com/opencv/opencv_3rdparty/fccf7cd6a4b12079f73bbfb21745f9babcd4eb1d now is 400: Invalid request.
From the commit https://github.com/opencv/opencv_contrib/commit/593e78c5d084aa0a29eb1e0459fc7f7a4dd52ea8 you can try to ignore the added line in CMakeLists include(cmake/download_vgg.cmake) and rebuild.
The below is basing on my experience, I'm not sure it will works for OpenCV 3.0.
Maybe you can try to clone opencv contrib from git, then copy it to somewhere (for example modules directory in opencv source code). Then use CMAKE to set OPENCV_EXTRA_MODULES_PATH. If the hash is correct then it won't download and use the offline package.
I have try and build success OpenCV 2.x with IPP.
Hope it help.
Just follow instructions here.
Make sure you have active internet connection while building Opencv with contrib module.
When you hit config button on cmake(gui), it downloads other files like
vgg_generated_...
boostdesc_binboost_...
boostdesc_lbgm.i
P.S: i compiled Opencv 3.1 with contrib. Cmake downloaded required files & configure was Done.

Installing the SFGUI with Cmake

I've been trying to install SFGUI library with Cmake tool with instructions given here: SFGUI Install Tutorial . Still got many problems in major with Cmake, which couldn't find few files from SFGUI directory, for example
CMake Error: The source "D:/SFGUI-master/CMakeLists.txt" does not match the source "D:/SFGUI-0.3.0/CMakeLists.txt" used to generate cache. Re-run cmake with a different source directory.
Restarting didn't help. Could anyone write how to install this in simple steps? Regards.
cmake is telling you that the files it has generated in it's cache from a previous run don't match the source files you are currently using. I would imagine that you ran cmake, then switched git branches or tags and tried to run cmake again. You can just rm -r CMakeFiles in your build directory to remove the cache. Then you should be able to run cmake again without errors.
Thanks! It moved a little bit, but stopped actually at error:
CMake Error at cmake/Modules/FindSFML.cmake:306 (message):
Could NOT find SFML (missing: SFML_GRAPHICS_LIBRARY SFML_WINDOW_LIBRARY
SFML_SYSTEM_LIBRARY)
Call Stack (most recent call first):
CMakeLists.txt:21 (find_package)
Configuring incomplete, errors occurred!
See also "C:/Users/admin/Documents/Visual Studio 2015/Projects/sfml1/sfml1/CMakeFiles/CMakeOutput.log".
To be honest, I will write down steps I did: 1.Configured SFML in VS15 in Windows 8.1 2. I installed the newswet version of CMake 3. Installed also newest SFGUI from Github. 4.In Cmake GUI as a build I choose my project in VS and as a source - SFGUI directory. 5.In CMake Configure and there are the errors. Did I missed something?

Installing PySide - OSX

Anyone had success installing and using PySide on OSX? I am following the install instructions on the PySide site, though I'm running into issues building the API Extractor. I run cmake on the CMakeLists.txt file inside the api extractor dir and:
This error is thrown-
CMake Error at /Applications/CMake 2.8-0.app/Contents/share/cmake-2.8/Modules/FindBoost.cmake:894 (message):
Unable to find the requested Boost libraries.
Unable to find the Boost header files. Please set BOOST_ROOT to the root
directory containing Boost or BOOST_INCLUDEDIR to the directory containing
Boost's headers.
Call Stack (most recent call first):
CMakeLists.txt:5 (find_package)
I am new to building source w/ cmake and I'm not event really sure what Boost is. Any light you might shed on the set up process would be great.
Thanks
You may want to check the newest release of PySide, out very recently, I believe the dependency on the Boost libraries has been removed.
It's a set of quite widespread C++ libraries, they're probably needed by PySide, even though I've never tried it.
Download them from there:
http://sourceforge.net/projects/boost/files/boost/1.42.0/
Otherwise, you can install them from macports: http://www.macports.org once you've installed macports, just run "sudo port install boost". Unluckily, pyside itself doesn't seem to be in macports yet.