#1
Posted
:
Monday, November 18, 2019 10:01:35 AM(UTC)
Groups: Registered
Posts: 4
Hi all
I need to compare two scanned documents and find the degree of similarity. I want to compare text content
https://www.leadtools.co...rer-comparedocument.htmlCode:
var doc1 = DocumentFactory.LoadFromFile(@"C:\img1.jpg", new LoadDocumentOptions());
var doc2 = DocumentFactory.LoadFromFile(@"C:\img2.jpg", new LoadDocumentOptions());
var docList = new List<LEADDocument>() { doc1, doc2 };
var comparer = new DocumentComparer();
var diffs = comparer.CompareDocument(docList);
Here i get an error
System.NullReferenceException: Object reference not set to an instance of an object.
What am I doing wrong ?
VS2017
.net framework 4.0
#2
Posted
:
Monday, November 18, 2019 12:59:31 PM(UTC)
Groups: Registered
Posts: 22
Hello Oles,
Since the Document Comparer Class compares text and you are loading in raster documents, you will have to use an OCR Engine to compare the text. The code below should fix the issue you are facing:
Code:IOcrEngine ocrEngine;
ocrEngine = OcrEngineManager.CreateEngine(OcrEngineType.LEAD, false);
ocrEngine.Startup(null, null, null, @"C:\LEADTOOLS 20\Bin\Common\OcrLEADRuntime");
var doc1 = DocumentFactory.LoadFromFile(@"C:\img1.jpg", new LoadDocumentOptions());
var doc2 = DocumentFactory.LoadFromFile(@"C:\img2.jpg", new LoadDocumentOptions());
var docList = new List<LEADDocument>() { doc1, doc2 };
foreach (var doc in docList)
doc.Text.OcrEngine = ocrEngine;
var comparer = new DocumentComparer();
var diffs = comparer.CompareDocument(docList);
Please keep in mind you will need to reference the appropriate DLLs to implement the OCR engine.
Thanks,
Robbey Rodriguez
Developer Support Engineer
LEAD Technologies, Inc.
#3
Posted
:
Tuesday, November 19, 2019 3:28:31 AM(UTC)
Groups: Registered
Posts: 4
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.