I am using ubuntu 14.04, and have anaconda python installed. I used conda install opencv and conda install cv2 to install opencv. However I am unable to use the VideoCapture at all (I need to process videos frames by frames). I need to use anaconda for the rest of the project.
Here is my code:
import cv2
import os
capture = cv2.VideoCapture('/home/Downloads/data/zfH2XdRcH14.mp4')
while not capture.isOpened():
print 'noob'
while True:
ret, frame = capture.read()
cv2.imwrite('~/Downloads/data/pic.png',frame)
cv2.imshow('Video', frame)
count += 1
print count
The code keeps printing noob. I have checked the location multiple times and it is correct. I have no clue what the issue is and I have been stuck on this for hours.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…