Color detection with OpenCV
We shall begin experimenting with OpenCV by performing some basic operations on live image data. In this recipe, we shall perform some basic image processing to allow detection of different colored objects and track their location on screen.
Getting ready
In addition to the setup from the previous recipe, you will need a suitable colored object to track. For example, a small colored ball, a suitable colored mug, or a pencil with a square of colored paper taped to it is ideal. The example should allow you to detect the location (indicated by a color spot) of blue, green, red, magenta (pink) or yellow objects.
How to do it…
Create the following opencv_display.py
script:
#!/usr/bin/python3 #opencv_display.py from picamera.array import PiRGBArray from picamera import PiCamera import time import cv2 import opencv_color_detect as PROCESS def show_images(images,text,MODE): # show the frame cv2.putText...