locked
How to get all supported resolution ,then change resolution when Preview from Code--Capture Engine webcam capture sample RRS feed

  • Question

  • Hi:

        I  use souce code CaptureEngine sample from MSDN. I use MF function: MFGetAttributeSize(pType, MF_MT_FRAME_SIZE, &width, &height)  to get resolution.For example,it is 1600*1200.

      Which function Can I use to get the maximum resolution?

       And How can I get all supported resolution,for example, 800*600,640*480,320*240. which function can I use to enumerate these resolution.

      Thank you.

      Attach:

             Thank CA 2 LA's reply, I can enumerate resolution. But I found I can't change the resolution when Previewing,Please see third floor in detail.





    • Edited by smartjimmy Thursday, May 17, 2012 12:25 PM
    Monday, May 14, 2012 12:27 PM

Answers

  • Use Function:

      SetCurrentDeviceMediaType((DWORD)MF_CAPTURE_ENGINE_PREFERRED_SOURCE_VIDEO_STREAM_FOR_PREVIEW,pMediaType);  

    can resolve the problem.

    • Marked as answer by smartjimmy Friday, May 18, 2012 8:09 AM
    Friday, May 18, 2012 8:09 AM

All replies

  • Thank you for your reply.

          I use code --Capture Engine webcam capture sample:  http://code.msdn.microsoft.com/windowsdesktop/Media-Foundation-Capture-78504c83/sourcecode?fileId=42771&pathId=1259357688

         I use your method ,can get all supported resolution. use function:

        hr = pSource->GetAvailableDeviceMediaType((DWORD)MF_CAPTURE_ENGINE_PREFERRED_SOURCE_VIDEO_STREAM_FOR_PREVIEW , i, &pMediaType);

         I increase the index-i,can enumerate all the resolutin.

         I use MFGetAttributeSize(pType, MF_MT_FRAME_SIZE, &width, &height) ,found the width,height can be changed.

         But  I found that I can't  to chage the Preview resolution, Preview image was no changed.

        What's wrong ?

        Thank you .



    • Edited by smartjimmy Thursday, May 17, 2012 12:22 PM
    Thursday, May 17, 2012 12:09 PM
  • Use Function:

      SetCurrentDeviceMediaType((DWORD)MF_CAPTURE_ENGINE_PREFERRED_SOURCE_VIDEO_STREAM_FOR_PREVIEW,pMediaType);  

    can resolve the problem.

    • Marked as answer by smartjimmy Friday, May 18, 2012 8:09 AM
    Friday, May 18, 2012 8:09 AM
  • Can I use  MFSetAttributeSize(pType, MF_MT_FRAME_SIZE, width, height) to set the preview resolution?

    I can use the function hr = pSource->GetAvailableDeviceMediaType((DWORD)MF_CAPTURE_ENGINE_PREFERRED_SOURCE_VIDEO_STREAM_FOR_PREVIEW , i, &pMediaType); 

    to get a valid pMediaType and use SetCurrentDeviceMediaType((DWORD)MF_CAPTURE_ENGINE_PREFERRED_SOURCE_VIDEO_STREAM_FOR_PREVIEW,pMediaType);   

    to set the resolution successfully.

    But I cannot use MFSetAttributeSize(pType, MF_MT_FRAME_SIZE, width, height); to set it. Therefore, I cannot assign the resolution size directly. Is there any problem for my using MFSetAttributeSize?

    thank you

    Thursday, May 24, 2012 8:41 AM
  • Dear Nicholas:

                    the following is only my view.Only use MFSetAttributeSize may not change resolution,because preview may be affected by many aspects,such as resolution ratio,frame rate.Only change resolution may result in previw failed.so use GetAvailableDeviceMediaType to get all supported resolution,then use MFGetAttributeSiz to read out Width and Height, then use SetCurrentDeviceMediaType to set the specific resulution which you need.

    Monday, May 28, 2012 1:53 AM
  • Dear smartjimmy,

            thank you for your reply, I think you are right, and I can understand it now.

           In additional, ask one more question maybe you can help me. Is there a function can set the brightness, contrast and other video properties of the webcam in Media Foundation, just like IAMVideoProcAmp interface in DirectShow? I'm so confused by this several days.

           thanks again for your help.

    Wednesday, May 30, 2012 7:32 AM
  • Dear Nicholas:

                I also can't answer your question about these questions.Your should open a new topic on the forum to ask someone else.

    Friday, June 1, 2012 1:31 AM
  • maybe it´s enough for you to set those values at rendering time by getting an IMFVideoProcessor from EVR and call SetProcAmpValues. 

    you can set brightness, contrast, hue and saturation there.

    Friday, June 1, 2012 6:26 AM
  • Thank you for your reply, the IMFVideoProcessor can set those values in graphics card.

    But now I need to write a test Media Foundation application which can be used to test the camera driver of AVStream, so I need to set the values in media source, but not in EVR or graphics card.

    I have found the IPropertyStore interface maybe suitable, but I don't know how to connect IPropertyStore with media source.

    I'm still working on it. Any suggestions would be appreciated.

    thank you again.

    Friday, June 1, 2012 6:52 AM
  • dear Smartjimmy:

               thank you for your help.

    Friday, June 1, 2012 6:53 AM