[VB.NET/C#] Image Comparison using GdPicture ADR Technology

Example requests & Code samples for GdPicture Toolkits.
Post Reply
User avatar
Loïc
Site Admin
Posts: 5581
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

[VB.NET/C#] Image Comparison using GdPicture ADR Technology

Post by Loïc » Sun Apr 19, 2009 2:49 pm

Here is a sample to compare two images. This sample uses GdPicture ADR Technology included in GdPicture.NET (including the latest V10 major release of course).
More information at: http://www.gdpicture.com/solutions/GdPicture-ADR.php

Using VB.NET

Code: Select all

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 by a demo or commercial license key
	Dim ImageID1 As Integer = oGdPictureImaging.CreateGdPictureImageFromFile("") 'Openning image 1
	Dim ImageID2 As Integer = oGdPictureImaging.CreateGdPictureImageFromFile("") 'Openning 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 image are the same at: " & Str(Confidence) & "%")
End Sub
Using C#

Code: Select all

private void Button1_Click(System.Object sender, System.EventArgs e)
{
	GdPicture.GdPictureImaging oGdPictureImaging = new GdPicture.GdPictureImaging();
	double Confidence = 0;

	oGdPictureImaging.SetLicenseNumber("XXX"); //Replace XXX by a demo or commercial license key	
	int ImageID1 = oGdPictureImaging.CreateGdPictureImageFromFile(""); //Openning image 1	
	int ImageID2 = oGdPictureImaging.CreateGdPictureImageFromFile(""); //Openning 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 image are the same at: " + Conversion.Str(Confidence) + "%");
}

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest