VideoCapture is not working in OpenCV 2.4.2
I recently installed OpenCV 2.4.2 in Ubuntu 12.04.
cap = VideoCapture(0)
is working. but I can't grab frames from some video source.
cap = VideoCapture("input.avi")
img = cap.read()
gives me a numpy with all zero elements.
I have also installed ffmpeg 0.11, Latest snapshot of x264, v4l-0.8.8 (All are latest stable versions)
cmake -D WITH_QT=ON -D WITH_FFMPEG=ON -D WITH_OPENGL=ON -D WITH_TBB=ON -D BUILD_EXAMPLES=OFF WITH_V4L=ON ..
make
sudo make install
When I do cmake, I get this
-- Detected version of GNU GCC: 46 (406) -- Found OpenEXR: /usr/lib/libIlmImf.so
-- Looking for linux/videodev.h
-- Looking for linux/videodev.h - not found
-- Looking for linux/videodev2.h
-- Looking for linux/videodev2.h - found
-- Looking for libavformat/avformat.h
-- Looking for libavformat/avformat.h - found
-- Looking for ffmpeg/avformat.h
-- Looking for ffmpeg/avformat.h - not found
-- checking for module 'tbb'
-- package 'tbb' not found
And
-- Video I/O:
-- DC1394 1.x: NO
-- DC1394 2.x: YES (ver 2.2.0)
-- FFMPEG: YES
-- codec: YES (ver 54.23.100)
-- format: YES (ver 54.6.100)
-- util: YES (ver 51.54.100)
-- swscale: YES (ver 2.1.100)
-- gentoo-style: YES
-- GStreamer:
-- base: YES (ver 0.10.36)
-- app: YES (ver 0.10.36)
-- video: YES (ver 0.10.36)
-- OpenNI: NO
-- OpenNI PrimeSensor Modules: NO
-- PvAPI: NO
-- UniCap: NO
-- UniCap ucil: NO
-- V4L/V4L2: Using libv4l (ver 0.8.8)
-- XIMEA: NO
-- Xine: NO
What's the problem here ?
read just gives you a frame, maybe it is a black frame ? At least you get something. What is your codec for that video ? What is the size of the array you get ? Your CMake looks fine
it's a black frame. But I solved the issue. I had not configured ffmpeg properly.