搞机械的假程序猿 2023-01-08 16:05 采纳率: 100%
浏览 42
已结题

Qt使用wechat_qrcode,编译报错!

最近学习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&)'

  • 写回答

1条回答 默认 最新

  • m0_54204465 2023-01-08 16:51
    关注

    首先,可以检查一下 c:/opencv/wechat_qrcode/ 目录下是否存在 detect.prototxt,detect.caffemodel,sr.prototxt,sr.caffemodel 这四个文件。如果没有这些文件,则可能导致出现这个错误。

    另外,在 Windows 系统中,路径分隔符使用的是反斜杠 '',而不是斜杠 '/'。可以把代码中的斜杠全部改为反斜杠,然后重新编译。

    例如,将:

    const std::string detect_prototxt = "c:/opencv/wechat_qrcode/detect.prototxt";

    改为:

    const std::string detect_prototxt = "c:\opencv\wechat_qrcode\detect.prototxt";

    如果问题仍然存在,还可以尝试检查一下项目中是否包含 opencv_wechat_qrcode 这个库,或者检查一下这个库是否在系统中正确安装。

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

问题事件

  • 系统已结题 1月17日
  • 已采纳回答 1月9日
  • 创建了问题 1月8日

悬赏问题

  • ¥15 Stata链式中介效应代码修改
  • ¥15 latex投稿显示click download
  • ¥15 请问读取环境变量文件失败是什么原因?
  • ¥15 在若依框架下实现人脸识别
  • ¥15 添加组件无法加载页面,某块加载卡住
  • ¥15 网络科学导论,网络控制
  • ¥15 利用Sentinel-2和Landsat8做一个水库的长时序NDVI的对比,为什么Snetinel-2计算的结果最小值特别小,而Lansat8就很平均
  • ¥15 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错