In Python, we can perform Computer Vision tasks related to Artificial Intelligence and its subsets. These tasks are related to processing and working with images and videos.
Python provides a standard library called OpenCV. It has a lot of tools and functionalities to process and implement different techniques and algorithms.
There is an addition to this OpenCV library called
OpenCV-contrib. We will talk about this
OpenCV-contrib module and its uses in this tutorial.
OpenCV-contrib Module in Python
OpenCV-contrib module has all the functionalities and tools of the OpenCV library and some additional features. These new modules are in the development phase and have not been tested properly to get a stable version.
They are not present in the standard OpenCV library since it aims to provide stable, maintained APIs.
One should remember that most of the techniques and algorithms provided by this library are copyrighted, so one should not replicate them.
To install the
OpenCV-contrib module, we can use the
pip command. The
pip command is the package manager for Python modules.
The following command can be used to install this module.
pip install opencv-contrib-python
We cannot have OpenCV and
OpenCV-contrib installed in the same environment. They both use the same namespace,
cv2, and can lead to errors.
We can, however, set up the extra modules from the
OpenCV-contrib library to be used alongside the master branch of the OpenCV library. We can create a new directory using the
cd command and the
cmake command to add the extra modules from this library.
The commands are shown below.
cd <opencv_directory> cmake -DOPENCV_EXTRA_MODULES_PATH=<opencv_contrib>/modules <opencv_source_directory> make -j5
The above command will create the OpenCV library in the specified path by adding the extra modules from the path of
OpenCV-contrib as well.
readme.txt file is recommended to maintain an overview of the model and tools used.
There is also an option for a headless version of OpenCV and
OpenCV-contrib. These versions are useful when working with environments like Docker, Cloud, and more where the GUI dependencies are not required.