Seeking a recommendation for reliable presence detection

    Jun 10 2009 | 6:34 pm
    I am working on a installation for an upcoming show. This installation is a version of one that ran for one week in a smaller gallery.
    I found that the presence detection patch I was using was a little unreliable. I am told that I need to incorporate some background removal, but I'm not sure if that'll work given the installation environment. So I thought I'd post a topic here and pick the collective brains of this community for recommendations/advice when it comes to writing this particular part of my patch.
    This is what I'm working with:
    The user interaction environment is contained within a 4' x 8' x 8' (W x H x D) box. There is a halogen spot light mounted in the ceiling which lights the inside of the box. There is a Unibrain Fire-i webcam mounted in the top back corner that I'm using for the presence detection. Entry to the environment is through one of two doorways which are covered by curtains.
    This is what needs to happen:
    Simple really, I just need to know if there is someone in the box.
    These are the problems I was having:
    1. When someone comes in, they don't necessarily close the curtains all the way. The ambient light from the outside was unpredictably changing the lighting situation, making it difficult for the patch I was using to tell me if there was someone inside the box.
    2. I had to dramatically increase the contrast of the camera to get the presence detection to work. The falloff from the spot light was so dramatic, that there if someone moved a bit outside of the light, the patch would sometimes report that no one was inside the box.
    3. I also found that if the curtains moved as a result of people passing by the outside box, it would trigger a false positive.
    4. I couldn't get the webcam far enough away to cover the entire area inside the box. It was almost far enough away, but not quite. Would bringing the camera down to eye level be a more reliable solution?
    Thanks in advance.

    • Jun 10 2009 | 7:27 pm
      in this situation, perhaps more reliable than a camera is some kind of sensor. ir distance sensor, or even a force sensitive resistor on the floor triggered by them stepping on it.
    • Jun 10 2009 | 8:05 pm
      Thanks Rob.
      Would an IR sensor mounted inside the box, at about chest level, cover the entire area? Or would it only cover a specific point in front of it. I don't really need to sense distance, I just need to know if there is someone inside the box.
      Do you have experience using IR sensors? If so, would you be able to recommend one?
    • Jun 10 2009 | 9:36 pm
      DaveH wrote on Wed, 10 June 2009 14:05Thanks Rob.
      Would an IR sensor mounted inside the box, at about chest level, cover the entire area? Or would it only cover a specific point in front of it. I don't really need to sense distance, I just need to know if there is someone inside the box.
      Do you have experience using IR sensors? If so, would you be able to recommend one?
      An IR sensor isn't going to help here given the range. Depending on the model they are good for about an inch to maybe a couple feet. Rob's suggestion of an FSR is a good idea if you are just looking for detection. Create a faux floor to your box above the real floor and place a couple FSR's in between. What you will need, however, is a digitizer, like an arduino, to actually quantize the sensor data into something you can use in your patch. Another sensor that might be useful is a sonar mounted above the curtain facing downwards towards the other wall.
      Let me know if you need more info.
    • Jun 11 2009 | 6:27 pm
      I think Passive Infrared motion sensor would be the way to go. Get one of the ones with just a digital (on/off) output and connect it through some sort of microcontroller->USB board. The nice thing about PIR is that it rarely picks up non-mammal false positives and the fresnel lenses typically used gives a pretty wide field of view. Typically used in security systems and automatic light switches.
      Best, Andrew B.
    • Jun 11 2009 | 8:41 pm
      Will a PIR have enough range? I would imagine so if these are the same ones used for automatic light switches.
      Andrew, do you have experience using these sensors? Can you recommend a vendor/product?
      Thanks for the quick responses!
    • Jun 11 2009 | 9:28 pm
      drrr. Andrew is completely right. When I saw IR proximity my head went immediately to the sharp IR sensors (e.g. The PIR will certainly have enough range for you.
      Sorry about that! David
    • Jun 11 2009 | 9:30 pm
      I haven't used these before, but it's a good starting place.
    • Jun 13 2009 | 3:25 pm
      Sharp has introduced a -> fat distances up to 550 cm:
      Power it with 5 volts and you have an ultrasimple analog output, with a voltage proportional to the distance of the sensed object. No serial protocol to learn and no additional circuits. Read it with an analog-to-digital converter, set a threshold and: when (distance < threshold) = someone is there. I think this is the easiest possibile solution.
      I've used the shorter range sharp IR sensor and found them really stable and precise, much more than the ultrasonic range sensors.
      Hope this helps, good luck, kk
    • Jun 17 2009 | 10:36 pm
      The Sharp IR sensors, although good for many uses, wouldn't be ideal here for a couple of reasons: - The optics are designed for a narrow field of view, so it will only sense objects directly in front of the sensor. This is really good for when you want to keep a robot from hitting a wall, but doesn't tell you much about the overall scene. - Using an analog value is probably overkill in a situation where you just need to know if there is someone in the room. PIR is usually just a logical output, so you can hook it to a digital pin on your microcontroller and not have to deal with all the trouble of analog data. - The non-linear response of IR beam sensors is a real hassle.
    • Jun 19 2009 | 3:46 pm
      It seems as if a PIR sensor would do the trick. Thanks Andrew.
      Aside from the sensor, what would I need to get the output from the sensor into Max/MSP/Jitter? My guess is that an Arduino microcontroller would probably do the trick? Can anyone recommend one that would work for this situation?
      I don't have any experience using a sensor & microcontroller setup, but I think that may be another topic for the forum!
      Thanks for all the help.
    • Jun 19 2009 | 4:11 pm
      I would vote for the Arduino. Great community, solid boards/digitizers/microcontrollers, easy to use programming environment on all the main platforms...and cheap! The Duemilanove is a good place to start. Check out for more info, and ask questions if you get stuck.
      Cheers, David
    • Jun 19 2009 | 5:14 pm
      get a cheap PIR from a security shop or from a motion activated floodlight, the better PIRs have a few knobs you can play with for sensitivity and delay, all have a relay. you can then connect it to an arduino (or a hacked keyboard, for the cheap) for inputting to the computer.
    • Jun 20 2009 | 11:41 pm
      OK. So I picked up this PIR sensor ( and have successfully hooked it up to an Arduino Diecimila board.
      I've figured out how to read the analog output from the sensor. If the sensor detects infrared motion, it outputs a low reading. The problem is that if I stay still, the sensor goes back to a high reading, even though I'm still in the sensor's field of vision.
      This is a problem because I not only need to when people enter the room, but I also need to know if they remain in the room, even if they're standing still. I was hoping the sensor would give me a low reading if it detected infrared light and a high reading if it didn't.
      So, my question is: Is this a problem that can be solved through some sort of logic built in MaxMSP (once I get the Arduino talking to Max) or is this better solved by getting a different PIR sensor or building some logic into the Arduino itself?
    • Jun 25 2009 | 12:51 pm
      Though PIR are cheaper and easier to use, I really thinks that an IR range sensor is the ideal tool for your project.
      if I suggest them is because I found they are really precise, stable and easy to use>
      You just need to be sure that the IRranger "ray" will hit the person if the person is where-you-need-him-to-be: just put it at chest height. Then you are SURE that there's someone if the distance is inferior than a threshold you set. And you're SURE that there's noone if the distance is greater than.
      Maybe I'm not smart enough, but I can't imagine how can you do this with a PIR, with the same degree of accuracy of an IRranger?
      You can linearize the values coming from the IR with this formula: But maybe you don't really need to linearize, just watch the values the sensor gives you and put a threshold, than if it's cm or inches, linear or log you don't care at all, as long as the range of the sensor is enough to cover the full depth of your box:
      So, I suggest you get a GP2Y0A02YK (20 to 150cm), connect it to GND/5V/ANALOG 0 on your arduino, upload the Smoothing example to the Arduino board, (you find in sketchbook->examples->analog folder), then make a simple patch in MaxMsp with: serial, some >,some
      Hope this helps more than confuses you! good luck, kk
    • Jun 25 2009 | 3:42 pm
      Hi David, I think the PIR might work, but you are going to have to do a bit more (re)search on it. e.g. here's a little discussion on the Arduino forum about it: In particular check out response #5 in the thread. Plus make sure you've checked out the manual on the parallax web site (i.e. are you giving it the time required to calibrate/take a snapshot, have you set the right pins high vs. low vs. ??). Again, I haven't used these before, but it still seems like a decent solution for your needs based on a quick review...just might need a bit more work to get the data that you need.
      HTH a bit more?
    • Dec 18 2009 | 1:05 am