[Nottingham] Webcam snapshots

Martin martin at ml1.co.uk
Mon Oct 31 21:48:18 UTC 2011


Folks,

> (This is also to get around the problem that you cannot use multiple
> HD webcams on one USB2 hub...)

OK, so I've been having fun trying to get multiple HD webcams to work
reliably... With partial success using uvccapture.

Something better still needed, so...

Anyone any experience of using OpenCV? Comments?
http://opencv.willowgarage.com/wiki/


My HD image grab attempt so far is noted below.

Cheers,
Martin



Thus far, the best I've come up with is to compile uvccapture from:

https://github.com/csete/uvccapture

and then to use:

####

#!/bin/bash

# Supported sizes:
# 1024 x 768
# 1280 x 960
# 1400 x 1050
# 1600 x 1200

for d in 0 1 2 3
do
        g="/mnt/view/video${d}_grab"

        /usr/local/bin/uvccapture -o${g}%1d.jpg -d/dev/video${d}
-x1280 -y960 -t1 -n2 -w
        sleep 0.1       # Bodge fix to allow the uvc drivers to clean up!
        g="${g}1.jpg"
        v="${g%_grab*}.jpg"
        echo "v='$v'"
        [ -f "$g" ] && mv -v "$g" "$v"
        [ "$1" == "-v" ] && ls -lh "$v"
done

####


That works well enough apart from being horribly slow. I need to take
the second frame from the webcams due to the first usually being badly
exposed or even corrupt. Occasionally, there can be many seconds of
pause before uvccapture responds with an image.

Curiously, trying to use such as ffmpeg to grab an image works ok for
a few times and then hangs on the n-th iteration of switching between
webcams. All works fine if I only use just one webcam...

The hope with using OpenCV is to speed things up and to make the image
grab more reliable. Anyone to comment?



More information about the Nottingham mailing list