1 | initial version |
I suggest using contours. Take a look at the tutorial here, then others on the subject. The best thing is most likely to find the contours and keep the ones that are closed (as in, they come back to the starting point).
If the tutorial doesn't make sense, go back to earlier tutorials. The Core and ImgProc tutorials follow a pretty nice progression for learning OpenCV and image processing.