只是好奇 Python+Numpy 到实时手势识别
我刚刚与我的顾问完成实验室会议,之前的代码是用 matlab 编写的,它运行离线模式而不是实时模式,所以我决定转换为 python+numpy (离线版本),但在实验室会议之后,我的顾问提出了有关问题实时识别的速度,所以我对python+numpy做这个项目的速度有疑问。还是用c更好?我的项目是关于使用电子手套(2个传感器)获取实时数据并进行数据处理、识别过程
i 'm just finish labs meeting with my advisor, previous code is written in matlab and it run offline mode not realtime mode, so i decide to convert to python+numpy (in offline version) but after labs meeting, my advisor raise issue about speed of realtime recognition, so i have doubt about speed of python+numpy to do this project. or better in c? my project is about using electronic glove (2x sensors) to get realtime data and do data processing, recognition process
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您遵循一些基本规则,NumPy 会非常快。您应该避免 Python 循环,尽可能使用 NumPy 提供的运算符。 这个和这应该是一个很好的起点。
读完之后,为什么不在 Matlab 和 NumPy 中编写一些简单的代码并比较性能呢?如果它在 NumPy 中表现良好,应该足以说服您的顾问,特别是如果代码代表您在项目中使用的实际算法。
注意:您还应该看到您的算法确实适合实时识别。
NumPy is very fast if you follow some basic rules. You should avoid Python loops, using the operators provided by NumPy instead whenever you can. This and this should be a good starting points.
After reading through that, why don't you write some simple code in both Matlab and NumPy and compare the performance? If it performs well in NumPy, it should be enough to convince your advisor, especially if the code is representative of the actual algorithms you are using in your project.
Note: you should also see that your algorithm really is suited for realtime recognition.
我认为答案取决于三件事:您在 Matlab 中编码的程度、您在 Python/Numpy 中编码的程度以及您的算法。如果您勤于向量化所有内容并使用库调用,Matlab 和 Python 都可以快速进行数字运算。
如果您的 Matlab 代码已经非常好,如果您发现迁移到 Numpy 能带来很多性能优势,我会感到惊讶,除非您可以使用一些特定的习惯用法来发挥自己的优势。您甚至可能看不到转向 C 的巨大好处。在这种情况下,您的精力可能会更好地花在调整算法上。
如果您的 Matlab 代码不太好,您可以 1) 编写更好的 Matlab 代码,2) 用好的 Numpy 代码重写,或 3) 用 C 重写。
I think the answer depends on three things: how well you code in Matlab, how well you code in Python/Numpy, and your algorithm. Both Matlab and Python can be fast for number crunching if you're diligent about vectorizing everything and using library calls.
If your Matlab code is already very good I would be surprised if you saw much performance benefit moving to Numpy unless there's some specific idiom you can use to your advantage. You might not even see a large benefit moving to C. I this case your effort would likely be better spent tuning your algorithm.
If your Matlab code isn't so good you could 1) write better Matlab code, 2) rewrite in good Numpy code, or 3) rewrite in C.
你可以看看OpenCV,它有Python库
ctypes-opencv
和 opencv-cython;
我自己没用过这些。
理想情况下,您希望结合快速运行的 C 内循环
具有灵活的 Python/Numpy 算法。
顺便谷歌“opencv手势识别”→6680次点击。
You might look at OpenCV, which has Python libs
ctypes-opencv
and opencv-cython;
I haven't used these myself.
Ideally you want to combine a fast-running C inner loop
with a flexible Python/Numpy play-with-algorithms.
Bytheway google "opencv gesture recognition" → 6680 hits.