FindObjectByColor¶
ID: Multimedia/FindObjectByColor
Searches for objects with a given color (Color Detection).
After applying a color filter, a dilation step connects identified pixel areas that lie within a distance of half the kernelSize. Each resulting pixel area will be represented by an ItemMatch (rectangular area) of the returned MatchList. The color filter is applied in HSV color schema. Therefore, the tolerances of the color filter must be provided in HSV schema.
Provided HSV parameters (ToleranceHue, Saturation, ToleranceValue, Color) must match the following conditions: - Hue is an integer between 0 and 180 and represents the position (in 2 degree steps) on the color circle. 180 corresponds to 360 degrees or a full circle and therefore is semantically equal to 0. (Please note: Some graphic programs provide different value ranges from 0 to 255 or from 0 to 360.) - Saturation is an integer between 0 and 255. - Value is an integer between 0 and 255
Signals¶
VideoFrames¶
The video signal to be analyzed.
Direction: IN
Optional: False
ContainsColor¶
Optional output signal, which stores the number of matches found for each frame.
Direction: OUT
Optional: True
Matches¶
Optional output signal, which stores a MatchList[ImageMatch] object for each frame. The MatchList and ImageMatch classes are described in the API documentation of media related objects. The Matches signal can be fed into the ReportFramesAtStartTrigger trace step template for visualizing found matches.
Direction: OUT
Optional: True
Parameters¶
Color¶
The color to identify object areas. Either a tuple of RGB integer values, a RGB hex string (e.g. ‘#FF0000’ for red) or a HSV color string in the form ‘hsv(hue, saturation, value)’ (e.g. ‘hsv(0, 255, 255)’ for red).
Direction: IN
ToleranceHue¶
The tolerance applied to the expected hue. The value can either be a tuple of integers for defining an asymmetric tolerance window (Hue(color) - tolH[0], Hue(color) + tolH[1]), or an integer for defining a symmetric tolerance window (Hue(color) - tolH, Hue(color) + tolH).
Direction: IN
ToleranceSaturation¶
The tolerance applied to the expected saturation. The value can either be a tuple of integers for defining an asymmetric tolerance window (Saturation(color) - tolS[0], Saturation(color) + tolS[1]), or an integer for defining a symmetric tolerance window (Saturation(color) - tolS, Saturation(color) + tolS).
Direction: IN
ToleranceValue¶
The tolerance applied to the expected value. It can either be a tuple of integers for defining an asymmetric tolerance window (Value(color) - tolV[0], Value(color) + tolV[1]), or an integer for defining a symmetric tolerance window (Value(color) - tolV, Value(color) + tolV).
Direction: IN
KernelSize¶
The size of the kernel that is used to connect separated pixel areas to one object (dilation). A larger kernel connects pixel areas that have more distance to each other. Must be an odd number!
Direction: IN
Mask¶
Optional mask, to limit the area where the color is searched. The Mask object can be constructed from a mask file path. Alternatively, api.DataBrowser.BrowseMultimedia(deviceKey) can be used.
Direction: IN