我有一个USB摄像头(uEye),它有一个C ++接口,允许您配置摄像头的一些功能。 C ++程序可以从摄像机读取图像数据并将其存储在预分配的内存中。 所有这些都在Windows下运行。
带有numpy的Python为我提供了一个简单的环境来操作图像并花费一些时间处理我的处理算法。
我想做的是:
使用c ++程序配置摄像头并获取图像(以视频速率), 将数据传递给Python 用Python处理数据我的印象是我不想用C ++在Python或Python中嵌入C ++,因为我更喜欢有两个独立的系统(所以我可以使用没有Python东西的相机,或者在没有相机的情况下使用Python的东西)。
到目前为止我能找到的是使用管道,套接字或映射内存共享某些数据的方法,尽管它似乎仅限于少量数据或字符串。 然而,我找不到的是一个表明这是否足够快以及我应该尝试实施的东西。 我应该这样做吗?
如果这是一个坏主意,那么什么是更好的选择呢? 将Python代码嵌入C ++中,反之亦然? 或者将Python放在一起,因为开发时间的节省不会抵消使进程间通信工作的额外工作量?
I have a USB camera (uEye) which has a C++ interface allowing you to configure some features of the camera. The C++ program can read the image data from the camera and store it somewhere in pre-allocated memory. All of this runs under Windows.
Python with numpy gives me a simple environment to manipulate images and spend some quality time working on my processing algorithms.
What I would like to do is:
Use the c++ program to configure the camera and obtain images (at video rate), Pass the data to Python Process the data in PythonI am under the impression that I do not want to embed C++ in Python or Python in C++, as I prefer to have two stand-alone systems (so I can use the camera without the Python stuff, or use the Python stuff without the camera).
What I can find so far are methods to share some data using pipes, sockets, or mapped memory, though it appears to be restricted to small amounts of data or strings. What I can not find, however, is an indication if this is fast enough and something that I should attempt to implement. Should I want to do this?
If this is a bad idea, what would be a better alternative? Embed the Python code in C++ or vice versa? Or ditch Python all together because the savings in development time there do not offset the additional effort in getting the interprocess communication to work?
最满意答案
PyPy博客上最近有一篇关于实时视频处理的文章。 在示例中,他们使用mplayer来抓取并显示视频,这可能比尝试与您的C ++程序接口更好(假设它适用于您的网络摄像头)。 如果没有,按照这些方法思考一个简单的解决方案就是连接两个应用程序的stdout / stdin。 考虑PyPy进行视频处理也是一个好主意。
There was a recent post on the PyPy blog about real-time video processing. In the example they use mplayer to be grab and display video, which might be preferable to trying to interface with your C++ program (assuming it works with your webcam). If not, thinking along those lines a simple solution is to just connect stdout/stdin of your two applications. Also probably a good idea to look at PyPy for video processing.
更多推荐
发布评论