Leadtools.Forms.Ocr Requires Document/Medical product license | Send comments on this topic. | Back to Introduction - All Topics | Help Version 16.5.9.25
OcrStatistic Structure
See Also  Members   Example
Leadtools.Forms.Ocr Namespace : OcrStatistic Structure



Processing statistic data.

Syntax

Visual Basic (Declaration) 
<SerializableAttribute()>
Public Structure OcrStatistic 
   Inherits ValueType
Visual Basic (Usage)Copy Code
Dim instance As OcrStatistic
C# 
[SerializableAttribute()]
public struct OcrStatistic : ValueType 
C++/CLI 
[SerializableAttribute()]
public value class OcrStatistic : public ValueType 

Example

This example will show the statistics of the last recognition operation on a page.

Visual BasicCopy Code
Public Sub OcrStatisticExample()
   ' Unlock the support needed for LEADTOOLS Plus OCR engine
   RasterSupport.Unlock(RasterSupportType.Document, "Replace with your own key here")
   RasterSupport.Unlock(RasterSupportType.OcrPlus, "Replace with your own key here")
   RasterSupport.Unlock(RasterSupportType.OcrPlusPdfLeadOutput, "Replace with your own key here")
   ' Create an instance of the engine
   Using ocrEngine As IOcrEngine = OcrEngineManager.CreateEngine(OcrEngineType.Plus, False)
      ' Start the engine using default parameters
      ocrEngine.Startup(Nothing, Nothing, Nothing, Nothing)

      Dim tifFileName As String = LeadtoolsExamples.Common.ImagesPath.Path + "Ocr1.tif"
      Dim pdfFileName As String = LeadtoolsExamples.Common.ImagesPath.Path + "Ocr1.pdf"

      ' Create an OCR document
      Using ocrDocument As IOcrDocument = ocrEngine.DocumentManager.CreateDocument()
         ' Add a page to the document
         Dim ocrPage As IOcrPage = ocrDocument.Pages.AddPage(tifFileName, Nothing)

         ' Process the page
         ocrPage.AutoPreprocess(OcrAutoPreprocessPageCommand.Deskew, Nothing)

         ' Recognize the page
         ' Note, Recognize can be called without calling AutoZone or manually adding zones. The engine will
         ' check and automatically auto-zones the page
         ocrPage.Recognize(Nothing)

         ' Save the document we have as PDF
         ocrDocument.Save(pdfFileName, DocumentFormat.Pdf, Nothing)

         ' Show the statistic about the last recognize operation
         Dim statistic As OcrStatistic = ocrEngine.GetLastStatistic()
         Console.WriteLine("Recognized characters: {0}", statistic.RecognizedCharacters)
         Console.WriteLine("Recognized words: {0}", statistic.RecognizedWords)
         Console.WriteLine("Rejected characters: {0}", statistic.RejectedCharacters)
         Console.WriteLine("Corrected words: {0}", statistic.CorrectedWords)
         Console.WriteLine("Recognition time: {0} ms", statistic.RecognitionTime)
         Console.WriteLine("Reading time: {0} ms", statistic.ReadingTime)
         Console.WriteLine("Image Preprocessing time: {0} ms", statistic.ImagePreprocessingTime)
         Console.WriteLine("Decomposition time: {0} ms", statistic.DecompositionTime)
         Console.WriteLine("Post processing time: {0} ms", statistic.ReadingTime - statistic.RecognitionTime)
      End Using

      ' Shutdown the engine
      ' Note: calling Dispose will also automatically shutdown the engine if it has been started
      ocrEngine.Shutdown()
   End Using
End Sub
C#Copy Code
public void OcrStatisticExample() 

   // Unlock the support needed for LEADTOOLS Plus OCR engine 
   RasterSupport.Unlock(RasterSupportType.Document, "Replace with your own key here"); 
   RasterSupport.Unlock(RasterSupportType.OcrPlus, "Replace with your own key here"); 
   RasterSupport.Unlock(RasterSupportType.OcrPlusPdfLeadOutput, "Replace with your own key here"); 
   // Create an instance of the engine 
   using(IOcrEngine ocrEngine = OcrEngineManager.CreateEngine(OcrEngineType.Plus, false)) 
   { 
      // Start the engine using default parameters 
      ocrEngine.Startup(null, null, null, null); 
 
      string tifFileName = LeadtoolsExamples.Common.ImagesPath.Path + "Ocr1.tif"; 
      string pdfFileName = LeadtoolsExamples.Common.ImagesPath.Path + "Ocr1.pdf"; 
 
      // Create an OCR document 
      using(IOcrDocument ocrDocument = ocrEngine.DocumentManager.CreateDocument()) 
      { 
         // Add a page to the document 
         IOcrPage ocrPage = ocrDocument.Pages.AddPage(tifFileName, null); 
 
         // Process the page 
         ocrPage.AutoPreprocess(OcrAutoPreprocessPageCommand.Deskew, null); 
 
         // Recognize the page 
         // Note, Recognize can be called without calling AutoZone or manually adding zones. The engine will 
         // check and automatically auto-zones the page 
         ocrPage.Recognize(null); 
 
         // Save the document we have as PDF 
         ocrDocument.Save(pdfFileName, DocumentFormat.Pdf, null); 
 
         // Show the statistic about the last recognize operation 
         OcrStatistic statistic = ocrEngine.GetLastStatistic(); 
         Console.WriteLine("Recognized characters: {0}", statistic.RecognizedCharacters); 
         Console.WriteLine("Recognized words: {0}", statistic.RecognizedWords); 
         Console.WriteLine("Rejected characters: {0}", statistic.RejectedCharacters); 
         Console.WriteLine("Corrected words: {0}", statistic.CorrectedWords); 
         Console.WriteLine("Recognition time: {0} ms", statistic.RecognitionTime); 
         Console.WriteLine("Reading time: {0} ms", statistic.ReadingTime); 
         Console.WriteLine("Image Preprocessing time: {0} ms", statistic.ImagePreprocessingTime); 
         Console.WriteLine("Decomposition time: {0} ms", statistic.DecompositionTime); 
         Console.WriteLine("Post processing time: {0} ms", statistic.ReadingTime - statistic.RecognitionTime); 
      } 
 
      // Shutdown the engine 
      // Note: calling Dispose will also automatically shutdown the engine if it has been started 
      ocrEngine.Shutdown(); 
   } 
}

Remarks

This structure contains the accuracy and timing data of the latest successful recognition process.

To obtain the statistic, use IOcrEngine.GetLastStatistic.

Note that the time spent for the text post-processing can be calculated as follows: PostProcessingTime = statistic.ReadingTime - statistic.RecognitionTime.

Note: Only the following members are available for the LEADTOOLS OCR Advantage Engine

Inheritance Hierarchy

System.Object
   System.ValueType
      Leadtools.Forms.Ocr.OcrStatistic

Requirements

Target Platforms: Microsoft .NET Framework 3.0, Windows XP, Windows Server 2003 family, Windows Server 2008 family

See Also

OcrStatistic requires an OCR module license and unlock key. For more information, refer to: Imaging Pro/Document/Medical Features