Presence Sensing / Position Tracking [Update#1]

A project log for SmartRoom

A Raspberry Pi and Arduino based voice enabled smart room system that controls lighting and music and responses to questions.

bennetBennet 12/26/2015 at 12:410 Comments

This is my current test setup for developing the OpenCV based presence sensing and room position tracking system component. It consists of my RasPi 2 and a 160° wide angle camera module from china (100% compatible with the original camera module) mounted on the power transformer of my ceiling lights (which will later on be disrupted by the Arduino controlled relay).

After quite some struggling with the compilation, I finally managed to compile the brand new OpenCV 3.1.0 (including the Java bindings) on my Pi.

Fortunatly, after loading the preinstalled (on Raspbian Jessie) V4L2 kernel driver, which creates a /dev/videoX, OpenCV can use the camera module out of the box, using it like a standard USB webcam. Therefore it only has a resolution of 640x480, but that is by far enough for motion tracking needs, a higher resolution would overload the RasPi anyways.

That way, I get about 2 to 5 position updates per second (unoptimized), with a single core at full load, leaving enough resources for the other software modules.

The detection of the current position of the occupant is done by taking the thresholded difference between two sequential images, blurring the result to remove noise, get a binary result image and filtering out too small or too close-by blobs and finally calculating the centroid of the result blob.

Support for multiple occupants will be added later on, more important is the interpretation of the constantly updated position. I will need to define rectangular zones for all interesting room areas (e.g. couch, bed, desk).

For presence sensing it is planned that a PIR will initially turn the camera on if a movement is detected. From then on the software constantly tracks the occupants position and (this is to be added) listens for a movement in outside direction through the door and thereby registers that the room is unoccupied again (turn off camera and lights).

Visualized, the position tracking looks as follows: