如何从 Windows 8 中的 MediaCapture API 获取反馈 [英] How to get feedback from MediaCapture API in Windows 8

查看:25
本文介绍了如何从 Windows 8 中的 MediaCapture API 获取反馈的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 Windows 8 应用程序中执行面部跟踪应用程序.而且我知道为了访问相机流,我必须使用 MediaCapture.AddEffectAsync() 必须与 C++ 合并,如图 在本示例中.

I'm trying to do face tracking apps in Windows 8 app. And I aware that in order to access the camera stream, I have to use MediaCapture.AddEffectAsync() which has to be done incorporate with C++ as shown in this sample.

现在我可以访问流并跟踪人脸,但我无法将跟踪人脸坐标传递/返回给 C# 以进行进一步处理.

Now I'm able to access the stream and track the face, but I'm not able to pass/return the tracking face coordinate to C# for further processing.

我尝试过的一种方法是在 C++ 中调用 C# 方法来传回跟踪坐标.但无济于事,因为 Visual Studio 不允许项目之间的循环依赖.

One way I've tried is to invoke C# method in C++ to pass back the tracking coordinate. But no avail, because Visual Studio doesn't allow circular dependencies between projects.

另一种方法是不断从C++中拉取数据,但这不是我想要的.

Another way is to constantly pull the data from C++, but this is not what I want.

也许还有另一种更直接的方式来访问相机缓冲区,我想知道.

Maybe there is another more straight forward way to access the camera buffer, I would like to know.

所以我的问题是,如何取回跟踪坐标?或者正确的做法是什么?谢谢!

So my question is, how to get back the tracking coordinate? Or What is the right way to do it? Thanks!

推荐答案

为了解决这个问题,我们只需在 C++ DLL 和 C# 代码之间设置 TCP/IP localhost 连接.也就是说,我们让 C# 成为服务器,而 C++ DLL 成为客户端.每当 C++ DLL 想要与 C# 对话时,C++ 只是通过 TCP/IP 套接字将数据传递给 C#.目前,Windows 8 对同一进程内的 TCP/IP 通信没有限制.

To overcome this, we simply setup TCP/IP localhost connection between C++ DLL and C# code. That is, we let C# become server, and C++ DLL become client. Whenever C++ DLL wants to talk with C#, C++ merely pass the data to C# through TCP/IP socket. Currently, Windows 8 doeesn't place restriction on TCP/IP communication within same process.

一个很好的入门参考是StreamSocket 示例

这不是最好的方法,而且由于数据需要通过 TCP/IP 层,因此它具有轻微的性能影响.但是,到目前为止,这也许是我们所能拥有的最好的,除非 Microsoft 打破障碍.

This is not a best way, and it is having slightly performance pernalty as the data need to go through TCP/IP layer. But, so far, perhaps this is the best we can have, unless Microsoft breaks the barrier.

这篇关于如何从 Windows 8 中的 MediaCapture API 获取反馈的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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