vc6.0 usa opencv1.0 para darse cuenta del problema de mostrar el video de la cámara en el control de imagen
#include "CvvImage.h"
#include lt;highgui.hgt;
#include lt;cv.hgt;
IplImage * g_Frame; // usado para almacenar un fotograma
CvvImage g_CvvImage;
CvCapture * g_Video;
CRect g_Rect;
bool g_bRun = true;
DWORD WINAPI ThreadFun(LPVOID lParam)
{
xxxDlg* dlg = (xxxDlg*)lParam;
CDC* pDC;
HDC hdc;
CWnd *pwnd;
mientras( g_bRun )
{
g_Frame = cvQueryFrame( g_Video );
pwnd= dlg-gt; GetDlgItem(IDC_STATIC); //control PIC
pDC=pwnd-gt(); p> p>
hdc=pDC-gt;GetSafeHdc();
pwnd-gt;GetClientRect(amp;g_Rect);
g_CvvImage.CopyOf(g_Frame, 1) ;/ /g_CvvImage es un tipo CvvImage
g_CvvImage.DrawToHDC(hdc, amp;g_Rect);
dlg-gt;ReleaseDC(pDC);
}
devuelve 0;
}
BOOL xxxDlg::OnInitDialog()
{
..
//Abrir cámara
g_Video = cvCreateCameraCapture( -1 );
if ( !g_Video )
{
AfxMessageBox ("No se puede abrir la cámara");
return FALSE;
}
//Crear un hilo
CreateThread ( NULL, 0 , ThreadFun, this, 0, NULL);
}
//Recuerda soltar al final
void xxxDlg::OnDestroy( )
{
CDialog::OnDestroy();
// TODO: Agregue el código del controlador de mensajes aquí
g_bRun = false;
cvReleaseCapture(amp;g_Video);
}