How to count distinct bottle caps in an image?

Viewed 157

I am new to image processing, I would like to be able to count distinct beer bottles in an image. For that I thought of counting the caps, but I could not find a way to start doing it. From my research I found people generally uses Hough Cicles to count caps, but it's not able to count caps of distinct brands for example. Also the image won't be from top, but from a diagonal view like below:

enter image description here

I isolated the 3 distinct caps:

Cap 1 Cap 2 Cap 3

I also read about Scale-Invariant Feature Transform (SIFT) that could be used to extract features of object images and use it later to detect the same object on new images, but I don't know how to use that for these isolated caps.

In the example image there is 13 bottles with Cap 1, 11 with Cap 2 and 13 with Cap 3. I want to count this using image processing.

1 Answers

With all the details you mentioned there is no other choice but to train a neural net. It does look like you just need a basic object detection. In order to achieve that you'll need a training set.

I did a quick test with color-based segmentation (not all caps can be identified with that approach):

enter image description here

Obviously it will not work as a general purpose solution, but it might help automating training set generation (depends on your motivation and your actual goal). BTW, you might need to capture various cases including:

  • overlapping caps
  • light conditions
  • partial visibility
  • other corner cases

I don't think you need anything beyond object detection. Let's check some segmentation results:

enter image description here

and actual mask:

enter image description here

So, long story short, use any "R-CNN object detection" tutorial, do several iterations to get good enough accuracy, have fun :)

Related