FisFilter_DL_LocateText
Header: | FIL.h |
---|---|
Namespace: | fil |
Module: | DL_OCR |
Performs text detection using a pre-trained deep learning model.
Syntax
void fil::FisFilter_DL_LocateText ( const fil::Image& inImage, ftl::Optional<const fil::Rectangle2D&> inRoi, ftl::Optional<const fil::CoordinateSystem2D&> inRoiAlignment, const fil::LocateTextModelId& inModelId, const int inCharHeight, const float inWidthScale, const int inOpenRadius, const int inMinTextArea, const int inMaxTextArea, const int inMargin, fil::Heatmap& outHeatmap, ftl::Array<fil::Region>& outTextRegions, ftl::Array<fil::LocateTextResult>& outResults, ftl::Optional<fil::Rectangle2D&> outAlignedRoi = ftl::NIL )
Parameters
Name | Type | Range | Default | Description | |
---|---|---|---|---|---|
inImage | const Image& | Input image | |||
inRoi | Optional<const Rectangle2D&> | NIL | Limits the area where recognized characters are located | ||
inRoiAlignment | Optional<const CoordinateSystem2D&> | NIL | |||
inModelId | const LocateTextModelId& | Identifier of a Read Characters model | |||
inCharHeight | const int | 8 - | 35 | Average height of characters in pixels | |
inWidthScale | const float | 0.1 - 10.0 | 1.0f | Scales image width by the given factor | |
inOpenRadius | const int | 0 - | 0 | Additional filtering of smaller blobs before merging characters into groups | |
inMinTextArea | const int | 0 - | 50 | Minimal character area to be considered as a candidate for a text part | |
inMaxTextArea | const int | 0 - | 500000 | Maximal character area to be considered as a candidate for a text part | |
inMargin | const int | -10 - 100 | 4 | Additional padding around the found character to be added before merging characters into text | |
outHeatmap | Heatmap& | Raw heatmap returned by network. It may be useful for more complex analysis | |||
outTextRegions | Array<Region>& | Extracted characters regions after filtering | |||
outResults | Array<LocateTextResult>& | ||||
outAlignedRoi | Optional<Rectangle2D&> | NIL |
Requirements
For input inImage only pixel formats are supported: 1⨯uint8, 3⨯uint8.
Read more about pixel formats in Image documentation.
Optional Outputs
The computation of following outputs can be switched off by passing value ftl::NIL
to these parameters: outAlignedRoi.
Read more about Optional Outputs.
Description
- oriented with angle up to ± 90 degrees,
- if height between 60% and 140% of inCharHeight (in pixels)
- 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.
In case of fonts with exceptionally 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.
Example:
The inMinTextArea parameter may be used to change minimum area of predicted text. Detected text with area below this limit will be discarded. By default, this parameter is set to 50.
The inOpenRadius helps disjoint merged words, by applying Open Morphological filter on heatmap. By default, it's set to 0. Example:
The inMargin parameter adds extra padding to outResults.Box. By default it's set to 4.
Too big inOpenRadius value on image with small text may cause issues with disappearing or wrong oriented boxes. Try to reduce this value if it happens. Example of too big inOpenRadius value:
Hints
- Reducing ROI may give a high performance boost.
- In case of characters having too much differing height, it is advised to separate the analysed area (e.g. with inRoi input) to smaller parts containing symbols with a more consistent height.
- Too big inOpenRadius value on image with small text may cause issues with disappearing or wrong oriented boxes. Try to reduce this value if it happens.
Errors
List of possible exceptions:
Error type | Description |
---|---|
DomainError | Not supported inImage pixel format in FisFilter_DL_LocateText. Supported formats: 1xUInt8, 3xUInt8. |