Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Checking version of OpenCV (cv)

I was checking the version of OpenCV installed previously in a system. I tried to check using

from cv2 import __version__

Its gave me the following error

No module named cv2

When I tried import cv, it's not giving me error. Is there a way to know the version?

like image 853
Venkat kamal Avatar asked Oct 19 '17 19:10

Venkat kamal


People also ask

Is cv2 same as CV?

cv2 (old interface in old OpenCV versions was named as cv ) is the name that OpenCV developers chose when they created the binding generators. This is kept as the import name to be consistent with different kind of tutorials around the internet.

Which OpenCV version should I use?

If you're working with Image Processing,hands down OpenCV 3 is way better(The latest stable version 3.4 was released around Feb 2018). Significant differences that you will find between 3 and 2 are: T-API or Transparent API has been introduced in OpenCV 3. Only thing that you'll need to use is UMat instead of Mat.

Is OpenCV Python and cv2 same?

cv2 is the module import name for opencv-python, "Unofficial pre-built CPU-only OpenCV packages for Python". The traditional OpenCV has many complicated steps involving building the module from scratch, which is unnecessary. I would recommend remaining with the opencv-python library.

What version of Python does OpenCV use?

The nice thing with OpenCV is that it comes with a complete Python 3 library. The latest GeeXlab 0.29. 17.0 for Windows 64-bit comes with Python 3.8.


2 Answers

__version__ is a variable and a property of the package, not something you can import. The general way to do this (from script or interpreter, Python 2 or Python 3):

import cv2
print(cv2.__version__)

You can check the version number of any Python package this way using the __version__ string. Also note that if you want to know what other special __variables__ are available, you can use the dir() function on your module:

import cv2
print(dir(cv2))
like image 189
charlesreid1 Avatar answered Oct 07 '22 13:10

charlesreid1


Open a python interpreter (simply type python in your terminal).
Now, you should import cv2 and then check the special variable version.
Like this:

import cv2
cv2.__version__

For more details, check this link

like image 23
Giordano Avatar answered Oct 07 '22 13:10

Giordano