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 49 50 51
|
#include "stdafx.h"
#include <stdio.h>
#include <iostream>
#include "cv.h"
#include "highgui.h"
int _tmain(int argc, _TCHAR* argv[])
{
CvCapture *capture = 0;
IplImage *frame = 0;
int key = 0;
CvFont font;
cvInitFont(&font, CV_FONT_HERSHEY_SIMPLEX, 1.0, 1.0, 0, 1, CV_AA);
/* initialize camera */
capture = cvCaptureFromCAM(0);
/* always check */
if ( !capture ) {
fprintf( stderr, "Cannot open initialize webcam!\n" );
return 1;
}
//Set the resolution of the capture stream
cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT, 640);
cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH, 480);
/* create a window for the video */
cvNamedWindow( "Turret", CV_WINDOW_AUTOSIZE );
while( key != 'q' ) {
/* get a frame */
frame = cvQueryFrame( capture );
/* always check */
if( !frame ) break;
cvPutText(frame, "Turret cam", cvPoint(10, 130), &font, cvScalar(255, 255, 255, 0));
/* display current frame */
cvShowImage( "Turret", frame );
/* exit if user press 'q' */
key = cvWaitKey( 10 );
}
/* free memory */
cvDestroyWindow( "result" );
cvReleaseCapture( &capture );
return 0;
}
|