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?
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.
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.
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.
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.
__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))
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With