저는 openCV 초보자입니다. 내가 dowloaded 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 경로가 포함되었습니다. 그러나 나는 오류가 있습니다.오류 : "img"식별자가 정의되지 않았습니다.
#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;
}
오류를 일으키는 라인은 무엇입니까? –