Ubuntu OpenCV does not compile

I am 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 am working with Ubuntu 16.04. I already had OpenCV in the system: maybe I'm not mistaken? I remember to compile OpenCV 3.2 with the same command as before.

+5
source share
5 answers

You must have the appropriate versions of opencv_contrib and opencv itself.

Under opencv github, go to OpenCV releases and download 3.2.0 (it should be the same in the main branch).

Now go to https://github.com/opencv/opencv_contrib/releases and download 3.2.0. Then you will have both versions.

After that, all cmake commands found on README.md in the opencv_contrib main branch should work fine.

+8
source

I get the same error, exact error, around protobuf. Another mistake in the xfeatures2d module is also if you remove the dnn modules (so that they are not configurable / not built). My problem is that I need a "non-free" xfeatures2d module. :(

The problem is opencv_contrib in the DNN and xfeatures2d modules, but I'm not sure how to fix it. the ocv_download call has empty inputs, although the dnn and xfeatures2d cmake files are passed in arguments. I'm not even new to cmake, so I'm not sure how to fix the problem further.

I get this error both when setting up Mac for Xcode and when setting up Windows for Visual Studio using the latest version of cmake-gui, 3.8.0-rc3.


EDIT: I think I found the problem. I discovered the problem in the opencv_contrib github file . There is an ocv_download call in the dnn and xfeatures2d cmake files that use FILENAME as the first parameter, but use PACKAGE instead. When I changed the settings to PACKAGE, CMake successfully configured opencv with the opencv_contrib modules.

Hope this helps! :)

+6
source

You may not be using 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

+5
source

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 the BOTH repositories.

Check which version you have and move the other one. In your case, I think you need to change the version of opencv_contrib and then go to the release using git or download it from github .

git checkout <number_opencv_version ie 3.2.0>

Long

I think Ken Lee that you do not have the same version in the repositories.

As Matt mentioned in the open problem , there is a problem with calling ocv_download because the version is not the one that was used when opencv-3.1, so it fails because the parameter is not expected.

This happens to me when I used opencv 3.1.0 and the latest version of opencv_contrib. You can change the cmake files one by one, but itโ€™s easier to get the correct version in each repo.

+3
source

Your build folder has a valid conflict (may arise from your previous sudo make install ). I donโ€™t remember how I fixed it, but you can try recursively chown both for source and for creating folders (or from chmod to 777).

0
source

Source: https://habr.com/ru/post/1266046/


All Articles