赞
踩
ippicv_xxxx.tgz/face_landmarkmodel.dat/boostredec系列/vgg系列 相关文件先下载好
修改opencv-4.4.0/3rdparty/ippicv/ippicv.cmake文件
,
- ocv_download(FILENAME ${OPENCV_ICV_NAME}
- HASH ${OPENCV_ICV_HASH}
- URL
- "${OPENCV_IPPICV_URL}"
- "$ENV{OPENCV_IPPICV_URL}"
- "file:///home/xinghu/software/opencv-4.4.0/"
- #"https://raw.githubusercontent.com/opencv/opencv_3rdparty/${IPPICV_COMMIT}/ippicv/"
- DESTINATION_DIR "${THE_ROOT}"
- ID IPPICV
- STATUS res
- UNPACK RELATIVE_URL)
修改opencv-4.4.0/opencv_contrib-4.4.0/modules/xfeatures2d/cmake下的download_boostdesc.cmake和download_vgg.cmake文件,同上
修改opencv-4.4.0/opencv_contrib-4.4.0/modules/face/CMakeLists.txt文件,同上
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D OPENCV_EXTRA_MODULES_PATH=../opencv_contrib-4.4.0/modules -D WITH_CUDA=1 -D WITH_CUDNN=1 -D OPENCV_DNN_CUDA=1 -D ENABLE_FAST_MATH=1 -D CUDA_FAST_MATH=1 -D WITH_CUBLAS=1 -D OPENCV_GENERATE_PKGCONFIG=1 -D BUILD_opencv_python3=1 -D PYTHON3_EXECUTABLE=/usr/bin/python -D CUDA_GENERATION=Pascal ..
sudo make
sudo make install
1. fatal error: features2d/test/test_detectors_regression.impl.hpp
step.1 进入opencv源码目录~/opencv/modules/features2d/test/,拷贝test_detectors_regression.impl.hpp 及 test_descriptors_regression.impl.hpp 到 ~/opencv_contrib/modules/xfeatures2d/test/下
step.2 编辑 test_features2d.cpp ,修改include文件地址
- // #include "features2d/test/test_detectors_regression.impl.hpp"
- // #include "features2d/test/test_descriptors_regression.impl.hpp"
- // 修改文件地址如下
- #include "test_detectors_regression.impl.hpp"
- #include "test_descriptors_regression.impl.hpp"
根据提示的缺少文件从~/opencv/modules/features2d/test中拷贝如下文件到~/opencv_contrib/modules/xfeatures2d/test/
- test_detectors_invariance.impl.hpp
- test_descriptors_invariance.impl.hpp
- test_invariance_utils.hpp
然后修改test_rotation_and_scale_invariance.cpp文件
- // #include "features2d/test/test_detectors_invariance.impl.hpp" // main OpenCV repo
- // #include "features2d/test/test_descriptors_invariance.impl.hpp" // main OpenCV repo
- #include "test_detectors_invariance.impl.hpp" // main OpenCV repo
- #include "test_descriptors_invariance.impl.hpp" // main OpenCV repo
2. [ WARN:0] global /tmp/pip-req-build-sw_3pm_8/opencv/modules/dnn/src/dnn.cpp (1429) setUpNet DNN module was not built with CUDA backend; switching to CPU
注意cmake的时候有-D WITH_CUDNN=1 -D OPENCV_DNN_CUDA=1
3. no moudule named cv2
4. make时候报错
解决:
- The problem was solved by adding the following code to opencv/cmake/FindCUDNN.cmake:
-
- set(CUDNN_ROOT_DIR "" CACHE PATH "Folder contains NVIDIA cuDNN")
-
- SET(CUDNN_LIBNAME "cudnn_static")
- SET(CULIBOS_LIBNAME "culibos")
-
- find_path(CUDNN_INCLUDE_DIR cudnn.h
- HINTS ${CUDNN_ROOT_DIR} ${CUDA_TOOLKIT_ROOT_DIR}
- PATH_SUFFIXES cuda/include include)
-
- find_library(CUDNN_LIBRARY ${CUDNN_LIBNAME}
- HINTS ${CUDNN_ROOT_DIR} ${CUDA_TOOLKIT_ROOT_DIR}
- PATH_SUFFIXES lib lib64 cuda/lib cuda/lib64 lib/x64)
-
- find_library(CULIBOS_LIBRARY ${CULIBOS_LIBNAME}
- HINTS ${CUDNN_ROOT_DIR} ${CUDA_TOOLKIT_ROOT_DIR}
- PATH_SUFFIXES lib lib64 cuda/lib cuda/lib64 lib/x64)
-
- set(CUDNN_LIBRARIES ${CUDNN_LIBRARY} ${CULIBOS_LIBRARY})
-
-
- I added it to the end of the file as it is, without making any changes.
- After that I run make -j12 (12 is based on the number of cores of the CPU) and all the rest of the build commands without any problems.
- I tested Opencv 4.4.0 with YOLOv4 and it works fine.

- sudo vim /etc/ld.so.conf.d/opencv.conf
- /usr/local/lib #保存本句 然后关闭
- ---
- sudo ldconfig
- vim /etc/bash.bashrc
- PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig
- export PKG_CONFIG_PATH #添加到末尾
pkg-config opencv4 --modversion #查看版本
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。