LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   v4l device -- fast capture (https://www.linuxquestions.org/questions/programming-9/v4l-device-fast-capture-612480/)

hbar 01-09-2008 08:30 PM

v4l device -- fast capture
 
I'm trying to acquire images from my webcam in the fastest way possible. I would like to make a program to simply take one frame from the webcam and dump it to a file. There are similar projects around (vgrabbj is one I've been working with), but they are all very slow, taking up to 0.4 seconds to output an image (even when writing to /tmp).

I can use this webcam to stream video at ~20 frames per second, so surely there must be a faster way to get frames from the camera than this?

I don't know very much about video device programming (and I've found it difficult to find relevant documentation online). I've tried looking at the source code from a few different projects but it's so under-commented that I can't understand it at all.

Any help with this problem, useful documentation (I *think* I am looking for v4l) or pointers would be a HUGE help.

Four 01-10-2008 04:36 PM

see v4l doc

I think the slow down is writing speed to harddrive. One thing you could do is create a ram disk and see if there is any speed improvements.

hbar 01-10-2008 10:15 PM

Still just as slow writing to ramdisk.

Code:

$ time vgrabbj -i sif -d /dev/video0 > /home/njl/ramdisk/0.jpg
Reading image from /dev/video0
vgrabbj -i sif -d /dev/video0 > /home/njl/ramdisk/0.jpg  0.01s user 0.00s system 2% cpu 0.313 total

The "user" and "system" times are very low for this, but the "total" (actual) time is much higher. Can this be a hint? What is the bottleneck here?


All times are GMT -5. The time now is 12:26 AM.