Tuesday, 15 June 2010

visual c++ - Capture still images from photo stream using capture engine manager in media foundation -


Thank you very much for your prompt reply. I have posted the sample code which I used on the image using the TakePhoto () method Use to capture. This method is returning success. OnCaptureEvent () is used to handle an event with the capture engine and its returning MF_CAPTURE_ENGINE_ERROR error.

  HRESULT TakePhoto () {HRESULT hr = m_pEngine-> GetSink (MF_CAPTURE_ENGINE_SINK_TYPE_PHOTO, and pSink); If (FAILED (HR)) {goto; } Hours = pSink-> QueryInterface (IID_PPV_ARGS (& amp; amp; pPhoto)); If (FAILED (HR)) {goto; } Hr = m_pEngine-> GetSource (& amp; pSource); If (FAILED (HR)) {goto; } Hr = pSource-> GetCurrentDeviceMediaType (1, and PMDI type); // 1 is the image stream index. I will find the current image stream media type here. If (FAILED (HR)) {goto; } // Configure picture format hours = CreatePhotoMediaType (pMediaType, & amp; pMediaType2, GUID_ContainerFormatBmp); If (FAILED (HR)) {goto; } Hr = pPhoto-> Remove AllStreams (); If (FAILED (HR)) {goto; } DWORD dwSinkStreamIndex; // Before attempts to connect the image stream to still sync the photo, (bHasPhotoStream) {hours = pPhoto-> AddStream ((DWORD) MF_CAPTURE_ENGINE_PREFERRED_SOURCE_STREAM_FOR_PHOTO, pMediaType2, Zero, & dwSinkStreamIndex); Instead of MF_CAPTURE_ENGINE_PREFERRED_SOURCE_STREAM_FOR_PHOTO //, I gave the index, as if the 1.i error is occurring, (FAILED (hour)) {Goto; }} Hr = pPhoto-> SetOutputFileName (pszFileName); If (FAILED (HR)) {goto; } Hr = m_pEngine-> TakePhoto (); If (FAILED (HR)) {goto; } Return hour; } HRESULT OnCaptureEvent (WPARAM wParam, LPARAM lParam) {GUID guidType; HRESULT HR Stratus; IMFMediaEvent * pEvent = reinterpret_cast & lt; IMFMediaEvent * & gt; (WParam); Hr = pEvent-> GetExtendedType (& guidType); If (SUCCEEDED (hour)) {if (guidType == MF_CAPTURE_ENGINE_ERROR) // I get this error if I give dwSourceStreamIndex as '1' in AddStream API {DestroyCaptureEngine; }} PEvent-> Release (); Returns HRStats; }  


No comments:

Post a Comment