简体   繁体   English

如何在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

Im my camera capturing application am used to take continuous photos using the Camera implemented in a view using CaptureElement . 我的相机拍摄应用程序用于在使用CaptureElement的视图中实现的相机拍摄连续照片。 When it taks continuouly capturing the photos the UI is moving back and forth seems like a jump effect. 当它连续拍摄照片时,UI来回移动似乎是一种跳跃效果。 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. 首先,我为videoController设置了默认的preview resolution [640x480] ,并且捕获过程正在顺利进行。 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. 之后,我通过在Surface平板电脑中设置“ High resolution [1200x800]进行了检查,在这种情况下,视频控件上会出现一帧相框,并且相框的每一侧都有很小的宽度。 It feels like a zoom in / zoom out effect [back n forward jumping] in the camera view. 在相机视图中,感觉就像是放大/缩小效果[后退n前跳]。

Have anybody getting this problem when setting high resolution to the video media element video controller in windows 8.1? 在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 有许多可用的分辨率640 x 360,1280x720,1280x800,640x480等

And i found that this problem is not at all occurs at the resolutions where width to height ratio is 1.777778. 我发现在宽高比为1.777778的分辨率下根本不会出现此问题。 All other resolutions where the rato is less than 1.777 have the issue. 比率小于1.777的所有其他分辨率都有问题。

That is , The problem doesn't exists for 640x360 , 1280x720 resolutions and other two have the jumping effect. 也就是说,对于640x360、1280x720分辨率不存在此问题,而其他两个具有跳跃效果。 I think the last 2 one have the ratio 1.6 and 1.33 respectively. 我认为最后2个比率分别为1.6和1.33。

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. 我还检查了default camera app并通过设置1280x800分辨率捕获了照片,在那里我看到窗口中相机元素的两侧都有黑色边框。

Conclusion: 结论:

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. 当我从可用的相机分辨率中设置了高分辨率[1280x800]时,该分辨率未保持曲面设备的纵横比[1366x768],因此图像试图适应屏幕并出现用户感觉到的跳跃效果。 So i set the Highest resolution which maintains the device aspect ratio , which is 1280x720 and the problem solved. 因此,我设置了最高分辨率以维持设备的宽高比,即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. 当我从可用的相机分辨率中设置了高分辨率[1280x800]时,该分辨率未保持曲面设备的纵横比[1366x768],因此图像试图适应屏幕并出现用户感觉到的跳跃效果。 So i set the Highest resolution which maintains the device aspect ratio , which is 1280x720 and the problem solved. 因此,我设置了最高分辨率以维持设备的宽高比,即1280x720并解决了问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM