Introduction: How to Detect a Green Ball Using OpenCV and Python

About: Hi , I am a Maker-Space Educator .I love to design thing and make things using tools like electronics,papercraft,3d printing,etc.which are parts of makerspace.

Dear Learners,


If you want to make a program to detect a ball than you can follow these steps and make your own .

Fast and simple code just need to download and run .


Thank you

Regards

Ajay Singh

Supplies

Supplies you will require to make :

  • webcam with pc or laptop
  • A green ball

Step 1: Software and Library Needed

All we need is Python Installed in your system and few library like :

  • OpenCV installed
  • NumPy installed
  • Imutils installed

Links for installing using these library are :

for OpenCV: pip install opencv-python

for NumPy: pip install numpy

for imutils: pip install imutils


You are done with the software now .

Step 2: Python Code

Finally I found this code on internet and works really great !!.


The code is given below please download and run.

If all the things goes correct than you can Enjoy the ball tracking .


Happy Learning and Exploring

Regards

Ajay Singh