Text (OCV/OCR)

Unless otherwise noted, each of the following functions references a Text data structure for the first parameter. Index (zero-based) determines which OCV/OCR character is being indexed from the structure.

Note:
  • The TrainFont, ReadText and VerifyText functions are only available on In-Sight vision systems using In-Sight firmware 4.x.x, and are not available on In-Sight vision systems running In-Sight firmware 5.1.0 and later. For a complete list of models and supported firmware versions, see Firmware Versions.
  • Cognex recommends that the OCRMax function be used instead of the ReadText, TrainFont and VerifyText functions, which are legacy functions. The OCRMax function has enhanced performance capabilities.

Function

Description

GetAngle(Text)

Returns the angle between the text string and the horizontal axis of the Image data structure. GetAngle will ignore an Index parameter.

GetChar(Text, Index0, [Index1])

Returns the indexed character. When an optional Index1 parameter is 1, returns the second highest scoring character. For the VerifyText function, the second highest scoring character will be returned only if the difference in match scores between the two characters is less than 10%. For more information, see VerifyText.

GetCol(Text, Index)

Returns the column coordinate (in pixels) of the indexed character.

GetContrast(Text, Index)

Returns the contrast between the foreground and background (in grey levels, 0 to 255) of the indexed character. If no indexed character is specified, returns the contrast for the first character in the string.

GetErrorCode(Text, Index)

Returns a diagnostic code for each information string.

ClosedSee diagnostic codes and corresponding information strings

Note: Error strings are inserted into the spreadsheet using the GetErrorString function. For more information, see GetErrorString(IDCode).
Code Corresponding String

00000011

Invalid Image Cell reference.

00400000

Invalid Font Cell reference.

00400002

Verification String can not be longer than 32 characters.

00400003

Verification String is blank.

00400004

Verification String contains untrained characters.

GetErrorString(Text, Index)

Returns an error string.

ClosedSee error strings

Note: Error codes are inserted into the spreadsheet using the GetErrorCode function. For more information, see GetErrorCode(IDCode).
Code Corresponding String

00000011

Invalid Image Cell reference.

00400000

Invalid Font Cell reference.

00400002

Verification String can not be longer than 32 characters.

00400003

Verification String is blank.

00400004

Verification String contains untrained characters.

GetHigh(Text, Index)

Returns the height (in pixels) of the indexed character.

GetPassed(Text, Index)

Returns the pass/fail status of the indexed character. If no Index parameter is specified, returns the pass/fail status of the entire string. The overall string passes only if all characters in the string pass.

GetRow(Text, Index)

Returns the row coordinate (in pixels) of the indexed character.

GetScore(Text, Index0, [Index1])

Returns the match score (0 to 100) for the indexed character. If the optional Index1 parameter is 1, returns the score of the second highest scoring character. For the VerifyText function, the match score of the second highest scoring character will be returned only if the difference in match scores between the two characters is less than 10%. For more information, see VerifyText.

GetString(Text)

Returns the text string.

GetWide(Text, Index)

Returns the width (in pixels) of the indexed character.