简体   繁体   English

如何从Python使用OpenCV的C ++函数?

[英]How to use the C++ functions of OpenCV from Python?

I'm using the Python bindings of OpenCV and it's really great. 我正在使用OpenCV的Python绑定,它真的很棒。 However, there are functions in the C++ version that are missing from the Python bindings, BackgroundSubstractorMOG2, and a lots of feature detection algorithms for example. 但是,C ++版本中的函数缺少Python绑定,BackgroundSubstractorMOG2以及许多特征检测算法。 What would be the easiest way to call them from Python? 从Python调用它们最简单的方法是什么?

I hope this helps people looking for a fast and easy way. 我希望这可以帮助人们寻找快速简便的方法。

Here is the github repo with the open C++ code I wrote for exposing code using OpenCV's Mat class with as little pain as possible. 这是github repo ,其中包含我用OpenCV Mat类暴露代码的开放C ++代码,尽可能少的痛苦。 It was originally inspired by Yati Sagade's example . 它最初的灵感来自Yati Sagade的例子

[Update] This code now works for OpenCV 2.X and OpenCV 3.X . [更新]此代码现在适用于OpenCV 2.XOpenCV 3.X。 CMake and experimental support for Python 3.X are now also available. 现在还提供对Python 3.X的CMake和实验支持。

I also found that a few months after my original utility was written, Sudeep Pillai also wrote a similar thing for C++/CMake. 我还发现,在我的原始实用程序写完几个月之后,Sudeep Pillai也为C ++ / CMake编写了类似的东西 There seems to be OpenCV 2 and OpenCV 3 support as well. 似乎也支持OpenCV 2和OpenCV 3。 May be worth a try. 可能值得一试。

Have a look to SimpleCV . 看看SimpleCV It Python base and it a warping OpenCV. 它是Python基础,它是一个翘曲的OpenCV。 Maybe you can found something there. 也许你可以找到一些东西。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM