title: Simple object detection using OpenCV and machine learning
body: <p>I have to code an object detector (in this case, a ball) using OpenCV. The problem is, every single search on google returns me something with FACE DETECTION in it. So i need help on where to start, what to use etc..</p>
  
  <p>Some info:</p>
  
  <ul>
  <li>The ball doesn't have a fixed color, it will probably be white, but it might change.</li>
  <li>I HAVE to use machine learning, doesn't have to be a complex and reliable one, suggestion is KNN (which is WAY simpler and easier).</li>
  <li>After all my searching, i found that calculating the histogram of samples ball-only images and teaching it to the ML could be useful, but my main concern here is that the ball size can and will change (closer and further from the camera) and i have no idea on what to pass to the ML to classify for me, i mean.. i can't (or can I?) just test every pixel of the image for every possible size (from, lets say, 5x5 to WxH) and hope to find a positive result.</li>
  <li>There might be a non-uniform background, like people, cloth behind the ball and etc..</li>
  <li>As I said, i have to use a ML algorithm, that means no Haar or Viola algorithms.</li>
  <li><p>Also, I thought on using contours to find circles on a Canny'ed image, just have to find a way to transform a contour into a row of data to teach the KNN.</p>
  
  <p>So... suggestions?</p>
  
  <p>Thanks in advance.
  ;)</p></li>
  </ul>