|
|
|
@ -51,6 +51,7 @@ |
|
|
|
|
#include "opencv2/imgproc/imgproc.hpp" |
|
|
|
|
#include "opencv2/objdetect/objdetect.hpp" |
|
|
|
|
#include "opencv2/features2d/features2d.hpp" |
|
|
|
|
#include "opencv2/ml/ml.hpp" |
|
|
|
|
|
|
|
|
|
namespace cv |
|
|
|
|
{ |
|
|
|
@ -1892,6 +1893,29 @@ namespace cv |
|
|
|
|
{ |
|
|
|
|
return (total + grain - 1) / grain; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/*!***************K Nearest Neighbour*************!*/ |
|
|
|
|
class CV_EXPORTS KNearestNeighbour: public CvKNearest |
|
|
|
|
{ |
|
|
|
|
public: |
|
|
|
|
KNearestNeighbour(); |
|
|
|
|
~KNearestNeighbour(); |
|
|
|
|
KNearestNeighbour(const Mat& trainData, const Mat& labels, |
|
|
|
|
const Mat& sampleIdx = Mat().setTo(Scalar::all(0)), bool isRegression = false, int max_k = 32); |
|
|
|
|
|
|
|
|
|
bool train(const Mat& trainData, Mat& labels, Mat& sampleIdx = Mat().setTo(Scalar::all(0)), |
|
|
|
|
bool isRegression = false, int max_k = 32, bool updateBase = false); |
|
|
|
|
|
|
|
|
|
void clear(); |
|
|
|
|
|
|
|
|
|
void find_nearest(const oclMat& samples, int k, oclMat& lables); |
|
|
|
|
|
|
|
|
|
private: |
|
|
|
|
int max_k, var_count; |
|
|
|
|
int total; |
|
|
|
|
bool regression; |
|
|
|
|
oclMat samples_ocl; |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
#if defined _MSC_VER && _MSC_VER >= 1200 |
|
|
|
|