Update Python bindings cv2.so after changing opencv source

asked 2016-06-17 00:49:03 -0500

I have modified the opencv cascade classifier's source code for object detection to incorporate new functionality. I made changes to the source code of opencv_createsamples and opencv_traincascade which are responsible for training the classifier. Then I also made similar changes to the cascade classifier's detectMultiScale which is the detector library. While the first two are executables the detector is compiled as an opencv library. Because of the changes to the source code of the library the Python wrapper cv2.so which links the C/C++ library to Python methods seems to be broken. As the set of symbols stored inside cv2.so pointing the sources are no more the same because of the changes I am getting the following error when I do import cv2.

ImportError: /usr/local/lib/python2.7/dist-packages/cv2.so: undefined symbol:_ZN2cv17CascadeClassifier16detectMultiScaleERKNS_11_InputArrayERSt6vectorINS_5Rect_IiEESaIS6_EEdiiNS_5Size_IiEESB_

How do I now update the Python bindings and hence cv2.so to reflect my changes? Any help is appreciated. Thanks.

edit retag flag offensive close merge delete


for one thing, you should build cv2.so statically, cmake -DBUILD_SHARED_LIBS=OFF

berak gravatar imageberak ( 2016-06-17 00:59:19 -0500 )edit

Thanks for replying. I tried adding this option to the existing cmake options but doesn't seem to update the bindings or make any changes to cv2.so.

Ramkumar Natarajan gravatar imageRamkumar Natarajan ( 2016-06-17 16:32:55 -0500 )edit

yea, sorry, that was the wrong trace.

can you show your modification to the c++ code ? maybe you forgot something there.

berak gravatar imageberak ( 2016-06-18 07:07:07 -0500 )edit