Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

asked 2020-05-14 12:43:39 -0600

Nbb gravatar image

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

I hope to get some help. Thank you.