Multiple (same) object recognition with OpenCv
i'm trying to find and count multiple instances of the same object into an image, with OpenCV (c++).
For example, i'm trying to count how many times a bottle of shampoo is placed into a market's shelf.
Firstly i tried to use SURF algorithm to solve this problem, but it finds only the image that i took from it (for querying).
This is an example:
http://s11.postimg.org/tr96s823n/surf.jpg
Now, this work well, but if i delete it from the shelf and repeat the match it gives me false positive or nothing(depending by the shelf image).
I think that it doesn't work because of the noise that the light, the position of the product, etc.. (--> maybe can a neural network or a SVN machine resolve the problem of the noise? If yes, i need to train them for each object that i should find on the shelf? )
-->Are not SURF and SIFT rotation, scale and light invariant?
So, to overcome the problem i tried to use the Template Match algorithm to find a iteratively "square" that contains a product and, on that square, use SURF algorithm to determine if the square really contains the object i'm searching for, or not.
This method seems to work until the products on the shelf are very similar to the query image (the one that i took from the shelf image).
This is an example:
http://s17.postimg.org/812f9mk67/template.jpg
So i lose the rotation and scale invariance. :(
- I thought that another way to reach the goal (more or less) is using the Graph Theory without using a matcher (like K-NN): if i connect with edges the keypoints of the shelf image (used like vertex) and the find a method tho cut the edges between keypoints the are not correlated(i need a measure of correlation! ) i could find the areas of the product. Then counting the areas i could find the number of the same product into the shelf.
I know that i do a lot of questions, but i'm stuck on that without any ideas. If somebody has any idea or advice it whould be really appreciated. Thanks to all who reads this!