如何在 Windows 8.1 中捕获高分辨率视频并从中捕获照片.我在尝试时遇到了 UI 跳跃效果 [英] How to capture high resolution video and capture photo from it in windows 8.1. I am having a UI jumping effect while tried it

查看:14
本文介绍了如何在 Windows 8.1 中捕获高分辨率视频并从中捕获照片.我在尝试时遇到了 UI 跳跃效果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的相机捕捉应用程序习惯于使用使用 CaptureElement 在视图中实现的相机拍摄连续照片.当它连续捕捉照片时,UI 来回移动似乎是一种跳跃效果.这就是我面临的问题.

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.

使用的代码如下

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();

设置高分辨率

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);

并使用

    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;

首先,我为 videoController 设置默认 预览分辨率 [640x480] 并且捕获过程正在发生,没有任何问题.之后,我通过在 Surface 平板电脑中设置 High resolution [1200x800] 来检查它,在这种情况下,视频控件上会出现一个相框,并且它的每一侧都有一些小宽度.感觉就像相机视图中的放大/缩小效果[后退向前跳跃].

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.

在 Windows 8.1 中为视频媒体元素视频控制器设置高分辨率时,有人遇到过这个问题吗?如果有人能解释它的原因,那就太好了.

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.

谢谢

我分析了一下情况,发现了以下几点

I analysed the situation and found the following things

有许多可用的分辨率640 x 360 , 1280x720 , 1280x800 , 640x480 等

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

我发现在宽高比为 1.777778 的分辨率下根本不会出现这个问题.比率小于 1.777 的所有其他分辨率都有问题.

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.

也就是说,640x360、1280x720分辨率不存在问题,另外两个有跳跃效果.我认为最后两个的比率分别为 1.6 和 1.33.

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.

我还检查了 default camera app 并通过设置 1280x800 分辨率拍摄照片,我看到窗口中相机元素的两侧都有黑色边框.

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.

结论:

问题在于纵横比.当我设置高分辨率[1280x800] 来自可用的相机分辨率保持表面设备的纵横比 [1366x768],以便图像正试图融入屏幕,并感受到跳跃效果用户.所以我设置了维护设备的最高分辨率纵横比,1280x720,问题解决了.

The issue was with the aspect ratio. When i set High resolution [1280x800] from the available camera resolutions which is not maintaining the surface device's aspect ratio [1366x768], so that the Image is trying to fit in to the screen and an jumping effect felt by the user. So i set the Highest resolution which maintains the device aspect ratio , which is 1280x720 and the problem solved.

推荐答案

实际上问题在于纵横比.当我设置高分辨率 [1280x800] 来自可用的相机分辨率,即不保持表面设备的纵横比 [1366x768],因此图像正试图适应屏幕并感觉到跳跃效果由用户.所以我设置了保持设备纵横比,1280x720,问题解决了.

Actually the issue was with the aspect ratio. When i set High resolution [1280x800] from the available camera resolutions which is not maintaining the surface device's aspect ratio [1366x768], so that the Image is trying to fit in to the screen and an jumping effect felt by the user. So i set the Highest resolution which maintains the device aspect ratio , which is 1280x720 and the problem solved.

这篇关于如何在 Windows 8.1 中捕获高分辨率视频并从中捕获照片.我在尝试时遇到了 UI 跳跃效果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