加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c – Opencv,未定义引用`cv :: imread(?? cv :: String const&am

发布时间:2020-12-16 07:12:18 所属栏目:百科 来源:网络整理
导读:参见英文答案 error: undefined reference to `cv::imread(std::string const,int)’????????????????????????????????????3个 ???????????? What is an undefined reference/unresolved external symbol error and how do I fix it????????????????????????
参见英文答案 > error: undefined reference to `cv::imread(std::string const&,int)’????????????????????????????????????3个
>???????????? What is an undefined reference/unresolved external symbol error and how do I fix it?????????????????????????????????????32个
我在QT Opencv中有一个项目,代码正在运行,但我不得不格式化窗口,现在我想再次导入项目,这个错误出现了.

未定义的引用`cv :: imread(cv :: String const&,int)’
在这一行:

mat = cv::imread(path);

虽然我的代码看起来像这样:

QString caminho = QFileDialog::getOpenFileName(this,tr("Open File"),"",tr("Images (*.png *.tiff)") );

 std::string path = caminho.toStdString();
 mat = cv::imread(path);

我尝试了像“image.png”这样的其他字符串代码,但没有用.

使用OpenCV3,QT5.4,Mingw,Windows8.1

抱歉,我的英文

解决方法

两个笔记:

> cv :: imread使用’C’类字符串char *.那条线就像你告诉openCV打开一个名为“path”的文件.您应该将其更改为:mat = cv :: imread(path.c_str())并且它很好!
> undefined reference是指编译器没有找到该函数的实现时(m.s.刚刚发布了一个关于该函数的链接). GCC(MinGW)正在试图查看“imread”功能的位置.由于您格式化了系统,因此可能需要重置环境变量“PATH”或其他配置路径.我推荐这个阅读:http://www.cs.swarthmore.edu/~newhall/unixhelp/howto_C_libraries.html,它解释了为什么你需要这样做.

希望能帮助到你!

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读