Motion Detection Reference System

Access to Reference Systems

The available reference systems are collected within the Reference Systems team. If you are not already a member, join this public team to get access to the included systems and libraries.

Learn more about importing blocks and joining teams.


This applications use the camera & utilities library to detect motion and give notice.

This is the application Alarm System SMS:

Alt text

Instructions for use

This demo works on any platform with Java SE, including headless Raspberry-Pi

It also assumes an USB camera is attached or integrated.

  • Import this project from within the Reactive Blocks SDK.
  • Press Build for system Alarm System SMS and select J2SE environment
  • Make sure logging level is INFO

On systems with screen attached:

  • Execute the generated project
  • Watch window on screen
  • The demo is terminated by closing windows on screen.

On headless system:

  • Make runnable jar file (Export/Runnable Jar)
  • Transfer jar file to system
  • Execute with *java -jar *
  • Watch output in console
  • Terminate with ^C

Enable SMS:

  • (Create &) edit config/ for phone numbers and Twilio access tokens.


Open the system block called Alarm System SMS and you will notice a periodic timer on the left side of the diagram. A tick is emitted from this timer twice a second. Follow this tick through the block and you will understand how images are captured.

Each image is fed into a Motion detection block that does a differential compare. If changes between two images are above a threshold the images are considered different and motion is detected. Look inside the method handleDetected(). You will see that an alarm is triggered if there is continous motion for more that two seconds. Block Limiter is used to make sure that there is a minimum of 5 minutes between to alarm messages.

The View blocks display the captured image. Closing any of them will stop the system.

Block SMS Send Buffered handles sending of the generated messages. It contains a buffer internally, to be able to store messages which haven’t been sent yet.

Also note the Test motion detection system block that can be used to test the system, but without actually sending SMS.

Variant with Email

Block Alarm System Email is a very similar application. However instead of sending SMS it is sending emails to a list of recipients with attached imaged from the camera.