Using Camera with DirectShow in Windows Mobile
-
How is this Qt related?
-
The CodeExample:
Windows Mobile 6 SDK\Samples\PocketPC\CPP\win32\CameraCaptureI included graphmanager.cpp and cpropertybag.cpp (and Headers) into my QT-Project.
In my QDialog i´ve a frame where I want to show the Preview of the Camera, todo this i included the code from the Example in a function called InitializeGraph()
@
bool Beladezustand::InitializeGraph()
{HRESULT hr; wchar_t szDevicename[MAX_PATH] = L"\0"; CPropertyBag PropBag; CComVariant varCamName; CComPtr<IGraphBuilder> pFilterGraph; CComPtr<ICaptureGraphBuilder2> pCaptureGraphBuilder; CComPtr<IBaseFilter> pVideoCaptureFilter; CComPtr<IPersistPropertyBag> pPropertyBag; CComPtr<IMediaControl> pMediaControl; IVideoWindow *pVidWin; //Capture Graph anlegen hr = CoCreateInstance(CLSID_CaptureGraphBuilder, NULL, CLSCTX_INPROC_SERVER, IID_ICaptureGraphBuilder2, (void **)&pCaptureGraphBuilder); hr = CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER,IID_IGraphBuilder, (void **)&pFilterGraph); hr = pCaptureGraphBuilder->SetFiltergraph( pFilterGraph ); //Media Control abrufen hr = pFilterGraph->QueryInterface(IID_IMediaControl,(void **)&pMediaControl); //Video Window abrufen hr = pFilterGraph->QueryInterface(IID_IVideoWindow,(void **)&pVidWin); //Capture Filter anlegen hr = CoCreateInstance(CLSID_VideoCapture, NULL, CLSCTX_INPROC,IID_IBaseFilter, (void**)&pVideoCaptureFilter); //IPersistPropertyBag abrufen hr = pVideoCaptureFilter->QueryInterface( &pPropertyBag ); //Kamera laden GetFirstCameraDriver(szDevicename); varCamName = szDevicename; hr = PropBag.Write( L"VCapName", &varCamName ); hr = pPropertyBag->Load( &PropBag, NULL ); hr = pFilterGraph->AddFilter( pVideoCaptureFilter, L"Video Capture Filter Source" ); //Mit dem Preview PIN verbinden hr = pCaptureGraphBuilder->RenderStream(&PIN_CATEGORY_PREVIEW, &MEDIATYPE_Video, pVideoCaptureFilter, NULL, NULL); //Das Preview Fenster setzen
// CRect rc;
// ::GetClientRect(m_hWnd,&rc);hr = pVidWin->put_Owner((OAHWND)frame->winId()); //<-- QT Frame where i want to show the Camera-Preview in hr = pVidWin->put_WindowStyle(WS_CHILD | WS_CLIPSIBLINGS); long pWidth, pHeight; hr = pVidWin->get_Width(&pWidth); hr = pVidWin->get_Height(&pHeight); hr = pVidWin->put_Height(215); hr = pVidWin->put_Width(162); //hr = pVidWin->SetWindowPosition(0,0,162,215); //Den Stream abspielen (Preview anzeigen) hr = pMediaControl->Run();
}
@I just wonder why the CodeExample from MS works and why not in my Qt-Project. Perhaps it works but the the delivered frame->winId() does not work for the MS functions...
EDIT: please sorround code by @-tags, Gerolf
-
-
I have no experience with debugging on windows mobile. Is there a way to get some debug output when trying to start the application? Does that yield anything?
Are you sure all your libraries and your application are in the same compile mode (debug or release)? I am just giving some suggestions on what might be wrong here...