Engo
Engo

Reputation: 969

How to find the correct HSV threshold values of an object for OpenCV?

I am trying to find the correct lowerbounds/upperbounds threshold values of a ball, so that I can use it in the OpenCV inRange function.

I've read Choosing correct HSV values for OpenCV thresholding with InRangeS, but I still dont understand how to do this in my case:

enter image description here

inRange function:

inRange(frmHsv, Scalar(lowerH, lowerS, lowerV), Scalar(upperH, upperS, upperV), rangeRes);

OpenCV HSV ranges:

H: 0 - 180

S: 0 - 255

V: 0 - 255

How can I find lowerH, lowerS, lowerV, upperH, upperS, upperV?

Upvotes: 2

Views: 3141

Answers (1)

Cristian Rodriguez
Cristian Rodriguez

Reputation: 813

Take a look of this tutorial is really good!

It create a trackbar to move the upper and lower value online and check what is the best response for your object. I used for a cylinder color coded detection and works really well.

http://opencv-srf.blogspot.com.au/2010/09/object-detection-using-color-seperation.html

Upvotes: 3

Related Questions