locked
Metro ap how to achieve MediaCapture resolution change lead to preview size change RRS feed

回答

  • 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

    • 回答としてマーク 淡黄妹 2012年1月5日 1:39
    2012年1月5日 0:21
    モデレータ

すべての返信

  • 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/

    2011年12月30日 23:28
    モデレータ
  • 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.

    2012年1月3日 1:46
  • 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

    • 回答としてマーク 淡黄妹 2012年1月5日 1:39
    2012年1月5日 0:21
    モデレータ
  • Thanks for your help.

    2012年1月5日 1:39
  • 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!!!)

     

    2012年2月24日 4:46
  • 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!

    • 回答の候補に設定 Srta Bang 2012年5月16日 19:35
    • 回答の候補の設定解除 Srta Bang 2012年5月16日 19:35
    2012年5月11日 18:49
  • 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]);
    
    
                }
            }

    • 回答の候補に設定 Srta Bang 2012年5月16日 19:44
    2012年5月16日 19:43
  • 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?

    2013年3月6日 12:43
  • Awesome, thanks. I have read much documentation on the MediaCapture class that claims it is not possible to alter the resolution, and I was getting quite discouraged. When I queried the available streams, I had 55 to choose from, and it was just a matter of selecting the correct one.

    Thanks.

    2013年7月8日 22:38
  • Well Done!  This has been plaguing me for two days.  Thanks!

    Rob

    2013年8月16日 14:21
  • I have also trouble with this problem.I have test your solution but not work.My project here:(https://github.com/79144876/ZXingStoreApp/blob/master/ZXingStoreApp/MainPage.xaml.cs)

    And i have ask here:http://stackoverflow.com/questions/23472248/how-to-adjust-zxing-on-windows-phone-store-app-8-1-camera-mediacapture-preview

    2014年5月5日 12:41