📚 Course contents

AI & Computer Vision, lesson 8 of 52

Contours & Colour Tracking: Follow the Ball

beginner20 min readFull course

Introduction

In lesson 4 you made a mask that showed where a colour is. A mask is just white blobs, though. Today you'll turn those blobs into shapes the computer can measure: how big, where the middle is. Then you'll do it on every frame and follow a ball around your webcam, drawing its path as it moves.

By the end of this lesson you'll be able to:

  • Find the contours (outlines) of white blobs in a mask with cv2.findContours
  • Measure a contour's area, bounding box and centroid (its centre point)
  • Filter out noise by area and by roundness
  • Track a coloured ball across frames and draw its path
  • Say why colour tracking breaks when the light, the background or the ball colour changes
Contours & Colour Tracking: Follow the Ball | Electronics Simplified