从 CaptureElement & 执行实时视频流处理媒体捕捉 [英] Perform live video stream processing from CaptureElement & MediaCapture

查看:27
本文介绍了从 CaptureElement & 执行实时视频流处理媒体捕捉的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的 Windows 8 应用商店应用程序中,我倾向于执行实时视频流处理(例如人脸检测).

In my Windows 8 Store Application, I tend to perform live video stream processing (Face detection for example).

在我之前的 Windows 7 应用程序中,我能够使用以下技术 (C# 中的相机人脸检测使用 Emgu CV(.NET 中的 OpenCV)和 WPF)执行实时视频处理.该技术是,具有固定周期的计时器回调,以主动从相机对象查询图像缓冲区.

In my previous Windows 7 application, I was able to use the following technique (Camera Face Detection in C# Using Emgu CV (OpenCV in .NET) and WPF) to perform live video processing. The technique was, having a fixed period timer callback, to actively query image buffer from camera object.

void timer_Tick(object sender, EventArgs e)
{
    Image<Bgr,Byte> currentFrame = capture.QueryFrame();
    // Perform image processing based on currentFrame

<小时>

技巧2

我之前在 Android 中使用的另一种技术是,我将在相机本身上安装一个相机缓冲区预览回调.相机将通过传递捕获的相机缓冲区定期触发回调.从那里,我可以进行图像处理.


Technique 2

Another technique I had used before in Android is that, I will install a camera buffer preview callback on camera itself. The camera will periodically trigger the callback, by passing along the captured camera buffer. From there, I can perform image processing.

public abstract void onPreviewFrame (byte[] data, Camera camera)
{
    // Perform image processing based on data

<小时>

然而,在讨论Windows 8 Store Application的视频处理的文章中,他们大多使用内置的处理功能


However, in articles which talks about video processing for Windows 8 Store Application, they are mostly using built-in processing functions

它们都没有演示如何访问原始相机捕获的缓冲区,逐个像素地迭代缓冲区.

我相信我需要使用 CaptureElement &MediaCapture 根据

I believe I need to make use of CaptureElement & MediaCapture according to

http://blog.xyzzer.me/2012/01/22/displaying-webcam-preview-in-a-metro-app-using-winrt-and-xaml/

如果您只想查看网络摄像头输入或轻松将其捕获到文件中.如果你想处理视频实时或覆盖一些其他 UI 组件 - 输入...

This method is great if you just want to see the webcam input or capture it to a file with no hassle. If you want to process the video in real time or overlay some other UI components – enter…

CaptureElement &媒体捕捉方式

The CaptureElement & MediaCapture Way

不过,之后作者没有再详细说明.(我希望他这样做:)

However, the author doesn't elaborate more after that. (I hope he does so :)

任何提示如何从 CaptureElement & 执行实时视频流处理媒体捕捉?

Any hint how to perform live video stream processing from CaptureElement & MediaCapture?

推荐答案

您可以首先尝试的是 MediaCapture.CapturePhotoToStreamAsync,我认为这也只是该照片将被压缩的场景,但您可能会很快将其解码回WriteableBitmap 并对其像素进行一些处理.不过,您可能不会每秒处理太多帧.

What you could try first is MediaCapture.CapturePhotoToStreamAsync which I think also only scenarios where that photo will be compressed, but you could probably fairly quickly decode it back into a WriteableBitmap and do some processing on its pixels. You probably aren't going to process too many frames per second that way though.

更好的方法可能是使用 MediaCapture.AddEffectAsync() 并用 C++ 编写一个媒体基础转换 (MFT) 来处理视频并以某种方式将结果传回应用程序.

The better way to do it would probably be to use MediaCapture.AddEffectAsync() and write a Media Foundation Transform (MFT) in C++ that would process the video and somehow communicate the results back to the app.

这篇关于从 CaptureElement &amp; 执行实时视频流处理媒体捕捉的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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