There is not much to work with, that's why the title is so "vague". I first tried to use the cv2, for some task I needed in my work, but it failed on the first try so I ended up testing just the basic code snippet. Which, does not seem to work at all.
import cv2
cap = cv2.VideoCapture("GoneNutty.avi")
while True:
# Capture frame-by-frame
ret, frame = cap.read()
# Our operations on the frame come here
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
# Display the resulting frame
cv2.imshow('frame', gray)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
# When everything done, release the capture
cap.release()
cv2.destroyAllWindows()
Frame, is a None value. Code fails. Even the cap object, seems to be nothing basically when I try the PyCharm IDE debug mode, to check its "contents".
What I tried so far
- The video is definitely valid an plays normally
- Tried inputting the direct path
- os.getcwd() gives the same directory as the video is in
- Tried different videos of different formats (avi, mp4)
- Reinstalled cv2 in various ways several times (slightly disorganized as I frantically tried to fix the problem)
- Used a cap.read("file") option to no avail
- print(cv2.version) >> 3.3.0
Potential clues
In terms of debugging its a nightmare, because I get zero useful information since the code does not throw an error until it performs an operation on Frame which is None.
PyCharm IDE, says that cv2.VideoCapture has an unexpected argument. More then that, I have no idea what is going on.
I tried many things with the reinstalling, and the versions it seems to return are correct, but I don't know ways of checking if the installation is correct.
Info about my system
I am running an Ubuntu 14.04 (Trusty).
Python3 - other stuff works
PyCharm 2017
If there is more info I should provide, let me know? Also, if you have suggestions how to improve the title, to be more informative let me know.
opencv_version
in terminal? – zindarodcv2.VideoCapture(0)
to capture from your webcam. Comment result. – zindarod