CogOCRMaxSegmenter ClassCognex VisionPro
CogOCRMaxSegmenter performs the first main step of OCRMax. Segmentation takes an image containing a line of text as input, and outputs CogOCRMaxChar(s) structures which contain information about where individual characters can be found in the image. For example, if the input image contains the line of text "ABCD", then segmenter outputs four separate CogOCRMaxChars, each of which contains an image of a single character. The segmenter does not know anything about actually determining which letter a CogOCRMaxChar corresponds to; in the above example, it has no way of knowing that the CogOCRMaxChar is the letter "A". The job of identifying each CogOCRMaxChar is left to the classifier. See the OCRMax Theory Guide for more information.
Inheritance Hierarchy

System Object
  System MarshalByRefObject
    Cognex.VisionPro.Implementation CogObjectBase
      Cognex.VisionPro.Implementation CogSerializableObjectBase
        Cognex.VisionPro.Implementation CogSerializableChangedEventBase
          Cognex.VisionPro.OCRMax CogOCRMaxSegmenter

Namespace: Cognex.VisionPro.OCRMax
Assembly: Cognex.VisionPro.OCRMax (in Cognex.VisionPro.OCRMax.dll) Version: 65.1.0.0
Syntax

[SerializableAttribute]
public class CogOCRMaxSegmenter : CogSerializableChangedEventBase

The CogOCRMaxSegmenter type exposes the following members.

Constructors

  NameDescription
Public methodCogOCRMaxSegmenter 
Construct a default CogOCRMaxSegmenter object.
Public methodCogOCRMaxSegmenter(CogOCRMaxSegmenter)
Constructs a deep copy of the supplied CogOCRMaxSegmenter object.
Protected methodCogOCRMaxSegmenter(SerializationInfo, StreamingContext)
Serialization constructor for CogOCRMaxSegmenter.
Top
Methods

  NameDescription
