opencv library has many tools and functionalities to perform Computer Vision tasks associated with machine learning techniques. The library was developed for Python, C++, and Java.
We can easily read and process images and videos efficiently with this library. This tutorial will demonstrate how to install the
opencv library in Python.
Install OpenCV in Python
Python, by default, provides the
pip package manager. This command is used to install, update, and remove packages.
We can use this command via the command prompt. We can use this command to install Python’s
pip install opencv-python
The above command installs the latest version of
opencv on the current environment. We can also install a specific version of this library by specifying it in the above command.
pip install opencv-python==220.127.116.11
opencv-contrib library also contains some extra modules not available in the
opencv library. These extra modules are usually in the development phase and may not have a stable API.
We can install this library using the same
pip install opencv-contrib-python
Two more options exist for the
opencv library. These are the headless versions of the
opencv-contrib that do not have any graphic interface and are used in Docker, Cloud, etc.
Note that we can install only one option of the
opencv library in a given environment because they all share the same namespace,
cv2, and can lead to fatal errors.