Object Search Approach

24 views
Skip to first unread message

mced...@gmail.com

unread,
Oct 7, 2014, 11:06:44 AM10/7/14
to accor...@googlegroups.com
Fantastic work on the Accord.NET library - it's seriously impressive! I just started using the library a few days ago and have gone through the examples that seem relevant to my goal. So, my question is geared more towards the direction of my approach, rather than specific code - at least for now.

I'm working to create an image search feature for drawings that users currently import into my application. The drawings typically have a legend of symbols and those symbols are used many times within the drawing. My current workflow allows the user to select the region around one of the symbols in the legend (to create my model), then locates instances of the model within the rest of the drawing. I'm currently using a FeaturesDetector on both images (FAST and SURF have both work great!), then using the KNearestNeighbor class to find matches between the model and the source drawing (similar code to that found in the panoramic stitch sample). I'm not sure this is the correct approach?

I'm new to all of this, so it's probably just my lack of understanding, but one problem seems to be (as an example) my model might return 20 featurepoints, and the source image may return 1000 feature points. The KNearestNeighbor match always returns the same number of matches as featurepoints found in the model. Is that correct? Or, maybe KNearestNeighbor matching is the wrong approach? I'm probably way off... so looking for guidance anyone can provide.

Thanks in advance for your time!

McEd

César

unread,
Oct 30, 2014, 4:56:39 PM10/30/14
to accor...@googlegroups.com
Hi there!

Your approach seems correct; however, if your images don't have rotations you may also achieve good results using AForge.NET's TemplateMatching class. Regarding your question, the KNearestNeighborMatching always builds k-NN classifier using the image that contains the biggest number of features. However, I can see now that this wouldn't always be desired. I am registering a new issue in the issue tracker to make this behavior optional

In the meantime, what you could do, and that I suppose will not be that difficult, is to copy and paste the KNearestNeighborMatching`1.cs file into your project, rename the class to KNearestNeighborMatching2, for example, and remove the following lines (130 to 140) from the code:

            // We should build the classifiers with the highest number
           
// of training points. Thus, if we have more points in the
           
// second image than in the first, we'll have to swap them


           
if (points2.Length > points1.Length)
           
{
               
var aux = points1;
                points1
= points2;
                points2
= aux;
                swap
= true;
           
}

This will effectively remove the preference for the bigger image, and the models will be created in order. Sorry for the inconvenience, and thanks again for bringing up this question!

I hope it helps!

Best regards,
Cesar
Reply all
Reply to author
Forward
0 new messages