Comparing text in images

[ ]

Aspose.OCR for .NET can compare texts on two images, regardless of the font, text size, case, styles, and colors.

To compare texts in 2 images, use ImageTextDiff method of AsposeOcr class. This method allows you to optionally customize recognition accuracy, performance, and other settings.

ImageTextDiff returns a number representing how similar the compared images are. The return value is a floating point number from 0 to 1; the lower the number, the more different image texts are. 0 means that the texts are completely different; 1 means the texts are identical. Fonts and styles are ignored.

Aspose.OCR.AsposeOcr recognitionEngine = new Aspose.OCR.AsposeOcr();
Aspose.OCR.RecognitionSettings recognitionSettings = new Aspose.OCR.RecognitionSettings();
recognitionSettings.AutoDenoising = true;
// case-insensitive comparison of image texts
if(!recognitionEngine.CompareImageTexts("image1.png", "image2.png", recognitionSettings, true))
	Console.WriteLine("Images contain the same text");
// percentage of similarity between texts
	float distance = recognitionEngine.ImageTextDiff("image1.png", "image2.png", recognitionSettings, true);
	Console.WriteLine($"The image texts are {distance*100}% similar");