I\'m using OpenCV 2.2 with visual studio 2010 on a win 7 64 bit pc.
I\'m able to display pictures and play AVI files through OpenCV as given in the book \"Learning O
The cap_ffmpeg.cpp is the source file which uses ffmpeg to perform capturing of the device. If the default example given from OpenCV doesn't work with your webcam, you are out of luck. I suggest you buy another one that is supported.
Here's an article I wrote some time back. It uses the videoInput library to get input from webcams. It uses DirectX, so it works with almost every webcam out there. Capturing images with DirectX
I had the same issue on Windows 7 64-bit. I had to recompile opencv_highgui changing the "Preprocesser Definitions" in the C/C++ panel of the properties page to include:
HAVE_VIDEOINPUT HAVE_DSHOW
Hope this helps
Once you create the cv::VideoCapture
you should give an integer not a string (since string implies the input is a file).
To open the default camera, open the stream with
cv::VideoCapture capture(0);
and it will work fine.
CMAKE GUI, MSVC++10E, Vista 32bit, OpenCV2.2
It looks like HAVE_VIDEOINPUT/WITH_VIDEOINPUT
option doesn't work.
However adding: /D HAVE_DSHOW /D HAVE_VIDEOINPUT
to CMAKE_CXX_FLAGS
, and CMAKE_C_FLAGS
did the trick for me (there will be warns due to macro redefinitions).
I just switched to OpenCV 2.2 and am having essentially the same problem but a 32 bit compture running Vista. The webcam would start but I'd get an error message setting the width property for the camera. If I specifically request the DirectShow camera, the cvCreateCameraCapture would fail.
What I think is going on is that the distribution version of HighGUI was build excluding the DirectShow camera. The favored Windows camera on OpenCV used to be Video For Windows, VFW but that has been deprecated since Windows Vista came out and has created all sorts of problems. Why they don't just include it, I don't know. Check the source file cap.cpp
My next step is to rebuild HighGUI myself and make sure the flag HAVE_DSHOW is set. I seem to remember having the same problem with the last version of OpenCV I've been using until I rebuilt it making sure the DirectShow version was enabled.