Скачал и установил OpenCV 2.1 для Windows.
Настроил в Visual Studio 2008 пути к папкам lib и include\opencv, как написано во всех учебниках.
Создал простейший проект для отображения видео с камеры в окно. Все отлично скомпилилось. И даже запускается из проводника. Но!...
При запуске из под Visual Studio доходит до
CvCapture* capture = cvCaptureFromCAM( 0); и приложение закрывается.
Помогите разобраться. Хотелось бы иметь возможность отлаживать программу в отлачике.
OpenCV 2.1
Visual Studio 2008
Код:
#include "cv.h"
#include "highgui.h"
#include <stdio.h>
int main() {
CvCapture* capture = cvCaptureFromCAM( 0);
if( !capture ) {
fprintf( stderr, "ERROR: capture is NULL \n" );
getchar();
return -1;
}
// Create a window in which the captured images will be presented
cvNamedWindow( "mywindow", CV_WINDOW_AUTOSIZE );
// Show the image captured from the camera in the window and repeat
while( 1 ) {
// Get one frame
IplImage* frame = cvQueryFrame( capture );
if( !frame ) {
fprintf( stderr, "ERROR: frame is null...\n" );
getchar();
break;
}
cvShowImage( "mywindow", frame );
// Do not release the frame!
//If ESC key pressed, Key=0x10001B under OpenCV 0.9.7(linux version),
//remove higher bits using AND operator
if( (cvWaitKey(10) & 255) == 27 ) break;
}
// Release the capture device housekeeping
cvReleaseCapture( &capture );
cvDestroyWindow( "mywindow" );
return 0;
}[/codebox]