Public methodCreateObjRef
Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.
(Inherited from MarshalByRefObject.)
Public methodEquals
Determines whether the specified Object is equal to the current Object.
(Inherited from Object.)
Public methodExecute(CogImage16Grey)
Segment one line of characters contained within the image.
Public methodExecute(CogImage16Range)
Segment one line of characters contained within the image.
Public methodExecute(CogImage8Grey)
Segment one line of characters contained within the image.
Public methodExecute(CogImage16Grey, CogRectangleAffine)
Segment one line of characters contained within the region.
Public methodExecute(CogImage16Grey,  CogRectangleAffine )
Segment several lines of characters contained within the search regions.
Public methodExecute(CogImage16Range, CogRectangleAffine)
Segment one line of characters contained within the 2D region.
Public methodExecute(CogImage16Range,  CogRectangleAffine )
Segment several lines of characters contained within the search regions.
Public methodExecute(CogImage8Grey, CogRectangleAffine)
Segment one line of characters contained within the region.
Public methodExecute(CogImage8Grey,  CogRectangleAffine )
Segment several lines of characters contained within the search regions.
Protected methodFinalize
Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection.
(Inherited from Object.)
Protected methodGetAttributes
Implements the corresponding member of the ICustomTypeDescriptor interface. May be overridden in derived classes to provide custom type information.
(Inherited from CogObjectBase.)
Protected methodGetClassName
Implements the corresponding member of the ICustomTypeDescriptor interface. May be overridden in derived classes to provide custom type information.
(Inherited from CogObjectBase.)
Protected methodGetComponentName
Implements the corresponding member of the ICustomTypeDescriptor interface. May be overridden in derived classes to provide custom type information.
(Inherited from CogObjectBase.)
Protected methodGetConverter
Implements the corresponding member of the ICustomTypeDescriptor interface. May be overridden in derived classes to provide custom type information.
(Inherited from CogObjectBase.)
Protected methodGetDefaultEvent
Implements the corresponding member of the ICustomTypeDescriptor interface. May be overridden in derived classes to provide custom type information.
(Inherited from CogObjectBase.)
Protected methodGetDefaultProperty
Implements the corresponding member of the ICustomTypeDescriptor interface. May be overridden in derived classes to provide custom type information.
(Inherited from CogObjectBase.)
Protected methodGetEditor
Implements the corresponding member of the ICustomTypeDescriptor interface. May be overridden in derived classes to provide custom type information.
(Inherited from CogObjectBase.)
Protected methodGetEvents 
Implements the corresponding member of the ICustomTypeDescriptor interface. May be overridden in derived classes to provide custom type information.
(Inherited from CogObjectBase.)
Protected methodGetEvents( Attribute )
Implements the corresponding member of the ICustomTypeDescriptor interface. May be overridden in derived classes to provide custom type information.
(Inherited from CogObjectBase.)
Public methodGetHashCode
Serves as a hash function for a particular type.
(Inherited from Object.)
Public methodGetLifetimeService
Retrieves the current lifetime service object that controls the lifetime policy for this instance.
(Inherited from MarshalByRefObject.)
Protected methodGetObjectData
Implements the GetObjectData method of the ISerializable interface.
(Inherited from CogSerializableObjectBase.)
Protected methodGetProperties 
Implements the corresponding member of the ICustomTypeDescriptor interface. May be overridden in derived classes to provide custom type information.
(Inherited from CogObjectBase.)
Protected methodGetProperties( Attribute )
Implements the corresponding member of the ICustomTypeDescriptor interface. May be overridden in derived classes to provide custom type information.
(Inherited from CogObjectBase.)
Protected methodGetPropertyOwner
Implements the corresponding member of the ICustomTypeDescriptor interface. May be overridden in derived classes to provide custom type information.
(Inherited from CogObjectBase.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodInitializeLifetimeService
Obtains a lifetime service object to control the lifetime policy for this instance.
(Inherited from MarshalByRefObject.)
Protected methodMemberwiseClone 
Creates a shallow copy of the current Object.
(Inherited from Object.)
Protected methodMemberwiseClone(Boolean)
Creates a shallow copy of the current MarshalByRefObject object.
(Inherited from MarshalByRefObject.)
Protected methodOnChanged(Int64)
This method should be called internally whenever the object's state may have changed.
(Inherited from CogSerializableChangedEventBase.)
Protected methodOnChanged(CogChangedEventArgs)
This method may be called internally whenever a derived object's state may have changed and the derived object expresses this change via a derived CogChangedEventArgs class.
(Inherited from CogSerializableChangedEventBase.)
Public methodResumeAndRaiseChangedEvent
Re-enables raising of the Changed event after SuspendChangedEvent has been called, and raises the Changed event if the ChangedEventSuspended count is reduced to zero and any changes were made while events were suspended. Must be called once for each call to SuspendChangedEvent.
(Inherited from CogSerializableChangedEventBase.)
Public methodSuspendChangedEvent
Temporarily suspends the raising of the Changed event. May be called more than once, and a corresponding call to ResumeAndRaiseChangedEvent must be made for each call to SuspendChangedEvent.
(Inherited from CogSerializableChangedEventBase.)
Public methodToString
Returns a String that represents the current Object.
(Inherited from Object.)
Top
Fields

  NameDescription
Public fieldStatic memberSfAnalysisMode
This bit will be set in the EventArgs of a Changed event every time the value returned by AnalysisMode may have changed.
Public fieldStatic memberSfAngleHalfRange
This bit will be set in the EventArgs of a Changed event every time the value returned by AngleHalfRange may have changed.
Public fieldStatic memberSfCellRectangleWidthType
This bit will be set in the EventArgs of a Changed event every time the value returned by CellRectangleWidthType may have changed.
Public fieldStatic memberSfCharacterFragmentContrastThreshold
This bit will be set in the EventArgs of a Changed event every time the value returned by CharacterFragmentContrastThreshold may have changed.
Public fieldStatic memberSfCharacterFragmentMainLineMinYOverlapFrac
This bit will be set in the EventArgs of a Changed event every time the value returned by CharacterFragmentMainLineMinYOverlapFrac may have changed.
Public fieldStatic memberSfCharacterFragmentMaxDistanceToMainLine
This bit will be set in the EventArgs of a Changed event every time the value returned by CharacterFragmentMaxDistanceToMainLine may have changed.
Public fieldStatic memberSfCharacterFragmentMergeMode
This bit will be set in the EventArgs of a Changed event every time the value returned by CharacterFragmentMergeMode may have changed.
Public fieldStatic memberSfCharacterFragmentMinNumPels
This bit will be set in the EventArgs of a Changed event every time the value returned by CharacterFragmentMinNumPels may have changed.
Public fieldStatic memberSfCharacterFragmentMinXOverlap
This bit will be set in the EventArgs of a Changed event every time the value returned by CharacterFragmentMinXOverlap may have changed.
Public fieldStatic memberSfCharacterMaxHeight
This bit will be set in the EventArgs of a Changed event every time the value returned by CharacterMaxHeight may have changed.
Public fieldStatic memberSfCharacterMaxWidth
This bit will be set in the EventArgs of a Changed event every time the value returned by CharacterMaxWidth may have changed.
Public fieldStatic memberSfCharacterMinAspect
This bit will be set in the EventArgs of a Changed event every time the value returned by CharacterMinAspect may have changed.
Public fieldStatic memberSfCharacterMinHeight
This bit will be set in the EventArgs of a Changed event every time the value returned by CharacterMinHeight may have changed.
Public fieldStatic memberSfCharacterMinNumPels
This bit will be set in the EventArgs of a Changed event every time the value returned by CharacterMinNumPels may have changed.
Public fieldStatic memberSfCharacterMinWidth
This bit will be set in the EventArgs of a Changed event every time the value returned by CharacterMinWidth may have changed.
Public fieldStatic memberSfComputeDiagnostics
This bit will be set in the EventArgs of a Changed event every time the value returned by ComputeDiagnostics may have changed.
Public fieldStatic memberSfForegroundThresholdFrac
This bit will be set in the EventArgs of a Changed event every time the value returned by ForegroundThresholdFrac may have changed.
Public fieldStatic memberSfIgnoreBorderFragments
This bit will be set in the EventArgs of a Changed event every time the value returned by IgnoreBorderFragments may have changed.
Public fieldStatic memberSfLineRefinementMode
This bit will be set in the EventArgs of a Changed event every time the value returned by LineRefinementMode may have changed.
Public fieldStatic memberSfMaxIntracharacterGap
This bit will be set in the EventArgs of a Changed event every time the value returned by MaxIntracharacterGap may have changed.
Public fieldStatic memberSfMinIntercharacterGap
This bit will be set in the EventArgs of a Changed event every time the value returned by MinIntercharacterGap may have changed.
Public fieldStatic memberSfMinPitch
This bit will be set in the EventArgs of a Changed event every time the value returned by MinPitch may have changed.
Protected fieldStatic memberSfNextSf
Public fieldStatic memberSfNormalizationMode
This bit will be set in the EventArgs of a Changed event every time the value returned by NormalizationMode may have changed.
Public fieldStatic memberSfPitchMetric
This bit will be set in the EventArgs of a Changed event every time the value returned by PitchMetric may have changed.
Public fieldStatic memberSfPitchType
This bit will be set in the EventArgs of a Changed event every time the value returned by PitchType may have changed.
Public fieldStatic memberSfPolarity
This bit will be set in the EventArgs of a Changed event every time the value returned by Polarity may have changed.
Public fieldStatic memberSfSkewHalfRange
This bit will be set in the EventArgs of a Changed event every time the value returned by SkewHalfRange may have changed.
Public fieldStatic memberSfSpaceParams
This bit will be set in the EventArgs of a Changed event every time the value returned by SpaceParams may have changed.
Public fieldStatic memberSfTimeout
This bit will be set in the EventArgs of a Changed event every time the value returned by Timeout may have changed.
Public fieldStatic memberSfTimeoutEnabled
This bit will be set in the EventArgs of a Changed event every time the value returned by TimeoutEnabled may have changed.
Public fieldStatic memberSfUseCharacterMaxHeight
This bit will be set in the EventArgs of a Changed event every time the value returned by UseCharacterMaxHeight may have changed.
Public fieldStatic memberSfUseCharacterMaxWidth
This bit will be set in the EventArgs of a Changed event every time the value returned by UseCharacterMaxWidth may have changed.
Public fieldStatic memberSfUseCharacterMinAspect
This bit will be set in the EventArgs of a Changed event every time the value returned by UseCharacterMinAspect may have changed.
Public fieldStatic memberSfUseStrokeWidthFilter
This bit will be set in the EventArgs of a Changed event every time the value returned by UseStrokeWidthFilter may have changed.
Public fieldStatic memberSfWidthType
This bit will be set in the EventArgs of a Changed event every time the value returned by WidthType may have changed.
Top
Properties

  NameDescription
Public propertyAnalysisMode
Whether to perform "minimal analysis" or "standard analysis". Minimal analysis performs straightforward segmentation according to the parameters above. Standard analysis performs an analysis of the line as a whole, including e.g. character spacing, to determine the optimal segmentation.
Public propertyAngleHalfRange
Half of the angle search range in radians.
Public propertyCellRectangleWidthType
How to compute the width of a character's cell rectangle.
Public propertyChangedEventSuspended
If nonzero, indicates that the raising of the Changed event has been suspended. This value is incremented when SuspendChangedEvent is called and decremented when ResumeAndRaiseChangedEvent is called.
(Inherited from CogSerializableChangedEventBase.)
Public propertyCharacterFragmentContrastThreshold
The minimum amount of contrast (in normalized image grey levels) that a fragment must have, relative to the binarization threshold, in order to be considered for possible inclusion in a character. See the comments for ForegroundThresholdFrac() for the value of the binarization threshold.
Public propertyCharacterFragmentMainLineMinYOverlapFrac
Get/set the minimum fraction by which a character fragment must overlap the mainline of characters in order for the fragment to be included.
Public propertyCharacterFragmentMaxDistanceToMainLine
Get/set a modifier in the range [0, 1] this is the maximum distance a fragment can have outside the main line of characters as percentage of estimated line height in order to be included.
Public propertyCharacterFragmentMergeMode
Get/set the mode used to determine whether to merge two fragments into one character during the Group stage.
Public propertyCharacterFragmentMinNumPels
The minimum number of foreground (i.e. text) pixels that a fragment must have in order to be considered for possible inclusion in a character. A character fragment is a blob in the binarized image.
Public propertyCharacterFragmentMinXOverlap
The minimum fraction by which two character fragments must overlap each other in the x direction in order for the two fragments to be considered part of the same character.
Public propertyCharacterMaxHeight
The maximum allowable height of a character's mark rectangle, in pixels. This value is used in two ways. First, this value is used when finding the line as a whole, e.g. to reject vertically adjacent noise and/or other lines of vertically adjacent characters. Second, an individual character whose height exceeds this value will be trimmed to meet this height.
Public propertyCharacterMaxWidth
The maximum allowable width of a character's mark rectangle, in pixels. A character wider than this value will be split into pieces that are not too wide.
Public propertyCharacterMinAspect
The minimum allowable aspect of a character, where the aspect is defined as the height of the entire line of characters divided by the width of the character's mark rectangle. A character whose aspect is smaller than this value (i.e. whose width is too large) will be split into pieces that are not too wide.
Public propertyCharacterMinHeight
The minimum height of a character's mark rectangle, in pixels, that a character must have in order to be reported.
Public propertyCharacterMinNumPels
The minimum number of foreground (i.e. text) pixels that a character must have in order to be reported.
Public propertyCharacterMinWidth
The minimum width of a character's mark rectangle, in pixels, that a character must have in order to be reported.
Public propertyComputeDiagnostics
Whether to compute additional segmenter diagnostics information when the segmenter is run.
Public propertyForegroundThresholdFrac
A modifier in the range [0, 1] that is used to compute the binarization threshold, in the normalized image, that binarizes between foreground and background.
Public propertyHasChanged (Inherited from CogSerializableChangedEventBase.)
Public propertyIgnoreBorderFragments
Whether to completely ignore any fragments that touch any border of the ROI. Ignoring such fragments can be useful for non-text features such as the edges of labels that might be included within the ROI.
Public propertyLineRefinementMode
Cognex Internal Use Only
Public propertyMaxIntracharacterGap
The maximum gap size, in pixels, that can occur within a single character, even for damaged characters. An intracharacter gap might occur, for example, between successive columns of dots in dot matrix print, or between two pieces of a solid character that was damaged by a scratch. Any gap larger than this value will always be interpreted as a break between two separate characters, whereas gaps less than or equal to this value may be interpreted either as a break between two separate characters or as a gap within a single character.
Public propertyMinIntercharacterGap
The minimum gap size, in pixels, that can occur between two characters. If the gap between two fragments is smaller than this, then they must be considered to be part of the same character, unless the combined character would be too wide (as specified by CharacterMaxWidth and/or CharacterMinAspect). The gap is measured from the right edge of the mark rectangle of one character to the left edge of the mark rectangle of the next character.
Public propertyMinPitch
The minimum pitch, in pixels, that can occur between two characters, where the pitch is computed as specified by the pitch metric. If the pitch between two fragments is smaller than this, then they must be considered to be part of the same character, unless the combined character would be too wide (as specified by CharacterMaxWidth and/or CharacterMinAspect).
Public propertyNormalizationMode
The method used to normalize the input image.
Public propertyPitchMetric
The metric used to specify the spacing of characters. Note that pitch is the distance between (approximately) corresponding points on adjacent characters and not the distance from the end of one character to the beginning of the next character (which is called the "intercharacter gap"). Also note that specifying the pitch metric does not necessarily imply that the measured pitch values are expected to be constant.
Public propertyPitchType
How individual pitch values are expected to vary; the pitch values are measured as specified by the pitch metric.
Public propertyPolarity
The polarity of the characters in the input image. If the polarity is Unknown, the polarity will be automatically determined.
Public propertySkewHalfRange
Half of the skew search range in radians.
Public propertySpaceParams
Parameters to control whether and how to insert space characters.
Public propertyStateFlags
Returns the complete set of state flags supported on this object. The flags may be indexed by name as shown in the following C# code snippet: if (changedObject.StateFlags["Color"] & eventArgs.StateFlags) { ... }
(Inherited from CogSerializableChangedEventBase.)
Public propertyTimeout
Gets or sets the timeout for running the segmenter in milliseconds.
Public propertyTimeoutEnabled
Enables the timeout for the segmenter.
Public propertyUseCharacterMaxHeight
Whether to use CharacterMaxHeight to limit the maximum height of a character and/or the line of characters.
Public propertyUseCharacterMaxWidth
Whether to use CharacterMaxWidth to split wide characters.
Public propertyUseCharacterMinAspect
Whether to use CharacterMinAspect to split wide characters.
Public propertyUseStrokeWidthFilter
Whether to remove from the normalized image everything that does not appear to have the same stroke width as the rest of the image. This can be useful if, for example, characters appear to be connected to each other by thin noise streaks. However, using the stroke width filter might incorrectly remove real characters if the stroke widths are inconsistent.
Public propertyWidthType
How the widths of characters in the font are expected to vary. Note that the character width is the width of the mark rectangle (e.g. the bounding box of the ink), not the cell rectangle (which would typically include padding around the mark rectangle).
Top
Events

  NameDescription
Public eventChanged
This event is raised when one or more parts of the object's state may have changed.
(Inherited from CogSerializableChangedEventBase.)
Top
Remarks

Each segmenter property is used in one or more stages of segmentation; each property will note which stage(s) it is used in with a comment of the form "Stage: Name", where "Name" is one of the stages listed below.

1) Refine line --- Determine line location, angle, skew, and/or polarity.

