StatModel.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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 "Algorithm.h"
  13. @class Mat;
  14. @class TrainData;
  15. // C++: enum StatModelFlags (cv.ml.StatModel.Flags)
  16. typedef NS_ENUM(int, StatModelFlags) {
  17. UPDATE_MODEL = 1,
  18. RAW_OUTPUT = 1,
  19. COMPRESSED_INPUT = 2,
  20. PREPROCESSED_INPUT = 4
  21. };
  22. NS_ASSUME_NONNULL_BEGIN
  23. // C++: class StatModel
  24. /**
  25. * Base class for statistical models in OpenCV ML.
  26. *
  27. * Member of `Ml`
  28. */
  29. CV_EXPORTS @interface StatModel : Algorithm
  30. #ifdef __cplusplus
  31. @property(readonly)cv::Ptr<cv::ml::StatModel> nativePtrStatModel;
  32. #endif
  33. #ifdef __cplusplus
  34. - (instancetype)initWithNativePtr:(cv::Ptr<cv::ml::StatModel>)nativePtr;
  35. + (instancetype)fromNative:(cv::Ptr<cv::ml::StatModel>)nativePtr;
  36. #endif
  37. #pragma mark - Methods
  38. //
  39. // int cv::ml::StatModel::getVarCount()
  40. //
  41. /**
  42. * Returns the number of variables in training samples
  43. */
  44. - (int)getVarCount NS_SWIFT_NAME(getVarCount());
  45. //
  46. // bool cv::ml::StatModel::empty()
  47. //
  48. - (BOOL)empty NS_SWIFT_NAME(empty());
  49. //
  50. // bool cv::ml::StatModel::isTrained()
  51. //
  52. /**
  53. * Returns true if the model is trained
  54. */
  55. - (BOOL)isTrained NS_SWIFT_NAME(isTrained());
  56. //
  57. // bool cv::ml::StatModel::isClassifier()
  58. //
  59. /**
  60. * Returns true if the model is classifier
  61. */
  62. - (BOOL)isClassifier NS_SWIFT_NAME(isClassifier());
  63. //
  64. // bool cv::ml::StatModel::train(Ptr_TrainData trainData, int flags = 0)
  65. //
  66. /**
  67. * Trains the statistical model
  68. *
  69. * @param trainData training data that can be loaded from file using TrainData::loadFromCSV or
  70. * created with TrainData::create.
  71. * @param flags optional flags, depending on the model. Some of the models can be updated with the
  72. * new training samples, not completely overwritten (such as NormalBayesClassifier or ANN_MLP).
  73. */
  74. - (BOOL)train:(TrainData*)trainData flags:(int)flags NS_SWIFT_NAME(train(trainData:flags:));
  75. /**
  76. * Trains the statistical model
  77. *
  78. * @param trainData training data that can be loaded from file using TrainData::loadFromCSV or
  79. * created with TrainData::create.
  80. * new training samples, not completely overwritten (such as NormalBayesClassifier or ANN_MLP).
  81. */
  82. - (BOOL)train:(TrainData*)trainData NS_SWIFT_NAME(train(trainData:));
  83. //
  84. // bool cv::ml::StatModel::train(Mat samples, int layout, Mat responses)
  85. //
  86. /**
  87. * Trains the statistical model
  88. *
  89. * @param samples training samples
  90. * @param layout See ml::SampleTypes.
  91. * @param responses vector of responses associated with the training samples.
  92. */
  93. - (BOOL)train:(Mat*)samples layout:(int)layout responses:(Mat*)responses NS_SWIFT_NAME(train(samples:layout:responses:));
  94. //
  95. // float cv::ml::StatModel::calcError(Ptr_TrainData data, bool test, Mat& resp)
  96. //
  97. /**
  98. * Computes error on the training or test dataset
  99. *
  100. * @param data the training data
  101. * @param test if true, the error is computed over the test subset of the data, otherwise it's
  102. * computed over the training subset of the data. Please note that if you loaded a completely
  103. * different dataset to evaluate already trained classifier, you will probably want not to set
  104. * the test subset at all with TrainData::setTrainTestSplitRatio and specify test=false, so
  105. * that the error is computed for the whole new set. Yes, this sounds a bit confusing.
  106. * @param resp the optional output responses.
  107. *
  108. * The method uses StatModel::predict to compute the error. For regression models the error is
  109. * computed as RMS, for classifiers - as a percent of missclassified samples (0%-100%).
  110. */
  111. - (float)calcError:(TrainData*)data test:(BOOL)test resp:(Mat*)resp NS_SWIFT_NAME(calcError(data:test:resp:));
  112. //
  113. // float cv::ml::StatModel::predict(Mat samples, Mat& results = Mat(), int flags = 0)
  114. //
  115. /**
  116. * Predicts response(s) for the provided sample(s)
  117. *
  118. * @param samples The input samples, floating-point matrix
  119. * @param results The optional output matrix of results.
  120. * @param flags The optional flags, model-dependent. See cv::ml::StatModel::Flags.
  121. */
  122. - (float)predict:(Mat*)samples results:(Mat*)results flags:(int)flags NS_SWIFT_NAME(predict(samples:results:flags:));
  123. /**
  124. * Predicts response(s) for the provided sample(s)
  125. *
  126. * @param samples The input samples, floating-point matrix
  127. * @param results The optional output matrix of results.
  128. */
  129. - (float)predict:(Mat*)samples results:(Mat*)results NS_SWIFT_NAME(predict(samples:results:));
  130. /**
  131. * Predicts response(s) for the provided sample(s)
  132. *
  133. * @param samples The input samples, floating-point matrix
  134. */
  135. - (float)predict:(Mat*)samples NS_SWIFT_NAME(predict(samples:));
  136. @end
  137. NS_ASSUME_NONNULL_END