How to perform color recognition and white line recognition at the same time

Color recognition can only be in RGB mode, while white line recognition can only be in gray mode,how to perform color recognition and white line recognition at the same time?Thanks!

Hi, you can do everything in RGB565 mode and just set your color bounds for different things.

Um… so, your question is really vague. Can you try to write my a paragraph or to on what you need help with?

Thanks,

Thanks kwagyeman!
Application scenario is as follows: the car in the process of driving, the need to constantly test the traffic lights ahead and around double solid line. Red light is detected and offset the double solid line, make a report to the buzzer.Thanks!

Application scenarios are as follows: openmv camera fixed in the car, the car in the process of driving, constantly testing whether there is a red light in front and whether beyond the next double solid line. In openmv-ide, the detection of color using RGB mode, and the detection of white lines is used in the find_edge function grayscale mode, in the openmv cam2 board, how to achieve the above functions. Is there a testable code, thanks!

Sorry for taking so long to reply to this.

Alright, so, um, I wouldn’t use the OpenMV Cam in a real car. Are you trying to do that or is this a toy problem? While I believe in the quality of our system I wouldn’t use it in anything serious like controlling an actual car.

Anyway, I would recommend using two OpenMV Cams to solve this problem. One to detect the line and one to detect the light. I say this because they will both be looking in different directions. The one looking at the light looks up while the one looking at the ground looks down.

As for detecting the red light… this is hard. The red light can move around in the field of view and there can be other red objects along with the lighting changing constantly. If you are trying to do this outside then you’re going to need to spend quite a lot of modifying color tracking settings on the fly and filtering the algorithm output.

The easiest thing to do to get something working is to just to call find_blobs with some red color tracking settings tuned for finding red lights. A good way to figure out the color bounds would be to get them from an actual red light. This will find all red light objects in the field of view. You’ll then want to filter out all objects that aren’t squarish with and that have a low pixel to area density. This should leave you with just the objects that are red lights and round.

Note that you’ll need different color tracking settings for different times in the day. Since find_blobs call take multiple color thresholds at once you should pass it a list of all thresholds you need to track with in the first call and set the threshold_cb callback to a function that filters out non-square / non-dense blobs.

This will allow you to find the reds lights in one “find_blobs” call.

As for the white line. find_edges in grayscale is fine for that. You can then filter out edges that aren’t parallel-ish to the ground.