0

Recently I was installed opencv in ubuntu 11.10 . And I planned to done a simple project in opencv using python. The project is to detect a red ball from an image using python. I'm new in python and opencv. Could you please help me to do this project. Could you please suggest a similar eg code.

thanks in advance

Hacker
  • 97
  • 1
  • 2
  • 9

2 Answers2

8

You can do it as follows :

  1. Convert image to HSV plane using cvtColor() function
  2. Extract red color from it using inRange() function
  3. Apply erosion and dilation to avoid noise using erode() and dilate() functions
  4. Find Contours using findContours() function
  5. Draw the contours using drawContours() function.

You can find a code in below link, which tracks yellow and blue color in a video. You can modify it for your purpose. Tracking blue and yellow colors

Also visit below link for a better explanation: Tracking colored objects

Abid Rahman K
  • 51,886
  • 31
  • 146
  • 157
4

Hough Transform may help you.

OpenCV C lib provide cvHoughCircles to detect circles.

cvHoughCircles

And python wrapper is cv.HoughCircles

hbprotoss
  • 1,385
  • 10
  • 27