yodermk
Posts: 35
Joined: Sat Mar 07, 2015 9:54 pm

Detecting a person's position on a sidewalk

Wed Jun 08, 2016 10:47 am

Thinking of possible Halloween projects - having things with motorized turnable heads in my yard, which would turn to face (and track) people as they walk past my house and up to my front door.

But to do that I need to know where people are on the sidewalks. There's of course the street sidewalk that goes past the whole yard, then in the middle of the yard there's a (straight) sidewalk to the front door, perpendicular to the street sidewalk.

Is there a good way to for a Pi to sense where people are?

I've thought about a few PIR type sensors, but that would give very low resolution unless I put in a LOT of them.

Thanks!

PiGraham
Posts: 4199
Joined: Fri Jun 07, 2013 12:37 pm
Location: Waterlooville

Re: Detecting a person's position on a sidewalk

Wed Jun 08, 2016 11:05 am

PIR sensing is probably the way to go for detecting people at night.
Standard security PIR sensors typically have broad sensing regions and on/off detection. If you can get several narrow angle PIRs and arrange them in an arc you turn towards a hot target.

You could use thermal sensor like this:
http://uk.farnell.com/omron-electronic- ... dp/2217999

If you can be sure of good lighting you could consider face detection (OpenCV). Find the face and turn to centre it. That would probably fail with Halloween masks though.

You could simply use motion to locate moving objects. Changing lighting, from moving cars etc, is likely to cause major problems with that.

EdMcr
Posts: 8
Joined: Thu Mar 03, 2016 6:38 pm

Re: Detecting a person's position on a sidewalk

Wed Jun 08, 2016 1:51 pm

I would use a camera and follow motion.

Using e.g. OpenCV, find the difference between two images. If something has moved, check how fast it moves (to exclude cars, birds etc and things that move faster than the head can turn)

Then output a measure that is the difference between the objects x-position and the middle of the image to see in which direction and by how much you need to rotate.

PiGraham
Posts: 4199
Joined: Fri Jun 07, 2013 12:37 pm
Location: Waterlooville

Re: Detecting a person's position on a sidewalk

Wed Jun 08, 2016 3:15 pm

EdMcr wrote:I would use a camera and follow motion.

Using e.g. OpenCV, find the difference between two images. If something has moved, check how fast it moves (to exclude cars, birds etc and things that move faster than the head can turn)

Then output a measure that is the difference between the objects x-position and the middle of the image to see in which direction and by how much you need to rotate.
Just beware that this is in the dark on the street, so lighting is likely to be very difficult, with moving lights, changing light levels, multiple shadows, lots of noise and poor object contrast.

User avatar
Gavinmc42
Posts: 4852
Joined: Wed Aug 28, 2013 3:31 am

Re: Detecting a person's position on a sidewalk

Wed Jun 08, 2016 9:41 pm

Pikrellcam can be setup to detect motion in regions and then run a script on motion.
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

CCitizenTO
Posts: 83
Joined: Sun May 20, 2012 2:14 am

Re: Detecting a person's position on a sidewalk

Thu Jun 09, 2016 6:52 pm

Would it be easier to use the infrared camera module and just have it track 'large' shapes moving (like the size of a kid or adult).

yodermk
Posts: 35
Joined: Sat Mar 07, 2015 9:54 pm

Re: Detecting a person's position on a sidewalk

Thu Jun 09, 2016 11:48 pm

Thanks. I have no experience with OpenCV but could be interesting to try it.

Maybe 12 or so PIR sensors would be enough, but that might get a bit unweildly...

PiGraham
Posts: 4199
Joined: Fri Jun 07, 2013 12:37 pm
Location: Waterlooville

Re: Detecting a person's position on a sidewalk

Fri Jun 10, 2016 10:01 am

Using lots of PIRs is one way to do this. Just turn a servo to point in the direction of an active PIR.
You could use a small number of sensors (two or three) mounted on the turntable. Roughly speaking, if the left=facing PIR fires turn to the left. If the right-facing PIR fires turn to the right and if the centre PIR fires stay still and do something. You will need a more complex algorithm to avoid erratic motion. The general idea is to turn so that the centre PIR is pointed at the target. The side PIRs allow to "catch the eye". You will need to deal with a case where there is motion both sides. Maybe randomly pick R or L and suppress the other side for a time.

PIRs only see movement so if someone moves into view and stops they won't be detected any more.

A benefit of mounting sensors on the turntable is that you can make them occasionally scan the scene to acquire a target.

Given PIR modules can be bought for ~£1 each having 12 or more is viable.

The Omron sensors see stationary targets and are effectively eight sensors in one.

Some search terms for you:

PIR turret tracking camera

Return to “Automation, sensing and robotics”