(Edit) : The file pi.py contains this.
We will be using OpenCV to detect green ball (tennis ball) and the code and camera will guide the bot to reach the ball.
- We shall convert image to HSV plane using cvtColor() function
- Extract green color from it using inRange() function
- Apply erosion and dilation to avoid noise using erode() and dilate() functions
- Find Contours using findContours() function
- Draw the contours using drawContours() function.
- Find the apparent radius of ball and calculate the distance required for the bot to move.
Then comes the job to instruct the bot.