2011-12-09 5 views
0

OpenCV 라이브러리가 설치된 간단한 코드를 실행하려고합니다. 오류가 있습니다. 응용 프로그램을 올바르게 시작할 수 없습니다 (0xc0150002).OpenCV에서 오류가 발생했습니다.

비주얼 스튜디오이 내 코드 2.1.0

나는 모든 곳에서 검색 한하지만이 문제를 해결하는 방법을 찾을 수 없습니다 ... 을 OpenCV. 내가 무엇을 할 수 있을지?

#include "stdafx.h" 

#include <cv.h> 
#include <cxcore.h> 
#include <highgui.h> 

#ifdef _EiC 
#define WIN32 
#endif 

static CvMemStorage* storage_face = 0; //Memory Storage to Sore faces 

static CvHaarClassifierCascade* cascade_face = 0; 

void detect_and_draw(IplImage* image); 

//Haar cascade - if your openc CV is installed at location C:/OpenCV2.0/ 
const char* cascade_name_face ="C:/OpenCV2.0/data/haarcascades/haarcascade_frontalface_alt.xml"; 

///////////////////////////////////////////////////////////////////////////////// 

int main() 
{ 
    IplImage *image =0; 
    image = cvLoadImage("picci.jpg",1); 
    if(!image) 
    { 
     printf("Error loading image\n"); 
     return -1; 
    } 

    cascade_face = (CvHaarClassifierCascade*)cvLoad(cascade_name_face, 0, 0, 0); 

    if(!cascade_face) 
    { 
     printf("ERROR: Could not load classifier of face cascade\n"); 
     return -1; 
    } 

    storage_face = cvCreateMemStorage(0); 
    cvNamedWindow("result", 1); 

    // Call function to detect and Draw rectagle around face 
    detect_and_draw(image); 

    // Wait for key event. 
    cvWaitKey(0); 

    // release resourses 
    cvReleaseImage(&image); 
    cvReleaseHaarClassifierCascade(&cascade_face); 
    cvReleaseMemStorage(&storage_face); 
    cvDestroyWindow("result"); 

    return 0; 
} 

//////////////////////////// Function To detect face ////////////////////////// 

void detect_and_draw(IplImage* img) 
{ 

    double scale = 2; 

    // create a gray image for the input image 
    IplImage* gray = cvCreateImage(cvSize(img->width,img->height), 8, 1); 
    // Scale down the ie. make it small. This will increase the detection speed 
    IplImage* small_img = cvCreateImage(cvSize(cvRound (img->width/scale),cvRound (img->height/scale)),8, 1); 

    int i; 

    cvCvtColor(img, gray, CV_BGR2GRAY); 

    cvResize(gray, small_img, CV_INTER_LINEAR); 

    // Equalise contrast by eqalizing histogram of image 
    cvEqualizeHist(small_img, small_img); 

    cvClearMemStorage(storage_face); 

    if(cascade_face) 
    { 
     // Detect object defined in Haar cascade. IN our case it is face 
     CvSeq* faces = cvHaarDetectObjects(small_img, cascade_face, storage_face, 
              1.1, 2, 0/*CV_HAAR_DO_CANNY_PRUNING*/, 
              cvSize(30, 30)); 

     // Draw a rectagle around all detected face 
     for(i = 0; i < (faces ? faces->total : 0); i++) 
     { 
      CvRect r = *(CvRect*)cvGetSeqElem(faces, i); 
      cvRectangle(img, cvPoint(r.x*scale,r.y*scale),cvPoint((r.x+r.width)*scale,(r.y+r.height)*scale),CV_RGB(255,0,0),3,8,0); 

     } 
    } 

    cvShowImage("result", img); 
    cvReleaseImage(&gray); 
    cvReleaseImage(&small_img); 
} 
+1

정말 확실합니까? –

+0

아니요 내 실수는 미안 해요 – TTTT

+1

어쩌면이 스레드에서보세요? http://stackoverflow.com/questions/2690374/windows-7-64-visual-studio-2008-opencv2-1-error-the-application-was-unable – psycho

답변

0

두 가지 잠재적 인 문제 :

  1. OpenCV의 DLL을 찾을 수없는 앱, 당신은 당신의 각각의 빈/해제 또는 빈/디버그 디렉토리에 OpenCV의 DLL을 복사해야 할 수도 있습니다.
  2. 또는 OpenCV 바이너리는 시스템에 설치 한 것과 다른 버전의 CRT로 작성되었습니다. 당신의 시스템에 OpenCV 바이너리를 만들었습니까? 그것은 도움이 될 수 있습니다.
+0

CMake2.8로 빌드되었습니다. – TTTT

관련 문제