Have eGeoffrey keeping an eye on your webcams
user2684 last edited by
Wouldn't be nice to have all your webcams available through eGeoffrey as well? As far as the webcam is reachable from a URL or you have a raspi camera attached to your raspberry pi, the setup is pretty simple.
Let's search the marketplace first:
$ sudo egeoffrey-cli search image egeoffrey-service-image: Retrieve images from a url or command, perform motion detection and object recognition
Install the package:
$ sudo egeoffrey-cli install egeoffrey-service-image egeoffrey-service-image:master installed successfully
And start it:
$ sudo egeoffrey-cli start demo_egeoffrey-gui_1 is up-to-date demo_egeoffrey-database_1 is up-to-date demo_egeoffrey-service-system_1 is up-to-date demo_egeoffrey-controller_1 is up-to-date demo_egeoffrey-service-earthquake_1 is up-to-date demo_egeoffrey-gateway_1 is up-to-date demo_egeoffrey-service-fcc_weather_1 is up-to-date Creating demo_egeoffrey-service-image_1 ... done
If we now connect back to eGeoffrey web interface, we have a "Image Service" menu item under the "Examples" section. This is an example deployed by the package we have just installed we can re-use or take inspiration from.
If we click on it we will see a simple page with three image widgets, each one with a different webcam which has been pulled from the internet:
If we now go in "House" / "Sensors" we will see those images are stored in three sensors associated by the newly installed
Now, if you have a webcam in your network whose snapshot can be retrieved with a web request, just create a new sensor, select "image" as format, ensure you have a "single_value" retention policy set (otherwise the database will grow up really fast for keeping every picture forever), associated it to the "image" service and fill in the URL in the configuration tab under "Download the image from this URL".
If the webcam requires (basic) authentication, fill in also username and password.
If you are using a camera attached to your raspberry pi, instead of the URL write down in "Run a command returning an image" something like
raspistill -w 640 -h 480 -o -. Generally speaking any operating system command which returns an image in binary format can be used for polling a new image (e.g. from a RTSP stream, etc.).
Ensure also to configure a schedule for polling images at regular intervals (e.g. every 5 minutes).
Keep in mind eGeoffrey right now can handle only static snapshots, not video streams.
If you don't have a webcam or the one you have is not exposing snapshots via web, evaluate if it is worth building a new one with https://piwebcam.github.io
Let's see now some advanced configuration available to you.
What if you want to update the snapshot without waiting for the scheduled refresh interval? Go to the page where the image is displayed, add a new "Button" widget and configure "Actions to Execute" to be
sensor_idis the sensor identifier which is storing the pictures from your webcam. In this way, once the button is clicked, eGeoffrey will manually poll the service for this sensor resulting in a new, updated image showing up in the page without the need to refresh anything.
eGeoffrey also has some very powerful image analysis capabilities like motion detection and image recognition hidden under the hood. When set, those capabilities work like filters, e.g. the newly incoming image is ignored if there is no motion or the object you want to detect (e.g. people) is not there.
In this way you can combine this feature with a rule alerting you only when a motion is detected or somebody is in your house (the rule has to be configured with a type of "realtime", triggering on the sensor identifier storing the image, without any further condition since a new image implies an interesting situation is taking place).
Got back, edit your sensor and visit the "Configuration" tab. Down below you will notice additional optional settings like
- Ignore the image unless a motion (higher than this %) is detected
- Ignore the image unless at least this number of people are detected in the image
- Ignore the image unless this object is detected in the image and Ignore the image unless the detected object has a confidence level higher than this percentage (this requires a valid API key from https://portal.clarifai.com/signup to be set in the
Motions and people are also highlighted with a red squares when identified.
Remember all of those conditions are applied with an AND logic so they all work as filters when set.
service/imagemodule is also able to capture images sent on a given MQTT topic (to be configured in the module's settings)