Posts: 1
Joined: Mon Nov 12, 2012 5:59 pm

New to Rasberry Pi: Sensing colors on a stop light.

Mon Nov 12, 2012 6:21 pm

Hi there,
I am new to the Rasberry Pi community. I was thinking of creating a mod for my car that would let me detect the color of the light in front of me.

I don't use my phone while I drive, but I do sometimes at stoplights. I hate being that guy, on his phone, who doesn't see the light change until somebody beeps.

Would it be possible to do simple image detection with the Rasberry Pi + a camera of some sort? I would also want to wire up either a speaker or an LED to flash / make a sound when the light changes.

If somebody could point me in the right direction I would really appreciate it!

User avatar
Forum Moderator
Forum Moderator
Posts: 12585
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

Re: New to Rasberry Pi: Sensing colors on a stop light.

Mon Nov 12, 2012 7:58 pm

:shock: :?: The words "simple" and "image detection" are mutually exclusive! :P

I don't say it cannot be done (but wait for the official raspberry PI camera!), I'm just saying that if you talking about this in this way, it means you do not understand what you are really asking!

Yes, image detection like this is done on a routine base these days, but the algorithms to do it are specialised to only one thing, and developing such software normally costs many man years.

Detecting the color of a stop light isn't an application for which you can get software off the shelve, let alone for free. Under laboratory conditions it might be simple enough to say if a red light burns in a certain area of the screen capture, but then that area must be clearly defined, and if you just drive up to a random stop light that will never happen, unless you want to kludge it, and point the camera directly at the red light each time, but that would defeat the usefulness I think.

Posts: 23
Joined: Mon Jan 30, 2012 9:45 am

Re: New to Rasberry Pi: Sensing colors on a stop light.

Tue Nov 13, 2012 9:58 am

Or you can monitor the movement of the car in front of you. It can be done also with a web camera and motion software.

Posts: 23
Joined: Thu Jul 05, 2012 3:06 pm

Re: New to Rasberry Pi: Sensing colors on a stop light.

Tue Nov 13, 2012 10:24 am

I think OpenCV could be a possible beginning.
I'm not sure if the Raspberry Pi has enough power to handle such a complex problem.
Some informations on Raspberry Pi and OpenCv :

User avatar
Posts: 10531
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK
Contact: Twitter YouTube

Re: New to Rasberry Pi: Sensing colors on a stop light.

Tue Nov 13, 2012 10:27 am

in the UK at least,
being stopped in the car and using a mobile phone is illegal
having the engine running and being in the drivers seat and using a phone is bad ... m'kay

now to the question ... it's not going to be easy.
How To ask Questions :-
WARNING - some parts of this post may be erroneous YMMV


User avatar
Posts: 3465
Joined: Sun Mar 04, 2012 2:13 pm
Location: ::1

Re: New to Rasberry Pi: Sensing colors on a stop light.

Tue Nov 13, 2012 11:06 am

Using your phone while driving or even stuck in traffic is illegal except for the use of handsfree kits.
So many accidents these days are caused by drivers who don't look where they're going like the recent incident involving Bradley Wiggins and a while van driver who couldn't multi-task. :)

Anyway to answer your question regarding traffic lights such a device is possible but practically impossible to implement.
To detect traffic lights you would need a video camera which is focused and pointing in the right direction.
The problem with this is not all traffic lights are located in the same position nor is your car going to be stopped at the same distance apart.
Also there maybe a situation in which the camera is blinded by the sun or by other light sources, or lights are broken and temporary lights are in use.
To be honest the only true way to know if the lights have changed is to keep your eyes on the traffic lights at all time and watch out for bad drivers who jumping the red light from on-coming traffic.
If you need to twitter or sms then play it safe pull over into a lay-by and turn your engine off.

Richard S.

Return to “Automation, sensing and robotics”