ovl.thresholds.color.color module¶
-
class
ovl.thresholds.color.color.
Color
(low: NewType.<locals>.new_type, high: NewType.<locals>.new_type)[source]¶ Bases:
ovl.thresholds.threshold.Threshold
Color is a Threshold object (an object that turns an image to a binary image - an image with pixels with the value 1 and 0) Color object thresholds using 2 HSV color ranges.
Read more about HSV here: https://www.lifewire.com/what-is-hsv-in-design-1078068
HSV Ranges in OVL (And in the underlying open-cv (cv2)) are: Hue - 0 to 179 (360/2 so divide any regular HSV value you use by 2)
So if Yellow is 40 - 80 (degrees) in regular HSV palette its 20 to 40 in ovlSaturation - 0 to 255 (255 is equal to 1 or 100%) Value - 0 to 255 (255 is equal to 1 or 100%)
- 2 ranges are passed to the Constructor:
- Low HSV Range - the lowest acceptable H S V values ([low_H, low_S, low_V])
- High HSV Range - the highest acceptable H S V values ([high_H, high_S, high_V])
low_range = [15, 100, 100] high_range = [45, 255, 255] color = ovl.Color(low_range, high_range)
The color object can the be passed to a Vision object to threshold binary images Threshold object can be used by themselves using the color.convert() method.
NOTE: Threshold objects automatically convert images to HSV (From the default BGR)
There are multiple built in “battery included” pre-made color object for instant use in testing and tuning List of colors:
Red (MultiColorObject) : Red (low) + Red (high) Red (Low): [0, 100, 100], [8, 255, 255] Red (High): [172, 100, 100], [179, 255, 255] Note: in order to find red, use both ranges (low and high) and use the some of both results. Blue: [105, 100, 100], [135, 255, 255] Green: [45, 100, 100], [75, 255, 255] Yellow: [20, 100, 100], [55, 255, 255] Orange: [10, 100, 100], [18, 255, 255] Grey: [0, 0, 0], [179, 50, 195] Black: [0, 0, 0], [179, 255, 30] White: [0, 0, 200], [179, 20, 255] Teal: [110, 100, 100], [130, 255, 255] Purple: [135, 100, 100], [165, 255, 255]-
convert
(image: numpy.ndarray) → numpy.ndarray[source]¶ Converts a given image to hsv and then thresholds and returns the binary mask
Parameters: image – a BGR image Returns: binary mask Return type: numpy array
-
copy
()[source]¶ Duplicates the Color object so that changes do not affect the original color Useful for modifying BuiltInColors without changing the default
Returns: a copy of the color object
-
high
¶ Returns the high hsv limit of the color.
Returns: An uint8 numpy array with the high limit of the color. Return type: uint8 numpy array
-
high_bound
¶
-
low
¶ Returns the low hsv limit of the color.
Returns: An uint8 numpy array with the low limit of the color. Return type: uint8 numpy array
-
low_bound
¶
-
ovl.thresholds.color.color.
assert_hsv
(hsv_point)[source]¶ Makes sure the hsv point(or vector) given in the parameter has valid values.
Parameters: hsv_point – a 3 length list with 3 ints describing a point the hsv color space that describe a color limit in a range for a findContour function. :return: True if valid False if not. :rtype: bool