How to get feedback from MediaCapture API in Windo

2019-04-07 09:48发布

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.

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.

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.

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!

1条回答
祖国的老花朵
2楼-- · 2019-04-07 10:46

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.

A good starting reference is StreamSocket sample

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.

查看更多
登录 后发表回答