0

I am working on " Controlling Raspberry Pi's GPIO pins according to change in traffic lights (Red, Green, Yellow)". Right now, I am focusing only on Traffic light detection part. For that, I am using Cascade classifier for Haar features.

I have 2000 negative sample images, which I have converted to grayscale and reshaped to 120 X 120. Also, I have ONE positive image of traffic signal (40 X 120), from which I am generating 2000 positive samples. And finally, I am training my classifier using 2000 positive samples and 1000 negative samples with 10 stages.

My output for some test images looks like following: Output 1

output 2

Output 3

Image from which I created positive samples: positive image

I have some questions/doubts and need some suggestions to improve or modify my classifier.

1) Do I need to use more than one image as positive image to create samples?

2) Why I am not able to detect all the traffic signals in above images?

3) Am I doing wrong in image shape or anything?

4) Please correct me in this point if I am wrong - To draw a rectangle over traffic signal, I am using cv2.rectangle function and provided constant height/width parameter, and thats the ONLY reason why it is drawing a big rectangle regardless of how near/far my traffic signal is in an image! Any suggestions to change this size dynamically?

Thank you.

Sailorman
  • 11
  • 6

1 Answers1

1

To me, it looks like your network has not learned enough.

1) I strongly suggest taking 20-50 samples of traffic lights, instead of one sample. You still can generate thousands of samples using them, for training.

2) most likely because of inadequate training, but you should also check the parameters in the detection stage. What are the minimum and maximum sizes that you have set for detection?

3) You don't have to re-shape or re-size the image, so that should not be a problem.

  1. The detector returns the position (x,Y) and the size (width, height) of all objects that were detected. So you should be able to change the size dynamically instead of using constant width and height. Please refer to the opencv example of Haar Face Detection, of the language of your choice.
Totoro
  • 3,398
  • 1
  • 24
  • 39