最近学习opencv,看见扩展库里有wechat_qrcode一项,忍不住想试一下。
参照网上的例子,编写如下代码,但是报错,不知道错在哪里,百思不得解。
#include "widget.h"
#include "ui_widget.h"
#include <iostream>
#include <opencv2/core.hpp>
#include <opencv2/opencv.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/wechat_qrcode.hpp>
using namespace std;
using namespace cv;
Widget::Widget(QWidget *parent)
: QWidget(parent)
, ui(new Ui::Widget)
{
ui->setupUi(this);
Ptr<wechat_qrcode::WeChatQRCode> detector;
const std::string detect_prototxt = "c:/opencv/wechat_qrcode/detect.prototxt";
const std::string detect_caffe_model = "c:/opencv/wechat_qrcode/detect.caffemodel";
const std::string sr_prototxt = "c:/opencv/wechat_qrcode/sr.prototxt";
const std::string sr_caffe_model = "c:/opencv/wechat_qrcode/sr.caffemodel";
detector = makePtr<wechat_qrcode::WeChatQRCode>(detect_prototxt, detect_caffe_model,sr_prototxt, sr_caffe_model);
}
Widget::~Widget()
{
delete ui;
}
运行结果及详细报错内容:
C:\Qt\Qt5.12.10\Tools\mingw730_64\lib\gcc\x86_64-w64-mingw32\7.3.0\include\c++\ext\new_allocator.h:136: error: undefined reference to `cv::wechat_qrcode::WeChatQRCode::WeChatQRCode(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&, std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&, std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&, std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&)'