Low Power Motion Detection

Version 10 (Kwabena Agyeman, 12/12/2012 07:59 pm)

1 4 Kwabena Agyeman
h1. Low Power Motion Detection - Article By: Kwabena Agyeman
2 1 Kwabena Agyeman
3 1 Kwabena Agyeman
h3. *Abstract*
4 1 Kwabena Agyeman
5 1 Kwabena Agyeman
Current motion detectors that control lighting and building HVAC systems use passive infrared (PIR) sensors to detect the presence of a person in a room.  However, PIR sensors cannot see small amounts of motion in a room and will turn the lights and HVAC system off on the occupants of a room who are sitting and working in the room.  To remedy this problem I propose that a low-power computer vision system is used along with a PIR sensor to perform variable frame rate image differencing to detect the presence of people sitting and working in the room.
6 1 Kwabena Agyeman
7 1 Kwabena Agyeman
h3. *Introduction*
8 1 Kwabena Agyeman
9 1 Kwabena Agyeman
Making systems smarter and more energy efficient is one of the many problems faced by our world today.  Dumb building lighting systems and HVAC systems consume tremendous amounts of energy while performing unnecessary work by illuminating and cooling or heating unoccupied rooms.  Efforts have been made to incorporate motion detector systems into the lighting and HVAC control loop that turn the lights and HVAC system on when motion is detected, and that turn the lights and HVAC system off after motion has not been detected for a long period of time. 
10 1 Kwabena Agyeman
11 9 Kwabena Agyeman
These motion detection systems rely on inexpensive passive infrared (PIR) sensors to detect motion within a room.  PIR sensors work by looking for large changes in the passive infrared light emitted by objects in the room.  Different objects at different temperatures in the room emit different amounts of infrared light.  PIR sensors are used in motion detection systems to detect when the amount of passive infrared light in a room changes when an object enters or exits the PIR sensor's field of view. 
12 1 Kwabena Agyeman
13 10 Kwabena Agyeman
Thus, when a person, who is at a different temperature than the room, enters or exits the PIR sensor's field of view it detects that the scene has changed.  However, the PIR sensor cannot detect if a person entered or exited the room.  The PIR sensor only detects if something in its field of view changed.  Additionally, PIR sensors cannot detect small amounts of motion within their field of view because small amounts of motion do not drastically change the amount of passive infrared light in the room.
14 1 Kwabena Agyeman
15 1 Kwabena Agyeman
Because of the limitations of PIR sensors, PIR based motion detectors cannot sense the presence of, for example, an office worker sitting at his or her desk who is in the line of sight of the PIR sensor.  The officer worker will have to get up and move around to re-trigger the sensor to keep the lights and HVAC system on.  Additionally, when the office worker leaves his or her room, the PIR sensor will not be able to detect the absence of the officer worker’s presence and will instead turn the lights off based on a countdown timer from the last time the PIR sensor was triggered.  This means that the lights and HVAC system will continue to run for a long while in the absence of the office worker. 
16 1 Kwabena Agyeman
17 1 Kwabena Agyeman
To solve these problems I propose that a low-power and inexpensive computer vision system is used along with the PIR sensor to perform variable frame rate image differencing to detect the presence of the office worker sitting in the room when the PIR sensor cannot.  Additionally, the low power and inexpensive computer vision system could also possibly be used to count the number of occupants in a room to control the lighting and HVAC system more precisely.
18 1 Kwabena Agyeman
19 1 Kwabena Agyeman
h3. *Implementation*
20 1 Kwabena Agyeman
21 1 Kwabena Agyeman
The proposed motion detection system will consist of a PIR sensor and the CMUcam4 low-power computer vision system.  The CMUcam4 is an embedded system development platform that pairs a microcontroller with a cell phone camera. 
22 1 Kwabena Agyeman
23 1 Kwabena Agyeman
The CMUcam4 will use the PIR sensor to detect motion in a room when the CMUcam4 cannot see because the lights are off.  When the PIR sensor detects motion, the CMUcam4 will then turn the lights on and wake up from sleeping. The CMUcam4 will then adjust to the lighting in the room and take a picture of the room for reference.  After which the CMUcam4 will proceed to go back to sleep to conserve power while leaving the lights on.
24 1 Kwabena Agyeman
25 1 Kwabena Agyeman
After sleeping for a while (the optimal sleep time must be determined empirically) the CMUcam4 will then wake up and take another picture and compare this new picture to the reference picture that was taken previously.  The differences between the two pictures will be thresholded using a look up table and the resulting binary bitmap will be stored to memory.  Additionally, the CMUcam4 will compute the average of the new image and the reference image and replace the reference image with the average image.  Finally, the CMUcam4 will also store the histogram of the differences to memory to adjust the threshold look up table in response to different distributions of the magnitude of differences in an image.
26 1 Kwabena Agyeman
27 1 Kwabena Agyeman
The CMUcam4 will then go back to sleep, wake up again after some amount of time sleeping, and repeat the above process again.  The CMUcam4 will detect motion in the room by looking at the binary bitmap of all the blobs in the thresholded pixel differenced image.  All binary blobs larger than a certain size and having a certain pixel density will be treated as differences.  The presence of large and dense binary blobs will tell the CMUcam4 to leave the lights on in the room.
28 1 Kwabena Agyeman
29 1 Kwabena Agyeman
The CMUcam4 will then go back to sleep for an amount of time inversely related to the amount of motion detected for the current sample period and the previous sample periods.  When the CMUcam4 detects a lack of motion over time, it will sleep for shorter periods of time increasing its sample rate.  When the CMUcam4 detects motion over time it will sleep for longer periods of time decreasing its sample rate.
30 1 Kwabena Agyeman
31 1 Kwabena Agyeman
Because the CMUcam4 averages images of the room each time it samples, objects that stop moving will slowly disappear into the background of the image.  By having a variable sample rate, the CMUcam4 will be able to more quickly react to the lack of the presence of motion in a room to turn the lights off faster by increasing the sample rate causing non-moving objects to fade into the background.  More importantly, the CMUcam4 will also able to stay in low power sleep mode for longer to avoid drawing excessive amounts of power when motion is detected.
32 1 Kwabena Agyeman
33 1 Kwabena Agyeman
The reason for using the CMUcam4 or any other low power vision system over a fully-fledged computer for this application is that the CMUcam4 is able to draw about 100 uA sleeping and less than 100 mA while operating.  Any sensor that controls the lights for the room should not draw an amount of energy comparable to the load it controls.
34 1 Kwabena Agyeman
35 1 Kwabena Agyeman
h3. *References*
36 1 Kwabena Agyeman
37 1 Kwabena Agyeman
[1] C. Stauffer, W.E.L. Grimson, “Adaptive background mixture models for real-time tracking”, published.
38 1 Kwabena Agyeman
[2] M. Piccardi, “Background subtraction techniques: a review”, unpublished.
39 1 Kwabena Agyeman
[3] A. Verdant, A. Dupret, H. Mathias, P. Villar, L. Lacassagne, “Low Power Motion Detection with Low Spatial and Temporal Resolution for CMOS Image Sensor”, published.
40 1 Kwabena Agyeman
[4] K. Agyeman, “CMUcam4: Open Source Programmable Embedded Color Vision Sensor”, unpublished.
41 5 Kwabena Agyeman
42 5 Kwabena Agyeman
h3. *Presentation and Reports*
43 5 Kwabena Agyeman
44 6 Kwabena Agyeman
"Mile Stone 1 Report":/attachments/710/M1%20Report.pdf
45 6 Kwabena Agyeman
"Mile Stone 1 Presentation":/attachments/712/M1%20Presentation.pdf
46 6 Kwabena Agyeman
47 7 Kwabena Agyeman
"Mile Stone 2 Report":/attachments/713/M2%20Report.pdf
48 7 Kwabena Agyeman
"Mile Stone 2 Presentation":/attachments/714/M2%20Presentation.pdf
49 6 Kwabena Agyeman
50 5 Kwabena Agyeman
h3. *Code*
51 8 Kwabena Agyeman
52 8 Kwabena Agyeman
"M2 - Top Object":/attachments/715/!CMUcam4_Terminal.spin
53 8 Kwabena Agyeman
"M2 - Camera Driver Driver Object":/attachments/716/CMUcam4_CAMEngine.spin
54 8 Kwabena Agyeman
"M2 - Serial Port Driver Object":/attachments/717/Full-Duplex_COMEngine.spin
55 8 Kwabena Agyeman
"M2 - File System Driver Object":/attachments/718/SD-MMC_FATEngine.spin