Video acquired in C++ and display it in Panda [revisit]

This is a revisit of a previous topic and I’m looking for a better method to get webcam video acquired by faceAPI (C++) and display it in Panda. The previous method we used was memory mapping to transfer the webcam image frames from a standalone C++ application to Python. Unfortunately, when I bring the color webcam image out of memory using Python / Panda the frame rates are not as fast as I’d like them to be.

I’ve read through the forum and I’ve found many different approaches to integrating C++ into Panda / Python such as Interrogate, compiling directly into Panda following basicSkel, cython, ctypes, etc, but I’m not sure which is the best for my application.

My goal would to be able to call my faceAPI (C++) functions from within Panda with the hopes that I can access the memory where faceAPI is storing each frame.

The two methods that look the most promising are Interrogate or compiling my C++ directly into Panda.

Can anyone talk to the best approach?

Thanks so much.

It sounds to me like you need to write a little bit of C++ glue code to create a Texture object with the memory pointer returned by face API. This little bit of glue code must be compiled against the Panda libraries, and presumably you also want it to be accessible to Python (so you can call it from your Python program).

For this purpose, I’d recommend following the example given in basicSkel. This illustrates the setup required to create your own DLL that links with Panda and also uses interrogate to generate a callable Python interface. The advantage to this approach is that you can easily just return a Texture * (or a PT(Texture)) from your method, and interrogate will automatically wrap it correctly into a Python Texture object.

On the other hand, Panda’s build system is not trivial, and neither is interrogate; and integrating with either or both of these has given people headaches in the past, despite the existence of the example. If you find you’re beating your head against the wall with this approach, you might find it easier to embrace another approach. This would mean writing the DLL by hand, and using a tool like boost or swig to generate your Python wrappers (or writing the wrappers by hand). Depending on your existing comfort level with C++ and the Python API, this might or might not be easier than following the basicSkel approach.