Represents processing statistic data.
[SerializableAttribute()]public struct OcrStatistic
<SerializableAttribute()>Public Structure OcrStatisticInherits System.ValueType
@interface LTOcrStatistic : NSObject public class OcrStatistic [SerializableAttribute()]public value class OcrStatistic : public System.ValueType
This structure contains the accuracy and timing data of the latest successful recognition process.
To obtain the statistic, use 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 Module - LEAD Engine
This example will show the statistics of the last recognition operation on a page.
using Leadtools;using Leadtools.Codecs;using Leadtools.Ocr;using Leadtools.Document.Writer;public void OcrStatisticExample(){// Create an instance of the engineusing (IOcrEngine ocrEngine = OcrEngineManager.CreateEngine(OcrEngineType.LEAD, false)){// Start the engine using default parametersocrEngine.Startup(null, null, null, LEAD_VARS.OcrLEADRuntimeDir);string tifFileName = Path.Combine(LEAD_VARS.ImagesDir, "Ocr1.tif");string pdfFileName = Path.Combine(LEAD_VARS.ImagesDir, "Ocr1.pdf");// Create an OCR pageusing (IOcrPage ocrPage = ocrEngine.CreatePage(ocrEngine.RasterCodecsInstance.Load(tifFileName, 1), OcrImageSharingMode.AutoDispose)){// Process the pageocrPage.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 pageocrPage.Recognize(null);// Show the statistic about the last recognize operationOcrStatistic 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 startedocrEngine.Shutdown();}}static class LEAD_VARS{public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images";public const string OcrLEADRuntimeDir = @"C:\LEADTOOLS 20\Bin\Common\OcrLEADRuntime";}
Imports LeadtoolsImports Leadtools.CodecsImports Leadtools.OcrImports Leadtools.Document.WriterPublic Sub OcrStatisticExample()' Create an instance of the engineUsing ocrEngine As IOcrEngine = OcrEngineManager.CreateEngine(OcrEngineType.LEAD, False)' Start the engine using default parametersocrEngine.Startup(Nothing, Nothing, Nothing, LEAD_VARS.OcrLEADRuntimeDir)Dim tifFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "Ocr1.tif")Dim pdfFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "Ocr1.pdf")' Create an OCR pageUsing ocrPage As IOcrPage = ocrEngine.CreatePage(ocrEngine.RasterCodecsInstance.Load(tifFileName, 1), OcrImageSharingMode.AutoDispose)' Process the pageocrPage.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 pageocrPage.Recognize(Nothing)' Show the statistic about the last recognize operationDim 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 startedocrEngine.Shutdown()End UsingEnd SubPublic NotInheritable Class LEAD_VARSPublic Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"Public Const OcrLEADRuntimeDir As String = "C:\LEADTOOLS 20\Bin\Common\OcrLEADRuntime"End Class
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document
