2 #pragma package <opencv>
12 int main( int argc, char** argv )
14 IplImage* laplace = 0;
15 IplImage* colorlaplace = 0;
16 IplImage* planes[3] = { 0, 0, 0 };
17 CvCapture* capture = 0;
19 if( argc == 1 || (argc == 2 && strlen(argv[1]) == 1 && isdigit(argv[1][0])))
20 capture = cvCaptureFromCAM( argc == 2 ? argv[1][0] - '0' : 0 );
22 capture = cvCaptureFromAVI( argv[1] );
26 fprintf(stderr,"Could not initialize capturing...\n");
30 cvNamedWindow( "Laplacian", 0 );
37 frame = cvQueryFrame( capture );
43 for( i = 0; i < 3; i++ )
44 planes[i] = cvCreateImage( cvSize(frame->width,frame->height), 8, 1 );
45 laplace = cvCreateImage( cvSize(frame->width,frame->height), IPL_DEPTH_16S, 1 );
46 colorlaplace = cvCreateImage( cvSize(frame->width,frame->height), 8, 3 );
49 cvCvtPixToPlane( frame, planes[0], planes[1], planes[2], 0 );
50 for( i = 0; i < 3; i++ )
52 cvLaplace( planes[i], laplace, 3 );
53 cvConvertScaleAbs( laplace, planes[i], 1, 0 );
55 cvCvtPlaneToPix( planes[0], planes[1], planes[2], 0, colorlaplace );
56 colorlaplace->origin = frame->origin;
58 cvShowImage("Laplacian", colorlaplace );
60 if( cvWaitKey(10) >= 0 )
64 cvReleaseCapture( &capture );
65 cvDestroyWindow("Laplacian");