Skip to content

C o s e

cretox

  • Info

Month: September 2010

ma fuori non c’e’ nessuno

Posted on 15/09/2010 - 14/11/2010 by cretox

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/bin/bash
 
echo starting ...
cd $HOME/immagini/bigbrother/
img=frame.jpg
 list=frames.list
 if [ -f $list ]
 then 
   n=`tail -n 1 $list`
 else
   touch $list
   n=0
 fi 
sleep 1
 webcam /etc/webcam/bigbrother.conf &> cam.log &
echo grabbing frames \(x-key to stop\) ...
until [ "$input" = "x" ]
 do
   read -t1 -s -n1 input
 
   if [ -f $img ]
 
   then
     n=$((10#$n))
     n=$[n+1]
     n=`printf %05d $n`
     mv $img $n.jpg
     echo $n >> $list
   fi
 done
pkill webcam # :(
echo webcam stopped.
echo starting avi creation ...
mencoder mf://*.jpg -mf w=640:h=480:fps=1:type=jpg -ovc copy -o btemp.avi &> menc.log &&
printf "\n=========================\n\n" >> menc.log &&
mencoder btemp.avi -forceidx -ovc copy -o bigB.avi >> menc.log 2>&1 &&
rm btemp.avi
echo done.

#!/bin/bash echo starting ... cd $HOME/immagini/bigbrother/ img=frame.jpg list=frames.list if [ -f $list ] then n=`tail -n 1 $list` else touch $list n=0 fi sleep 1 webcam /etc/webcam/bigbrother.conf &> cam.log & echo grabbing frames \(x-key to stop\) ... until [ "$input" = "x" ] do read -t1 -s -n1 input if [ -f $img ] then n=$((10#$n)) n=$[n+1] n=`printf %05d $n` mv $img $n.jpg echo $n >> $list fi done pkill webcam # :( echo webcam stopped. echo starting avi creation ... mencoder mf://*.jpg -mf w=640:h=480:fps=1:type=jpg -ovc copy -o btemp.avi &> menc.log && printf "\n=========================\n\n" >> menc.log && mencoder btemp.avi -forceidx -ovc copy -o bigB.avi >> menc.log 2>&1 && rm btemp.avi echo done.

Posted in Debian e GNU/Linux

webcam come sensore di movimento

Posted on 05/09/2010 - 14/11/2010 by cretox

Ebbene ho una webcam.
Oggi ho provato ad usarla con il programma “webcam” (che fantasia).
Il programmino richiede una webcam compatibile con v4l2, poi, dice che funziona.
Sì funziona ma io mi stufo subito.
Poi scopro l’opzione ‘trigger’:

With ‘trigger’ set to a non-zero value webcam will upload the image only if the content of the image has changed. It just looks for the maximum difference between the last uploaded and current image and if it is greater than the specified value the image will be uploaded.

\o/
Ma tutto ciò apre infinite possibilità!
Metto ‘trigger’ a 100 e mi infilo nei meandri del bash scrpting.
Infatti ‘webcam’ registra una jpeg, sovrascivendola tutte le volte che cattura.
Quindi ho scritto uno script che avvia ‘webcam’, rinomina ogni nuova cattura e tiene il conto delle immagine salvate:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/bin/bash
 
cd $HOME/immagini/bigbrother/
i=frame.jpg
touch frames.list
n=`tail -n 1 frames.list`
sleep 5
webcam /etc/webcam/bigbrother.conf &> bb.log &
echo x-key to stop
until [ "$input" = "x" ]
do
  read -t1 -s -n1 input
   if [ -f $i ]
   then
     n=$[n+1]
     mv $i $n.jpg
     echo $n >> frames.list
   fi
done
killall webcam

#!/bin/bash cd $HOME/immagini/bigbrother/ i=frame.jpg touch frames.list n=`tail -n 1 frames.list` sleep 5 webcam /etc/webcam/bigbrother.conf &> bb.log & echo x-key to stop until [ "$input" = "x" ] do read -t1 -s -n1 input if [ -f $i ] then n=$[n+1] mv $i $n.jpg echo $n >> frames.list fi done killall webcam

Adesso non mi basta fare altro che trovare il modo di creare un video con ffmpeg ed metterlo nello script.

Risorse:
– bash @ tldp.org
– webcam @ aboutdebian.com

Posted in anvedi, Debian e GNU/Linux, FLOSS


Supporta:

Questo weblog esiste ed è visibile sulla rete grazie al Collettivo Autistici/Inventati che offre il servizio e mette a disposizione i mezzi (banda e macchine). Il progetto ha costi notevoli ma vive solo delle donazioni: nessun amministratorə verrà mai a casa tua a chiederti il canone.
Se vuoi che questo blog e la miriade di altri servizi offerti da A/I continuino ad esistere, sarebbe molto carino se impegnassi qualche euro in questo senso. Per fare una donazione, visita questa pagina.


Follow this blog on:

Follow this blog
Proudly powered by WordPress | Theme: micro, developed by DevriX.