Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c++

python

opencv

I'm using the Python bindings of OpenCV and it's really great. 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. What would be the easiest way to call them from Python?

like image 737
b_m Avatar asked Nov 13 '22 11:11

b_m


1 Answers

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. It was originally inspired by Yati Sagade's example.

[Update] This code now works for OpenCV 2.X and OpenCV 3.X. CMake and experimental support for Python 3.X are now also available.

I also found that a few months after my original utility was written, Sudeep Pillai also wrote a similar thing for C++/CMake. There seems to be OpenCV 2 and OpenCV 3 support as well. May be worth a try.

like image 61
Greg Kramida Avatar answered Nov 15 '22 06:11

Greg Kramida