我是openCV的初学者。我下载了opencv2.4.5和visual studio express 2012然后我按照这个链接http://opencv-srf.blogspot.in/2013/05/installing-configuring-opencv-with-vs.html来设置环境变量等中的所有内容。然后我在链接http://opencv-srf.blogspot.in/2013/06/load-display-image.html下面创建了示例应用程序。我包含了正确的#include路径。但是我收到了错误。
#include "stdafx.h"
#include <C:\opencv\build\include\opencv\cv.h>
#include <C:\opencv\build\include\opencv\cxcore.h>
#include <C:\opencv\build\include\opencv\highgui.h>
#include "C:\opencv\build\include\opencv2\highgui\highgui.hpp"
#include <iostream>
using namespace cv;
using namespace std;
int main( int argc, const char** argv )
{
Mat img = imread("MyPic.JPG", CV_LOAD_IMAGE_UNCHANGED); //read the image data in the file "MyPic.JPG" and store it in 'img'
if (img.empty()) //check whether the image is loaded or not
{
cout << "Error : Image cannot be loaded..!!" << endl;
//system("pause"); //wait for a key press
return -1;
}
namedWindow("MyWindow", CV_WINDOW_AUTOSIZE); //create a window with the name "MyWindow"
imshow("MyWindow", img); //display the image which is stored in the 'img' in the "MyWindow" window
waitKey(0); //wait infinite time for a keypress
destroyWindow("MyWindow"); //destroy the window with the name, "MyWindow"
return 0;
}
答案 0 :(得分:1)
请不使用包含的绝对路径,这是完全不可移植的。
它应该是这样的:
// the usual suspects:
#include "opencv2\core\core.hpp" // Mat is defined here.
#include "opencv2\imgproc\imgproc.hpp"
#include "opencv2\highgui\highgui.hpp"
另外,为了使这项工作,您的“其他包含文件夹”应指向“opencv / build / include”
并避免旧的c-api头文件,如cv.h,highgui.h,cxcore.h