2 #pragma package <opencv>
5 #define CV_NO_BACKWARD_COMPATIBILITY
15 int smoothType = CV_GAUSSIAN;
17 int main( int argc, char** argv )
19 IplImage* laplace = 0;
20 IplImage* colorlaplace = 0;
21 IplImage* planes[3] = { 0, 0, 0 };
22 CvCapture* capture = 0;
24 if( argc == 1 || (argc == 2 && strlen(argv[1]) == 1 && isdigit(argv[1][0])))
25 capture = cvCaptureFromCAM( argc == 2 ? argv[1][0] - '0' : 0 );
27 capture = cvCaptureFromAVI( argv[1] );
31 fprintf(stderr,"Could not initialize capturing...\n");
35 cvNamedWindow( "Laplacian", 0 );
36 cvCreateTrackbar( "Sigma", "Laplacian", &sigma, 15, 0 );
43 frame = cvQueryFrame( capture );
49 for( i = 0; i < 3; i++ )
50 planes[i] = cvCreateImage( cvGetSize(frame), 8, 1 );
51 laplace = cvCreateImage( cvGetSize(frame), IPL_DEPTH_16S, 1 );
52 colorlaplace = cvCreateImage( cvGetSize(frame), 8, 3 );
56 cvSmooth( frame, colorlaplace, smoothType, ksize, ksize, sigma, sigma );
57 cvSplit( colorlaplace, planes[0], planes[1], planes[2], 0 );
58 for( i = 0; i < 3; i++ )
60 cvLaplace( planes[i], laplace, 5 );
61 cvConvertScaleAbs( laplace, planes[i], (sigma+1)*0.25, 0 );
63 cvMerge( planes[0], planes[1], planes[2], 0, colorlaplace );
64 colorlaplace->origin = frame->origin;
66 cvShowImage("Laplacian", colorlaplace );
70 smoothType = smoothType == CV_GAUSSIAN ? CV_BLUR : smoothType == CV_BLUR ? CV_MEDIAN : CV_GAUSSIAN;
71 if( c == 'q' || c == 'Q' || (c & 255) == 27 )
75 cvReleaseCapture( &capture );
76 cvDestroyWindow("Laplacian");