Mar 19, 2009 at 8:23am UTC
My code is to display a webcam. I meet problem when it runs. I am working with VC 6.0 and using opencv , and I add a button command function ,codes as follow:
void CFace2View::OnBtnStart()
{
CClientDC pDC(this);
if((m_pcapture = cvCaptureFromCAM(-1)) == NULL)
{
MessageBox("Could not initialize capturing...\n");
return ;
}
for(;;)
{
if(NULL==(m_frame=cvQueryFrame(m_pcapture)))
{
MessageBox("Can not get frame!");
break;
}
CRect r;
GetClientRect (&r);
m_image.CopyOf(m_frame,1);
m_image.DrawToHDC(pDC.GetSafeHdc() ,r);
if(!m_camflag)
break;
}
cvReleaseCapture(&m_pcapture);
//return ;
}
and in ONDRAW()function :
void CFace2View::OnDraw(CDC* pDC)
{
CFace2Doc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
CRect r;
GetClientRect (&r);
m_image.DrawToHDC(pDC->GetSafeHdc() ,r);
}
When it runs ,it displays well ,but when I click mouse in window or move window, the program would die. Who can help me?? thanks
Mar 19, 2009 at 9:04am UTC
You already have a topic on the other Board. Delete one of them?