?
Hallo,
gibt es eine Reihenfolge bei der Verwendung von video for windows und diesen cap Funktionen bzw. Makros ?
Ich erstelle ein Fenster mit capCreateCaptureWindow
mit capGetVideoFormat und capSetVideoFormat kann man die
Größe ändern.
m_hwndCap = capCreateCaptureWindow("USB-Camera",WS_CHILD | WS_VISIBLE,rect.TopLeft().x,rect.TopLeft().y,rect.Width(),rect.Height(),m_ParentWindowHandle,999);
capSetCallbackOnError(m_hwndCap, NULL);
capSetCallbackOnStatus(m_hwndCap, NULL);
capSetCallbackOnVideoStream(m_hwndCap, NULL);
capSetCallbackOnFrame(m_hwndCap, NULL);
capSetCallbackOnCapControl(m_hwndCap, NULL); //?
capSetCallbackOnWaveStream(m_hwndCap, NULL);
capSetCallbackOnYield(m_hwndCap, NULL);
if(capDriverConnect(m_hwndCap,m_iDriverID) && m_iDriverID >= 0)
{
capSetCallbackOnFrame(m_hwndCap,lpFrameCallback);
capSetUserData(m_hwndCap,userData);
//// set video format
//DWORD dwSize;
//dwSize = capGetVideoFormatSize(m_hwndCap);
//// allocate memory for bitmapinfo structure
//m_lpbi = (LPBITMAPINFO)malloc(sizeof(BITMAPINFO));
//capGetVideoFormat(m_hwndCap, m_lpbi, dwSize);
//m_lpbi->bmiHeader.biWidth = 640;//m_dwWidth;
//m_lpbi->bmiHeader.biHeight = 480;//m_dwHeight;
//capSetVideoFormat(m_hwndCap,m_lpbi,dwSize);
capPreviewRate(m_hwndCap,100);
capPreview(m_hwndCap,TRUE);
//// set video format
DWORD dwSize;
dwSize = capGetVideoFormatSize(m_hwndCap);
// allocate memory for bitmapinfo structure
m_lpbi = (LPBITMAPINFO)malloc(sizeof(BITMAPINFO));
capGetVideoFormat(m_hwndCap, m_lpbi, dwSize);
m_lpbi->bmiHeader.biWidth = 352;//m_dwWidth;
m_lpbi->bmiHeader.biHeight = 288;//m_dwHeight;
capSetVideoFormat(m_hwndCap,m_lpbi,dwSize);
capSetVideoFormat(m_hwndCap,m_lpbi,dwSize);
// free memory
free(m_lpbi);
}
else
{
::MessageBox(NULL,_T("Es ist ein Fehler aufgetreten"),_T("Fehler"),MB_OK);
::DestroyWindow(m_hwndCap);
return FALSE;
}
Gibt es da eine Reihenfolge die zu beachten ist ? Wenn ich die Videogröße umstelle dann erscheint bei dem ersten Versuch nur ein schwazes FEnster.
Starte ich dann zum zweiten mal Habe ich das Fenster in der gewünschten Größe.
Weiß jemand woran das liegt?
Ich arbeite mit der MFC. Also das ist alles in einem Dialog eingebettet.
Grüße
cmos