00001 #ifdef _CH_
00002 #pragma package <opencv>
00003 #endif
00004
00005 #ifndef _EiC
00006 #include "cv.h"
00007 #include "highgui.h"
00008 #include <ctype.h>
00009 #include <stdio.h>
00010 #endif
00011
00012 int main( int argc, char** argv )
00013 {
00014 IplImage* laplace = 0;
00015 IplImage* colorlaplace = 0;
00016 IplImage* planes[3] = { 0, 0, 0 };
00017 CvCapture* capture = 0;
00018
00019 if( argc == 1 || (argc == 2 && strlen(argv[1]) == 1 && isdigit(argv[1][0])))
00020 capture = cvCaptureFromCAM( argc == 2 ? argv[1][0] - '0' : 0 );
00021 else if( argc == 2 )
00022 capture = cvCaptureFromAVI( argv[1] );
00023
00024 if( !capture )
00025 {
00026 fprintf(stderr,"Could not initialize capturing...\n");
00027 return -1;
00028 }
00029
00030 cvNamedWindow( "Laplacian", 0 );
00031
00032 for(;;)
00033 {
00034 IplImage* frame = 0;
00035 int i;
00036
00037 frame = cvQueryFrame( capture );
00038 if( !frame )
00039 break;
00040
00041 if( !laplace )
00042 {
00043 for( i = 0; i < 3; i++ )
00044 planes[i] = cvCreateImage( cvSize(frame->width,frame->height), 8, 1 );
00045 laplace = cvCreateImage( cvSize(frame->width,frame->height), IPL_DEPTH_16S, 1 );
00046 colorlaplace = cvCreateImage( cvSize(frame->width,frame->height), 8, 3 );
00047 }
00048
00049 cvCvtPixToPlane( frame, planes[0], planes[1], planes[2], 0 );
00050 for( i = 0; i < 3; i++ )
00051 {
00052 cvLaplace( planes[i], laplace, 3 );
00053 cvConvertScaleAbs( laplace, planes[i], 1, 0 );
00054 }
00055 cvCvtPlaneToPix( planes[0], planes[1], planes[2], 0, colorlaplace );
00056 colorlaplace->origin = frame->origin;
00057
00058 cvShowImage("Laplacian", colorlaplace );
00059
00060 if( cvWaitKey(10) >= 0 )
00061 break;
00062 }
00063
00064 cvReleaseCapture( &capture );
00065 cvDestroyWindow("Laplacian");
00066
00067 return 0;
00068 }
00069
00070 #ifdef _EiC
00071 main(1,"laplace.c");
00072 #endif