Remote watching by USB Webcam

Setup USB Webcam to take photo periodically and send it to the MONITOR™ service with a "view_id" which you got at previous Sign up chapter. You can watch the latest picture by your Web Browser throug the MONITOR™.

What you need

No matter what kind of USB Webcam can be used. Even Berry old used Webcam or just 2$ inexpensive Webcam, it's OK.

A board computer, to control a Webcam and the network acess, is necessary. Raspberry Pi, BeagleBone and these similar product is good candidate. In addition to that, even PC is good if Linux is running, USB Port can be used, and Internet access is available.

For Internet access, both flat-rate fix network and 3G network are OK. In general, remote wathing by 3G network tend to be expensively. But MONITOR™ is still image base, so by adjusting a interval of posting image, it possible to keep montly fee about 10$.
For detail of how to use 3G network, this article might be informative.

The software running on the Linux, to take photo and send it, named "View" is available at here. After here, we will explain how to install and setting of "View". If you would implement your own application, Appendix of this document might be informative.

Prepareing

As mentioned above, prepare a board computer running Linux and connecting internet. Then open console and install "View".

Install of View

download from release

or

git clone https://github.com/UedaTakeyuki/view.git

Setup of View

Go to installed directory, Install & setup prerequired software by setup.sh command as follows:

./setup.sh

Set view_id

Set your view_id to View 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

Plug your USB WebCam to your board computer. Then, take & send photo by view.sh command as follow:

./view.sh

You may see following sequence of log In case everything succeeded, expected response is consist of the log of taking photo, sending it, and {"ok":true} as follows:

--- Opening /dev/video0...
Trying source module v4l2...
/dev/video0 opened.
No input was specified, using the first.
Delaying 1 seconds.
--- Capturing frame...
Skipping 20 frames...
Capturing 1 frames...
Captured 21 frames in 0.67 seconds. (31 fps)
--- Processing captured image...
Writing JPEG image to '/tmp/20180823190339.jpg'.
{"ok":true}

At the last line, {"ok":true} indicate that take & send photo are successfully finished. By Web Browser, you can see the MONITOR™ display is updated by your taken & sent photo.

In case something wrong, response finished with {"ok":false,"reason":"XXX"}. For Example:

{"ok":false,"reason":"ViewID not valid"}

In this case, you should make sure if correct view_id was set by setid.sh command.

Debug

In case your MONITOR™ display is NOT updated, try view.sh command with test option

./view.sh test

With test option, view.sh doesn't use WebCam. Instead, view.sh send a Rainbow test bars. In case Rainbow bars are shown on your MONITOR™ display, at least network connection between your device and MONITOR™ server is working well. In case still NOT update, most posible cause is that the board computer doesn't connect to the internet.

In case Rainbow bar can be seen well, at next, try view.sh command again with keep option

./view.sh keep

With keep option, view.sh doesn't remove a photo even after send and keep it on the folder "/tmp" with the filename consist of date & time like as /tmp/20181114201302.jpg. So, please check this .jpg file. If this file seems to be broken, also confirm your WebCam device is working well or not.

Auto start-up setting

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

Also turn off as follows:

# set autostart off
./autostart.sh --off

Tecknically speaking, autostart.sh set timer service of systemctl for view.sh. Incase 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:

pi@raspberrypi:~/view-v_1.1.1 $ sudo systemctl status view.service 
● 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 20:42:26 JST; 5s ago
  Process: 7057 ExecStart=/home/pi/view/view.sh (code=exited, status=0/SUCCESS)
 Main PID: 7057 (code=exited, status=0/SUCCESS)
● view.timer - Take photos & Post to the monitor
   Loaded: loaded (/home/pi/view/view.timer; enabled; vendor preset: enabled)
   Active: active (waiting) since Wed 2018-11-14 18:38:51 JST; 2h 3min ago

Nov 14 18:38:51 raspberrypi systemd[1]: Started Take photos & Post to the monito

In case waiting key input, type "q" key.

In case afte service set as off, you can see followings:

Unit view.service could not be found.
Unit view.timer could not be found.

APPENDIX A. Interface of send picture

For implement your own application of sending picture, send picture to the following url.

https://monitor3.uedasoft.com/postpic.php

In this case, add viewid parameter with your view_id value.
Let's say your view_id is axwdjqwy, and take a photo by fswebcam and send it by curl as above picture, an example implementation is as follows:

your_view_id=axwdjqwy

filepath=/tmp/`date +%Y%m%d%H%M%S`.jpg
fswebcam $filepath -d /dev/video0 -D 1 -S 20 -r 320x240
curl https://monitor3.uedasoft.com/postpic.php -F viewid=$your_view_id -F upfile=@$filepath

Set picture size as 320x240 as above example. The file size of the 320x240 picture is, depend on the environment, about 100KByte.

Have at leaset 1 minutes interval of send picture.

In case using 3G network, typically, 5$ - 10$ cost per 1GByte network traffic. To keep montly network traffic about 1GByte, keep to monthly sendings about 10,000 times, in other word, 330 times a day, 13 times an hours, that is, 5 minutes interval is appropriate.

Empirically, when using berry old webcam and so inexpensive webcam, this is good practice for getting a good quarity picture that to provide some delay and to throw first several pictres.

results matching ""

    No results matching ""