[英]opencv and visual studio 2010 cannot load image from a subdirectory
im new to open cv. 我是新来打开简历。 im using Open CV 2.4.9 with visual Studio 2010. Im using a basic program to open an image. 我在Visual Studio 2010中使用Open CV 2.4.9。我在使用基本程序打开图像。 the problem is that when i put the image file on the main drive (eg: D:\\image.png), it works correctly. 问题是,当我将图像文件放在主驱动器上时(例如:D:\\ image.png),它可以正常工作。 but when i move the image to a subdirectory (eg:D:\\OpenCV\\opencv\\build\\doc\\opencv-logo.png), the output says "image cannot be loaded" 但是,当我将图像移动到子目录(例如:D:\\ OpenCV \\ opencv \\ build \\ doc \\ opencv-logo.png)时,输出显示“图像无法加载”
where am i going wrong. 我要去哪里错了。 please help me out 请帮帮我
here is the code that im using: 这是即时通讯使用的代码:
#include <opencv2/highgui/highgui.hpp>
#include <iostream>
using namespace cv;
using namespace std;
int main()
{
Mat im = imread("D:\OpenCV\opencv\build\doc\opencv-logo.png");
if (im.empty())
{
cout << "Cannot load image!" << endl;
return -1;
}
imshow("Image", im);
waitKey(0);
}
You need to understand about escape characters 您需要了解转义字符
try this 尝试这个
Mat im = imread("D:\\OpenCV\\opencv\\build\\doc\\opencv-logo.png");
You will have to escape the \\
character. 您将必须转义\\
字符。 You have to do this : 您必须这样做:
Mat im = imread("D:\\OpenCV\\opencv\\build\\doc\\opencv-logo.png")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.