KNearest.h 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  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/ml.hpp"
  8. #else
  9. #define CV_EXPORTS
  10. #endif
  11. #import <Foundation/Foundation.h>
  12. #import "StatModel.h"
  13. @class Mat;
  14. // C++: enum KNearestTypes (cv.ml.KNearest.Types)
  15. typedef NS_ENUM(int, KNearestTypes) {
  16. BRUTE_FORCE = 1,
  17. KDTREE = 2
  18. };
  19. NS_ASSUME_NONNULL_BEGIN
  20. // C++: class KNearest
  21. /**
  22. * The class implements K-Nearest Neighbors model
  23. *
  24. * @see REF: ml_intro_knn
  25. *
  26. * Member of `Ml`
  27. */
  28. CV_EXPORTS @interface KNearest : StatModel
  29. #ifdef __cplusplus
  30. @property(readonly)cv::Ptr<cv::ml::KNearest> nativePtrKNearest;
  31. #endif
  32. #ifdef __cplusplus
  33. - (instancetype)initWithNativePtr:(cv::Ptr<cv::ml::KNearest>)nativePtr;
  34. + (instancetype)fromNative:(cv::Ptr<cv::ml::KNearest>)nativePtr;
  35. #endif
  36. #pragma mark - Methods
  37. //
  38. // int cv::ml::KNearest::getDefaultK()
  39. //
  40. /**
  41. * @see `-setDefaultK:`
  42. */
  43. - (int)getDefaultK NS_SWIFT_NAME(getDefaultK());
  44. //
  45. // void cv::ml::KNearest::setDefaultK(int val)
  46. //
  47. /**
  48. * getDefaultK @see `-getDefaultK:`
  49. */
  50. - (void)setDefaultK:(int)val NS_SWIFT_NAME(setDefaultK(val:));
  51. //
  52. // bool cv::ml::KNearest::getIsClassifier()
  53. //
  54. /**
  55. * @see `-setIsClassifier:`
  56. */
  57. - (BOOL)getIsClassifier NS_SWIFT_NAME(getIsClassifier());
  58. //
  59. // void cv::ml::KNearest::setIsClassifier(bool val)
  60. //
  61. /**
  62. * getIsClassifier @see `-getIsClassifier:`
  63. */
  64. - (void)setIsClassifier:(BOOL)val NS_SWIFT_NAME(setIsClassifier(val:));
  65. //
  66. // int cv::ml::KNearest::getEmax()
  67. //
  68. /**
  69. * @see `-setEmax:`
  70. */
  71. - (int)getEmax NS_SWIFT_NAME(getEmax());
  72. //
  73. // void cv::ml::KNearest::setEmax(int val)
  74. //
  75. /**
  76. * getEmax @see `-getEmax:`
  77. */
  78. - (void)setEmax:(int)val NS_SWIFT_NAME(setEmax(val:));
  79. //
  80. // int cv::ml::KNearest::getAlgorithmType()
  81. //
  82. /**
  83. * @see `-setAlgorithmType:`
  84. */
  85. - (int)getAlgorithmType NS_SWIFT_NAME(getAlgorithmType());
  86. //
  87. // void cv::ml::KNearest::setAlgorithmType(int val)
  88. //
  89. /**
  90. * getAlgorithmType @see `-getAlgorithmType:`
  91. */
  92. - (void)setAlgorithmType:(int)val NS_SWIFT_NAME(setAlgorithmType(val:));
  93. //
  94. // float cv::ml::KNearest::findNearest(Mat samples, int k, Mat& results, Mat& neighborResponses = Mat(), Mat& dist = Mat())
  95. //
  96. /**
  97. * Finds the neighbors and predicts responses for input vectors.
  98. *
  99. * @param samples Input samples stored by rows. It is a single-precision floating-point matrix of
  100. * `<number_of_samples> * k` size.
  101. * @param k Number of used nearest neighbors. Should be greater than 1.
  102. * @param results Vector with results of prediction (regression or classification) for each input
  103. * sample. It is a single-precision floating-point vector with `<number_of_samples>` elements.
  104. * @param neighborResponses Optional output values for corresponding neighbors. It is a single-
  105. * precision floating-point matrix of `<number_of_samples> * k` size.
  106. * @param dist Optional output distances from the input vectors to the corresponding neighbors. It
  107. * is a single-precision floating-point matrix of `<number_of_samples> * k` size.
  108. *
  109. * For each input vector (a row of the matrix samples), the method finds the k nearest neighbors.
  110. * In case of regression, the predicted result is a mean value of the particular vector's neighbor
  111. * responses. In case of classification, the class is determined by voting.
  112. *
  113. * For each input vector, the neighbors are sorted by their distances to the vector.
  114. *
  115. * In case of C++ interface you can use output pointers to empty matrices and the function will
  116. * allocate memory itself.
  117. *
  118. * If only a single input vector is passed, all output matrices are optional and the predicted
  119. * value is returned by the method.
  120. *
  121. * The function is parallelized with the TBB library.
  122. */
  123. - (float)findNearest:(Mat*)samples k:(int)k results:(Mat*)results neighborResponses:(Mat*)neighborResponses dist:(Mat*)dist NS_SWIFT_NAME(findNearest(samples:k:results:neighborResponses:dist:));
  124. /**
  125. * Finds the neighbors and predicts responses for input vectors.
  126. *
  127. * @param samples Input samples stored by rows. It is a single-precision floating-point matrix of
  128. * `<number_of_samples> * k` size.
  129. * @param k Number of used nearest neighbors. Should be greater than 1.
  130. * @param results Vector with results of prediction (regression or classification) for each input
  131. * sample. It is a single-precision floating-point vector with `<number_of_samples>` elements.
  132. * @param neighborResponses Optional output values for corresponding neighbors. It is a single-
  133. * precision floating-point matrix of `<number_of_samples> * k` size.
  134. * is a single-precision floating-point matrix of `<number_of_samples> * k` size.
  135. *
  136. * For each input vector (a row of the matrix samples), the method finds the k nearest neighbors.
  137. * In case of regression, the predicted result is a mean value of the particular vector's neighbor
  138. * responses. In case of classification, the class is determined by voting.
  139. *
  140. * For each input vector, the neighbors are sorted by their distances to the vector.
  141. *
  142. * In case of C++ interface you can use output pointers to empty matrices and the function will
  143. * allocate memory itself.
  144. *
  145. * If only a single input vector is passed, all output matrices are optional and the predicted
  146. * value is returned by the method.
  147. *
  148. * The function is parallelized with the TBB library.
  149. */
  150. - (float)findNearest:(Mat*)samples k:(int)k results:(Mat*)results neighborResponses:(Mat*)neighborResponses NS_SWIFT_NAME(findNearest(samples:k:results:neighborResponses:));
  151. /**
  152. * Finds the neighbors and predicts responses for input vectors.
  153. *
  154. * @param samples Input samples stored by rows. It is a single-precision floating-point matrix of
  155. * `<number_of_samples> * k` size.
  156. * @param k Number of used nearest neighbors. Should be greater than 1.
  157. * @param results Vector with results of prediction (regression or classification) for each input
  158. * sample. It is a single-precision floating-point vector with `<number_of_samples>` elements.
  159. * precision floating-point matrix of `<number_of_samples> * k` size.
  160. * is a single-precision floating-point matrix of `<number_of_samples> * k` size.
  161. *
  162. * For each input vector (a row of the matrix samples), the method finds the k nearest neighbors.
  163. * In case of regression, the predicted result is a mean value of the particular vector's neighbor
  164. * responses. In case of classification, the class is determined by voting.
  165. *
  166. * For each input vector, the neighbors are sorted by their distances to the vector.
  167. *
  168. * In case of C++ interface you can use output pointers to empty matrices and the function will
  169. * allocate memory itself.
  170. *
  171. * If only a single input vector is passed, all output matrices are optional and the predicted
  172. * value is returned by the method.
  173. *
  174. * The function is parallelized with the TBB library.
  175. */
  176. - (float)findNearest:(Mat*)samples k:(int)k results:(Mat*)results NS_SWIFT_NAME(findNearest(samples:k:results:));
  177. //
  178. // static Ptr_KNearest cv::ml::KNearest::create()
  179. //
  180. /**
  181. * Creates the empty model
  182. *
  183. * The static method creates empty %KNearest classifier. It should be then trained using StatModel::train method.
  184. */
  185. + (KNearest*)create NS_SWIFT_NAME(create());
  186. //
  187. // static Ptr_KNearest cv::ml::KNearest::load(String filepath)
  188. //
  189. /**
  190. * Loads and creates a serialized knearest from a file
  191. *
  192. * Use KNearest::save to serialize and store an KNearest to disk.
  193. * Load the KNearest from this file again, by calling this function with the path to the file.
  194. *
  195. * @param filepath path to serialized KNearest
  196. */
  197. + (KNearest*)load:(NSString*)filepath NS_SWIFT_NAME(load(filepath:));
  198. @end
  199. NS_ASSUME_NONNULL_END