Detect an object on known color on a green surface?
On a white surface, the object can be detected by providing a color threshold to filter the image. Then the image is converted gray scale and passed through a medianBlur + Canny filter.
The green surface is actually artificial turf so its shiny and has texture.
I've tried looking at only the green plane instead of graying out the picture. In addition, it helped to remove the Canny filter.
The image can be scanned for the width of the object (if the red color is above a certain threshold). The, the max amount of the red color pixels in a row can be saved into a variable (giving position and size). However, I'm still not sure the correct thresholds to check for and am getting inconsistent results. On the white surface I am getting slightly bigger widths than on the green surface.
Thresholds used:
lower,upper new_image = [0, 0, 20], [120,150,205]cv2.add(cv2.add(image[:,:,2],-image[:,:,1]/2),-image[:,:,0]/2)