采集视频并显示在picture控件上面,
void FunDraw()
{m_pcapture = NULL;
IplImage* image = 0; //original image
CvvImage cimg;
m_dlg = (CTttestDlg *)GetDlgItem(IDC_VIEW1); //picture 控件的ID 值IDC_VIEW1
CDC *pDC = m_dlg->GetDC(); //获得picture控件的DC
HDC hDC = pDC->GetSafeHdc();
CRect rect;
m_dlg->GetClientRect(&rect);//获得控件的大小
m_pcapture = cvCaptureFromCAM(0);
while (1)
{
if( !(cvGrabFrame(m_pcapture)) )
break;
image = cvQueryFrame( m_pcapture );
cimg.CopyOf(image,2);
cvWaitKey(20);
cimg.DrawToHDC(hDC,&rect);
Sleep(100);
}
cvReleaseCapture( &m_pcapture );
}