OpenCV: Difference between revisions
(Created OpenCV page.) |
m (Use X.Y.Z to help user specify a version) |
||
(7 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
<languages /> | <languages /> | ||
<translate> | <translate> | ||
<!--T:1--> | |||
[https://opencv.org/ OpenCV] (Open Source Computer Vision Library) is a library of programming functions mainly aimed at real-time computer vision. | [https://opencv.org/ OpenCV] (Open Source Computer Vision Library) is a library of programming functions mainly aimed at real-time computer vision. | ||
== CUDA == | == CUDA == <!--T:2--> | ||
OpenCV is also available with CUDA. | OpenCV is also available with CUDA. | ||
{{Command|module load gcc/ | {{Command|module load gcc cuda opencv/X.Y.Z}} | ||
where <TT>X.Y.Z</TT> represent the desired version. | |||
== Extra modules == | == Extra modules == <!--T:3--> | ||
The module also contains the [https://github.com/opencv/opencv_contrib/tree/4.x/modules#an-overview-of-the-opencv_contrib-modules extra modules (contrib)]. | The module also contains the [https://github.com/opencv/opencv_contrib/tree/4.x/modules#an-overview-of-the-opencv_contrib-modules extra modules (contrib)]. | ||
== Python bindings == | == Python bindings == <!--T:4--> | ||
The module contains bindings for multiple Python versions. | The module contains bindings for multiple Python versions. | ||
To discover which are the compatible Python versions, run | To discover which are the compatible Python versions, run | ||
{{Command|module spider opencv/ | {{Command|module spider opencv/X.Y.Z}} | ||
Or search directly | Or search directly <i>opencv_python</i>, by running | ||
{{Command|module spider opencv_python/ | {{Command|module spider opencv_python/X.Y.Z}} | ||
where <TT>X.Y.Z</TT> represent the desired version. | |||
=== Usage === | === Usage === <!--T:5--> | ||
1. Load the required modules. | 1. Load the required modules. | ||
{{Command|module load gcc/ | {{Command|module load gcc opencv/X.Y.Z python scipy-stack}} | ||
where <TT>X.Y.Z</TT> represent the desired version. | |||
<!--T:6--> | |||
2. Import OpenCV. | 2. Import OpenCV. | ||
{{Command|python -c "import cv2"}} | {{Command|python -c "import cv2"}} | ||
<!--T:7--> | |||
If the command displays nothing, the import was successful. | If the command displays nothing, the import was successful. | ||
==== | ==== Available Python packages ==== <!--T:8--> | ||
Other Python packages | Other Python packages depend on OpenCV bindings in order to be installed. | ||
OpenCV provides four different packages: | OpenCV provides four different packages: | ||
* < | * <code>opencv_python</code> | ||
* < | * <code>opencv_contrib_python</code> | ||
* < | * <code>opencv_python_headless</code> | ||
* < | * <code>opencv_contrib_python_headless</code> | ||
<!--T:10--> | |||
{{Command | {{Command | ||
|pip list {{!}} grep opencv | |pip list {{!}} grep opencv | ||
Line 43: | Line 50: | ||
}} | }} | ||
With the < | <!--T:9--> | ||
With the <code>opencv</code> module loaded, your package dependency for one of the OpenCV named will be satisfied. | |||
== Use with OpenEXR == <!--T:11--> | |||
In order to read EXR files with OpenCV, the module must be activated through an environment variable. | |||
{{Command|OPENCV_IO_ENABLE_OPENEXR{{=}}1 python <file>}} | |||
</translate> | </translate> |
Latest revision as of 14:58, 9 April 2024
OpenCV (Open Source Computer Vision Library) is a library of programming functions mainly aimed at real-time computer vision.
CUDA
OpenCV is also available with CUDA.
[name@server ~]$ module load gcc cuda opencv/X.Y.Z
where X.Y.Z represent the desired version.
Extra modules
The module also contains the extra modules (contrib).
Python bindings
The module contains bindings for multiple Python versions. To discover which are the compatible Python versions, run
[name@server ~]$ module spider opencv/X.Y.Z
Or search directly opencv_python, by running
[name@server ~]$ module spider opencv_python/X.Y.Z
where X.Y.Z represent the desired version.
Usage
1. Load the required modules.
[name@server ~]$ module load gcc opencv/X.Y.Z python scipy-stack
where X.Y.Z represent the desired version.
2. Import OpenCV.
[name@server ~]$ python -c "import cv2"
If the command displays nothing, the import was successful.
Available Python packages
Other Python packages depend on OpenCV bindings in order to be installed. OpenCV provides four different packages:
opencv_python
opencv_contrib_python
opencv_python_headless
opencv_contrib_python_headless
[name@server ~]$ pip list | grep opencv
opencv-contrib-python 4.5.5
opencv-contrib-python-headless 4.5.5
opencv-python 4.5.5
opencv-python-headless 4.5.5
With the opencv
module loaded, your package dependency for one of the OpenCV named will be satisfied.
Use with OpenEXR
In order to read EXR files with OpenCV, the module must be activated through an environment variable.
[name@server ~]$ OPENCV_IO_ENABLE_OPENEXR=1 python <file>