-
Notifications
You must be signed in to change notification settings - Fork 0
/
testWebcam
executable file
·46 lines (43 loc) · 1.38 KB
/
testWebcam
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
39
40
41
42
43
44
45
#!/bin/bash
/show/listecho "Test webcam" $OK
/system/install v4l-utils
/system/install fswebcam
/show/listecho "Detect Camera" $OK
/show/console
v4l2-ctl --all
webcam_detected=$?
/show/console
if [ $webcam_detected == 1 ]
then
/show/listecho "No webcam detected" $ERR
exit 1
else
/show/listecho "Detect Resolutions" $OK
resolutions=$(v4l2-ctl --list-formats-ext |grep "Size:"|awk '{print $3}')
echo $resolutions
/show/listecho "Test all resolutions" $OK
/show/listecho "Pictures will be saved inside /tmp/webcamTest" $INFO
mkdir /tmp/webcamTest
name=$(lsusb |grep -i "cam" |awk '{ $1=""; $2=""; $3=""; $4=""; $5=""; $6=""; print $0 }'|tr -d ' ')
for resolution in $resolutions
do
/show/console
fswebcam -r "$resolution" -S 5 --save "/tmp/webcamTest"/"$name"-test"$resolution".jpg
/show/console
done
kill -9 $(pgrep -f "python -m SimpleHTTPServer 1234") > /dev/null 2>&1;
cd /tmp/webcamTest; python -m SimpleHTTPServer 1234 &
/show/linebreak
/show/linebreak
/show/linebreak
/show/linebreak
/show/listecho "Images available at"
/show/listecho $(cat /etc/hostname)":1234" $OK
/show/listecho $(cat /etc/hostname)".local:1234" $OK
/show/listecho $(/show/ipAddress)":1234" $OK
/show/listecho "Press any key to stop sharing pictures" $WARN
read
/show/listecho "Stopping webserver" $OK
kill -9 $(pgrep -f "python -m SimpleHTTPServer 1234") > /dev/null 2>&1;
rm -rf /tmp/webcamTest
fi