QRCodeDetector not found by linker

Viewed 11

I am developing a QrDetector on a Raspi using opencv and cmake I compiled openCV on the raspi and it works well I can read from th ecamera using videocapture etc.. No I'd like to ad the QRDetector but that the linker does not seem to be able find the library although it is in the OpenCV_LIBS directory.

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

undefined reference to `cv::QRCodeDetector::QRCodeDetector()'

#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 file:

    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)
1 Answers

I was simply missing "objdetect" in "find_package"

Related