I pip-installed opencv-python and now I can do import cv2
. But import cv
fails:
ImportError: No module named 'cv'
I need cv
because API of some classes, for example VideoCapture, require constants that are defined there.
I pip-installed opencv-python and now I can do import cv2
. But import cv
fails:
ImportError: No module named 'cv'
I need cv
because API of some classes, for example VideoCapture, require constants that are defined there.
OK, so it turned out I was misled by an old version of documentation (for some reason search engine placed link to this version on top) that uses constants like CV_CAP_PROP_FPS
. Also I've seen some code previously that used cv
and not cv2
to get to these constants (but it was a while ago and I guess it was for Python 2 and some old version of opencv).
Thanks to this answer I realized that names of the constants changed between versions of opencv. A new version of docs seems to confirm that -- prefix CV_
is no longer there. I checked that the constants that I need are accessible from cv2
, for example
import cv2
capture = cv2.VideoCapture("film.webm")
video_fps = capture.get(cv2.CAP_PROP_FPS)
print("fps", video_fps)
works fine!