Take a Camera Image & send to MONITOR server
This view module provide 3 features:
- view.sh: Take Camera Image & send to the MONITOR server
- autostart.sh: RUn view.sh at 5 minutes interval.
- hdc_autostart.sh: Run view.sh with outside event by GPIO, like PIR(Passive Infra-Red) Human detection Sensor.
download from release
or
git clone https://github.com/UedaTakeyuki/view2.git
Install & setup prerequired modules by
cd view2
./setup.sh
By Web Browser, Sign up to MONITOR™ Service at here. Following Quick Start document of Sign up to Monitor might be informative.
Sign up/in to MONITOR™ and confirm your view_id on the top page as follows:
Return back to view on the console, set view_id mentioned above by setid.sh command. Let's say your view_id is axwdjqwy as above picture, set it by setid.sh as
./setid.sh axwdjqwy
###Test to take & send photo
After view_id setting is finished, you can take & send photo by following command.
python3 -m pondslider
You may see following sequence of log.
{'photo': '/tmp/20190625210920.jpg'}
start handle
end handle
call value handler
start terminate
end terminate
By Web Browser, you can see the MONITOR™ display is updated by your taken & sent photo.
You can set that view.sh is called repeatedly at 5 minute interval after device is turned on by autostart.sh command as follows:
# set autostart on
./autostart.sh --on
# set autostart off
./autostart.sh --off
Technically speaking, autostart.sh set timer service of systemctl for view.sh. In case you are familiar with crontab, it's OK to set view.sh on the cron yourself instead of using autostart command.
You can confirm current status with --status option:
./autostart.sh --status
You may see following sequence:
./autostart.sh --status
● view2.service - Take photos & Post to the monitor
Loaded: loaded (/home/pi/SCRIPT/view2/view2.service; enabled; vendor preset: enabled)
Active: active (running) since Tue 2019-06-25 21:13:00 JST; 8s ago
Main PID: 830 (sudo)
CGroup: /system.slice/view2.service
├─830 /usr/bin/sudo /usr/bin/python -m pondslider --interval 5
├─837 /usr/bin/python -m pondslider --interval 5
├─838 /bin/sh -c fswebcam /tmp/20190625211306.jpg -d /dev/video0 -D 1 -S 20 -r 320x240
└─839 fswebcam /tmp/20190625211306.jpg -d /dev/video0 -D 1 -S 20 -r 320x240
Jun 25 21:13:00 raspberrypi systemd[1]: Started Take photos & Post to the monitor.
Jun 25 21:13:00 raspberrypi sudo[830]: root : TTY=unknown ; PWD=/home/pi/SCRIPT/view2 ; USER=root ; COMMAND=/usr/bin/pytho
Jun 25 21:13:00 raspberrypi sudo[830]: pam_unix(sudo:session): session opened for user root by (uid=0)
In case waiting key input, type "q" key.
In case afte service set as off, you can see followings:
Unit view2.service could not be found.
8. setting for automatically run view.sh with outside event by GPIO, like PIR(Passive Infra-Red) Human detection Sensor.
Instead of periodical running menttioned above step 5, you can set GPIO Event trigger by hdc.sh. hdc.sh runs as event loop to wach GPIO level change and kick view.sh. You can also set hdc.sh as service by hdc_autostart.sh as follows.
# set autostart on
./hdc_autostart.sh --on
# set autostart off
./hdc_autostart.sh --off
You can confirm current status with --status option:
./hdc_autostart.sh --status
You may see the following sequence:
● view.service - Take photos & Post to the monitor
Loaded: loaded (/home/pi/view/view.service; enabled; vendor preset: enabled)
Active: activating (auto-restart) since Wed 2018-11-14 21:01:52 JST; 25s ago
Process: 7947 ExecStart=/home/pi/view/view.sh (code=exited, status=0/SUCCESS)
Main PID: 7947 (code=exited, status=0/SUCCESS)
CGroup: /system.slice/view.service
In case waiting for key input, type "q" key.
In case of service set as off, you can see followings:
pi@raspberrypi:~/view $ ./hdc_autostart.sh --status
Unit view.service could not be found.
By default setting, view2 doesn't leave photo on the RPi. You can change this setting with uvc_photo.ini. To leave it, please delete first # of comment outed data_path settings as follow:
[save]
#data_path=/home/pi/DATA
[save]
data_path=/home/pi/DATA
The folder specified as data_path setting will be created automatically if not exist. You can leave it on other path with editting this path.
To reflect configration change, restarting of view2 process is required.
./autostart --off
./autostart --on- How to make Security camera with 2$ USB Webam & Raspberry Pi
- How to make Security camera with 2$ USB Webam & Beagle Bone Green
Any questions, suggestions, reports are welcome! Please make issue without hesitation!
- 0.1.0 2018.12.06 first version self-forked from view.
- 1.0.1 2022.03.24 Fix for support python 3.9 to run on BullsEye.
- 1.0.2 2023.11.13 Don't install python2-pip if OS version is BullsEye or later.




