Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Create invisible window to hold the capture window.
- hwnd = CreateWindowEx(0, _T("webcampcapwindow"), _T(""), 0, 0, 0, 1, 1, HWND_DESKTOP, NULL, GetModuleHandle(NULL), NULL);
- if( !hwnd )
- throw FatalException( _T("main Capture window create failed"), _T(__FILE__), __LINE__ );
- //Create capture window.
- capHwnd = capCreateCaptureWindow(_T("webcampcapwindowchild"), WS_CHILD, 0, 0, 1, 1, hwnd, 1);
- if( !capHwnd )
- throw FatalException( _T("secondary Capture window create failed"), _T(__FILE__), __LINE__ );
- CAPDRIVERCAPS caps;
- if(capDriverConnect(capHwnd, 0)) {
- connectedtoWc = true;
- break;
- }
- if ( !connectedtoWc )
- throw FatalException( _T("Could not connect to capture driver."), _T(__FILE__), __LINE__ );
- //Attach our callback to the capture window.
- if( !capSetCallbackOnVideoStream(capHwnd, videoCallback))
- throw FatalException( _T("Unable to Attach our callback to the capture window."), _T(__FILE__), __LINE__ );
- //Make sure we can access this object from the callback.
- if(!capSetUserData(capHwnd, this))
- throw FatalException( _T("Could not associate user data with capture."), _T(__FILE__), __LINE__ );
- //Check everything's initialised.
- caps.fCaptureInitialized = false;
- if( !capDriverGetCaps(capHwnd, &caps, sizeof(CAPDRIVERCAPS)))
- throw FatalException( _T("Unable to get driver caps"), _T(__FILE__), __LINE__ );
- if(!caps.fCaptureInitialized)
- throw FatalException( _T("Unable to initialize capture driver"), _T(__FILE__), __LINE__ );
- if (caps.fHasDlgVideoSource)
- capDlgVideoSource(capHwnd);
Add Comment
Please, Sign In to add comment