How do I build OpenCV Contrib modules?

2k Views Asked by At

I have downloaded the file opencv_contrib_python-4.4.0.46-cp38-cp38-manylinux2014_x86_64.whl from https://pypi.org/project/opencv-contrib-python/4.4.0.46/#files

I open the whl file and see that it contains a folder called opencv_contrib_python.libs which contains the following files:

enter image description here

I'm looking for the source code for these so files so I download the source code opencv-contrib-python-4.4.0.46.tar.gz from the same link above and extracted it but I do not see the source code for any of the files e.g libavformat-06a336f2.so.58.61.100

I then built the opencv contrib project code using the cmake flag OPENCV_EXTRA_MODULES_PATH like so:

cmake ../opencv-contrib-python-4.4.0.46/opencv/ -D OPENCV_EXTRA_MODULES_PATH=../opencv-contrib-python-4.4.0.46/opencv_contrib/modules/

But I do not see any of these files getting built.

How do I get the source fof these modules? I need to modify one of them and need to need to ensure I have it built and linked correctly with OpenCV.

2

There are 2 best solutions below

0
On

Try building the source from https://github.com/opencv/opencv_contrib with command

cmake -DOPENCV_EXTRA_MODULES_PATH=../opencv_contrib-master/modules ../../opencv-contrib-python-4.4.0.46/opencv Then do :- make -j5

Download python source also and set its include(Python-3.6.13/Include/) to $PYTHON_INCLUDE_DIRS. Set other cmake directives as required. For more info check link

0
On

The libraries created depend on the platform you are building your code and it should have all required libraries and tools(like gcc, python includes etc). The libraries which you mentioned are a part of ffmpeg, qt, x11 which are part of screen capture and video creator/converter. Opencv depend on them for its functioning. Recently I built ffmpeg on sles platform from source and created those libraries successfully. I can tell more about your issue if you can ping me the logs of building opencv using cmake, before make install.