我正在使用opencv和cmake在Raspi上开发一个QrDetector我在raspi上编译了openCV,它运行良好,我可以使用视频捕获等从ecamera中读取。不,我想广告QRDetector,但链接器似乎找不到库,尽管它在openCV_LBS目录中。
ls -la /usr/local/lib/arm-linux-gnueabihf/
lrwxrwxrwx 1 root root 26 Sep 20 09:58 libopencv_objdetect.so -> libopencv_objdetect.so.405
lrwxrwxrwx 1 root root 28 Sep 20 09:58 libopencv_objdetect.so.405 -> libopencv_objdetect.so.4.5.5
对`cv::QRCodeDetector::QRCode Detector(('的未定义引用
#include <iostream>
#include <opencv2/core.hpp>
#include <opencv2/videoio.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/objdetect.hpp>
//using namespace cv;
//using namespace std;
int detectQR(cv::Mat inputImage)
{
//QRCodeDetector qrDecoder = new QRCodeDetector();
cv::Mat bbox, rectifiedImage;
cv::QRCodeDetector qrDecoder = cv::QRCodeDetector();
std::string data = qrDecoder.detectAndDecode(inputImage, bbox, rectifiedImage);
int length = data.length();
if(length>0)
{
std::cout << "Decoded Data : " << data << std::endl;
}
delete &qrDecoder;
return length;
}
cmake文件:
cmake_minimum_required(VERSION 3.18)
project(untitled2)
set(CMAKE_CXX_STANDARD 11)
find_package( OpenCV REQUIRED core highgui imgproc )
include_directories( ${OpenCV_INCLUDE_DIRS} )
add_executable(sift main.cpp)
target_link_libraries(sift ${OpenCV_LIBS} ${OPENCV_EXTRA_MODULES_PATH} /usr/local/lib/arm-linux-gnueabihf/libopencv_dnn_objdetect.so)
我只是缺少"objdetect";在";find_ package";