2014-04-21 2 views
0

저는 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; 
} 
+0

오류를 일으키는 라인은 무엇입니까? –

답변

1

INCLUDES를위한 하지 절대 경로를 사용 마십시오이 완전히 비 휴대용이다.

은 다음과 같아야합니다 또한

// the usual suspects: 
#include "opencv2\core\core.hpp"  // Mat is defined here. 
#include "opencv2\imgproc\imgproc.hpp" 
#include "opencv2\highgui\highgui.hpp" 

을,이 일을하려면 "추가 폴더 포함" "OpenCV의// 빌드 포함"

을하고 이전 C-을 피하기 위해 가리켜 야합니다 API 헤더 (예 : cv.h, highgui.h, cxcore.h)

+0

나는 모든 include 줄에 대해 "opencv2 \ core \ core.hpp"파일을 opensource 할 수 없다. "include include folders"에서 $ (OPENCV_DIR) 줄 아래에서 사용한다. – user3496826

+0

을 포함한다. $ (OPENCV_DIR) 올바른 위치를 가리 킵니다. 그건 틀릴 수도 있습니다. 파일은 "opencv/build/include"에 있어야합니다. – berak

+0

나는 이해하지 못했습니다. 확인 할 곳? – user3496826

관련 문제