【发布时间】:2019-11-21 07:24:33
【问题描述】:
我在使用 OpenCV for Visual Studio 2017 读取图像时遇到很大问题
我的程序在它确实存在时无法找到我的图像(我多次检查它确实存在于我的 E:/ 驱动器上)。我已将图像放在相对路径、绝对路径上,但无论我尝试什么似乎都无关紧要,它仍然无法找到图像。我还将图像与 .exe 程序放在同一个文件夹中,并将其添加为资源等。
Mat img = imread("E:\\test.jpg", 0);
Mat img = imread("E:/test.jpg", 0);
Mat img = imread("E:\test.jpg", 0);
Mat img = imread("test.jpg", 0);
以上所有示例都返回了所提供图像中的错误。
这些是我的导入:
#include "opencv2/core/core.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include <iostream>
#include <math.h>
我尝试了一些可能的修复方法,但它们根本不起作用。我假设我的问题与 Visual Studio 相关,而不是 OpenCV(我的 OpenCV 已正确安装)。我的项目设置中的设置是否错误?还是我的问题与其他问题有关?
构建错误:
1>------ Build started: Project: Alphatree, Configuration: Debug x64 ------
1>main.obj : error LNK2019: unresolved external symbol "class cv::Mat __cdecl cv::imread(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,int)" (?imread@cv@@YA?AVMat@1@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@H@Z) referenced in function main
1>E:\In-company research project\In-company-research\ConsoleApplication4\Alphatree.exe : fatal error LNK1120: 1 unresolved externals
1>Done building project "ConsoleApplication4.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
【问题讨论】:
-
Visual Studio 找不到您的程序,这与您的图像无关。它甚至编译成功了吗?
-
是的,它编译成功,但是构建失败。每当我删除 Imread 时,程序都可以正常工作,并且编译/构建/运行成功
-
什么是构建错误?
-
我在正文中添加了构建错误
标签: c++ visual-studio opencv