Metro ap how to achieve MediaCapture resolution change lead to preview size change

Con risposta Metro ap how to achieve MediaCapture resolution change lead to preview size change

All Replies

  • Friday, December 30, 2011 11:28 PM
    Moderator
     
     

    Hello,

    Unfortunately I don’t fully understand your question. Are you trying to get an event from the MediaCapture object when a dynamic format change occurs? I’m not sure that we have fully tested dynamic format change from a USB camera source. Theoretically this should work. Can you please give me more detail about what you are trying to do and I will do what I can to help.

    James,

    Windows Media SDK Technologies
    Microsoft Developer Services
    http://blogs.msdn.com/mediasdkstuff/

  • Tuesday, January 03, 2012 1:46 AM
     
     

    Hi James,

    USB camera support some diff resolution,eg:1920x1080 1280x720 640x480.w/h=16/9 or 4/3,I want different w/h,the preview size can change with it.

  • Thursday, January 05, 2012 12:21 AM
    Moderator
     
     Answered

    So from what I understand you are expecting the preview “window” height and width to change automatically when you set the resolution of the camera. I expect that you will need to do this in your code. I don’t expect that the preview window itself will change its resolution. I expect the rich compositor to automatically scale the video to fit in the predefined “window” size. To make this change happen you will have to change the size of the preview “window” yourself.

    I hope this helps,

    James

    • Marked As Answer by 淡黄妹 Thursday, January 05, 2012 1:39 AM
    •  
  • Thursday, January 05, 2012 1:39 AM
     
     

    Thanks for your help.

  • Friday, February 24, 2012 4:46 AM
     
     

    Dears,

    When you use MediaCapture to create a camera Metro ap,

    Do you know how to change the Resolution? 

    (Please provide me the source code.. Thanks!!!)

     

  • Friday, May 11, 2012 6:49 PM
     
     

    Hi all, does anyone know how to change the resolution of mediaCapture?

    The photos I take with my aplication comes with lower resolution then the ones I take with the camera app that comes with windows (wich I can set to a greater resolution).

    Thanks in advance!

    • Proposed As Answer by Srta Bang Wednesday, May 16, 2012 7:35 PM
    • Unproposed As Answer by Srta Bang Wednesday, May 16, 2012 7:35 PM
    •  
  • Wednesday, May 16, 2012 7:43 PM
     
     Proposed Has Code

    Hi, i just found the solution.

    The code bellow provides information about the resolution of camera. It gets the greater resolution available in YUY2 format. You can see on output windows the available resolutions.

    private MediaCapture mediaCapture_;
    bool DEBUG_ = true;
    ...
    this.mediaCapture_ = new MediaCapture();
    await this.mediaCapture_.InitializeAsync();
    ...
    
    public async Task SetResolution()
            {
                System.Collections.Generic.IReadOnlyList<IMediaEncodingProperties> res;
                res = this.mediaCapture_.VideoDeviceController.GetAvailableMediaStreamProperties(MediaStreamType.VideoPreview);
                uint maxResolution = 0;
                int indexMaxResolution = 0;
                string s = "";
    
                if (res.Count >= 1)
                {
                    for (int i = 0; i < res.Count; i++)
                    {
                        VideoEncodingProperties vp = (VideoEncodingProperties)res[i];
                        var frameRate = (vp.FrameRate.Numerator / vp.FrameRate.Denominator);
                        
    
                        s = i + ") " + vp.Subtype + ", ";
                        s = s + vp.Width;
                        s = s + " x " + vp.Height;
                        s = s + " , Frame/s: " + frameRate;
                        
                        if (vp.Width > maxResolution && vp.Subtype.Equals("YUY2"))
                        {
                            indexMaxResolution = i;
                            maxResolution = vp.Width;
    
                        }
                        if (DEBUG_)
                        {
                            Debug.WriteLine(s);
                        }
                        s = "";
                    }
    
                    //setting resolution
                    await mediaCapture_.VideoDeviceController.SetMediaStreamPropertiesAsync(MediaStreamType.VideoPreview, res[maxResolution]);
    
    
                }
            }

    • Proposed As Answer by Srta Bang Wednesday, May 16, 2012 7:44 PM
    •  
  • Wednesday, March 06, 2013 12:43 PM
     
     

    Thanks for your help.

       你好,我现在也想用MediaCapture拍摄,问题和你一样,也是没法调宽高比,不知道这个问题你解决了没呢。。。

       Hi,now I want to use MediaCapture ,the same problem come to me ,i can't reset the video's hight or width , i guess u have sovled the question ,can you help me?