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 52 53 54 55 56 57 58 59 60 61 62 63 64
|
#include <stdlib.h>
#include <cv.h>
#include <cvaux.h>
#include <cxcore.h>
#include <highgui.h>
#include <stdio.h>
Void Laplacien_Apartir_Dune_VIDEO(){
IplImage* laplace = 0;
IplImage* colorlaplace = 0;
IplImage* planes[3] = { 0, 0, 0 };
CvCapture* capture = 0;
char* c="blabla.avi";
capture = cvCaptureFromAVI( c);
// capture = cvCaptureFromCAM(0); // pour lancer la capture à partir d'une webcam
if( !capture )
{
fprintf(stderr,"Could not initialize capturing...\n");
return -1;
}
cvNamedWindow( "Laplacian", 0 );
for(;;)
{
IplImage* frame = 0;
int i;
frame = cvQueryFrame( capture );
if( !frame )
break;
if( !laplace )
{
for( i = 0; i < 3; i++ )
planes[i] = cvCreateImage( cvSize(frame->width,frame->height), 8, 1 );
laplace = cvCreateImage( cvSize(frame->width,frame->height), IPL_DEPTH_16S, 1 );
colorlaplace = cvCreateImage( cvSize(frame->width,frame->height), 8, 3 );
}
cvCvtPixToPlane( frame, planes[0], planes[1], planes[2], 0 );
for( i = 0; i < 3; i++ )
{
cvLaplace( planes[i], laplace, 3 );
cvConvertScaleAbs( laplace, planes[i], 1, 0 );
}
cvCvtPlaneToPix( planes[0], planes[1], planes[2], 0, colorlaplace );
colorlaplace->origin = frame->origin;
cvShowImage("Laplacian", colorlaplace );
if( cvWaitKey(10) >= 0 )
break;
}
cvReleaseCapture( &capture );
cvDestroyWindow("Laplacian");
} |
Partager