Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What algorithms or approaches apart from Haar cascades could be used for custom objects detection?

I need to do computer visions tasks in order to detect watter bottles or soda cans. I will obtain 'frontal' images of bottles, soda cans or any other random objects (one by one) and my algorithm should determine whether it's a bottle, a can or any of them.

Some details about object detecting scenario:

  • As mentioned, I will test one single object per image/video frame.
  • Not all watter bottles are the same. There could be color in plastic, lid or label variation. Maybe some could not get label or lid.
  • Same about variation goes for soda cans. No wrinkled soda cans are gonna be tested though.
  • There could be small size variation between objects.
  • I could have a green (or any custom color) background.
  • I will do any needed filters on image.
  • This will be run on a Raspberry Pi.

Just in case, an example of each:

enter image description hereenter image description here

I've tested a couple times OpenCV face detection algorithms and I know it works pretty good but I'd need to obtain an special Haar Cascades features XML file for detecting each custom object on this approach.

So, the distinct alternatives I have in mind are:

  • Creating a custom Haar Classifier.
  • Considering shapes.
  • Considering outlines.

I'd like to get a simple algorithm and I think creating a custom Haar classifier could be even not needed. What would you suggest?

Update

I strongly considered the shape/aspect ratio approach.

However I guess I'm facing some issues as bottles come in distinct sizes or even shapes each. But this made me think or set following considerations:

  • I'm applying a threshold with THRESH_BINARY method. (Thanks to the answers).
  • I will use a white background on detection.
  • Soda cans are all same size.
  • So, a bounding box for soda cans with high accuracy might distinguish a can.

What I've achieved:

Threshold really helped me, I could notice that on white background tests I would obtain for cans:

enter image description hereenter image description hereenter image description hereenter image description hereenter image description here

And this is what it's obtained for bottles:

enter image description hereenter image description hereenter image description hereenter image description here

So, darker areas left dominancy is noticeable. There are some cases in cans where this might turn into false negatives. And for bottles, light and angle may lead to not consistent results but I really really think this could be a shorter approach.

So, I'm quite confused now how I should evaluate that darkness dominancy, I've read that findContours leads to it but I'm quite lost on how to seize such function. For example, in case of soda cans, it may find several contours, so I get lost on what to evaluate.

Note: I'm open to test any other algorithms or libraries distinct to Open CV.

like image 788
diegoaguilar Avatar asked Apr 01 '15 17:04

diegoaguilar


People also ask

What is better than Haar Cascade?

An LBP cascade can be trained to perform similarly (or better) than the Haar cascade, but out of the box, the Haar cascade is about 3x slower, and depending on your data, about 1-2% better at accurately detecting the location of a face.

Is hog better than Haar Cascade?

The obtained results show that HOG+SVM approach is more robust and accurate than LBP and Haar approaches with an average detection rate of 92.68%.

Is Viola-Jones algorithm and Haar Cascade same?

Haar cascade classifier, (a.k.a. Viola-Jones algorithm) is a very fast face detection algorithm that is used in most real time face recognition systems like digital cameras.

Is Haar cascade only for face detection?

Haar Cascade Detection is one of the oldest yet powerful face detection algorithms invented. It has been there since long, long before Deep Learning became famous. Haar Features were not only used to detect faces, but also for eyes, lips, license number plates etc.


1 Answers

I see few basic ideas here:

  1. Check object (to be precise - object boundind rect) width/height ratio. For can it's approimetely 2-2.5, for bottle i think it will be >3. It's very simple idea to it should be easy to test it quickly and i think it should has quite good accuracy. For some values, like 2.75 (assumimg that values that i gave are correct, which most likely isn't true) you can use some different algorithm.
  2. Check whether you object contains glass/transparence regions - if yes, than definitely it's a bottle. Here you can read more about it.
  3. Use grabcut algorithm to get object mask/more precise shape and check whether this shape width at the top is similar to width at the bottom - if yes than it's a can, no - bottle (bottles has screw cap at the top).
like image 135
cyriel Avatar answered Sep 28 '22 15:09

cyriel