Reputation: 11
I am currently working on a hobby project for a robot car. In front of the camera, I will place 2 light sources and with computer vision I want to detect the light sources and position my robot car in front of it.
With Python and OpenCV on a Raspberry Pi 3, I have the following working: I am using 2 red light sources. Using the following OpenCV functions: cvtColor(frame to HSV), inRange(red filter), findContours(find the 2 light sources), Moments(get the x,y coordinates of the light sources), calculate distance of the light sources compared to the edge of the frame and generate which direction the car have to move.
The problem now is, I cannot determine which red light source is left and which one is right. If I turn for example my breadboard with 2 red light sources, the program won't be able to tell that the car has to move around the light sources.
I have 2 ideas to fix this: - using frequency to let the light sources blink different. let's say LEFT(1, 0, 1) and RIGHT(0, 1, 0). I might not be able to use threading here, since I need 'every frame'. - using 1 red and 1 green light source. For this I have to add separate functions to detect green, which means more processing power.
I'm struggling with choosing the best option since I'm inexperienced in this field. Do you have any tips? Or which idea is better?
Upvotes: 0
Views: 1721
Reputation: 623
It's not a complete answer but I hope it will help you.
In this program LedBlinkingFrequency I estimated pixels frequency (time) using fourier transform for fixed points (can be rectangle) using thread. I think you can translate in python. May be you can disable fourier and use only time signal with a threshold to count 1 per unit time
Upvotes: 1