Text
Objective-C
@interface Text : NSObject
Swift
class Text : NSObject
The Text module
Member classes: ERFilter
, ERFilterCallback
, BaseOCR
, OCRTesseract
, OCRHMMDecoder
, OCRHMMDecoderClassifierCallback
, OCRBeamSearchDecoder
, OCRBeamSearchDecoderClassifierCallback
, TextDetector
, TextDetectorCNN
Member enums: erGrouping_Modes
, page_seg_mode
, ocr_engine_mode
, decoder_mode
, classifier_type
-
Declaration
Objective-C
@property (class, readonly) int ERFILTER_NM_RGBLGrad
Swift
class var ERFILTER_NM_RGBLGrad: Int32 { get }
-
Declaration
Objective-C
@property (class, readonly) int ERFILTER_NM_IHSGrad
Swift
class var ERFILTER_NM_IHSGrad: Int32 { get }
-
Declaration
Objective-C
@property (class, readonly) int OCR_LEVEL_WORD
Swift
class var OCR_LEVEL_WORD: Int32 { get }
-
Declaration
Objective-C
@property (class, readonly) int OCR_LEVEL_TEXTLINE
Swift
class var OCR_LEVEL_TEXTLINE: Int32 { get }
-
Utility function to create a tailored language model transitions table from a given list of words (lexicon).
The function calculate frequency statistics of character pairs from the given lexicon and fills the output transition_probabilities_table with them. The transition_probabilities_table can be used as input in the OCRHMMDecoder::create() and OCRBeamSearchDecoder::create() methods. @note
- (C++) An alternative would be to load the default generic language transition table provided in the text module samples folder (created from ispell 42869 english words list) : https://github.com/opencv/opencv_contrib/blob/master/modules/text/samples/OCRHMM_transitions_table.xml
Declaration
Objective-C
+ (nonnull Mat *)createOCRHMMTransitionsTable:(nonnull NSString *)vocabulary lexicon:(nonnull NSArray<NSString *> *) lexicon;
Swift
class func createOCRHMMTransitionsTable(vocabulary: String, lexicon: [String]) -> Mat
Parameters
vocabulary
The language vocabulary (chars when ASCII English text).
lexicon
The list of words that are expected to be found in a particular image.
-
+createERFilterNM1:
thresholdDelta: minArea: maxArea: minProbability: nonMaxSuppression: minProbabilityDiff: Create an Extremal Region Filter for the 1st stage classifier of N&M algorithm CITE: Neumann12.
loadClassifierNM1, e.g. from file in samples/cpp/trained_classifierNM1.xml
The component tree of the image is extracted by a threshold increased step by step from 0 to 255, incrementally computable descriptors (aspect_ratio, compactness, number of holes, and number of horizontal crossings) are computed for each ER and used as features for a classifier which estimates the class-conditional probability P(er|character). The value of P(er|character) is tracked using the inclusion relation of ER across all thresholds and only the ERs which correspond to local maximum of the probability P(er|character) are selected (if the local maximum of the probability is above a global limit pmin and the difference between local maximum and local minimum is greater than minProbabilityDiff).
Declaration
Objective-C
+ (nonnull ERFilter *)createERFilterNM1:(nonnull ERFilterCallback *)cb thresholdDelta:(int)thresholdDelta minArea:(float)minArea maxArea:(float)maxArea minProbability:(float)minProbability nonMaxSuppression:(BOOL)nonMaxSuppression minProbabilityDiff:(float)minProbabilityDiff;
Swift
class func createERFilterNM1(cb: ERFilterCallback, thresholdDelta: Int32, minArea: Float, maxArea: Float, minProbability: Float, nonMaxSuppression: Bool, minProbabilityDiff: Float) -> ERFilter
-
Create an Extremal Region Filter for the 1st stage classifier of N&M algorithm CITE: Neumann12.
loadClassifierNM1, e.g. from file in samples/cpp/trained_classifierNM1.xml
The component tree of the image is extracted by a threshold increased step by step from 0 to 255, incrementally computable descriptors (aspect_ratio, compactness, number of holes, and number of horizontal crossings) are computed for each ER and used as features for a classifier which estimates the class-conditional probability P(er|character). The value of P(er|character) is tracked using the inclusion relation of ER across all thresholds and only the ERs which correspond to local maximum of the probability P(er|character) are selected (if the local maximum of the probability is above a global limit pmin and the difference between local maximum and local minimum is greater than minProbabilityDiff).
Declaration
Objective-C
+ (nonnull ERFilter *)createERFilterNM1:(nonnull ERFilterCallback *)cb thresholdDelta:(int)thresholdDelta minArea:(float)minArea maxArea:(float)maxArea minProbability:(float)minProbability nonMaxSuppression:(BOOL)nonMaxSuppression;
Swift
class func createERFilterNM1(cb: ERFilterCallback, thresholdDelta: Int32, minArea: Float, maxArea: Float, minProbability: Float, nonMaxSuppression: Bool) -> ERFilter
-
Create an Extremal Region Filter for the 1st stage classifier of N&M algorithm CITE: Neumann12.
loadClassifierNM1, e.g. from file in samples/cpp/trained_classifierNM1.xml
The component tree of the image is extracted by a threshold increased step by step from 0 to 255, incrementally computable descriptors (aspect_ratio, compactness, number of holes, and number of horizontal crossings) are computed for each ER and used as features for a classifier which estimates the class-conditional probability P(er|character). The value of P(er|character) is tracked using the inclusion relation of ER across all thresholds and only the ERs which correspond to local maximum of the probability P(er|character) are selected (if the local maximum of the probability is above a global limit pmin and the difference between local maximum and local minimum is greater than minProbabilityDiff).
Declaration
Objective-C
+ (nonnull ERFilter *)createERFilterNM1:(nonnull ERFilterCallback *)cb thresholdDelta:(int)thresholdDelta minArea:(float)minArea maxArea:(float)maxArea minProbability:(float)minProbability;
Swift
class func createERFilterNM1(cb: ERFilterCallback, thresholdDelta: Int32, minArea: Float, maxArea: Float, minProbability: Float) -> ERFilter
-
Create an Extremal Region Filter for the 1st stage classifier of N&M algorithm CITE: Neumann12.
loadClassifierNM1, e.g. from file in samples/cpp/trained_classifierNM1.xml
The component tree of the image is extracted by a threshold increased step by step from 0 to 255, incrementally computable descriptors (aspect_ratio, compactness, number of holes, and number of horizontal crossings) are computed for each ER and used as features for a classifier which estimates the class-conditional probability P(er|character). The value of P(er|character) is tracked using the inclusion relation of ER across all thresholds and only the ERs which correspond to local maximum of the probability P(er|character) are selected (if the local maximum of the probability is above a global limit pmin and the difference between local maximum and local minimum is greater than minProbabilityDiff).
Declaration
Objective-C
+ (nonnull ERFilter *)createERFilterNM1:(nonnull ERFilterCallback *)cb thresholdDelta:(int)thresholdDelta minArea:(float)minArea maxArea:(float)maxArea;
Swift
class func createERFilterNM1(cb: ERFilterCallback, thresholdDelta: Int32, minArea: Float, maxArea: Float) -> ERFilter
-
Create an Extremal Region Filter for the 1st stage classifier of N&M algorithm CITE: Neumann12.
loadClassifierNM1, e.g. from file in samples/cpp/trained_classifierNM1.xml
The component tree of the image is extracted by a threshold increased step by step from 0 to 255, incrementally computable descriptors (aspect_ratio, compactness, number of holes, and number of horizontal crossings) are computed for each ER and used as features for a classifier which estimates the class-conditional probability P(er|character). The value of P(er|character) is tracked using the inclusion relation of ER across all thresholds and only the ERs which correspond to local maximum of the probability P(er|character) are selected (if the local maximum of the probability is above a global limit pmin and the difference between local maximum and local minimum is greater than minProbabilityDiff).
Declaration
Objective-C
+ (nonnull ERFilter *)createERFilterNM1:(nonnull ERFilterCallback *)cb thresholdDelta:(int)thresholdDelta minArea:(float)minArea;
Swift
class func createERFilterNM1(cb: ERFilterCallback, thresholdDelta: Int32, minArea: Float) -> ERFilter
-
Create an Extremal Region Filter for the 1st stage classifier of N&M algorithm CITE: Neumann12.
loadClassifierNM1, e.g. from file in samples/cpp/trained_classifierNM1.xml
The component tree of the image is extracted by a threshold increased step by step from 0 to 255, incrementally computable descriptors (aspect_ratio, compactness, number of holes, and number of horizontal crossings) are computed for each ER and used as features for a classifier which estimates the class-conditional probability P(er|character). The value of P(er|character) is tracked using the inclusion relation of ER across all thresholds and only the ERs which correspond to local maximum of the probability P(er|character) are selected (if the local maximum of the probability is above a global limit pmin and the difference between local maximum and local minimum is greater than minProbabilityDiff).
Declaration
Objective-C
+ (nonnull ERFilter *)createERFilterNM1:(nonnull ERFilterCallback *)cb thresholdDelta:(int)thresholdDelta;
Swift
class func createERFilterNM1(cb: ERFilterCallback, thresholdDelta: Int32) -> ERFilter
-
Create an Extremal Region Filter for the 1st stage classifier of N&M algorithm CITE: Neumann12.
loadClassifierNM1, e.g. from file in samples/cpp/trained_classifierNM1.xml
The component tree of the image is extracted by a threshold increased step by step from 0 to 255, incrementally computable descriptors (aspect_ratio, compactness, number of holes, and number of horizontal crossings) are computed for each ER and used as features for a classifier which estimates the class-conditional probability P(er|character). The value of P(er|character) is tracked using the inclusion relation of ER across all thresholds and only the ERs which correspond to local maximum of the probability P(er|character) are selected (if the local maximum of the probability is above a global limit pmin and the difference between local maximum and local minimum is greater than minProbabilityDiff).
Declaration
Objective-C
+ (nonnull ERFilter *)createERFilterNM1:(nonnull ERFilterCallback *)cb;
Swift
class func createERFilterNM1(cb: ERFilterCallback) -> ERFilter
-
+createERFilterNM1FromFile:
thresholdDelta: minArea: maxArea: minProbability: nonMaxSuppression: minProbabilityDiff: Reads an Extremal Region Filter for the 1st stage classifier of N&M algorithm from the provided path e.g. /path/to/cpp/trained_classifierNM1.xml
Declaration
Objective-C
+ (nonnull ERFilter *)createERFilterNM1FromFile:(nonnull NSString *)filename thresholdDelta:(int)thresholdDelta minArea:(float)minArea maxArea:(float)maxArea minProbability:(float)minProbability nonMaxSuppression:(BOOL)nonMaxSuppression minProbabilityDiff:(float)minProbabilityDiff;
Swift
class func createERFilterNM1(filename: String, thresholdDelta: Int32, minArea: Float, maxArea: Float, minProbability: Float, nonMaxSuppression: Bool, minProbabilityDiff: Float) -> ERFilter
-
Reads an Extremal Region Filter for the 1st stage classifier of N&M algorithm from the provided path e.g. /path/to/cpp/trained_classifierNM1.xml
Declaration
Objective-C
+ (nonnull ERFilter *)createERFilterNM1FromFile:(nonnull NSString *)filename thresholdDelta:(int)thresholdDelta minArea:(float)minArea maxArea:(float)maxArea minProbability:(float)minProbability nonMaxSuppression:(BOOL)nonMaxSuppression;
Swift
class func createERFilterNM1(filename: String, thresholdDelta: Int32, minArea: Float, maxArea: Float, minProbability: Float, nonMaxSuppression: Bool) -> ERFilter
-
Reads an Extremal Region Filter for the 1st stage classifier of N&M algorithm from the provided path e.g. /path/to/cpp/trained_classifierNM1.xml
Declaration
Objective-C
+ (nonnull ERFilter *)createERFilterNM1FromFile:(nonnull NSString *)filename thresholdDelta:(int)thresholdDelta minArea:(float)minArea maxArea:(float)maxArea minProbability:(float)minProbability;
Swift
class func createERFilterNM1(filename: String, thresholdDelta: Int32, minArea: Float, maxArea: Float, minProbability: Float) -> ERFilter
-
Reads an Extremal Region Filter for the 1st stage classifier of N&M algorithm from the provided path e.g. /path/to/cpp/trained_classifierNM1.xml
Declaration
Objective-C
+ (nonnull ERFilter *)createERFilterNM1FromFile:(nonnull NSString *)filename thresholdDelta:(int)thresholdDelta minArea:(float)minArea maxArea:(float)maxArea;
Swift
class func createERFilterNM1(filename: String, thresholdDelta: Int32, minArea: Float, maxArea: Float) -> ERFilter
-
Reads an Extremal Region Filter for the 1st stage classifier of N&M algorithm from the provided path e.g. /path/to/cpp/trained_classifierNM1.xml
-
Reads an Extremal Region Filter for the 1st stage classifier of N&M algorithm from the provided path e.g. /path/to/cpp/trained_classifierNM1.xml
-
Reads an Extremal Region Filter for the 1st stage classifier of N&M algorithm from the provided path e.g. /path/to/cpp/trained_classifierNM1.xml
-
Create an Extremal Region Filter for the 2nd stage classifier of N&M algorithm CITE: Neumann12.
loadClassifierNM2, e.g. from file in samples/cpp/trained_classifierNM2.xml
In the second stage, the ERs that passed the first stage are classified into character and non-character classes using more informative but also more computationally expensive features. The classifier uses all the features calculated in the first stage and the following additional features: hole area ratio, convex hull ratio, and number of outer inflexion points.
Declaration
Objective-C
+ (nonnull ERFilter *)createERFilterNM2:(nonnull ERFilterCallback *)cb minProbability:(float)minProbability;
Swift
class func createERFilterNM2(cb: ERFilterCallback, minProbability: Float) -> ERFilter
-
Create an Extremal Region Filter for the 2nd stage classifier of N&M algorithm CITE: Neumann12.
loadClassifierNM2, e.g. from file in samples/cpp/trained_classifierNM2.xml
In the second stage, the ERs that passed the first stage are classified into character and non-character classes using more informative but also more computationally expensive features. The classifier uses all the features calculated in the first stage and the following additional features: hole area ratio, convex hull ratio, and number of outer inflexion points.
Declaration
Objective-C
+ (nonnull ERFilter *)createERFilterNM2:(nonnull ERFilterCallback *)cb;
Swift
class func createERFilterNM2(cb: ERFilterCallback) -> ERFilter
-
Reads an Extremal Region Filter for the 2nd stage classifier of N&M algorithm from the provided path e.g. /path/to/cpp/trained_classifierNM2.xml
-
Reads an Extremal Region Filter for the 2nd stage classifier of N&M algorithm from the provided path e.g. /path/to/cpp/trained_classifierNM2.xml
-
Allow to implicitly load the default classifier when creating an ERFilter object.
returns a pointer to ERFilter::Callback.
Declaration
Objective-C
+ (nonnull ERFilterCallback *)loadClassifierNM1:(nonnull NSString *)filename;
Swift
class func loadClassifierNM1(filename: String) -> ERFilterCallback
Parameters
filename
The XML or YAML file with the classifier model (e.g. trained_classifierNM1.xml)
-
Allow to implicitly load the default classifier when creating an ERFilter object.
returns a pointer to ERFilter::Callback.
Declaration
Objective-C
+ (nonnull ERFilterCallback *)loadClassifierNM2:(nonnull NSString *)filename;
Swift
class func loadClassifierNM2(filename: String) -> ERFilterCallback
Parameters
filename
The XML or YAML file with the classifier model (e.g. trained_classifierNM2.xml)
-
Allow to implicitly load the default character classifier when creating an OCRBeamSearchDecoder object.
The CNN default classifier is based in the scene text recognition method proposed by Adam Coates & Andrew NG in [Coates11a]. The character classifier consists in a Single Layer Convolutional Neural Network and a linear classifier. It is applied to the input image in a sliding window fashion, providing a set of recognitions at each window location.
Declaration
Objective-C
+ (nonnull OCRBeamSearchDecoderClassifierCallback *) loadOCRBeamSearchClassifierCNN:(nonnull NSString *)filename;
Swift
class func loadOCRBeamSearchClassifierCNN(filename: String) -> OCRBeamSearchDecoderClassifierCallback
Parameters
filename
The XML or YAML file with the classifier model (e.g. OCRBeamSearch_CNN_model_data.xml.gz)
-
Allow to implicitly load the default character classifier when creating an OCRHMMDecoder object.
Declaration
Objective-C
+ (nonnull OCRHMMDecoderClassifierCallback *) loadOCRHMMClassifier:(nonnull NSString *)filename classifier:(classifier_type)classifier;
Swift
class func loadOCRHMMClassifier(filename: String, classifier: classifier_type) -> OCRHMMDecoderClassifierCallback
Parameters
filename
The XML or YAML file with the classifier model (e.g. OCRBeamSearch_CNN_model_data.xml.gz)
classifier
Can be one of classifier_type enum values.
-
Deprecated
Allow to implicitly load the default character classifier when creating an OCRHMMDecoder object.
The CNN default classifier is based in the scene text recognition method proposed by Adam Coates & Andrew NG in [Coates11a]. The character classifier consists in a Single Layer Convolutional Neural Network and a linear classifier. It is applied to the input image in a sliding window fashion, providing a set of recognitions at each window location.
@deprecated use loadOCRHMMClassifier instead
Declaration
Objective-C
+ (nonnull OCRHMMDecoderClassifierCallback *)loadOCRHMMClassifierCNN: (nonnull NSString *)filename;
Swift
class func loadOCRHMMClassifierCNN(filename: String) -> OCRHMMDecoderClassifierCallback
Parameters
filename
The XML or YAML file with the classifier model (e.g. OCRBeamSearch_CNN_model_data.xml.gz)
-
Deprecated
Allow to implicitly load the default character classifier when creating an OCRHMMDecoder object.
The KNN default classifier is based in the scene text recognition method proposed by Lukás Neumann & Jiri Matas in [Neumann11b]. Basically, the region (contour) in the input image is normalized to a fixed size, while retaining the centroid and aspect ratio, in order to extract a feature vector based on gradient orientations along the chain-code of its perimeter. Then, the region is classified using a KNN model trained with synthetic data of rendered characters with different standard font types.
@deprecated loadOCRHMMClassifier instead
Declaration
Objective-C
+ (nonnull OCRHMMDecoderClassifierCallback *)loadOCRHMMClassifierNM: (nonnull NSString *)filename;
Swift
class func loadOCRHMMClassifierNM(filename: String) -> OCRHMMDecoderClassifierCallback
Parameters
filename
The XML or YAML file with the classifier model (e.g. OCRHMM_knn_model_data.xml)
-
Compute the different channels to be processed independently in the N&M algorithm CITE: Neumann12.
In N&M algorithm, the combination of intensity (I), hue (H), saturation (S), and gradient magnitude channels (Grad) are used in order to obtain high localization recall. This implementation also provides an alternative combination of red ®, green (G), blue (B), lightness (L), and gradient magnitude (Grad).
Declaration
Objective-C
+ (void)computeNMChannels:(nonnull Mat *)_src _channels:(nonnull NSMutableArray<Mat *> *)_channels _mode:(int)_mode;
Swift
class func computeNMChannels(_src: Mat, _channels: NSMutableArray, _mode: Int32)
Parameters
_src
Source image. Must be RGB CV_8UC3.
_channels
Output vector<Mat> where computed channels are stored.
_mode
Mode of operation. Currently the only available options are: ERFILTER_NM_RGBLGrad* (used by default) and ERFILTER_NM_IHSGrad.
-
Compute the different channels to be processed independently in the N&M algorithm CITE: Neumann12.
ERFILTER_NM_RGBLGrad* (used by default) and ERFILTER_NM_IHSGrad.
In N&M algorithm, the combination of intensity (I), hue (H), saturation (S), and gradient magnitude channels (Grad) are used in order to obtain high localization recall. This implementation also provides an alternative combination of red ®, green (G), blue (B), lightness (L), and gradient magnitude (Grad).
Declaration
Objective-C
+ (void)computeNMChannels:(nonnull Mat *)_src _channels:(nonnull NSMutableArray<Mat *> *)_channels;
Swift
class func computeNMChannels(_src: Mat, _channels: NSMutableArray)
Parameters
_src
Source image. Must be RGB CV_8UC3.
_channels
Output vector<Mat> where computed channels are stored.
-
Extracts text regions from image.
Declaration
Objective-C
+ (void)detectRegions:(nonnull Mat *)image er_filter1:(nonnull ERFilter *)er_filter1 er_filter2:(nonnull ERFilter *)er_filter2 groups_rects:(nonnull NSMutableArray<Rect2i *> *)groups_rects method:(erGrouping_Modes)method filename:(nonnull NSString *)filename minProbability:(float)minProbability;
Swift
class func detectRegions(image: Mat, er_filter1: ERFilter, er_filter2: ERFilter, groups_rects: NSMutableArray, method: erGrouping_Modes, filename: String, minProbability: Float)
Parameters
image
Source image where text blocks needs to be extracted from. Should be CV_8UC3 (color).
er_filter1
Extremal Region Filter for the 1st stage classifier of N&M algorithm CITE: Neumann12
er_filter2
Extremal Region Filter for the 2nd stage classifier of N&M algorithm CITE: Neumann12
groups_rects
Output list of rectangle blocks with text
method
Grouping method (see text::erGrouping_Modes). Can be one of ERGROUPING_ORIENTATION_HORIZ, ERGROUPING_ORIENTATION_ANY.
filename
The XML or YAML file with the classifier model (e.g. samples/trained_classifier_erGrouping.xml). Only to use when grouping method is ERGROUPING_ORIENTATION_ANY.
minProbability
The minimum probability for accepting a group. Only to use when grouping method is ERGROUPING_ORIENTATION_ANY.
-
Extracts text regions from image.
Declaration
Objective-C
+ (void)detectRegions:(nonnull Mat *)image er_filter1:(nonnull ERFilter *)er_filter1 er_filter2:(nonnull ERFilter *)er_filter2 groups_rects:(nonnull NSMutableArray<Rect2i *> *)groups_rects method:(erGrouping_Modes)method filename:(nonnull NSString *)filename;
Swift
class func detectRegions(image: Mat, er_filter1: ERFilter, er_filter2: ERFilter, groups_rects: NSMutableArray, method: erGrouping_Modes, filename: String)
Parameters
image
Source image where text blocks needs to be extracted from. Should be CV_8UC3 (color).
er_filter1
Extremal Region Filter for the 1st stage classifier of N&M algorithm CITE: Neumann12
er_filter2
Extremal Region Filter for the 2nd stage classifier of N&M algorithm CITE: Neumann12
groups_rects
Output list of rectangle blocks with text
method
Grouping method (see text::erGrouping_Modes). Can be one of ERGROUPING_ORIENTATION_HORIZ, ERGROUPING_ORIENTATION_ANY.
filename
The XML or YAML file with the classifier model (e.g. samples/trained_classifier_erGrouping.xml). Only to use when grouping method is ERGROUPING_ORIENTATION_ANY.
-
Extracts text regions from image.
Declaration
Objective-C
+ (void)detectRegions:(nonnull Mat *)image er_filter1:(nonnull ERFilter *)er_filter1 er_filter2:(nonnull ERFilter *)er_filter2 groups_rects:(nonnull NSMutableArray<Rect2i *> *)groups_rects method:(erGrouping_Modes)method;
Swift
class func detectRegions(image: Mat, er_filter1: ERFilter, er_filter2: ERFilter, groups_rects: NSMutableArray, method: erGrouping_Modes)
Parameters
image
Source image where text blocks needs to be extracted from. Should be CV_8UC3 (color).
er_filter1
Extremal Region Filter for the 1st stage classifier of N&M algorithm CITE: Neumann12
er_filter2
Extremal Region Filter for the 2nd stage classifier of N&M algorithm CITE: Neumann12
groups_rects
Output list of rectangle blocks with text
method
Grouping method (see text::erGrouping_Modes). Can be one of ERGROUPING_ORIENTATION_HORIZ, ERGROUPING_ORIENTATION_ANY.
-
Extracts text regions from image.
Declaration
Parameters
image
Source image where text blocks needs to be extracted from. Should be CV_8UC3 (color).
er_filter1
Extremal Region Filter for the 1st stage classifier of N&M algorithm CITE: Neumann12
er_filter2
Extremal Region Filter for the 2nd stage classifier of N&M algorithm CITE: Neumann12
groups_rects
Output list of rectangle blocks with text
-
Converts MSER contours (vector<Point>) to ERStat regions.
It takes as input the contours provided by the OpenCV MSER feature detector and returns as output two vectors of ERStats. This is because MSER() output contains both MSER+ and MSER- regions in a single vector<Point>, the function separates them in two different vectors (this is as if the ERStats where extracted from two different channels).
An example of MSERsToERStats in use can be found in the text detection webcam_demo: https://github.com/opencv/opencv_contrib/blob/master/modules/text/samples/webcam_demo.cpp
Declaration
Parameters
image
Source image CV_8UC1 from which the MSERs where extracted.
regions
Output where the ERStat regions are stored.
-
Applies the Stroke Width Transform operator followed by filtering of connected components of similar Stroke Widths to return letter candidates. It also chain them by proximity and size, saving the result in chainBBs.
Declaration
Parameters
input
the input image with 3 channels.
result
a vector of resulting bounding boxes where probability of finding text is high
dark_on_light
a boolean value signifying whether the text is darker or lighter than the background, it is observed to reverse the gradient obtained from Scharr operator, and significantly affect the result.
draw
an optional Mat of type CV_8UC3 which visualises the detected letters using bounding boxes.
chainBBs
an optional parameter which chains the letter candidates according to heuristics in the paper and returns all possible regions where text is likely to occur.
-
Applies the Stroke Width Transform operator followed by filtering of connected components of similar Stroke Widths to return letter candidates. It also chain them by proximity and size, saving the result in chainBBs.
Declaration
Parameters
input
the input image with 3 channels.
result
a vector of resulting bounding boxes where probability of finding text is high
dark_on_light
a boolean value signifying whether the text is darker or lighter than the background, it is observed to reverse the gradient obtained from Scharr operator, and significantly affect the result.
draw
an optional Mat of type CV_8UC3 which visualises the detected letters using bounding boxes.
-
Applies the Stroke Width Transform operator followed by filtering of connected components of similar Stroke Widths to return letter candidates. It also chain them by proximity and size, saving the result in chainBBs.
Declaration
Objective-C
+ (void)detectTextSWT:(nonnull Mat *)input result:(nonnull NSMutableArray<Rect2i *> *)result dark_on_light:(BOOL)dark_on_light;
Swift
class func detectTextSWT(input: Mat, result: NSMutableArray, dark_on_light: Bool)
Parameters
input
the input image with 3 channels.
result
a vector of resulting bounding boxes where probability of finding text is high
dark_on_light
a boolean value signifying whether the text is darker or lighter than the background, it is observed to reverse the gradient obtained from Scharr operator, and significantly affect the result.
-
Find groups of Extremal Regions that are organized as text blocks.
provided regions.
Declaration
Objective-C
+ (void)erGrouping:(nonnull Mat *)image channel:(nonnull Mat *)channel regions:(nonnull NSArray<NSArray<Point2i *> *> *)regions groups_rects:(nonnull NSMutableArray<Rect2i *> *)groups_rects method:(erGrouping_Modes)method filename:(nonnull NSString *)filename minProbablity:(float)minProbablity;
Swift
class func erGrouping(image: Mat, channel: Mat, regions: [[Point2i]], groups_rects: NSMutableArray, method: erGrouping_Modes, filename: String, minProbablity: Float)
Parameters
regions
Vector of ER’s retrieved from the ERFilter algorithm from each channel.
groups_rects
The output of the algorithm are stored in this parameter as list of rectangles.
method
Grouping method (see text::erGrouping_Modes). Can be one of ERGROUPING_ORIENTATION_HORIZ, ERGROUPING_ORIENTATION_ANY.
filename
The XML or YAML file with the classifier model (e.g. samples/trained_classifier_erGrouping.xml). Only to use when grouping method is ERGROUPING_ORIENTATION_ANY.
minProbablity
The minimum probability for accepting a group. Only to use when grouping method is ERGROUPING_ORIENTATION_ANY.
-
Find groups of Extremal Regions that are organized as text blocks.
provided regions.
method is ERGROUPING_ORIENTATION_ANY.
Declaration
Objective-C
+ (void)erGrouping:(nonnull Mat *)image channel:(nonnull Mat *)channel regions:(nonnull NSArray<NSArray<Point2i *> *> *)regions groups_rects:(nonnull NSMutableArray<Rect2i *> *)groups_rects method:(erGrouping_Modes)method filename:(nonnull NSString *)filename;
Swift
class func erGrouping(image: Mat, channel: Mat, regions: [[Point2i]], groups_rects: NSMutableArray, method: erGrouping_Modes, filename: String)
Parameters
regions
Vector of ER’s retrieved from the ERFilter algorithm from each channel.
groups_rects
The output of the algorithm are stored in this parameter as list of rectangles.
method
Grouping method (see text::erGrouping_Modes). Can be one of ERGROUPING_ORIENTATION_HORIZ, ERGROUPING_ORIENTATION_ANY.
filename
The XML or YAML file with the classifier model (e.g. samples/trained_classifier_erGrouping.xml). Only to use when grouping method is ERGROUPING_ORIENTATION_ANY.
-
Find groups of Extremal Regions that are organized as text blocks.
provided regions.
samples/trained_classifier_erGrouping.xml). Only to use when grouping method is ERGROUPING_ORIENTATION_ANY.
method is ERGROUPING_ORIENTATION_ANY.
Declaration
Objective-C
+ (void)erGrouping:(nonnull Mat *)image channel:(nonnull Mat *)channel regions:(nonnull NSArray<NSArray<Point2i *> *> *)regions groups_rects:(nonnull NSMutableArray<Rect2i *> *)groups_rects method:(erGrouping_Modes)method;
Swift
class func erGrouping(image: Mat, channel: Mat, regions: [[Point2i]], groups_rects: NSMutableArray, method: erGrouping_Modes)
Parameters
regions
Vector of ER’s retrieved from the ERFilter algorithm from each channel.
groups_rects
The output of the algorithm are stored in this parameter as list of rectangles.
method
Grouping method (see text::erGrouping_Modes). Can be one of ERGROUPING_ORIENTATION_HORIZ, ERGROUPING_ORIENTATION_ANY.
-
Find groups of Extremal Regions that are organized as text blocks.
provided regions.
ERGROUPING_ORIENTATION_ANY.
samples/trained_classifier_erGrouping.xml). Only to use when grouping method is ERGROUPING_ORIENTATION_ANY.
method is ERGROUPING_ORIENTATION_ANY.
Declaration
Parameters
regions
Vector of ER’s retrieved from the ERFilter algorithm from each channel.
groups_rects
The output of the algorithm are stored in this parameter as list of rectangles.