Color and motion finding
OpenCV and your webcam can also track colored objects. This will be useful if you want your biped to follow a colored object. OpenCV makes this amazingly simple by providing some high-level libraries that can help us with this task. To accomplish this, you'll edit a file to look something like what is shown in the following screenshot:
Let's look specifically at the code that makes it possible to isolate the colored ball:
hue_img = cv.CvtColor(frame, cv.CV_BGR2HSV):
This line creates a new image that stores the image as per the values of hue (color), saturation, and value (HSV), instead of the red, green, and blue (RGB) pixel values of the original image. Converting to HSV focuses our processing more on the color, as opposed to the amount of light hitting it.threshold_img = cv.InRangeS(hue_img, low_range, high_range
): Thelow_range, high_range
parameters determine the color range. In this case, it is an orange ball, so you want to detect the color orange. For a good...