A Collection of CogOCRMaxPositionResults which represent the output/result of
running the OCRMax tool.
Inheritance Hierarchy
System MarshalByRefObject
Cognex.VisionPro.Implementation CogObjectBase
Cognex.VisionPro.Implementation CogSerializableObjectBase
Cognex.VisionPro.Implementation CogReadOnlyCollection CogOCRMaxPositionResult
Cognex.VisionPro.OCRMax CogOCRMaxLineResult
Namespace: Cognex.VisionPro.OCRMax
Assembly: Cognex.VisionPro.OCRMax (in Cognex.VisionPro.OCRMax.dll) Version: 75.1.0.0
Syntax
The CogOCRMaxLineResult type exposes the following members.
Constructors
| Name | Description | |
|---|---|---|
| CogOCRMaxLineResult |
Construct a default CogOCRMaxLineResult object.
| |
| CogOCRMaxLineResult(CogOCRMaxLineResult) |
Constructs a deep copy of the supplied CogOCRMaxLineResult object.
| |
| CogOCRMaxLineResult(SerializationInfo, StreamingContext) |
Serialization constructor for CogOCRMaxLineResult.
|
Methods
| Name | Description | |
|---|---|---|
| Contains |
Determines whether an element is in the collection.
(Inherited from CogReadOnlyCollection T .) | |
| CopyTo |
Copies the entire Collection to a compatible one-dimensional Array, starting at the specified index of the target array.
(Inherited from CogReadOnlyCollection T .) | |
| CreateObjRef | Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object. (Inherited from MarshalByRefObject.) | |
| CreateResultGraphics |
Creates a CogGraphicCollection which represents the result.
| |
| CreateTuneRecordFromResult |
Returns a CogOCRMaxTuneRecord based on this result.
The record can be corrected and then used to tune the
the CogOCRMaxTool.
| |
| Equals | (Inherited from Object.) | |
| Finalize | Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.) | |
| GetAttributes |
Implements the corresponding member of the ICustomTypeDescriptor interface.
May be overridden in derived classes to provide custom type information.
(Inherited from CogObjectBase.) | |
| GetClassifierLineResult |
Returns a copy of the result of the Tool's classifier operation.
| |
| GetClassName |
Implements the corresponding member of the ICustomTypeDescriptor interface.
May be overridden in derived classes to provide custom type information.
(Inherited from CogObjectBase.) | |
| GetComponentName |
Implements the corresponding member of the ICustomTypeDescriptor interface.
May be overridden in derived classes to provide custom type information.
(Inherited from CogObjectBase.) | |
| GetConverter |
Implements the corresponding member of the ICustomTypeDescriptor interface.
May be overridden in derived classes to provide custom type information.
(Inherited from CogObjectBase.) | |
| GetDefaultEvent |
Implements the corresponding member of the ICustomTypeDescriptor interface.
May be overridden in derived classes to provide custom type information.
(Inherited from CogObjectBase.) | |
| GetDefaultProperty |
Implements the corresponding member of the ICustomTypeDescriptor interface.
May be overridden in derived classes to provide custom type information.
(Inherited from CogObjectBase.) | |
| GetEditor |
Implements the corresponding member of the ICustomTypeDescriptor interface.
May be overridden in derived classes to provide custom type information.
(Inherited from CogObjectBase.) | |
| GetEvents |
Implements the corresponding member of the ICustomTypeDescriptor interface.
May be overridden in derived classes to provide custom type information.
(Inherited from CogObjectBase.) | |
| GetEvents( Attribute ) |
Implements the corresponding member of the ICustomTypeDescriptor interface.
May be overridden in derived classes to provide custom type information.
(Inherited from CogObjectBase.) | |
| GetFieldingLineResult |
Returns a copy of the result of the Tool's fielding operation.
| |
| GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) | |
| GetLifetimeService | Retrieves the current lifetime service object that controls the lifetime policy for this instance. (Inherited from MarshalByRefObject.) | |
| GetObjectData |
Implements the GetObjectData method of the ISerializable interface.
(Inherited from CogSerializableObjectBase.) | |
| GetProperties |
Implements the corresponding member of the ICustomTypeDescriptor interface.
May be overridden in derived classes to provide custom type information.
(Inherited from CogObjectBase.) | |
| GetProperties( Attribute ) |
Causes the list of items to show up in the property grid.
(Inherited from CogReadOnlyCollection T .) | |
| GetPropertyOwner |
Implements the corresponding member of the ICustomTypeDescriptor interface.
May be overridden in derived classes to provide custom type information.
(Inherited from CogObjectBase.) | |
| GetSegmenterLineResult |
Returns a copy of the result of the Tool's segmenter operation.
| |
| GetString |
Returns a string which represents this CogOCRMaxLineResult.
| |
| GetString(String) |
Returns a string which represents this CogOCRMaxLineResult.
| |
| GetType | Gets the Type of the current instance. (Inherited from Object.) | |
| IndexOf |
Searches the collection for the specified object and returns the zero-based index of the first occurrence.
(Inherited from CogReadOnlyCollection T .) | |
| InitializeLifetimeService | Obtains a lifetime service object to control the lifetime policy for this instance. (Inherited from MarshalByRefObject.) | |
| MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) | |
| MemberwiseClone(Boolean) | Creates a shallow copy of the current MarshalByRefObject object. (Inherited from MarshalByRefObject.) | |
| ToArray |
Calls CopyTo() and returns a new array which contains the members of this collection.
(Inherited from CogReadOnlyCollection T .) | |
| ToString | (Inherited from Object.) |
Fields
| Name | Description | |
|---|---|---|
| mInnerList | (Inherited from CogReadOnlyCollection T .) |
Properties
| Name | Description | |
|---|---|---|
| BinarizedLineImage |
Return an image of the line of the characters after normalization, and
binarization.
| |
| Count |
The number of elements contained in the Collection.
(Inherited from CogReadOnlyCollection T .) | |
| Item |
Gets the element at the specified index.
(Inherited from CogReadOnlyCollection T .) | |
| LineImage |
An image of the line of the characters.
| |
| NormalizedLineImage |
An image of the line of characters after normalization.
| |
| ResultString |
The result string read by the OCRMax tool.
| |
| Status |
The overall status of the result.
| |
| UnknownCharacterMarker |
Used to represent characters that could not be classified in the
ResultString.
|
Examples
Imports System.Drawing
Imports Cognex.VisionPro
Imports Cognex.VisionPro.OCRMax
Module CogOCRMaxExample
Sub Main()
Dim OCRMaxTool As New CogOCRMaxTool()
' Load an image containing the text to read.
Dim bmp As New Bitmap(System.Environment.GetEnvironmentVariable("VPRO_ROOT") & "\images\alphanumbers.bmp")
Dim image As New CogImage8Grey(bmp)
' Create a rectangle that surrounds the text
' "ABCDEFGHIJKLMNOPQRSTUVWXYZ" in the image.
Dim rect As New CogRectangleAffine()
rect.SetOriginLengthsRotationSkew(340, 748, 1010, 93, 0, 0)
' Set the image and search region of the tool.
OCRMaxTool.InputImage = image
OCRMaxTool.Region = rect
' Segment the characters in the image.
OCRMaxTool.Run()
If OCRMaxTool.RunStatus.Result <> CogToolResultConstants.Accept OrElse OCRMaxTool.LineResult.Count <> 26 Then
Console.WriteLine("Initial segmentation failed. " + OCRMaxTool.RunStatus.Message)
Return
End If
' Get an array of Unicode UTF-32 character codes
' which represent a string of all the letters in the
' english alphabet.
Dim alphabetString As String = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
Dim alphabetCharCodes As Integer() = CogOCRMaxChar.GetCharCodesFromString(alphabetString)
' Label each segmented character with the correct
' character code and add it to the classifier's font.
For i As Integer = 0 To OCRMaxTool.LineResult.Count - 1
Dim c As CogOCRMaxChar = OCRMaxTool.LineResult(i).GetCharacter()
c.CharacterCode = alphabetCharCodes(i)
OCRMaxTool.Classifier.Font.Add(c)
Next
Try
' Train the classifier based on the font.
OCRMaxTool.Classifier.Train()
Catch ex As Exception
Console.WriteLine("Failed to train classifier characters: " & ex.Message)
End Try
' Run the (now trained) tool again.
OCRMaxTool.Run()
If OCRMaxTool.RunStatus.Result <> CogToolResultConstants.Accept Then
Console.WriteLine("OCRMax tool failed: " + OCRMaxTool.RunStatus.Message)
Return
End If
If OCRMaxTool.LineResult.Status <> CogOCRMaxLineResultStatusConstants.Read Then
Console.WriteLine("OCRMax tool failed to read the line of text.")
Return
End If
' Print out the read string.
Console.WriteLine("OCRMax Tool read the string: " + OCRMaxTool.LineResult.ResultString)
End Sub
End Moduleusing System; using System.Drawing; using Cognex.VisionPro; using Cognex.VisionPro.OCRMax; class CogOCRMaxExample { static void Main() { CogOCRMaxTool OCRMaxTool = new CogOCRMaxTool(); // Load an image containing the text to read. Bitmap bmp = new Bitmap( System.Environment.GetEnvironmentVariable("VPRO_ROOT") + @"\images\alphanumbers.bmp"); CogImage8Grey image = new CogImage8Grey(bmp); // Create a rectangle that surrounds the text // "ABCDEFGHIJKLMNOPQRSTUVWXYZ" in the image. CogRectangleAffine rect = new CogRectangleAffine(); rect.SetOriginLengthsRotationSkew(340, 748, 1010, 93, 0, 0); // Set the image and search region of the tool. OCRMaxTool.InputImage = image; OCRMaxTool.Region = rect; // Segment the characters in the image. OCRMaxTool.Run(); if (OCRMaxTool.RunStatus.Result != CogToolResultConstants.Accept || OCRMaxTool.LineResult.Count != 26) { Console.WriteLine( "Initial segmentation failed. " + OCRMaxTool.RunStatus.Message); return; } // Get an array of Unicode UTF-32 character codes // which represent a string of all the letters in the // english alphabet. string alphabetString = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; int[] alphabetCharCodes = CogOCRMaxChar.GetCharCodesFromString(alphabetString); // Label each segmented character with the correct // character code and add it to the classifier's font. for (int i = 0; i < OCRMaxTool.LineResult.Count; i++) { CogOCRMaxChar c = OCRMaxTool.LineResult[i].GetCharacter(); c.CharacterCode = alphabetCharCodes[i]; OCRMaxTool.Classifier.Font.Add(c); } try { // Train the classifier based on the font. OCRMaxTool.Classifier.Train(); } catch (Exception ex) { Console.WriteLine( "Failed to train classifier characters: " + ex.Message); } // Run the (now trained) tool again. OCRMaxTool.Run(); if (OCRMaxTool.RunStatus.Result != CogToolResultConstants.Accept) { Console.WriteLine("OCRMax tool failed: " + OCRMaxTool.RunStatus.Message); return; } if (OCRMaxTool.LineResult.Status != CogOCRMaxLineResultStatusConstants.Read) { Console.WriteLine("OCRMax tool failed to read the line of text."); return; } // Print out the read string. Console.WriteLine("OCRMax Tool read the string: " + OCRMaxTool.LineResult.ResultString); } }
See Also