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
| #include <cv.h>
#include <cvaux.h>
#include <highgui.h>
#include <stdio.h>
void on_mouse(int event, int x, int y, int flags, void *param)
{
switch(event)
{
case CV_EVENT_LBUTTONDOWN: printf("MouseLeftButtonDown x= %d y= %d\n",x,y);break;
case CV_EVENT_RBUTTONDOWN: printf("MouseRightButtonDown x= %d y= %d\n",x,y);break;
}
}
int main()
{
CvCapture* capture=cvCaptureFromCAM(0);
cvNamedWindow("Capture Webcam", CV_WINDOW_AUTOSIZE);
cvNamedWindow("Lissage Gaussien", CV_WINDOW_AUTOSIZE);
cvSetMouseCallback("Capture Webcam",on_mouse,0);
if(capture)
{
IplImage* frame=cvQueryFrame(capture);
int width = (int)cvGetCaptureProperty( capture, CV_CAP_PROP_FRAME_WIDTH );
int height= (int)cvGetCaptureProperty( capture, CV_CAP_PROP_FRAME_HEIGHT);
IplImage* gray = cvCreateImage(cvSize(width,height), IPL_DEPTH_8U ,1);
IplImage* gaussian = cvCreateImage(cvSize(width,height), IPL_DEPTH_8U ,1);
printf("PRESS SPACE TO QUIT \n\n");
while(1)
{
frame = cvQueryFrame(capture);
cvShowImage("Capture Webcam",frame);
cvConvertImage(frame,gray,1);
cvSmooth(gray,gaussian,CV_GAUSSIAN,5,5);
cvShowImage("Lissage Gaussien",gaussian);
if(cvWaitKey(1)==' ')break;
}
}
else printf("Video stream not found\n\n");
cvWaitKey(0);
return 0;
} |
Partager