Minimal Python Build (OpenCV 2.4.3)

asked 2013-01-25 11:38:25 -0500


I'm using the Python bindings to call the function matchTemplate. This is the only function I need. In order to be able to call matchTemplate, I have to ship cv2.pyd with my (Windows) application, which weighs in at a hefty 9MB.

Is there any way of building (the Python bindings of) OpenCV in such a way that only the modules I require are included in cv2.pyd? matchTemplate seems to be a part of the imgproc module so I assume I'd only really need core and imgproc.

I already tried playing around with the CMake options, and I think I have managed to only have some modules built. However, as soon as I disable a single module, say calib3d by setting CMake's BUILD_OPENCV_calib3d to false, I also "lose" the Python build. In other words, when I use CMake to generate Visual Studio solution files for building all modules except calib3d and with python, the Visual Studio solution contains all modules but calib3d and python. I tried tinkering with the CMakeLists file of the python module by removing calib3d from the ocv_add_module call

ocv_add_module(python BINDINGS opencv_core opencv_flann ...)

and the setting of included headers


Unfortunately, to no avail. Does anybody know how to do this?

I'm building with Microsoft Visual Studio 2012.

Thanks, Michael

edit retag flag offensive close merge delete