1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
| #include <opencv/cv.h>
#include <opencv/highgui.h>
using namespace cv;
using namespace std;
int main( int argc, const char** argv )
{
CvCapture* capture = 0;
Mat frame, frameCopy, image;
capture = cvCaptureFromCAM( CV_CAP_DSHOW ); //0=default, -1=any camera, 1..99=your camera
if( !capture )
{
cout << "No camera detected" << endl;
}
cvNamedWindow( "result", CV_WINDOW_AUTOSIZE );
if( capture )
{
cout << "In capture ..." << endl;
for(;;)
{
IplImage* iplImg = cvQueryFrame( capture );
frame = iplImg;
if( frame.empty() )
break;
if( iplImg->origin == IPL_ORIGIN_TL )
frame.copyTo( frameCopy );
else
flip( frame, frameCopy, 0 );
cvShowImage( "result", iplImg );
if( waitKey( 10 ) >= 0 )
break;
}
// waitKey(0);
}
cvReleaseCapture( &capture );
cvDestroyWindow( "result" );
return 0;
} |
Partager