opencv编译4.2失败

错误

[ 92%] Building CXX object modules/tracking/CMakeFiles/opencv_tracking.dir/src/trackerFeature.cpp.o [ 92%] Building CXX object modules/tracking/CMakeFiles/opencv_tracking.dir/src/trackerFeatureSet.cpp.o [ 92%] Building CXX object modules/tracking/CMakeFiles/opencv_tracking.dir/src/trackerKCF.cpp.o [ 92%] Building CXX object modules/tracking/CMakeFiles/opencv_tracking.dir/src/trackerMILModel.cpp.o [ 92%] Building CXX object modules/tracking/CMakeFiles/opencv_tracking.dir/src/trackerMIL.cpp.o [ 92%] Building CXX object modules/tracking/CMakeFiles/opencv_tracking.dir/src/trackerMedianFlow.cpp.o [ 92%] Building CXX object modules/tracking/CMakeFiles/opencv_tracking.dir/src/trackerModel.cpp.o [ 92%] Building CXX object modules/tracking/CMakeFiles/opencv_tracking.dir/src/trackerSampler.cpp.o [ 92%] Building CXX object modules/tracking/CMakeFiles/opencv_tracking.dir/src/trackerSamplerAlgorithm.cpp.o [ 92%] Building CXX object modules/tracking/CMakeFiles/opencv_tracking.dir/src/trackerStateEstimator.cpp.o [ 92%] Building CXX object modules/tracking/CMakeFiles/opencv_tracking.dir/src/unscented_kalman.cpp.o [ 92%] Building CXX object modules/tracking/CMakeFiles/opencv_tracking.dir/src/tracking_utils.cpp.o [ 93%] Building CXX object modules/tracking/CMakeFiles/opencv_tracking.dir/src/tracking_by_matching.cpp.o [ 93%] Building CXX object modules/tracking/CMakeFiles/opencv_tracking.dir/opencl_kernels_tracking.cpp.o [ 93%] Linking CXX shared library ../../lib/libopencv_sfm.so [ 93%] Built target opencv_sfm [ 93%] Linking CXX shared library ../../lib/libopencv_stitching.so [ 93%] Built target opencv_stitching [ 93%] Linking CXX shared library ../../lib/libopencv_optflow.so [ 93%] Built target opencv_optflow [ 93%] Linking CXX shared library ../../lib/libopencv_tracking.so [ 93%] Built target opencv_tracking make: *** [Makefile:166:all] 错误 2

这个错误表示在 test_features2d.cpp 文件中,SIFT 未声明。这通常是因为在 OpenCV 的某些配置中,SIFT 功能被排除在外。可能的原因包括:

  • OpenCV 没有启用 xfeatures2d 模块,或者模块没有正确编译。
  • 缺少 opencv_contrib 模块,特别是 xfeatures2d 模块。

解决方案 

OpenCV4版本默认不生成.pc文件,执行OPENCV_GENERATE_PKGCONFIG=ON生成。

cmake .. -DOPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules -DOPENCV_GENERATE_PKGCONFIG=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local  

你可能感兴趣的:(opencv,webpack,javascript)