locked
How to get feedback from MediaCapture API in Windows 8

    Question

  • 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!

    Wednesday, October 17, 2012 10:01 AM

Answers

  • 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.

    Friday, November 02, 2012 1:33 AM

All replies

  • Hello,

    You should be able to add a standard WinRT event to your transform and then register for this event in your C# module. Take a look at the following sample for more information. Keep in mind that you will likely have to convert the C++ Cx way of doing this to MoCOM. This may likely be a very difficult thing to do.

    http://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh755799.aspx

    I hope this helps,

    James


    Windows Media SDK Technologies - Microsoft Developer Services - http://blogs.msdn.com/mediasdkstuff/


    Thursday, November 01, 2012 11:41 PM
    Moderator
  • 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.

    Friday, November 02, 2012 1:33 AM
  • Have you tried James' suggestion of firing an event? That would be much cleaner and more efficient.

    --Rob

    Friday, November 02, 2012 4:12 AM
    Owner
  • I had gone through the article. I do not find a way to pass complex data structure in between c++/c# using event way.
    Friday, November 02, 2012 6:12 AM