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 "cvcam.h"
#include "highgui.h"
#include <iostream>
#include "cv.h"
static int index;
/**************************************************************************\
How to set video resolution programatically
\**************************************************************************/
void callback(IplImage* image)
{
IplImage* image1 = image;
int iheight,iwidth;
assert (image);
iheight = image1->height;
iwidth = image1->width;
//Algo de canny et affichage
cvCanny(image1, averageImage, 20, 100, 3);
cvShowImage("Original window",image1);
}
int ShowCamVideo(HWND hwnd, int width, int height)
{
VidFormat vidFmt={ width, height, 60.0};
int ncams = cvcamGetCamerasCount( );
cvcamSetProperty(0, CVCAM_PROP_ENABLE, CVCAMTRUE);
cvcamSetProperty(0, CVCAM_PROP_CALLBACK,(void*)callback);
cvcamSetProperty(0, CVCAM_PROP_WINDOW, &hwnd);
//Set Video Format Property
cvcamSetProperty( 0, CVCAM_PROP_SETFORMAT, &vidFmt);
if( !cvcamInit() )
return 0;
cvcamStart();
return 1;
}
int main( int argc, char** argv )
{
index = 0;
cvNamedWindow("Original window", CV_WINDOW_AUTOSIZE);
cvNamedWindow("Treated window", CV_WINDOW_AUTOSIZE);
if( ShowCamVideo((HWND)cvGetWindowHandle("Treated window"), 640, 480) )
{
cvWaitKey(0);
cvcamStop();
}
cvcamExit();
} |
Partager