Welcome Guest! To enable all features, please Login or Register.

Notification

Icon
Error

Options
View
Last Go to last post Unread Go to first unread post
#1 Posted : Monday, November 18, 2019 10:01:35 AM(UTC)

oles_r  
oles_r

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.html

Code:
   
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
 

Try the latest version of LEADTOOLS for free for 60 days by downloading the evaluation: https://www.leadtools.com/downloads

Wanna join the discussion? Login to your LEADTOOLS Support accountor Register a new forum account.

#2 Posted : Monday, November 18, 2019 12:59:31 PM(UTC)

Robbey  
Robbey

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.
Leadtools Logo
 
#3 Posted : Tuesday, November 19, 2019 3:28:31 AM(UTC)

oles_r  
oles_r

Groups: Registered
Posts: 4


Thanks
 
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.

Powered by YAF.NET | YAF.NET © 2003-2024, Yet Another Forum.NET
This page was generated in 0.145 seconds.