Savatage
Posts: 5
Joined: Fri Jan 12, 2018 4:19 pm

Human distance detection for Art Piece

Fri Jan 12, 2018 5:12 pm

Hi Everyone,

My first time posting here. A family member asked me to help them design a human range sensing system for a painting exhibition (or bunch of paintings clustered together). The idea is that standing / walking humans will be detected at a range (6 feet) and trigger LED strip brightness and music volume depending on the proximity of the viewer. Additionally I need to be able to detect if 2 people are present.

I got a raspberry PI 3B, and arduino uno. I purchased some infrared (HC-SR501) and ultrasonic sensors (HC-SR04). I put raspbian (This is probably not a good choice of operating system, correct?) on the PI and am using python3 to write code. I played around with the IR sensors last night and they seemed to have too wide of a detection angle and very finicky.

I would think arduino would be better at interfacing with the sensors, and the PI for controlling LED's and playing music.

Please keep in mind that I am an electrical hardware engineer by profession and am not very great with traditional programming languages (unless it's HDL). I have approximately 3 months to do this project and will be able to spend 3 hours after work each day and perhaps twice that on weekends. Time is very limited therefore I do not mind spending money to make my life easier.

Would someone be able to help me figure out which Hardware / OS / sensor technology and programming language I should be working in?

Thanks in advance!

User avatar
topguy
Posts: 4611
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: Human distance detection for Art Piece

Fri Jan 12, 2018 8:54 pm

If you sensors have analog output then the arduino is better suited, but most digital sensors work just as well with the Raspberry.
I see no requirements that this system need sub milisecond responsetimes either.

Raspbian is just as good for this job as most operating systems.
Additionally I need to be able to detect if 2 people are present.
If you can get rid of this requirement I feel it will make the job ten times easier.

At least you should think well about how the detection logic should work.
The ultrasonic sensor could detect presence/distance and that could trigger a camera to grab a picture and then face-detection in the picture could tell you how many people was looking at the art. Remove the need to count people and you only need the ultrasonic sensors ( in my head at least.)

Savatage
Posts: 5
Joined: Fri Jan 12, 2018 4:19 pm

Re: Human distance detection for Art Piece

Fri Jan 12, 2018 9:24 pm

Hi Topguy,

Thanks for your response and thanks for pointing out that I can get away with digital sensor output, I guess i'll remove the Arduino from the setup.
If you can get rid of this requirement I feel it will make the job ten times easier.
Unfortunately for me, the theme of the artwork is collaboration and it is intrinsic to the concept that the system should be able to detect two people in front of the piece.

I was hoping I could mess around with the position of the ultrasonic sensors and isolate their detection radius from each other as well as fire them in sequence with some delay (so sensor 2 will not pick up echo of sensor 1). Am I expecting too much from these ultrasonic sensors? Would hate to put a lot of effort into it to find out it's not feasible.
Raspbian is just as good for this job as most operating systems.
Would I benefit at all from trying a real-time OS for PI? Would this significantly complicate the task?
The ultrasonic sensor could detect presence/distance and that could trigger a camera to grab a picture and then face-detection in the picture could tell you how many people was looking at the art. Remove the need to count people and you only need the ultrasonic sensors ( in my head at least.)
I'm a bit scared of treading into the image processing territory, I was under the impression that this would complicate the code - what is your opinion? Would you happen to know any hardware that will allow me to recycle code and/or utilize easy to call library functions?

Thanks,

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

Re: Human distance detection for Art Piece

Sat Jan 13, 2018 3:43 am

https://www.adafruit.com/product/3317
An array of these?
Normally only up to 1.2m but I think the datasheet said max 2m

Some ultrasonics have a narrow beam.
https://www.adafruit.com/?q=ultrasonic
Use the narrow beam ones and have an array of them too.

Or use a Kinect, the old on, the new one is too hard.
You can pickup secondhand Kinect's for reasonable prices.
Software is harder :(

Pi camera + OpenCV, harder again.
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

User avatar
PangolinPaws
Posts: 89
Joined: Wed Mar 05, 2014 9:04 pm
Location: Wiltshire, UK
Contact: Website

Re: Human distance detection for Art Piece

Sat Jan 13, 2018 6:53 pm

Savatage wrote:
Fri Jan 12, 2018 9:24 pm
I'm a bit scared of treading into the image processing territory, I was under the impression that this would complicate the code - what is your opinion?
Hello,

A long time ago I messed about with the OpenCV image-processing library in Python. The code required to detect & count the no. of people in an image was suprisingly simple. Here's an example I wrote years ago (old code is always embarrassing, but this is at least functional):

Code: Select all

print 'Initialize'	# SimpleCV is BIG so it takes a good 5 seconds to import
from SimpleCV import Display, Image
import os

display = Display()

while display.isNotDone()::
    print 'Capturing...'
    os.system('raspistill -n -w 500 -h 500 -o image.jpg')
    img = Image('image.jpg') # Pass the captured image to SimpleCV
    print 'Searching...'
    # This is the bit that does all the work:
    faces = img.findHaarFeatures('face.xml') # Try 'upper_body.xml' for better range
    if faces != []: # If any faces are found
        print '{} face(s) found at:'.format(len(faces))
        for face in faces:
            # Print the coordinates for each face found
            coOrd = face.coordinates()
            print coOrd
    else:
        print 'No faces found.'
print '--------------------'	# This just breaks things up for easy viewing
Old, failed blog posts are more embarassing than old code, but here's what I wrote on the subject in full:
https://pangolinpad.wordpress.com/2014/ ... detection/

Edit: It may not matter, but FYI all of this is Python 2.7 and was run on an original raspberry pi.
https://github.com/PangolinPaw

Savatage
Posts: 5
Joined: Fri Jan 12, 2018 4:19 pm

Re: Human distance detection for Art Piece

Mon Jan 15, 2018 2:37 pm

Hi

@PangolinPaws

Thank you for your response. You gave me the courage to try simplecv, I messed around with it over the weekend. I was having trouble and getting errors because (as you mentioned) it is written for python 2.7 on older raspberry pi's. Has anyone had luck trying to run this on a raspberry pi 3b?

@ Gavinmc42
Thank you for these suggestions, these look much better than what I was working with. I shall order some and see how they respond.

Will do some more work on this and post back.

Return to “Beginners”

Who is online

Users browsing this forum: ArturoHuchim, Bing [Bot], Inled, klricks and 54 guests