Model.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  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 "Dnn.h"
  14. @class Mat;
  15. @class Net;
  16. @class Scalar;
  17. @class Size2i;
  18. NS_ASSUME_NONNULL_BEGIN
  19. // C++: class Model
  20. /**
  21. * This class is presented high-level API for neural networks.
  22. *
  23. * Model allows to set params for preprocessing input image.
  24. * Model creates net from file with trained weights and config,
  25. * sets preprocessing input and runs forward pass.
  26. *
  27. * Member of `Dnn`
  28. */
  29. CV_EXPORTS @interface Model : NSObject
  30. #ifdef __cplusplus
  31. @property(readonly)cv::Ptr<cv::dnn::Model> nativePtr;
  32. #endif
  33. #ifdef __cplusplus
  34. - (instancetype)initWithNativePtr:(cv::Ptr<cv::dnn::Model>)nativePtr;
  35. + (instancetype)fromNative:(cv::Ptr<cv::dnn::Model>)nativePtr;
  36. #endif
  37. #pragma mark - Methods
  38. //
  39. // cv::dnn::Model::Model(String model, String config = "")
  40. //
  41. /**
  42. * Create model from deep learning network represented in one of the supported formats.
  43. * An order of @p model and @p config arguments does not matter.
  44. * @param model Binary file contains trained weights.
  45. * @param config Text file contains network configuration.
  46. */
  47. - (instancetype)initWithModel:(NSString*)model config:(NSString*)config;
  48. /**
  49. * Create model from deep learning network represented in one of the supported formats.
  50. * An order of @p model and @p config arguments does not matter.
  51. * @param model Binary file contains trained weights.
  52. */
  53. - (instancetype)initWithModel:(NSString*)model;
  54. //
  55. // cv::dnn::Model::Model(Net network)
  56. //
  57. /**
  58. * Create model from deep learning network.
  59. * @param network Net object.
  60. */
  61. - (instancetype)initWithNetwork:(Net*)network;
  62. //
  63. // Model cv::dnn::Model::setInputSize(Size size)
  64. //
  65. /**
  66. * Set input size for frame.
  67. * @param size New input size.
  68. * NOTE: If shape of the new blob less than 0, then frame size not change.
  69. */
  70. - (Model*)setInputSize:(Size2i*)size NS_SWIFT_NAME(setInputSize(size:));
  71. //
  72. // Model cv::dnn::Model::setInputSize(int width, int height)
  73. //
  74. /**
  75. *
  76. * @param width New input width.
  77. * @param height New input height.
  78. */
  79. - (Model*)setInputSize:(int)width height:(int)height NS_SWIFT_NAME(setInputSize(width:height:));
  80. //
  81. // Model cv::dnn::Model::setInputMean(Scalar mean)
  82. //
  83. /**
  84. * Set mean value for frame.
  85. * @param mean Scalar with mean values which are subtracted from channels.
  86. */
  87. - (Model*)setInputMean:(Scalar*)mean NS_SWIFT_NAME(setInputMean(mean:));
  88. //
  89. // Model cv::dnn::Model::setInputScale(double scale)
  90. //
  91. /**
  92. * Set scalefactor value for frame.
  93. * @param scale Multiplier for frame values.
  94. */
  95. - (Model*)setInputScale:(double)scale NS_SWIFT_NAME(setInputScale(scale:));
  96. //
  97. // Model cv::dnn::Model::setInputCrop(bool crop)
  98. //
  99. /**
  100. * Set flag crop for frame.
  101. * @param crop Flag which indicates whether image will be cropped after resize or not.
  102. */
  103. - (Model*)setInputCrop:(BOOL)crop NS_SWIFT_NAME(setInputCrop(crop:));
  104. //
  105. // Model cv::dnn::Model::setInputSwapRB(bool swapRB)
  106. //
  107. /**
  108. * Set flag swapRB for frame.
  109. * @param swapRB Flag which indicates that swap first and last channels.
  110. */
  111. - (Model*)setInputSwapRB:(BOOL)swapRB NS_SWIFT_NAME(setInputSwapRB(swapRB:));
  112. //
  113. // void cv::dnn::Model::setInputParams(double scale = 1.0, Size size = Size(), Scalar mean = Scalar(), bool swapRB = false, bool crop = false)
  114. //
  115. /**
  116. * Set preprocessing parameters for frame.
  117. * @param size New input size.
  118. * @param mean Scalar with mean values which are subtracted from channels.
  119. * @param scale Multiplier for frame values.
  120. * @param swapRB Flag which indicates that swap first and last channels.
  121. * @param crop Flag which indicates whether image will be cropped after resize or not.
  122. * blob(n, c, y, x) = scale * resize( frame(y, x, c) ) - mean(c) )
  123. */
  124. - (void)setInputParams:(double)scale size:(Size2i*)size mean:(Scalar*)mean swapRB:(BOOL)swapRB crop:(BOOL)crop NS_SWIFT_NAME(setInputParams(scale:size:mean:swapRB:crop:));
  125. /**
  126. * Set preprocessing parameters for frame.
  127. * @param size New input size.
  128. * @param mean Scalar with mean values which are subtracted from channels.
  129. * @param scale Multiplier for frame values.
  130. * @param swapRB Flag which indicates that swap first and last channels.
  131. * blob(n, c, y, x) = scale * resize( frame(y, x, c) ) - mean(c) )
  132. */
  133. - (void)setInputParams:(double)scale size:(Size2i*)size mean:(Scalar*)mean swapRB:(BOOL)swapRB NS_SWIFT_NAME(setInputParams(scale:size:mean:swapRB:));
  134. /**
  135. * Set preprocessing parameters for frame.
  136. * @param size New input size.
  137. * @param mean Scalar with mean values which are subtracted from channels.
  138. * @param scale Multiplier for frame values.
  139. * blob(n, c, y, x) = scale * resize( frame(y, x, c) ) - mean(c) )
  140. */
  141. - (void)setInputParams:(double)scale size:(Size2i*)size mean:(Scalar*)mean NS_SWIFT_NAME(setInputParams(scale:size:mean:));
  142. /**
  143. * Set preprocessing parameters for frame.
  144. * @param size New input size.
  145. * @param scale Multiplier for frame values.
  146. * blob(n, c, y, x) = scale * resize( frame(y, x, c) ) - mean(c) )
  147. */
  148. - (void)setInputParams:(double)scale size:(Size2i*)size NS_SWIFT_NAME(setInputParams(scale:size:));
  149. /**
  150. * Set preprocessing parameters for frame.
  151. * @param scale Multiplier for frame values.
  152. * blob(n, c, y, x) = scale * resize( frame(y, x, c) ) - mean(c) )
  153. */
  154. - (void)setInputParams:(double)scale NS_SWIFT_NAME(setInputParams(scale:));
  155. /**
  156. * Set preprocessing parameters for frame.
  157. * blob(n, c, y, x) = scale * resize( frame(y, x, c) ) - mean(c) )
  158. */
  159. - (void)setInputParams NS_SWIFT_NAME(setInputParams());
  160. //
  161. // void cv::dnn::Model::predict(Mat frame, vector_Mat& outs)
  162. //
  163. /**
  164. * Given the @p input frame, create input blob, run net and return the output @p blobs.
  165. * @param outs Allocated output blobs, which will store results of the computation.
  166. */
  167. - (void)predict:(Mat*)frame outs:(NSMutableArray<Mat*>*)outs NS_SWIFT_NAME(predict(frame:outs:));
  168. //
  169. // Model cv::dnn::Model::setPreferableBackend(dnn_Backend backendId)
  170. //
  171. - (Model*)setPreferableBackend:(Backend)backendId NS_SWIFT_NAME(setPreferableBackend(backendId:));
  172. //
  173. // Model cv::dnn::Model::setPreferableTarget(dnn_Target targetId)
  174. //
  175. - (Model*)setPreferableTarget:(Target)targetId NS_SWIFT_NAME(setPreferableTarget(targetId:));
  176. @end
  177. NS_ASSUME_NONNULL_END