TextRecognitionModel.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  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/dnn.hpp"
  8. #import "opencv2/dnn/dnn.hpp"
  9. #else
  10. #define CV_EXPORTS
  11. #endif
  12. #import <Foundation/Foundation.h>
  13. #import "Model.h"
  14. @class Mat;
  15. @class Net;
  16. NS_ASSUME_NONNULL_BEGIN
  17. // C++: class TextRecognitionModel
  18. /**
  19. * This class represents high-level API for text recognition networks.
  20. *
  21. * TextRecognitionModel allows to set params for preprocessing input image.
  22. * TextRecognitionModel creates net from file with trained weights and config,
  23. * sets preprocessing input, runs forward pass and return recognition result.
  24. * For TextRecognitionModel, CRNN-CTC is supported.
  25. *
  26. * Member of `Dnn`
  27. */
  28. CV_EXPORTS @interface TextRecognitionModel : Model
  29. #ifdef __cplusplus
  30. @property(readonly)cv::Ptr<cv::dnn::TextRecognitionModel> nativePtrTextRecognitionModel;
  31. #endif
  32. #ifdef __cplusplus
  33. - (instancetype)initWithNativePtr:(cv::Ptr<cv::dnn::TextRecognitionModel>)nativePtr;
  34. + (instancetype)fromNative:(cv::Ptr<cv::dnn::TextRecognitionModel>)nativePtr;
  35. #endif
  36. #pragma mark - Methods
  37. //
  38. // cv::dnn::TextRecognitionModel::TextRecognitionModel(Net network)
  39. //
  40. /**
  41. * Create Text Recognition model from deep learning network
  42. * Call setDecodeType() and setVocabulary() after constructor to initialize the decoding method
  43. * @param network Net object
  44. */
  45. - (instancetype)initWithNetwork:(Net*)network;
  46. //
  47. // cv::dnn::TextRecognitionModel::TextRecognitionModel(string model, string config = "")
  48. //
  49. /**
  50. * Create text recognition model from network represented in one of the supported formats
  51. * Call setDecodeType() and setVocabulary() after constructor to initialize the decoding method
  52. * @param model Binary file contains trained weights
  53. * @param config Text file contains network configuration
  54. */
  55. - (instancetype)initWithModel:(NSString*)model config:(NSString*)config;
  56. /**
  57. * Create text recognition model from network represented in one of the supported formats
  58. * Call setDecodeType() and setVocabulary() after constructor to initialize the decoding method
  59. * @param model Binary file contains trained weights
  60. */
  61. - (instancetype)initWithModel:(NSString*)model;
  62. //
  63. // TextRecognitionModel cv::dnn::TextRecognitionModel::setDecodeType(string decodeType)
  64. //
  65. /**
  66. * Set the decoding method of translating the network output into string
  67. * @param decodeType The decoding method of translating the network output into string, currently supported type:
  68. * - `"CTC-greedy"` greedy decoding for the output of CTC-based methods
  69. * - `"CTC-prefix-beam-search"` Prefix beam search decoding for the output of CTC-based methods
  70. */
  71. - (TextRecognitionModel*)setDecodeType:(NSString*)decodeType NS_SWIFT_NAME(setDecodeType(decodeType:));
  72. //
  73. // string cv::dnn::TextRecognitionModel::getDecodeType()
  74. //
  75. /**
  76. * Get the decoding method
  77. * @return the decoding method
  78. */
  79. - (NSString*)getDecodeType NS_SWIFT_NAME(getDecodeType());
  80. //
  81. // TextRecognitionModel cv::dnn::TextRecognitionModel::setDecodeOptsCTCPrefixBeamSearch(int beamSize, int vocPruneSize = 0)
  82. //
  83. /**
  84. * Set the decoding method options for `"CTC-prefix-beam-search"` decode usage
  85. * @param beamSize Beam size for search
  86. * @param vocPruneSize Parameter to optimize big vocabulary search,
  87. * only take top @p vocPruneSize tokens in each search step, @p vocPruneSize <= 0 stands for disable this prune.
  88. */
  89. - (TextRecognitionModel*)setDecodeOptsCTCPrefixBeamSearch:(int)beamSize vocPruneSize:(int)vocPruneSize NS_SWIFT_NAME(setDecodeOptsCTCPrefixBeamSearch(beamSize:vocPruneSize:));
  90. /**
  91. * Set the decoding method options for `"CTC-prefix-beam-search"` decode usage
  92. * @param beamSize Beam size for search
  93. * only take top @p vocPruneSize tokens in each search step, @p vocPruneSize <= 0 stands for disable this prune.
  94. */
  95. - (TextRecognitionModel*)setDecodeOptsCTCPrefixBeamSearch:(int)beamSize NS_SWIFT_NAME(setDecodeOptsCTCPrefixBeamSearch(beamSize:));
  96. //
  97. // TextRecognitionModel cv::dnn::TextRecognitionModel::setVocabulary(vector_string vocabulary)
  98. //
  99. /**
  100. * Set the vocabulary for recognition.
  101. * @param vocabulary the associated vocabulary of the network.
  102. */
  103. - (TextRecognitionModel*)setVocabulary:(NSArray<NSString*>*)vocabulary NS_SWIFT_NAME(setVocabulary(vocabulary:));
  104. //
  105. // vector_string cv::dnn::TextRecognitionModel::getVocabulary()
  106. //
  107. /**
  108. * Get the vocabulary for recognition.
  109. * @return vocabulary the associated vocabulary
  110. */
  111. - (NSArray<NSString*>*)getVocabulary NS_SWIFT_NAME(getVocabulary());
  112. //
  113. // string cv::dnn::TextRecognitionModel::recognize(Mat frame)
  114. //
  115. /**
  116. * Given the @p input frame, create input blob, run net and return recognition result
  117. * @param frame The input image
  118. * @return The text recognition result
  119. */
  120. - (NSString*)recognize:(Mat*)frame NS_SWIFT_NAME(recognize(frame:));
  121. //
  122. // void cv::dnn::TextRecognitionModel::recognize(Mat frame, vector_Mat roiRects, vector_string& results)
  123. //
  124. /**
  125. * Given the @p input frame, create input blob, run net and return recognition result
  126. * @param frame The input image
  127. * @param roiRects List of text detection regions of interest (cv::Rect, CV_32SC4). ROIs is be cropped as the network inputs
  128. * @param results A set of text recognition results.
  129. */
  130. - (void)recognize:(Mat*)frame roiRects:(NSArray<Mat*>*)roiRects results:(NSMutableArray<NSString*>*)results NS_SWIFT_NAME(recognize(frame:roiRects:results:));
  131. @end
  132. NS_ASSUME_NONNULL_END