Skip to content

Instantly share code, notes, and snippets.

@kiki67100
Last active March 30, 2020 17:36
Show Gist options
  • Save kiki67100/2825d7e46390f2fe7aee34e8299dd4dd to your computer and use it in GitHub Desktop.
Save kiki67100/2825d7e46390f2fe7aee34e8299dd4dd to your computer and use it in GitHub Desktop.
Libpuzzle IP WEBCAM Android detect motion
#!/bin/bash
#Using libpuzzle trough command line tools puzzle-diff to detect difference image from IP WEBCAM Android application
#Keep in mind this not replace the real detection video, because the real detection motion use realtime detection.
#This bash script detection two image first +0s and +60s and detect the difference trough puzzle-diff
#Require "puzzle-diff" run apt-get install libpuzzle-bin
while((1));
do
base_url="http://user:pass@IP:8080"
wget $base_url/enabletorch -O /dev/null;
echo "Enable flash wait...";
sleep 2s;
echo "Take first picture";
wget_opt="-t 3 -T 10 --connect-timeout=10 -w 10 "
first="photo$(date +%s--%H:%M:%S-%d-%m).jpg";
wget $base_url/photo.jpg -O $first;
sleep 60s;
second="photo$(date +%s--%H:%M:%S-%d-%m).jpg";
echo "Take second picture...";
wget $wget_opt $base_url/photo.jpg -O $second;
wget $wget_opt $base_url/disabletorch -O /dev/null;
echo "Run puzzle-diff 10=similar 20=different";
/usr/bin/puzzle-diff -e "$first" "$second";
exit_code=$?;
if [ "$exit_code" -eq "10" ]; then
echo "Image is same";
fi;
if [ "$exit_code" -eq "20" ];then
echo "Image is different alert!!";
echo "Image different http://WEBSERVER/$first et Image different http://WEBSERVER/$second" | swaks -4 --server smtp.gmail.com:587 --from user@gmail.com --to user@gmail.com -tls --auth PLAIN --auth-user user@gmail.com --auth-password PASSWORD --h-Subject "Alert" --body -
fi;
echo "Wait 60s";
sleep 60s;
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment