Text.h 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656
  1. //
  2. // This file is auto-generated. Please don't modify it!
  3. //
  4. #pragma once
  5. #ifdef __cplusplus
  6. //#import "opencv.hpp"
  7. #import "opencv2/text.hpp"
  8. #else
  9. #define CV_EXPORTS
  10. #endif
  11. #import <Foundation/Foundation.h>
  12. @class ERFilter;
  13. @class ERFilterCallback;
  14. @class Mat;
  15. @class OCRBeamSearchDecoderClassifierCallback;
  16. @class OCRHMMDecoderClassifierCallback;
  17. @class Point2i;
  18. @class Rect2i;
  19. // C++: enum classifier_type (cv.text.classifier_type)
  20. typedef NS_ENUM(int, classifier_type) {
  21. OCR_KNN_CLASSIFIER = 0,
  22. OCR_CNN_CLASSIFIER = 1
  23. };
  24. // C++: enum decoder_mode (cv.text.decoder_mode)
  25. typedef NS_ENUM(int, decoder_mode) {
  26. OCR_DECODER_VITERBI = 0
  27. };
  28. // C++: enum erGrouping_Modes (cv.text.erGrouping_Modes)
  29. typedef NS_ENUM(int, erGrouping_Modes) {
  30. ERGROUPING_ORIENTATION_HORIZ = 0,
  31. ERGROUPING_ORIENTATION_ANY = 1
  32. };
  33. // C++: enum ocr_engine_mode (cv.text.ocr_engine_mode)
  34. typedef NS_ENUM(int, ocr_engine_mode) {
  35. OEM_TESSERACT_ONLY = 0,
  36. OEM_CUBE_ONLY = 1,
  37. OEM_TESSERACT_CUBE_COMBINED = 2,
  38. OEM_DEFAULT = 3
  39. };
  40. // C++: enum page_seg_mode (cv.text.page_seg_mode)
  41. typedef NS_ENUM(int, page_seg_mode) {
  42. PSM_OSD_ONLY = 0,
  43. PSM_AUTO_OSD = 1,
  44. PSM_AUTO_ONLY = 2,
  45. PSM_AUTO = 3,
  46. PSM_SINGLE_COLUMN = 4,
  47. PSM_SINGLE_BLOCK_VERT_TEXT = 5,
  48. PSM_SINGLE_BLOCK = 6,
  49. PSM_SINGLE_LINE = 7,
  50. PSM_SINGLE_WORD = 8,
  51. PSM_CIRCLE_WORD = 9,
  52. PSM_SINGLE_CHAR = 10
  53. };
  54. NS_ASSUME_NONNULL_BEGIN
  55. // C++: class Text
  56. /**
  57. * The Text module
  58. *
  59. * Member classes: `ERFilter`, `ERFilterCallback`, `BaseOCR`, `OCRTesseract`, `OCRHMMDecoder`, `OCRHMMDecoderClassifierCallback`, `OCRBeamSearchDecoder`, `OCRBeamSearchDecoderClassifierCallback`, `TextDetector`, `TextDetectorCNN`
  60. *
  61. * Member enums: `erGrouping_Modes`, `page_seg_mode`, `ocr_engine_mode`, `decoder_mode`, `classifier_type`
  62. */
  63. CV_EXPORTS @interface Text : NSObject
  64. #pragma mark - Class Constants
  65. @property (class, readonly) int ERFILTER_NM_RGBLGrad NS_SWIFT_NAME(ERFILTER_NM_RGBLGrad);
  66. @property (class, readonly) int ERFILTER_NM_IHSGrad NS_SWIFT_NAME(ERFILTER_NM_IHSGrad);
  67. @property (class, readonly) int OCR_LEVEL_WORD NS_SWIFT_NAME(OCR_LEVEL_WORD);
  68. @property (class, readonly) int OCR_LEVEL_TEXTLINE NS_SWIFT_NAME(OCR_LEVEL_TEXTLINE);
  69. #pragma mark - Methods
  70. //
  71. // void cv::text::detectTextSWT(Mat input, vector_Rect& result, bool dark_on_light, Mat& draw = Mat(), Mat& chainBBs = Mat())
  72. //
  73. /**
  74. * 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.
  75. * @param input the input image with 3 channels.
  76. * @param result a vector of resulting bounding boxes where probability of finding text is high
  77. * @param 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.
  78. * @param draw an optional Mat of type CV_8UC3 which visualises the detected letters using bounding boxes.
  79. * @param 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.
  80. */
  81. + (void)detectTextSWT:(Mat*)input result:(NSMutableArray<Rect2i*>*)result dark_on_light:(BOOL)dark_on_light draw:(Mat*)draw chainBBs:(Mat*)chainBBs NS_SWIFT_NAME(detectTextSWT(input:result:dark_on_light:draw:chainBBs:));
  82. /**
  83. * 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.
  84. * @param input the input image with 3 channels.
  85. * @param result a vector of resulting bounding boxes where probability of finding text is high
  86. * @param 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.
  87. * @param draw an optional Mat of type CV_8UC3 which visualises the detected letters using bounding boxes.
  88. */
  89. + (void)detectTextSWT:(Mat*)input result:(NSMutableArray<Rect2i*>*)result dark_on_light:(BOOL)dark_on_light draw:(Mat*)draw NS_SWIFT_NAME(detectTextSWT(input:result:dark_on_light:draw:));
  90. /**
  91. * 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.
  92. * @param input the input image with 3 channels.
  93. * @param result a vector of resulting bounding boxes where probability of finding text is high
  94. * @param 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.
  95. */
  96. + (void)detectTextSWT:(Mat*)input result:(NSMutableArray<Rect2i*>*)result dark_on_light:(BOOL)dark_on_light NS_SWIFT_NAME(detectTextSWT(input:result:dark_on_light:));
  97. //
  98. // Ptr_ERFilter cv::text::createERFilterNM1(Ptr_ERFilter_Callback cb, int thresholdDelta = 1, float minArea = (float)0.00025, float maxArea = (float)0.13, float minProbability = (float)0.4, bool nonMaxSuppression = true, float minProbabilityDiff = (float)0.1)
  99. //
  100. /**
  101. * Create an Extremal Region Filter for the 1st stage classifier of N&M algorithm CITE: Neumann12.
  102. *
  103. * loadClassifierNM1, e.g. from file in samples/cpp/trained_classifierNM1.xml
  104. *
  105. * The component tree of the image is extracted by a threshold increased step by step from 0 to 255,
  106. * incrementally computable descriptors (aspect_ratio, compactness, number of holes, and number of
  107. * horizontal crossings) are computed for each ER and used as features for a classifier which estimates
  108. * the class-conditional probability P(er|character). The value of P(er|character) is tracked using the
  109. * inclusion relation of ER across all thresholds and only the ERs which correspond to local maximum of
  110. * the probability P(er|character) are selected (if the local maximum of the probability is above a
  111. * global limit pmin and the difference between local maximum and local minimum is greater than
  112. * minProbabilityDiff).
  113. */
  114. + (ERFilter*)createERFilterNM1:(ERFilterCallback*)cb thresholdDelta:(int)thresholdDelta minArea:(float)minArea maxArea:(float)maxArea minProbability:(float)minProbability nonMaxSuppression:(BOOL)nonMaxSuppression minProbabilityDiff:(float)minProbabilityDiff NS_SWIFT_NAME(createERFilterNM1(cb:thresholdDelta:minArea:maxArea:minProbability:nonMaxSuppression:minProbabilityDiff:));
  115. /**
  116. * Create an Extremal Region Filter for the 1st stage classifier of N&M algorithm CITE: Neumann12.
  117. *
  118. * loadClassifierNM1, e.g. from file in samples/cpp/trained_classifierNM1.xml
  119. *
  120. * The component tree of the image is extracted by a threshold increased step by step from 0 to 255,
  121. * incrementally computable descriptors (aspect_ratio, compactness, number of holes, and number of
  122. * horizontal crossings) are computed for each ER and used as features for a classifier which estimates
  123. * the class-conditional probability P(er|character). The value of P(er|character) is tracked using the
  124. * inclusion relation of ER across all thresholds and only the ERs which correspond to local maximum of
  125. * the probability P(er|character) are selected (if the local maximum of the probability is above a
  126. * global limit pmin and the difference between local maximum and local minimum is greater than
  127. * minProbabilityDiff).
  128. */
  129. + (ERFilter*)createERFilterNM1:(ERFilterCallback*)cb thresholdDelta:(int)thresholdDelta minArea:(float)minArea maxArea:(float)maxArea minProbability:(float)minProbability nonMaxSuppression:(BOOL)nonMaxSuppression NS_SWIFT_NAME(createERFilterNM1(cb:thresholdDelta:minArea:maxArea:minProbability:nonMaxSuppression:));
  130. /**
  131. * Create an Extremal Region Filter for the 1st stage classifier of N&M algorithm CITE: Neumann12.
  132. *
  133. * loadClassifierNM1, e.g. from file in samples/cpp/trained_classifierNM1.xml
  134. *
  135. * The component tree of the image is extracted by a threshold increased step by step from 0 to 255,
  136. * incrementally computable descriptors (aspect_ratio, compactness, number of holes, and number of
  137. * horizontal crossings) are computed for each ER and used as features for a classifier which estimates
  138. * the class-conditional probability P(er|character). The value of P(er|character) is tracked using the
  139. * inclusion relation of ER across all thresholds and only the ERs which correspond to local maximum of
  140. * the probability P(er|character) are selected (if the local maximum of the probability is above a
  141. * global limit pmin and the difference between local maximum and local minimum is greater than
  142. * minProbabilityDiff).
  143. */
  144. + (ERFilter*)createERFilterNM1:(ERFilterCallback*)cb thresholdDelta:(int)thresholdDelta minArea:(float)minArea maxArea:(float)maxArea minProbability:(float)minProbability NS_SWIFT_NAME(createERFilterNM1(cb:thresholdDelta:minArea:maxArea:minProbability:));
  145. /**
  146. * Create an Extremal Region Filter for the 1st stage classifier of N&M algorithm CITE: Neumann12.
  147. *
  148. * loadClassifierNM1, e.g. from file in samples/cpp/trained_classifierNM1.xml
  149. *
  150. * The component tree of the image is extracted by a threshold increased step by step from 0 to 255,
  151. * incrementally computable descriptors (aspect_ratio, compactness, number of holes, and number of
  152. * horizontal crossings) are computed for each ER and used as features for a classifier which estimates
  153. * the class-conditional probability P(er|character). The value of P(er|character) is tracked using the
  154. * inclusion relation of ER across all thresholds and only the ERs which correspond to local maximum of
  155. * the probability P(er|character) are selected (if the local maximum of the probability is above a
  156. * global limit pmin and the difference between local maximum and local minimum is greater than
  157. * minProbabilityDiff).
  158. */
  159. + (ERFilter*)createERFilterNM1:(ERFilterCallback*)cb thresholdDelta:(int)thresholdDelta minArea:(float)minArea maxArea:(float)maxArea NS_SWIFT_NAME(createERFilterNM1(cb:thresholdDelta:minArea:maxArea:));
  160. /**
  161. * Create an Extremal Region Filter for the 1st stage classifier of N&M algorithm CITE: Neumann12.
  162. *
  163. * loadClassifierNM1, e.g. from file in samples/cpp/trained_classifierNM1.xml
  164. *
  165. * The component tree of the image is extracted by a threshold increased step by step from 0 to 255,
  166. * incrementally computable descriptors (aspect_ratio, compactness, number of holes, and number of
  167. * horizontal crossings) are computed for each ER and used as features for a classifier which estimates
  168. * the class-conditional probability P(er|character). The value of P(er|character) is tracked using the
  169. * inclusion relation of ER across all thresholds and only the ERs which correspond to local maximum of
  170. * the probability P(er|character) are selected (if the local maximum of the probability is above a
  171. * global limit pmin and the difference between local maximum and local minimum is greater than
  172. * minProbabilityDiff).
  173. */
  174. + (ERFilter*)createERFilterNM1:(ERFilterCallback*)cb thresholdDelta:(int)thresholdDelta minArea:(float)minArea NS_SWIFT_NAME(createERFilterNM1(cb:thresholdDelta:minArea:));
  175. /**
  176. * Create an Extremal Region Filter for the 1st stage classifier of N&M algorithm CITE: Neumann12.
  177. *
  178. * loadClassifierNM1, e.g. from file in samples/cpp/trained_classifierNM1.xml
  179. *
  180. * The component tree of the image is extracted by a threshold increased step by step from 0 to 255,
  181. * incrementally computable descriptors (aspect_ratio, compactness, number of holes, and number of
  182. * horizontal crossings) are computed for each ER and used as features for a classifier which estimates
  183. * the class-conditional probability P(er|character). The value of P(er|character) is tracked using the
  184. * inclusion relation of ER across all thresholds and only the ERs which correspond to local maximum of
  185. * the probability P(er|character) are selected (if the local maximum of the probability is above a
  186. * global limit pmin and the difference between local maximum and local minimum is greater than
  187. * minProbabilityDiff).
  188. */
  189. + (ERFilter*)createERFilterNM1:(ERFilterCallback*)cb thresholdDelta:(int)thresholdDelta NS_SWIFT_NAME(createERFilterNM1(cb:thresholdDelta:));
  190. /**
  191. * Create an Extremal Region Filter for the 1st stage classifier of N&M algorithm CITE: Neumann12.
  192. *
  193. * loadClassifierNM1, e.g. from file in samples/cpp/trained_classifierNM1.xml
  194. *
  195. * The component tree of the image is extracted by a threshold increased step by step from 0 to 255,
  196. * incrementally computable descriptors (aspect_ratio, compactness, number of holes, and number of
  197. * horizontal crossings) are computed for each ER and used as features for a classifier which estimates
  198. * the class-conditional probability P(er|character). The value of P(er|character) is tracked using the
  199. * inclusion relation of ER across all thresholds and only the ERs which correspond to local maximum of
  200. * the probability P(er|character) are selected (if the local maximum of the probability is above a
  201. * global limit pmin and the difference between local maximum and local minimum is greater than
  202. * minProbabilityDiff).
  203. */
  204. + (ERFilter*)createERFilterNM1:(ERFilterCallback*)cb NS_SWIFT_NAME(createERFilterNM1(cb:));
  205. //
  206. // Ptr_ERFilter cv::text::createERFilterNM2(Ptr_ERFilter_Callback cb, float minProbability = (float)0.3)
  207. //
  208. /**
  209. * Create an Extremal Region Filter for the 2nd stage classifier of N&M algorithm CITE: Neumann12.
  210. *
  211. * loadClassifierNM2, e.g. from file in samples/cpp/trained_classifierNM2.xml
  212. *
  213. * In the second stage, the ERs that passed the first stage are classified into character and
  214. * non-character classes using more informative but also more computationally expensive features. The
  215. * classifier uses all the features calculated in the first stage and the following additional
  216. * features: hole area ratio, convex hull ratio, and number of outer inflexion points.
  217. */
  218. + (ERFilter*)createERFilterNM2:(ERFilterCallback*)cb minProbability:(float)minProbability NS_SWIFT_NAME(createERFilterNM2(cb:minProbability:));
  219. /**
  220. * Create an Extremal Region Filter for the 2nd stage classifier of N&M algorithm CITE: Neumann12.
  221. *
  222. * loadClassifierNM2, e.g. from file in samples/cpp/trained_classifierNM2.xml
  223. *
  224. * In the second stage, the ERs that passed the first stage are classified into character and
  225. * non-character classes using more informative but also more computationally expensive features. The
  226. * classifier uses all the features calculated in the first stage and the following additional
  227. * features: hole area ratio, convex hull ratio, and number of outer inflexion points.
  228. */
  229. + (ERFilter*)createERFilterNM2:(ERFilterCallback*)cb NS_SWIFT_NAME(createERFilterNM2(cb:));
  230. //
  231. // Ptr_ERFilter cv::text::createERFilterNM1(String filename, int thresholdDelta = 1, float minArea = (float)0.00025, float maxArea = (float)0.13, float minProbability = (float)0.4, bool nonMaxSuppression = true, float minProbabilityDiff = (float)0.1)
  232. //
  233. /**
  234. * Reads an Extremal Region Filter for the 1st stage classifier of N&M algorithm
  235. * from the provided path e.g. /path/to/cpp/trained_classifierNM1.xml
  236. *
  237. */
  238. + (ERFilter*)createERFilterNM1FromFile:(NSString*)filename thresholdDelta:(int)thresholdDelta minArea:(float)minArea maxArea:(float)maxArea minProbability:(float)minProbability nonMaxSuppression:(BOOL)nonMaxSuppression minProbabilityDiff:(float)minProbabilityDiff NS_SWIFT_NAME(createERFilterNM1(filename:thresholdDelta:minArea:maxArea:minProbability:nonMaxSuppression:minProbabilityDiff:));
  239. /**
  240. * Reads an Extremal Region Filter for the 1st stage classifier of N&M algorithm
  241. * from the provided path e.g. /path/to/cpp/trained_classifierNM1.xml
  242. *
  243. */
  244. + (ERFilter*)createERFilterNM1FromFile:(NSString*)filename thresholdDelta:(int)thresholdDelta minArea:(float)minArea maxArea:(float)maxArea minProbability:(float)minProbability nonMaxSuppression:(BOOL)nonMaxSuppression NS_SWIFT_NAME(createERFilterNM1(filename:thresholdDelta:minArea:maxArea:minProbability:nonMaxSuppression:));
  245. /**
  246. * Reads an Extremal Region Filter for the 1st stage classifier of N&M algorithm
  247. * from the provided path e.g. /path/to/cpp/trained_classifierNM1.xml
  248. *
  249. */
  250. + (ERFilter*)createERFilterNM1FromFile:(NSString*)filename thresholdDelta:(int)thresholdDelta minArea:(float)minArea maxArea:(float)maxArea minProbability:(float)minProbability NS_SWIFT_NAME(createERFilterNM1(filename:thresholdDelta:minArea:maxArea:minProbability:));
  251. /**
  252. * Reads an Extremal Region Filter for the 1st stage classifier of N&M algorithm
  253. * from the provided path e.g. /path/to/cpp/trained_classifierNM1.xml
  254. *
  255. */
  256. + (ERFilter*)createERFilterNM1FromFile:(NSString*)filename thresholdDelta:(int)thresholdDelta minArea:(float)minArea maxArea:(float)maxArea NS_SWIFT_NAME(createERFilterNM1(filename:thresholdDelta:minArea:maxArea:));
  257. /**
  258. * Reads an Extremal Region Filter for the 1st stage classifier of N&M algorithm
  259. * from the provided path e.g. /path/to/cpp/trained_classifierNM1.xml
  260. *
  261. */
  262. + (ERFilter*)createERFilterNM1FromFile:(NSString*)filename thresholdDelta:(int)thresholdDelta minArea:(float)minArea NS_SWIFT_NAME(createERFilterNM1(filename:thresholdDelta:minArea:));
  263. /**
  264. * Reads an Extremal Region Filter for the 1st stage classifier of N&M algorithm
  265. * from the provided path e.g. /path/to/cpp/trained_classifierNM1.xml
  266. *
  267. */
  268. + (ERFilter*)createERFilterNM1FromFile:(NSString*)filename thresholdDelta:(int)thresholdDelta NS_SWIFT_NAME(createERFilterNM1(filename:thresholdDelta:));
  269. /**
  270. * Reads an Extremal Region Filter for the 1st stage classifier of N&M algorithm
  271. * from the provided path e.g. /path/to/cpp/trained_classifierNM1.xml
  272. *
  273. */
  274. + (ERFilter*)createERFilterNM1FromFile:(NSString*)filename NS_SWIFT_NAME(createERFilterNM1(filename:));
  275. //
  276. // Ptr_ERFilter cv::text::createERFilterNM2(String filename, float minProbability = (float)0.3)
  277. //
  278. /**
  279. * Reads an Extremal Region Filter for the 2nd stage classifier of N&M algorithm
  280. * from the provided path e.g. /path/to/cpp/trained_classifierNM2.xml
  281. *
  282. */
  283. + (ERFilter*)createERFilterNM2FromFile:(NSString*)filename minProbability:(float)minProbability NS_SWIFT_NAME(createERFilterNM2(filename:minProbability:));
  284. /**
  285. * Reads an Extremal Region Filter for the 2nd stage classifier of N&M algorithm
  286. * from the provided path e.g. /path/to/cpp/trained_classifierNM2.xml
  287. *
  288. */
  289. + (ERFilter*)createERFilterNM2FromFile:(NSString*)filename NS_SWIFT_NAME(createERFilterNM2(filename:));
  290. //
  291. // Ptr_ERFilter_Callback cv::text::loadClassifierNM1(String filename)
  292. //
  293. /**
  294. * Allow to implicitly load the default classifier when creating an ERFilter object.
  295. *
  296. * @param filename The XML or YAML file with the classifier model (e.g. trained_classifierNM1.xml)
  297. *
  298. * returns a pointer to ERFilter::Callback.
  299. */
  300. + (ERFilterCallback*)loadClassifierNM1:(NSString*)filename NS_SWIFT_NAME(loadClassifierNM1(filename:));
  301. //
  302. // Ptr_ERFilter_Callback cv::text::loadClassifierNM2(String filename)
  303. //
  304. /**
  305. * Allow to implicitly load the default classifier when creating an ERFilter object.
  306. *
  307. * @param filename The XML or YAML file with the classifier model (e.g. trained_classifierNM2.xml)
  308. *
  309. * returns a pointer to ERFilter::Callback.
  310. */
  311. + (ERFilterCallback*)loadClassifierNM2:(NSString*)filename NS_SWIFT_NAME(loadClassifierNM2(filename:));
  312. //
  313. // void cv::text::computeNMChannels(Mat _src, vector_Mat& _channels, int _mode = ERFILTER_NM_RGBLGrad)
  314. //
  315. /**
  316. * Compute the different channels to be processed independently in the N&M algorithm CITE: Neumann12.
  317. *
  318. * @param _src Source image. Must be RGB CV_8UC3.
  319. *
  320. * @param _channels Output vector\<Mat\> where computed channels are stored.
  321. *
  322. * @param _mode Mode of operation. Currently the only available options are:
  323. * *ERFILTER_NM_RGBLGrad** (used by default) and **ERFILTER_NM_IHSGrad**.
  324. *
  325. * In N&M algorithm, the combination of intensity (I), hue (H), saturation (S), and gradient magnitude
  326. * channels (Grad) are used in order to obtain high localization recall. This implementation also
  327. * provides an alternative combination of red (R), green (G), blue (B), lightness (L), and gradient
  328. * magnitude (Grad).
  329. */
  330. + (void)computeNMChannels:(Mat*)_src _channels:(NSMutableArray<Mat*>*)_channels _mode:(int)_mode NS_SWIFT_NAME(computeNMChannels(_src:_channels:_mode:));
  331. /**
  332. * Compute the different channels to be processed independently in the N&M algorithm CITE: Neumann12.
  333. *
  334. * @param _src Source image. Must be RGB CV_8UC3.
  335. *
  336. * @param _channels Output vector\<Mat\> where computed channels are stored.
  337. *
  338. * *ERFILTER_NM_RGBLGrad** (used by default) and **ERFILTER_NM_IHSGrad**.
  339. *
  340. * In N&M algorithm, the combination of intensity (I), hue (H), saturation (S), and gradient magnitude
  341. * channels (Grad) are used in order to obtain high localization recall. This implementation also
  342. * provides an alternative combination of red (R), green (G), blue (B), lightness (L), and gradient
  343. * magnitude (Grad).
  344. */
  345. + (void)computeNMChannels:(Mat*)_src _channels:(NSMutableArray<Mat*>*)_channels NS_SWIFT_NAME(computeNMChannels(_src:_channels:));
  346. //
  347. // void cv::text::erGrouping(Mat image, Mat channel, vector_vector_Point regions, vector_Rect& groups_rects, erGrouping_Modes method = ERGROUPING_ORIENTATION_HORIZ, String filename = String(), float minProbablity = (float)0.5)
  348. //
  349. /**
  350. * Find groups of Extremal Regions that are organized as text blocks.
  351. *
  352. *
  353. *
  354. * @param regions Vector of ER's retrieved from the ERFilter algorithm from each channel.
  355. *
  356. * provided regions.
  357. *
  358. * @param groups_rects The output of the algorithm are stored in this parameter as list of rectangles.
  359. *
  360. * @param method Grouping method (see text::erGrouping_Modes). Can be one of ERGROUPING_ORIENTATION_HORIZ,
  361. * ERGROUPING_ORIENTATION_ANY.
  362. *
  363. * @param filename The XML or YAML file with the classifier model (e.g.
  364. * samples/trained_classifier_erGrouping.xml). Only to use when grouping method is
  365. * ERGROUPING_ORIENTATION_ANY.
  366. *
  367. * @param minProbablity The minimum probability for accepting a group. Only to use when grouping
  368. * method is ERGROUPING_ORIENTATION_ANY.
  369. */
  370. + (void)erGrouping:(Mat*)image channel:(Mat*)channel regions:(NSArray<NSArray<Point2i*>*>*)regions groups_rects:(NSMutableArray<Rect2i*>*)groups_rects method:(erGrouping_Modes)method filename:(NSString*)filename minProbablity:(float)minProbablity NS_SWIFT_NAME(erGrouping(image:channel:regions:groups_rects:method:filename:minProbablity:));
  371. /**
  372. * Find groups of Extremal Regions that are organized as text blocks.
  373. *
  374. *
  375. *
  376. * @param regions Vector of ER's retrieved from the ERFilter algorithm from each channel.
  377. *
  378. * provided regions.
  379. *
  380. * @param groups_rects The output of the algorithm are stored in this parameter as list of rectangles.
  381. *
  382. * @param method Grouping method (see text::erGrouping_Modes). Can be one of ERGROUPING_ORIENTATION_HORIZ,
  383. * ERGROUPING_ORIENTATION_ANY.
  384. *
  385. * @param filename The XML or YAML file with the classifier model (e.g.
  386. * samples/trained_classifier_erGrouping.xml). Only to use when grouping method is
  387. * ERGROUPING_ORIENTATION_ANY.
  388. *
  389. * method is ERGROUPING_ORIENTATION_ANY.
  390. */
  391. + (void)erGrouping:(Mat*)image channel:(Mat*)channel regions:(NSArray<NSArray<Point2i*>*>*)regions groups_rects:(NSMutableArray<Rect2i*>*)groups_rects method:(erGrouping_Modes)method filename:(NSString*)filename NS_SWIFT_NAME(erGrouping(image:channel:regions:groups_rects:method:filename:));
  392. /**
  393. * Find groups of Extremal Regions that are organized as text blocks.
  394. *
  395. *
  396. *
  397. * @param regions Vector of ER's retrieved from the ERFilter algorithm from each channel.
  398. *
  399. * provided regions.
  400. *
  401. * @param groups_rects The output of the algorithm are stored in this parameter as list of rectangles.
  402. *
  403. * @param method Grouping method (see text::erGrouping_Modes). Can be one of ERGROUPING_ORIENTATION_HORIZ,
  404. * ERGROUPING_ORIENTATION_ANY.
  405. *
  406. * samples/trained_classifier_erGrouping.xml). Only to use when grouping method is
  407. * ERGROUPING_ORIENTATION_ANY.
  408. *
  409. * method is ERGROUPING_ORIENTATION_ANY.
  410. */
  411. + (void)erGrouping:(Mat*)image channel:(Mat*)channel regions:(NSArray<NSArray<Point2i*>*>*)regions groups_rects:(NSMutableArray<Rect2i*>*)groups_rects method:(erGrouping_Modes)method NS_SWIFT_NAME(erGrouping(image:channel:regions:groups_rects:method:));
  412. /**
  413. * Find groups of Extremal Regions that are organized as text blocks.
  414. *
  415. *
  416. *
  417. * @param regions Vector of ER's retrieved from the ERFilter algorithm from each channel.
  418. *
  419. * provided regions.
  420. *
  421. * @param groups_rects The output of the algorithm are stored in this parameter as list of rectangles.
  422. *
  423. * ERGROUPING_ORIENTATION_ANY.
  424. *
  425. * samples/trained_classifier_erGrouping.xml). Only to use when grouping method is
  426. * ERGROUPING_ORIENTATION_ANY.
  427. *
  428. * method is ERGROUPING_ORIENTATION_ANY.
  429. */
  430. + (void)erGrouping:(Mat*)image channel:(Mat*)channel regions:(NSArray<NSArray<Point2i*>*>*)regions groups_rects:(NSMutableArray<Rect2i*>*)groups_rects NS_SWIFT_NAME(erGrouping(image:channel:regions:groups_rects:));
  431. //
  432. // void cv::text::detectRegions(Mat image, Ptr_ERFilter er_filter1, Ptr_ERFilter er_filter2, vector_vector_Point& regions)
  433. //
  434. /**
  435. * Converts MSER contours (vector\<Point\>) to ERStat regions.
  436. *
  437. * @param image Source image CV_8UC1 from which the MSERs where extracted.
  438. *
  439. *
  440. * @param regions Output where the ERStat regions are stored.
  441. *
  442. * It takes as input the contours provided by the OpenCV MSER feature detector and returns as output
  443. * two vectors of ERStats. This is because MSER() output contains both MSER+ and MSER- regions in a
  444. * single vector\<Point\>, the function separates them in two different vectors (this is as if the
  445. * ERStats where extracted from two different channels).
  446. *
  447. * An example of MSERsToERStats in use can be found in the text detection webcam_demo:
  448. * <https://github.com/opencv/opencv_contrib/blob/master/modules/text/samples/webcam_demo.cpp>
  449. */
  450. + (void)detectRegions:(Mat*)image er_filter1:(ERFilter*)er_filter1 er_filter2:(ERFilter*)er_filter2 regions:(NSMutableArray<NSMutableArray<Point2i*>*>*)regions NS_SWIFT_NAME(detectRegions(image:er_filter1:er_filter2:regions:));
  451. //
  452. // void cv::text::detectRegions(Mat image, Ptr_ERFilter er_filter1, Ptr_ERFilter er_filter2, vector_Rect& groups_rects, erGrouping_Modes method = ERGROUPING_ORIENTATION_HORIZ, String filename = String(), float minProbability = (float)0.5)
  453. //
  454. /**
  455. * Extracts text regions from image.
  456. *
  457. * @param image Source image where text blocks needs to be extracted from. Should be CV_8UC3 (color).
  458. * @param er_filter1 Extremal Region Filter for the 1st stage classifier of N&M algorithm CITE: Neumann12
  459. * @param er_filter2 Extremal Region Filter for the 2nd stage classifier of N&M algorithm CITE: Neumann12
  460. * @param groups_rects Output list of rectangle blocks with text
  461. * @param method Grouping method (see text::erGrouping_Modes). Can be one of ERGROUPING_ORIENTATION_HORIZ, ERGROUPING_ORIENTATION_ANY.
  462. * @param 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.
  463. * @param minProbability The minimum probability for accepting a group. Only to use when grouping method is ERGROUPING_ORIENTATION_ANY.
  464. */
  465. + (void)detectRegions:(Mat*)image er_filter1:(ERFilter*)er_filter1 er_filter2:(ERFilter*)er_filter2 groups_rects:(NSMutableArray<Rect2i*>*)groups_rects method:(erGrouping_Modes)method filename:(NSString*)filename minProbability:(float)minProbability NS_SWIFT_NAME(detectRegions(image:er_filter1:er_filter2:groups_rects:method:filename:minProbability:));
  466. /**
  467. * Extracts text regions from image.
  468. *
  469. * @param image Source image where text blocks needs to be extracted from. Should be CV_8UC3 (color).
  470. * @param er_filter1 Extremal Region Filter for the 1st stage classifier of N&M algorithm CITE: Neumann12
  471. * @param er_filter2 Extremal Region Filter for the 2nd stage classifier of N&M algorithm CITE: Neumann12
  472. * @param groups_rects Output list of rectangle blocks with text
  473. * @param method Grouping method (see text::erGrouping_Modes). Can be one of ERGROUPING_ORIENTATION_HORIZ, ERGROUPING_ORIENTATION_ANY.
  474. * @param 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.
  475. */
  476. + (void)detectRegions:(Mat*)image er_filter1:(ERFilter*)er_filter1 er_filter2:(ERFilter*)er_filter2 groups_rects:(NSMutableArray<Rect2i*>*)groups_rects method:(erGrouping_Modes)method filename:(NSString*)filename NS_SWIFT_NAME(detectRegions(image:er_filter1:er_filter2:groups_rects:method:filename:));
  477. /**
  478. * Extracts text regions from image.
  479. *
  480. * @param image Source image where text blocks needs to be extracted from. Should be CV_8UC3 (color).
  481. * @param er_filter1 Extremal Region Filter for the 1st stage classifier of N&M algorithm CITE: Neumann12
  482. * @param er_filter2 Extremal Region Filter for the 2nd stage classifier of N&M algorithm CITE: Neumann12
  483. * @param groups_rects Output list of rectangle blocks with text
  484. * @param method Grouping method (see text::erGrouping_Modes). Can be one of ERGROUPING_ORIENTATION_HORIZ, ERGROUPING_ORIENTATION_ANY.
  485. */
  486. + (void)detectRegions:(Mat*)image er_filter1:(ERFilter*)er_filter1 er_filter2:(ERFilter*)er_filter2 groups_rects:(NSMutableArray<Rect2i*>*)groups_rects method:(erGrouping_Modes)method NS_SWIFT_NAME(detectRegions(image:er_filter1:er_filter2:groups_rects:method:));
  487. /**
  488. * Extracts text regions from image.
  489. *
  490. * @param image Source image where text blocks needs to be extracted from. Should be CV_8UC3 (color).
  491. * @param er_filter1 Extremal Region Filter for the 1st stage classifier of N&M algorithm CITE: Neumann12
  492. * @param er_filter2 Extremal Region Filter for the 2nd stage classifier of N&M algorithm CITE: Neumann12
  493. * @param groups_rects Output list of rectangle blocks with text
  494. */
  495. + (void)detectRegions:(Mat*)image er_filter1:(ERFilter*)er_filter1 er_filter2:(ERFilter*)er_filter2 groups_rects:(NSMutableArray<Rect2i*>*)groups_rects NS_SWIFT_NAME(detectRegions(image:er_filter1:er_filter2:groups_rects:));
  496. //
  497. // Ptr_OCRHMMDecoder_ClassifierCallback cv::text::loadOCRHMMClassifierNM(String filename)
  498. //
  499. /**
  500. * Allow to implicitly load the default character classifier when creating an OCRHMMDecoder object.
  501. *
  502. * @param filename The XML or YAML file with the classifier model (e.g. OCRHMM_knn_model_data.xml)
  503. *
  504. * The KNN default classifier is based in the scene text recognition method proposed by Lukás Neumann &
  505. * Jiri Matas in [Neumann11b]. Basically, the region (contour) in the input image is normalized to a
  506. * fixed size, while retaining the centroid and aspect ratio, in order to extract a feature vector
  507. * based on gradient orientations along the chain-code of its perimeter. Then, the region is classified
  508. * using a KNN model trained with synthetic data of rendered characters with different standard font
  509. * types.
  510. *
  511. * @deprecated loadOCRHMMClassifier instead
  512. */
  513. + (OCRHMMDecoderClassifierCallback*)loadOCRHMMClassifierNM:(NSString*)filename NS_SWIFT_NAME(loadOCRHMMClassifierNM(filename:)) DEPRECATED_ATTRIBUTE;
  514. //
  515. // Ptr_OCRHMMDecoder_ClassifierCallback cv::text::loadOCRHMMClassifierCNN(String filename)
  516. //
  517. /**
  518. * Allow to implicitly load the default character classifier when creating an OCRHMMDecoder object.
  519. *
  520. * @param filename The XML or YAML file with the classifier model (e.g. OCRBeamSearch_CNN_model_data.xml.gz)
  521. *
  522. * The CNN default classifier is based in the scene text recognition method proposed by Adam Coates &
  523. * Andrew NG in [Coates11a]. The character classifier consists in a Single Layer Convolutional Neural Network and
  524. * a linear classifier. It is applied to the input image in a sliding window fashion, providing a set of recognitions
  525. * at each window location.
  526. *
  527. * @deprecated use loadOCRHMMClassifier instead
  528. */
  529. + (OCRHMMDecoderClassifierCallback*)loadOCRHMMClassifierCNN:(NSString*)filename NS_SWIFT_NAME(loadOCRHMMClassifierCNN(filename:)) DEPRECATED_ATTRIBUTE;
  530. //
  531. // Ptr_OCRHMMDecoder_ClassifierCallback cv::text::loadOCRHMMClassifier(String filename, classifier_type classifier)
  532. //
  533. /**
  534. * Allow to implicitly load the default character classifier when creating an OCRHMMDecoder object.
  535. *
  536. * @param filename The XML or YAML file with the classifier model (e.g. OCRBeamSearch_CNN_model_data.xml.gz)
  537. *
  538. * @param classifier Can be one of classifier_type enum values.
  539. */
  540. + (OCRHMMDecoderClassifierCallback*)loadOCRHMMClassifier:(NSString*)filename classifier:(classifier_type)classifier NS_SWIFT_NAME(loadOCRHMMClassifier(filename:classifier:));
  541. //
  542. // Mat cv::text::createOCRHMMTransitionsTable(String vocabulary, vector_String lexicon)
  543. //
  544. /**
  545. * Utility function to create a tailored language model transitions table from a given list of words (lexicon).
  546. *
  547. * @param vocabulary The language vocabulary (chars when ASCII English text).
  548. *
  549. * @param lexicon The list of words that are expected to be found in a particular image.
  550. *
  551. *
  552. * 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.
  553. * NOTE:
  554. * - (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) :
  555. * <https://github.com/opencv/opencv_contrib/blob/master/modules/text/samples/OCRHMM_transitions_table.xml>
  556. *
  557. */
  558. + (Mat*)createOCRHMMTransitionsTable:(NSString*)vocabulary lexicon:(NSArray<NSString*>*)lexicon NS_SWIFT_NAME(createOCRHMMTransitionsTable(vocabulary:lexicon:));
  559. //
  560. // Ptr_OCRBeamSearchDecoder_ClassifierCallback cv::text::loadOCRBeamSearchClassifierCNN(String filename)
  561. //
  562. /**
  563. * Allow to implicitly load the default character classifier when creating an OCRBeamSearchDecoder object.
  564. *
  565. * @param filename The XML or YAML file with the classifier model (e.g. OCRBeamSearch_CNN_model_data.xml.gz)
  566. *
  567. * The CNN default classifier is based in the scene text recognition method proposed by Adam Coates &
  568. * Andrew NG in [Coates11a]. The character classifier consists in a Single Layer Convolutional Neural Network and
  569. * a linear classifier. It is applied to the input image in a sliding window fashion, providing a set of recognitions
  570. * at each window location.
  571. */
  572. + (OCRBeamSearchDecoderClassifierCallback*)loadOCRBeamSearchClassifierCNN:(NSString*)filename NS_SWIFT_NAME(loadOCRBeamSearchClassifierCNN(filename:));
  573. @end
  574. NS_ASSUME_NONNULL_END