David Rodriguez
David Rodriguez

Reputation: 21

Tracking changing LED in OpenCV

I've been working my mind on this a few over the last days and I haven't reached (yet) an answer. I'm working on an OpenCV (Actually, EmguCV as I'm using C#) video processing application and I need to track a LED light position on a video.

Up to this part, everything seems normal. I can convert the image to the HSV color range and detect any colour. The point is that there's only one LED light and it keeps changing on an RGB basis, so in the video there's a red light for a few frames, then it turns blue and after that green and back to red again.

I've written some code and I can track for each frame both red, blue and green, then apply a gaussian filter and add the three images so there's a constant point in my image, which is the LED light.

But I'd like to know how, if it's possible, can I track only an area where the color changes in this basis all the time, because by performing this operation I also get constant blue, red and green additions on the final image.

Does anybody have an idea on how to work this out?

Upvotes: 0

Views: 704

Answers (1)

David Rodriguez
David Rodriguez

Reputation: 21

Just for the record, I actually managed to solve the problem. As the HSV color space is circular (Hue 0 is red, as well as hue 179), I defined a change from red to green as a Hue increment of 60, a change from green to blue as another increment of 60, and a change from blue to red as another increment of 60 (Obviously, not exactly 60 always, but you can get an idea).

This way, a LED color blinking patter where you have a light going from red to green, green to blue and blue back to red, can be observed in the HSV color space if you pick the H channel and compare it to the previous frame's H channel, and then look for an approximated increment of 60.

I can't post the code due to the nature of the project I was working on, but it did work pretty well. I know it might be late, but I guess it's better than nothing.

Upvotes: 1

Related Questions