Compare Images in C#
GdPicture enables comparing two images. The example below uses GdPicture Automatic Document Recognition (ADR) technology, which is included in GdPicture.NET:
private void Button1_Click(System.Object sender, System.EventArgs e) { GdPicture.GdPictureImaging oGdPictureImaging = new GdPicture.GdPictureImaging(); double Confidence = 0; oGdPictureImaging.SetLicenseNumber("XXX"); // Replace XXX with a demo or commercial license key int ImageID1 = oGdPictureImaging.CreateGdPictureImageFromFile(""); // Opening image 1 int ImageID2 = oGdPictureImaging.CreateGdPictureImageFromFile(""); // Opening image 2 int TemplateID = oGdPictureImaging.ADRCreateTemplateFromGdPictureImage(ImageID1); oGdPictureImaging.ReleaseGdPictureImage(ImageID1); oGdPictureImaging.ADRGetCloserTemplateForGdPictureImage(ImageID2); oGdPictureImaging.ReleaseGdPictureImage(ImageID2); Confidence = oGdPictureImaging.ADRGetLastConfidence(); oGdPictureImaging.ADRDeleteTemplate(TemplateID); MessageBox.Show("The two images are the same at: " + Conversion.Str(Confidence) + "%"); }
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim oGdPictureImaging As New GdPicture.GdPictureImaging Dim Confidence As Double oGdPictureImaging.SetLicenseNumber("XXX") 'Replace XXX with a demo or commercial license key. Dim ImageID1 As Integer = oGdPictureImaging.CreateGdPictureImageFromFile("") 'Opening image 1. Dim ImageID2 As Integer = oGdPictureImaging.CreateGdPictureImageFromFile("") 'Opening image 2. Dim TemplateID As Integer = oGdPictureImaging.ADRCreateTemplateFromGdPictureImage(ImageID1) oGdPictureImaging.ReleaseGdPictureImage(ImageID1) oGdPictureImaging.ADRGetCloserTemplateForGdPictureImage(ImageID2) oGdPictureImaging.ReleaseGdPictureImage(ImageID2) Confidence = oGdPictureImaging.ADRGetLastConfidence() oGdPictureImaging.ADRDeleteTemplate(TemplateID) MessageBox.Show("The two images are the same at: " & Str(Confidence) & "%") End Sub