-2
I want to create a mask for my image with Opencv using the function inRange
, but I don’t know which color format to use. The documentation only says that the image (first parameter) must be in HSV, but does not speak the color format of the crease.
I found an example of his use in that site, which defines the following crease for the blue color:
blue_lower = np.array([94, 80, 2], np.uint8)
blue_upper = np.array([120, 255, 255], np.uint8)
blue_mask = cv2.inRange(hsvFrame, blue_lower, blue_upper)
The problem is that if the color format is RBG, the blue_lower
is yellow in colour and the blue_upper
is blue. If the color is BGR, it is reversed. And the format should certainly not be HSV because the last two values are greater than 100%
.
What color format should I use? If it is BGR or RGB, this crease for the blue color is really correct?
Don’t use Opencv and much less C++ but the project repository has this test using BGR and this one also.. so I suppose you can assume that the color format is this same.
– fernandosavio
These two answers talk about this: > Different applications use different scales for HSV. For example Gimp uses H = 0-360, S = 0-100 and V = 0-100. But Opencv uses H: 0-179, S: 0-255, V: 0-255. 1- Choosing the correct upper and Lower HSV boundaries for color Detection with
inRange
(Opencv) 2- [How to Detect two Different Colors usingcv2.inRange
in Python-Opencv? ](https://stackoverflow.com/questions/48109650/how-to-detecttwo-different-color– Lucas Pedro
@Lucaspedro thanks for your help!
– JeanExtreme002
Guys, can you please explain to me why so many negatives, both in the question and in the answer?
– JeanExtreme002
Jean, I also do not understand what happens to Stack in Portuguese. So I gave you an upvote to give a moral.
– Arnon