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

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 matlab答疑 关于海上风电的爬坡事件检测
  • ¥88 python部署量化回测异常问题
  • ¥30 酬劳2w元求合作写文章
  • ¥15 在现有系统基础上增加功能
  • ¥15 远程桌面文档内容复制粘贴,格式会变化
  • ¥15 关于#java#的问题:找一份能快速看完mooc视频的代码
  • ¥15 这种微信登录授权 谁可以做啊
  • ¥15 请问我该如何添加自己的数据去运行蚁群算法代码
  • ¥20 用HslCommunication 连接欧姆龙 plc有时会连接失败。报异常为“未知错误”
  • ¥15 网络设备配置与管理这个该怎么弄