You are here: Start » FILDL.DL_ReadCharacters Method

FILDL.DL_ReadCharacters Method

Namespace:FilNet.DeepLearning
Assembly:FilDl.Net.dll

Syntax

public static void DL_ReadCharacters
(
	FilNet.Image inImage,
	FilNet.Rectangle2D? inRoi,
	FilNet.CoordinateSystem2D? inRoiAlignment,
	FilNet.ReadCharactersModelId inModelId,
	int inCharHeight,
	float inWidthScale,
	NullableRef<string> inCharRange,
	float inMinScore,
	FilNet.Polarity inPolarization,
	float inContrastThreshold,
	IList<FilNet.OcrResult> outCharacters,
	IList<FilNet.Region> outMasks,
	NullableValue<FilNet.Rectangle2D> outAlignedRoi
)

Parameters

Name Type Range Default Description
inImageFilNet.Image
inRoiFilNet.Rectangle2D?
inRoiAlignmentFilNet.CoordinateSystem2D?
inModelIdFilNet.ReadCharactersModelId
inCharHeightint
inWidthScalefloat
inCharRangeFilNet.NullableRef<string>
inMinScorefloat
inPolarizationFilNet.Polarity
inContrastThresholdfloat
outCharactersSystem.Collections.Generic.IList<FilNet.OcrResult>
outMasksSystem.Collections.Generic.IList<FilNet.Region>
outAlignedRoiFilNet.NullableValue<FilNet.Rectangle2D>

Description

This tool locates and recognizes characters. Without additional training, it is suitable for reading characters:

  • horizontally oriented,
  • of height between 60% and 140% of inCharHeight (in pixels) - for the FastWide, Balanced, Extended or OcrA models
  • of height between 85% and 115% of inCharHeight (in pixels) - for the Fast model
  • of height between 45% and 225% of inCharHeight (in pixels) - for the Scalable model
  • being latin letters (upper- or lower-case), digits or one of: !#$%&()*+,-./:;<=>?@[]^_`{|}~"'\€£¥.

This behavior can be configured with parameters described below.

The inRoi and inRoiAlignment inputs may be used to limit the analysed area, which, in most cases, leads to improved performance. Moreover, it may be used to adjust to text which is not horizontally oriented.

The inCharHeight should be set to the average height of characters (specifically, capital letters) in the analysed area. E.g. if image contains 2 kind of characters: one being 24 pixels high and the second being 40 pixels high, inCharHeight should be set to 32, irrespective of number of characters of each kind. Fast mode supports a more narrow range of character sizes, the character size should be between 30 and 40 pixels.

In case of fonts with exceptionally thin or wide symbols, inWidthScale may be used to reshape them to a more "typical" aspect ratio. The analysed area will be scaled by inWidthScale in the horizontal axis. It may improve quality of results. Furthermore, it may also help in reading a text with tight spaces between subsequent characters.

To limit the set of recognized characters, inCharRange may be used. This string has to be formatted according to the following rules:

  • allowed characters have to be separated with commas,
  • for ease of use, continuous range of letters or digits, may be written as starting_character-ending_character, e.g. A-Z or 1-6,
  • comma and backslash have to be prepended with backslash.

For example, inCharRange equal to A-F,g-o,0-9,X,Y,Z,-,\\,\, will result in recognizing only ABCDEFXYZghijklmno0123456789-\, characters.

The inMinScore parameter may be used to change minimum score of a character. By default, this threshold is set to 0.5.

The inContrastThreshold and inPolarization parameters sets a desired contrast interval of a character, which may be used to reduce amount of false positives:

  • For inPolarization = Polarity::Bright, only characters with a contrast greater than inContrastThreshold will be returned.
  • For inPolarization = Polarity::Dark, only characters with a contrast lower than -inContrastThreshold will be returned.
  • For inPolarization = Polarity::Any, only characters with a contrast lower than -inContrastThreshold or greater than inContrastThreshold will be returned.

Character which is darker than its background have a negative contrast. Opposite situation results in a positive contrast.

Remarks

This filter should not be executed along with running Deep Learning Service as it may result in degraded performance or even out-of-memory errors.

Errors

List of possible exceptions:

Error type Description
DomainError Not supported inImage pixel format in FisFilter_DL_ReadCharacters. Supported formats: 1xUInt8, 3xUInt8.

Function Overrides

See also