我正在尝试通过以下方式编译opencv-3.1.0/samples/gpu/surf_keypoint_matcher.cpp
:
g++ -I/usr/local/include/opencv -I/usr/local/include/opencv2 -L/usr/local/lib/ -g -o binary surf_keypoint_matcher.cpp -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_ml -lopencv_video -lopencv_features2d -lopencv_calib3d -lopencv_objdetect -lopencv_stitching -lopencv_imgcodecs -lopencv_xfeatures2d
但是我收到了这个错误:
/tmp/ccQW7t3Z.o: In function `main':
/home/luca/Downloads/opencv-3.1.0/samples/gpu/surf_keypoint_matcher.cpp:65: undefined reference to `cv::cuda::DescriptorMatcher::createBFMatcher(int)'
collect2: error: ld returned 1 exit status
为什么?
答案 0 :(得分:1)
您的错误消息:
/home/luca/Downloads/opencv-3.1.0/samples/gpu/surf_keypoint_matcher.cpp:65: undefined reference to `cv::cuda::DescriptorMatcher::createBFMatcher(int)'
collect2: error: ld returned 1 exit status
表示您对cv::cuda::DescriptorMatcher::createBFMatcher
这位于cuda libs中,因此您需要包含相应的标题并链接到以下库中,因为opencv_cudafeatures2d
取决于它们:
对于我正在使用的opencv 3.1.0版本来说确实如此
答案 1 :(得分:0)
DescriptorMatcher is in cudafeatures2d.hpp
。因此,您必须在.cpp程序和link the library in the compile process中添加标头cudafeatures2d.hpp
。
如果您使用此-lopencv_cudafeatures2d
:
g++ -I/usr/local/include/opencv -I/usr/local/include/opencv2 -L/usr/local/lib/ -g -o binary surf_gpu_probe1.cpp -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_ml -lopencv_video -lopencv_features2d -lopencv_calib3d -lopencv_objdetect -lopencv_stitching -lopencv_imgcodecs -lopencv_xfeatures2d -lopencv_cudafeatures2d