2) Normalize --- Normalize the input image to produce a normalized image. The normalized image should be binarizable using a single global threshold.

3) Binarize --- Determine a threshold and use it to binarize the normalized image to produce a binarized image.

4) Fragment --- Perform blob analysis to produce character fragments, where each character fragment is a single blob.

5) Group --- Group character fragments together to form characters. Grouping may include merging and/or splitting fragments. Small characters may be discarded.

6) Analyze --- Optionally perform additional analysis to determine a more optimal grouping.

The OCRMax Segmenter splits a line of text in an image into images of the individual characters. The user specifies a CogRectangleAffine as a region of interest (ROI) that specifies the approximate location, angle, and skew of the line of text. The Segmenter is capable of refining the angle and skew of the line if requested.

The x axis of the affine rectangle should be parallel to the baseline of the text, and the y axis should be parallel to the vertical strokes of the characters; if there is no skew, the y axis is perpendicular to the x axis. The positive direction of the x axis corresponds to the reading direction. (Note that the baseline of the text may have any angle 0-360 in the image, as long as the affine rectangle is oriented at approximately the same angle.

The ROI is expected to contain only the one line of text to be read and some surrounding background. The background is allowed to be noisy and it may have significant background gradients/shading. In images that are clearly printed and have little noise, the ROI may be significantly larger than the line of text; noisy images may require that the ROI be relatively tight around the line of text. Note that the ROI should not contain significant image features other than the line of text; for example, it should not partially enclose a different nearby line of text, nor should it enclose a label edge.

As an approximate rule of thumb, the ROI should be larger than the line of text by at least half a character width on all sides if possible (i.e. unless a border that large would cause other features to be enclosed within the ROI).

It is important to note that the OCRMax Segmenter tool is not a general purpose string finder; it is not capable of finding a string in an arbitrarily complex image with a large ROI.

See Also