How to Detect a Green Ball Using OpenCV and Python

by Ajay Singh in Circuits > Arduino

1898 Views, 2 Favorites, 0 Comments

How to Detect a Green Ball Using OpenCV and Python

ball 2.png

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

Software and Library Needed

ball 4.png
ball 5.png
ball 6.png

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 .

Python Code

ball 3.png

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

Downloads