1 | initial version |
In other way, instead of using RGB better to use HSV in color based segmentation, by which you can easily crate threshold image based on the lower and higher color value.
If you know the color to be segmented, you could do
Create threshold using inRange().
Calculate the area using countnonZero().
Do these steps for every predefined color range and decide which color is most dominant in the frame.
Also see the answer here might be helpful to select proper hsv range.