OpenCV VideoCapture Not Opening

opencv, python, ubuntu-14.04

Solution

I also faced a similar problem. Possible solutions:

Check if you have given the correct path.

If you have installed OpenCV using pip, it will not work. You can remove OpenCV and reinstall it looking at the official documentation.

Ways to install via pip, `pip install opencv-python` Only installs main module `pip install opencv-contrib-python` Install main and contrib module, so use this command.

Problem

I'm trying to use OpenCV's cv2 python bindings on an Amazon server running Ubuntu 14.04 and I can't seem to get VideoCapture to work properly. I tried opening the default capture as follows: ``` import cv2 cap = cv2.VideoCapture(0) cap.isOpened() #Returns false ``` I tested this on my local machine and it was true as expected, so there is something wrong with my open CV configuration. I've tried a variety of things: - Using an actual filepath that I confirmed points to an .mp4 file - Using -1 and 1 in place of 0 on the second line - Installing ffmpeg (from a ppa as it isn't available by default on Ubuntu 14.04) and rebuilding OpenCV - Removing my OpenCV directory entirely and rebuilding using the script here - Verifying and reinstalling various other libraries including x264, gstreamer, and gtk I'm kind of out of ideas at this point. Any ideas of what could be going wrong? Edit: OpenCV version is 2.4.9.

Original source