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.
ffmpeg is not present in default conda channel.
You need to download opencv from conda-forge channel which contains latest and additional packages and dependencies for video processing. Try the following:
conda install -c conda-forge ffmpeg
conda install -c conda-forge opencv
Here -c tells which channel to use. In our case we need 'conda-forge'.
The solution is to compile ffmpeg with opencv. For opencv3, refer to https://github.com/menpo/conda-opencv3
For opencv2, refer to http://dhaneshr.net/2016/06/03/installing-opencv-2-4-x-with-ffmpeg-python-on-anaconda/
I ran into the same problem. VideoCapture doesn't work with Conda's default version of OpenCV because ffmpeg is not enabled. In order for VideoCapture to work, you have to enable ffmpeg in the Cmake GUI and compile. You can also install my version of OpenCV which has ffmpeg enabled:
conda install -c https://conda.binstar.org/jaimeivancervantes opencv
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