轉灰階
IplImage * GRAY = 0; GRAY = cvCreateImage(cvSize(frame1->width,frame1->height),IPL_DEPTH_8U,1); cvCvtColor(frame1, GRAY, CV_RGB2GRAY); cvCvtColor(GRAY, frame1, CV_GRAY2RGB); cvReleaseImage(&GRAY);
啟動WebCam,並指定handle給 Panel
int ncams = cvcamGetCamerasCount(); int width=640; int height=480; Panel1->Width = width; Panel1->Height = height; HWND hwnd = Panel1->Handle; cvcamSetProperty(0, CVCAM_PROP_ENABLE, CVCAMTRUE); cvcamSetProperty(0, CVCAM_PROP_CALLBACK,CaptureCallback); cvcamSetProperty(0, CVCAM_PROP_WINDOW, &hwnd); cvcamSetProperty(0,CVCAM_RNDWIDTH,&width); cvcamSetProperty(0,CVCAM_RNDHEIGHT,&height); cvcamGetProperty(0,CVCAM_CAMERAPROPS,NULL); // 開啟webcam設定介面 cvcamInit(); cvcamStart();
關閉WebCam
cvcamStop(); cvcamExit();