Detect boxes on shelf Android OpenCV
Hi all, i'll repost here a question posted on StackOverflow (without real responses), I'll hope i'll be luckier here!
I'm developing an Android app that recognizes, from a store shelf image, all the boxes (products) present on the shelf.
My approach so far is the following:
- grayscale
- bilateral filter (or GaussianBlur, but I've found that using bilateral filter is better to preserve edges)
- adaptive threshold
- dilate (don't know if it's necessary)
- canny
- findContours
So, if the source image is simple, (like a b/w drawing of a shelf and some boxes) it can detect them, but with real images of shelves it isn't working.
The main problem is that single boxes have different "foreground" colors and logos, and my steps detect also all the edges of the "inner" box (i.e., the colours inside the edges of the box) and gives me totally nosense results. For simplicity I'll show belows my intermediate results and the source image:
1) source
2) grayscale
3) filtered (gaussianBlur in this case)
5) dilation
6) canny
As you can see, because I cannot remove the foreground of each box, also all the edges given by the logos or text come into play and noises my results.
How can I overcome this problem?
My ony idea is trying to "remove" or decolouring the inner boxes, but i don't konw how to do it! Thanks to all!
P.S. please don't reply with links relative to the already tried tutorials found on this website. They didn't helped me solving the probem. Thanks!
EDIT:
A possible solution to that specific image could be (is really raw in this example cause i've done it manually ;) ):
And this app has to detect boxes and cans possibly, because ithout perspective (i.e. assume that I have images in front of the shelf), cans are viewed as boxes.
i see cans, but no box at all ;)
please post a picture represents what you want to get.
Sorry, I'm italian, and for my english cans are like boxes! ahah, yeah , i'll post a possible output.
^^ naw, i'm trying to hint at that the outline of a can might not be best represented by a box, which is more a conceptual problem ;)
Yes, i understood, but i think that, assuming that i take an image quite perfectly in front of a shelf, they can be viewed as boxes, because there is not a perspective on the circled shape! :)