3

I'm using a Raspberry pi to monitor a self-service fridge. When the door opens, a shell script is being executed to capture pictures until the door closes again. The problem, however, is the speed of the ARM-processor. Capturing in full resolution using fswebcam takes 2-4 seconds, which is too long.

Our idea to solve this is to split the process:

  1. Capture raw images and save to memory card
  2. After the door is closed, process the raw data. This is not time-critical.

Now, my questions are:

  1. Is this possible / wise?
  2. Which program should I use?
slm
  • 363,520
  • 117
  • 767
  • 871
Finwood
  • 141
  • 1
  • 6
  • 1
    It sounds wise to me, and it must be possible since `fswebcam` gets its data from somewhere. I've edited your title to hone in on that issue better. – goldilocks Oct 30 '13 at 16:00
  • Can you share what you're done thus far? Show us details if possible. I agreee w/ Goldilocks. – slm Oct 30 '13 at 18:05

1 Answers1

1

Thats what we've got so far:

#!/bin/bash

tempdir=/tmp/fswebcam
host="167.174.70.42"
destdir=~/fsweb
tformat=%Y-%m-%d_%H-%M-%S

if [ ! -d "$tempdir" ]; then
    mkdir $tempdir
fi

cd $tempdir

dooropentime=$(date +$tformat)

for i in {1..3}
do
    starttime=$(date +%s%N)
    echo -e "\n==== starting capture at" $(date +%H:%M:%S.%N) "====  (# $i)"
    fswebcam --device /dev/video0 --input 0 --resolution 1280x720 --timestamp "$tformat" $tformat.jpg
#   fswebcam --device RAW:/dev/video0 --palette NV12MB --resolution 1280x720 $tformat.jpg
    endtime=$(date +%s%N)
    echo -e "==== capture finished at" $(date +%H:%M:%S.%N) "==== (in "$((($endtime - $starttime) / 1000000))"ms)\n"
done

echo "packing..."
tar -cjf $dooropentime.tar.bz2 *.jpg

echo "copying..."
scp *.tar.bz2 pi@$host:$destdir
#cp *.tar.bz2 $destdir
rm -r $tempdir/*
echo "done!"

It's still pretty raw, but at least it's working. Capturing a frame takes approximately 3300ms on the pi.

--device RAW:/dev/video0 produces a palette incompatibility error, and the NV12MB palette (http://www.firestorm.cx/fswebcam/ "fswebcam-20060604: Added NV12MB palette type (for raw source only)") seems to be missing.

Any ideas?

Finwood
  • 141
  • 1
  • 6