How to identify a red flag using opencv?

651 views Asked by At

How to identify a red flag using opencv in Python? I can identify a red flag using threshold but it is only useful when the background is the same color. How to identify the red flag in different background using open cv2? Or how to get the exact HSV number of a color in a image and than identify it? Thanks.

1

There are 1 answers

0
morotspaj On

You can use cvtColor to convert your image to HSV. When you have it in HSV you can split it into separate channels with split and threshold the hue, saturation and value to find a region with the color you are looking for. The number of pixels matching your criteria can be counted by countNonZero to see if the flag is present or not.