61

I want to be able to compare an image taken from a webcam to an image stored on my computer.

The library doesn't need to be one hundred percent accurate as it won't be used in anything mission critical (e.g. police investigation), I just want something OK I can work with.

I have tried a demonstration project for Image Recognition from CodeProject, and it only works with small images / doesn't work at all when I compare an exact same image 120x90 pixels (this is not classified as OK :P ).

Has there been any success with image recognition before?

If so, would you be able to provide a link to a library I could use in either C# or VB.NET?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
RodgerB
  • 8,608
  • 9
  • 36
  • 47
  • It definately works with much larger images than this, must be some other problem possibly the format. – Peter C Jan 25 '10 at 15:59

3 Answers3

80

You could try this: http://code.google.com/p/aforge/

It includes a comparison analysis that will give you a score. There are many other great imaging features of all types included as well.

// The class also can be used to get similarity level between two image of the same size, which can be useful to get information about how different/similar are images:
// Create template matching algorithm's instance

// Use zero similarity to make sure algorithm will provide anything
ExhaustiveTemplateMatching tm = new ExhaustiveTemplateMatching(0);

// Compare two images
TemplateMatch[] matchings = tm.ProcessImage( image1, image2 );

// Check similarity level
if (matchings[0].Similarity > 0.95)
{
    // Do something with quite similar images
}
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
mattlant
  • 15,384
  • 4
  • 34
  • 44
  • Sounds great! Lets hope it works as expected... I'll mark your answer as accepted if it does. :) – RodgerB Sep 30 '08 at 07:27
  • 9
    It works absolutely fantastic! 100% similar for comparing its own image, 91% similar for me sitting upright on my chair and me leaning to my left. This is everything I could have hoped for, thanks a billion :) – RodgerB Sep 30 '08 at 08:43
  • 4
    Thats awesome, i am glad i could link you to it. I wish somehow there was a way to payback the guy who linked to me first. It was exactly what i needed in one of my projects as well. Thanks – mattlant Sep 30 '08 at 08:50
  • 10
    You can always trust Stackoverflow for your hard questions! Done a lot of googling without finding any good libs. Thanks – StefanE Mar 23 '10 at 08:27
  • 1
    Okay i always had the idea of implementing my hypothetical application using image recognition.. now i could get ma hands dirty! thanks mattlant! ;) – ioWint Aug 21 '11 at 05:39
  • @mattlant which dll should be added as a reference and included using header for this comparison ? – Furkan Gözükara Jun 24 '12 at 00:01
  • 1
    i searched for a long time, but this answer is PERFECT – teamalpha5441 Oct 25 '12 at 13:16
  • This answer is great, but is does pixel matching which can be taxing on a large set of images. Is there a better method that can create a "signature" of an image ahead of time, store that signature in a database, and then match against that instead so there is less overhead at comparison time? – Ethan Allen Apr 27 '15 at 00:43
10

You can exactly use EmguCV for .NET.

KamilDev
  • 718
  • 2
  • 7
  • 21
snndynya
  • 111
  • 1
  • 2
4

I did it simply. Just download the EyeOpen library here. Then use it in your C# class and write this:

 use eyeopen.imaging.processing

Write

ComparableImage cc;

ComparableImage pc;

int sim;

void compare(object sender, EventArgs e){

    pc = new ComparableImage(new FileInfo(files));

    cc = new ComparableImage(new FileInfo(file));

    pc.CalculateSimilarity(cc);

    sim = pc.CalculateSimilarity(cc);

    int sim2 = sim*100

    Messagebox.show(sim2 + "% similar");
}
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Hydarnes
  • 49
  • 1