designing sleep monitors prototype 3

In order to verify my arduino based prototype, by the end of 2011, I decided to use the depth infrared camera from a kinect to verify "visually" that it works.

I am not going to watch 8 hours of someone sleeping, I'll just get a computer to do that, so I learned some basics for "computer vision" in R.
Here I am using frame subtracting by importing each greyscale frame from the depth camera and subtracting it to the next frame. This way I can identify changes and how small/large are these changes between each frame.
Here is a sample,

the first frame is at t0,
the second frame is taken 4 seconds later,
the third frame is the result of subtracting the first two frames,
if there is no movement that third frame will be black (zeroes), otherwise the areas where depth changed will be grey/white (pixels values up to 255) then I sum the value of all pixels in that third frame to estimate how much movement there was.
To sum it up, if the third frame shows no movement then the pixels sum is near zero, otherwise the sum will be much greater than zero.
Then repeat for all frames. The code in R is only ~50 lines thanks to the pixmap library. And plotting against time gives something like this:

The peaks in black are the movements measured by the kinect through time. The higher the peak the larger the movement. The lines in red are from the arduino monitor, they are not quantitative though, it just knows there was movement at this point in time. Both systems clocks were synchronised before going to sleep.
The arduino PIR sensor didn't catch all movements but otherwise agrees near perfectly with the kinect feed. There is a slight delay towards the end of the night because arduino clocks usually drift and it could also be due to sampling frequency on the kinect.

You will notice the baseline is a bit noisy because of the infrared beams not being reflected and recorded identically in each frame, though it is still very easy to spot any movement, and how they compare to each other.
From there also, someone could design with the kinect API a more advanced system, tracking multiple persons, with skeleton recognition and limbs tracking , or just shoot your own depth infrared sex tape video (rule 34 of the internet)

additional links and similar projects:
lullaby http://dub.washington.edu/projects/lullaby
Anita Lillie's sleep tracker project http://flyingpudding.com/projects/sleep_tracker
lolo https://code.google.com/p/lolosalarmclock/

Rating: 
Average: 4 (1 vote)

Add new comment

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
By submitting this form, you accept the Mollom privacy policy.