Ask Your Question
1

OpenCV and VideoInput library/MSFT Media Foundation

asked 2013-04-08 11:28:22 -0600

pistorinoj gravatar image

I am hoping that this question will be of use to others as how to handle input from a webcam into OpenCV seems to be a recurring issue. It would seem that many who are working in this area would also target Windows so I am hoping that my questions will have broader applicability. Sorry if my questions reflect my newbie status.

I am using the videoinput library with OpenCV 2.4.3 with a multithreaded approach for a WinForm using VS2010SE C++/cli. I am using two MSFT Lifecam 3000s as the video sources.

Currently, one thread runs a loop that polls the open VI cameras by calling isFrameNew to determine if there is a new frame to process. If a new frame is found, it is processed by running the OpenCV Canny function and then displaying the result in a WinForm picturebox on the UI thread. With two cameras at 640x480 resolution and color, I am getting ~4 frames/sec without trying a GPU approach on a Win7 machine with an Intel i3 processor.

While this works, it does not appear to be the best way of doing this in terms of polling the cameras. It would be better to have an event driven approach.

All of that is the lead up to my questions:

1) does the VideoInput library have some event driven capability that could avoid the need for polling or is there some other way of determining when new frames are available other than polling?

2) should I even be using the VideoInput library? I saw recent references that led me to the library and I understand that it is better than what is internal to OpenCV. I got it working with no problem and it is easy to use. However, it is not supported and seems to be several years old. Does it make sense to try and build something entirely new using MSFT Media Foundation? Again, this seems like an issue that huge numbers of people must face.

Thanks for any insight.

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
2

answered 2013-04-08 12:23:13 -0600

Basically I do not get why people use other libraries to import video's in openCV. If you follow the tutorials correct and the data type of your video is supported, than the following classes are all you need for processing video data.

http://docs.opencv.org/modules/highgui/doc/reading_and_writing_images_and_video.html

I succeed in processing up to 40 frames per sec on my webcam, and up to 25 frames per sec on a video, by just using the standard C++ implementation

Another positive thing about it is that people do not need to handle decoding frames themselve if they use the standard read functionality. Max speed all depends on window size and hardware performance.

edit flag offensive delete link more

Comments

I kept on seeing comments that the video capture parts of OpenCV were really just for demos and recommending VideoInput.

pistorinoj gravatar imagepistorinoj ( 2013-04-08 20:26:19 -0600 )edit

Yeah and about 90% of those comments are people using OpenCV for the first time, not going trough documents and trying to use the older C - style OpenCV 1.x API. There indeed video processing wasn't that easy since you needed to grab, decode and load a frame of a video file. But now everything works perfectly fine.

StevenPuttemans gravatar imageStevenPuttemans ( 2013-04-09 01:22:43 -0600 )edit
0

answered 2015-07-09 00:59:10 -0600

Hi pistorinoj,

you write that you are "using the videoinput library with OpenCV 2.4.3". I have been searching the web for days and have not found a single person or a piece of code demonstrating how to do that. It would be of great value for me (and probably others) if you could post a short example of how to do this. I've tried using the VideoCapture approach and it fails horribly in almost every case where I would need it (e.g. setting exposure, gain, Logitech functions like RightLight, auto-exposure, getting the webcam's name etc). All this worked fine in OpenCV2.1.0 with the then-external videoInput library.

As for StevenPuttemans' answer ("Yeah and about 90% of those comments are people using OpenCV for the first time, not going trough documents and trying to use the older C - style OpenCV 1.x API.") - think before you sneer... OpenCV is still very, very, VERY weak when it comes to addressing webcams' properties and the videoInput library had solved lots of these problems for YEARS.

edit flag offensive delete link more

Comments

Hi Eigehirner, Sorry for just seeing your message now. For some reason, I cannot access my account using the pistorinoj handle. I am now using jpistorino. Send me a note if you would still like to see the code. I did not do anything special and simply called the VideoInput functions as indicated in the sample code.

jpistorino gravatar imagejpistorino ( 2015-08-10 17:44:14 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2013-04-08 11:28:22 -0600

Seen: 4,923 times

Last updated: Apr 08 '13