locked
How to capture high resolution video and capture photo from it in windows 8.1. I am having a UI jumping effect while teied it

    Question

  • Im my camera capturing application am used to take continuous photos using the Camera implemented in a view using `CaptureElement`. When it taks continuouly capturing the photos the UI is moving back and forth seems like a jump effect. That is the problem am facing.

    Codes used are the following

        var cameras = await DeviceInformation.FindAllAsync(DeviceClass.VideoCapture);
        MediaCaptureInitializationSettings settings=new MediaCaptureInitializationSettings { VideoDeviceId = cameras[0].Id, StreamingCaptureMode = StreamingCaptureMode.Video };
        var_mediaCapture = new MediaCapture();
        await _mediaCapture.InitializeAsync(settings);
        if (null != videoCapture) videoCapture.Source = _mediaCapture;
                    await _mediaCapture.StartPreviewAsync();

    setting the high resolution

        int max = 0;
        var resolutions = videoController.GetAvailableMediaStreamProperties(MediaStreamType.Photo);
                    for (var i = 0; i < resolutions.Count; i++)
                    {
                        ImageEncodingProperties res = resolutions[i] as ImageEncodingProperties;
                        if (null == res) continue;

                      
                        if (res.Width * res.Height < max)
                        {
                            max = (int)(res.Width * res.Height);
                            _imageEncodingProperties = res;
                        }
                    }

             await videoController.SetMediaStreamPropertiesAsync(MediaStreamType.Photo, _imageEncodingProperties);
    And capturing the photo from video frame using 

            using (var photoStream = new InMemoryRandomAccessStream())
                        {                        
                            await _mediaCapture.CapturePhotoToStreamAsync(_imageEncodingProperties, photoStream);
                            await photoStream.FlushAsync(); 
                        }

    I tested capturing by setting different video resolutions.

        var videoController = _mediaCapture.VideoDeviceController;

     Firstly i set default `preview resolution [640x480]` for the videoController and capturing process is taking place without any issue. And after that i checked it by setting `High resolution [1200x800]` in Surface tablet , in this case a photo frame is appearing over the video control for a moment and and it is having some small width on each side. It feels like a zoom in / zoom out effect [back n forward jumping] in the camera view. 

    Have anybody getting this problem when setting high resolution to the video media element video controller in windows 8.1? I t will be great if anybody can explain it's reason. 

    Thanks

    **EDIT:**
    I analysed the situation and found the following things

    There many available resolutions
    640 x 360 , 1280x720 , 1280x800 , 640x480 etc

    And i found that this problem is not at all occurs at the resolutions where width to height ratio is 1.777778. All other resolutions where the rato is less than 1.777 have the issue.

    That is , The problem doesn't exists for 640x360 , 1280x720 resolutions and other two have the jumping effect. I think the last 2 one have the ratio 1.6 and 1.33 respectively.

    Also i checked with `default camera app` and captured photos by setting 1280x800 resolution, there i saw there is a black border both sides of the camera element in the window.

    What is wrong there ? Anybody knows the reason ?


    Friday, May 23, 2014 2:07 PM

All replies

  • This is expected. If your image is a different aspect ratio from the window it is displayed in then it can't fit exactly. It can  stretch and distort, crop and lose part of the picture, or letterbox and not completely fill in one direction. The black bars are letterboxing and fill the space outside of the image.
    Friday, May 23, 2014 2:51 PM
    Owner
  • This is expected. If your image is a different aspect ratio from the window it is displayed in then it can't fit exactly. It can  stretch and distort, crop and lose part of the picture, or letterbox and not completely fill in one direction. The black bars are letterboxing and fill the space outside of the image.

    Hi Rob, it is important that you did reply to the thread.

    Bu i need little more clarification on your answer. The camera capture UI is filled in the 1366x768 window and i could understand that normally there will be a jump for fit a 1280x800 size preview image.

    But as i seem in the default windows camera application that there are 2 black bars appears on both left and right sides of the camera UI on 1280x800 resolution or 16:10 aspect ration. So i adjusted my camera UI width and but there is not such improvements happened. 

    How can i handle this atleast in the 1280x800 resolution? 

    Also note that this issue occurs on continuous capturing the photo and we are not saving and displaying image over the UI. 

    I also tested with setting different Camera Capture element Height and Width . But in those cases also the jumping effect is there while capturing on  1280x800 resolution.

    Also i found the following data. 

    In surface RT these are the following available camera  resolutions. Their Width to Height ratios also enumerated below. 

    1.        640x360       w/h ratio : 1.7777777778
    2.        1280x720        "              : 1.7777777778
    3.        960x540           "              : 1.7777777778
    4.        800x480          "              : 1.6666666667
    5.        640x480          "              : 1.333333333
    6.        424x240          "              : 1.76666666
    7.        320x240          "              : 1.3333333333
    8.        320x180           "             : 1.77777777778
    9.        160x120          "              : 1.3333333
    10.    160x90             "             : 1.77777777778
    11.    1280x800       "              : 1.6

    This effect is present in all resolutions which marked as red colored and notice that all other resolution Width to height ratio is 1.777778 .

    Thanks
    Tuesday, May 27, 2014 5:55 AM
  • What behavior do you want?

    It is physically impossible to fit two rectangles of different aspect ratios into exactly the same space without either distorting, clipping, or letterboxing.

    In most cases letterboxing (the black bars you mention) is preferred since that will still show the entire video without distortion.

    --Rob

    Tuesday, May 27, 2014 10:16 PM
    Owner