001//
002// This file is auto-generated. Please don't modify it!
003//
004package org.opencv.ml;
005
006import org.opencv.core.Mat;
007import org.opencv.ml.KNearest;
008import org.opencv.ml.StatModel;
009
010// C++: class KNearest
011/**
012 * The class implements K-Nearest Neighbors model
013 *
014 * SEE: REF: ml_intro_knn
015 */
016public class KNearest extends StatModel {
017
018    protected KNearest(long addr) { super(addr); }
019
020    // internal usage only
021    public static KNearest __fromPtr__(long addr) { return new KNearest(addr); }
022
023    // C++: enum Types (cv.ml.KNearest.Types)
024    public static final int
025            BRUTE_FORCE = 1,
026            KDTREE = 2;
027
028
029    //
030    // C++:  int cv::ml::KNearest::getDefaultK()
031    //
032
033    /**
034     * SEE: setDefaultK
035     * @return automatically generated
036     */
037    public int getDefaultK() {
038        return getDefaultK_0(nativeObj);
039    }
040
041
042    //
043    // C++:  void cv::ml::KNearest::setDefaultK(int val)
044    //
045
046    /**
047     *  getDefaultK SEE: getDefaultK
048     * @param val automatically generated
049     */
050    public void setDefaultK(int val) {
051        setDefaultK_0(nativeObj, val);
052    }
053
054
055    //
056    // C++:  bool cv::ml::KNearest::getIsClassifier()
057    //
058
059    /**
060     * SEE: setIsClassifier
061     * @return automatically generated
062     */
063    public boolean getIsClassifier() {
064        return getIsClassifier_0(nativeObj);
065    }
066
067
068    //
069    // C++:  void cv::ml::KNearest::setIsClassifier(bool val)
070    //
071
072    /**
073     *  getIsClassifier SEE: getIsClassifier
074     * @param val automatically generated
075     */
076    public void setIsClassifier(boolean val) {
077        setIsClassifier_0(nativeObj, val);
078    }
079
080
081    //
082    // C++:  int cv::ml::KNearest::getEmax()
083    //
084
085    /**
086     * SEE: setEmax
087     * @return automatically generated
088     */
089    public int getEmax() {
090        return getEmax_0(nativeObj);
091    }
092
093
094    //
095    // C++:  void cv::ml::KNearest::setEmax(int val)
096    //
097
098    /**
099     *  getEmax SEE: getEmax
100     * @param val automatically generated
101     */
102    public void setEmax(int val) {
103        setEmax_0(nativeObj, val);
104    }
105
106
107    //
108    // C++:  int cv::ml::KNearest::getAlgorithmType()
109    //
110
111    /**
112     * SEE: setAlgorithmType
113     * @return automatically generated
114     */
115    public int getAlgorithmType() {
116        return getAlgorithmType_0(nativeObj);
117    }
118
119
120    //
121    // C++:  void cv::ml::KNearest::setAlgorithmType(int val)
122    //
123
124    /**
125     *  getAlgorithmType SEE: getAlgorithmType
126     * @param val automatically generated
127     */
128    public void setAlgorithmType(int val) {
129        setAlgorithmType_0(nativeObj, val);
130    }
131
132
133    //
134    // C++:  float cv::ml::KNearest::findNearest(Mat samples, int k, Mat& results, Mat& neighborResponses = Mat(), Mat& dist = Mat())
135    //
136
137    /**
138     * Finds the neighbors and predicts responses for input vectors.
139     *
140     *     @param samples Input samples stored by rows. It is a single-precision floating-point matrix of
141     *         {@code <number_of_samples> * k} size.
142     *     @param k Number of used nearest neighbors. Should be greater than 1.
143     *     @param results Vector with results of prediction (regression or classification) for each input
144     *         sample. It is a single-precision floating-point vector with {@code <number_of_samples>} elements.
145     *     @param neighborResponses Optional output values for corresponding neighbors. It is a single-
146     *         precision floating-point matrix of {@code <number_of_samples> * k} size.
147     *     @param dist Optional output distances from the input vectors to the corresponding neighbors. It
148     *         is a single-precision floating-point matrix of {@code <number_of_samples> * k} size.
149     *
150     *     For each input vector (a row of the matrix samples), the method finds the k nearest neighbors.
151     *     In case of regression, the predicted result is a mean value of the particular vector's neighbor
152     *     responses. In case of classification, the class is determined by voting.
153     *
154     *     For each input vector, the neighbors are sorted by their distances to the vector.
155     *
156     *     In case of C++ interface you can use output pointers to empty matrices and the function will
157     *     allocate memory itself.
158     *
159     *     If only a single input vector is passed, all output matrices are optional and the predicted
160     *     value is returned by the method.
161     *
162     *     The function is parallelized with the TBB library.
163     * @return automatically generated
164     */
165    public float findNearest(Mat samples, int k, Mat results, Mat neighborResponses, Mat dist) {
166        return findNearest_0(nativeObj, samples.nativeObj, k, results.nativeObj, neighborResponses.nativeObj, dist.nativeObj);
167    }
168
169    /**
170     * Finds the neighbors and predicts responses for input vectors.
171     *
172     *     @param samples Input samples stored by rows. It is a single-precision floating-point matrix of
173     *         {@code <number_of_samples> * k} size.
174     *     @param k Number of used nearest neighbors. Should be greater than 1.
175     *     @param results Vector with results of prediction (regression or classification) for each input
176     *         sample. It is a single-precision floating-point vector with {@code <number_of_samples>} elements.
177     *     @param neighborResponses Optional output values for corresponding neighbors. It is a single-
178     *         precision floating-point matrix of {@code <number_of_samples> * k} size.
179     *         is a single-precision floating-point matrix of {@code <number_of_samples> * k} size.
180     *
181     *     For each input vector (a row of the matrix samples), the method finds the k nearest neighbors.
182     *     In case of regression, the predicted result is a mean value of the particular vector's neighbor
183     *     responses. In case of classification, the class is determined by voting.
184     *
185     *     For each input vector, the neighbors are sorted by their distances to the vector.
186     *
187     *     In case of C++ interface you can use output pointers to empty matrices and the function will
188     *     allocate memory itself.
189     *
190     *     If only a single input vector is passed, all output matrices are optional and the predicted
191     *     value is returned by the method.
192     *
193     *     The function is parallelized with the TBB library.
194     * @return automatically generated
195     */
196    public float findNearest(Mat samples, int k, Mat results, Mat neighborResponses) {
197        return findNearest_1(nativeObj, samples.nativeObj, k, results.nativeObj, neighborResponses.nativeObj);
198    }
199
200    /**
201     * Finds the neighbors and predicts responses for input vectors.
202     *
203     *     @param samples Input samples stored by rows. It is a single-precision floating-point matrix of
204     *         {@code <number_of_samples> * k} size.
205     *     @param k Number of used nearest neighbors. Should be greater than 1.
206     *     @param results Vector with results of prediction (regression or classification) for each input
207     *         sample. It is a single-precision floating-point vector with {@code <number_of_samples>} elements.
208     *         precision floating-point matrix of {@code <number_of_samples> * k} size.
209     *         is a single-precision floating-point matrix of {@code <number_of_samples> * k} size.
210     *
211     *     For each input vector (a row of the matrix samples), the method finds the k nearest neighbors.
212     *     In case of regression, the predicted result is a mean value of the particular vector's neighbor
213     *     responses. In case of classification, the class is determined by voting.
214     *
215     *     For each input vector, the neighbors are sorted by their distances to the vector.
216     *
217     *     In case of C++ interface you can use output pointers to empty matrices and the function will
218     *     allocate memory itself.
219     *
220     *     If only a single input vector is passed, all output matrices are optional and the predicted
221     *     value is returned by the method.
222     *
223     *     The function is parallelized with the TBB library.
224     * @return automatically generated
225     */
226    public float findNearest(Mat samples, int k, Mat results) {
227        return findNearest_2(nativeObj, samples.nativeObj, k, results.nativeObj);
228    }
229
230
231    //
232    // C++: static Ptr_KNearest cv::ml::KNearest::create()
233    //
234
235    /**
236     * Creates the empty model
237     *
238     *     The static method creates empty %KNearest classifier. It should be then trained using StatModel::train method.
239     * @return automatically generated
240     */
241    public static KNearest create() {
242        return KNearest.__fromPtr__(create_0());
243    }
244
245
246    //
247    // C++: static Ptr_KNearest cv::ml::KNearest::load(String filepath)
248    //
249
250    /**
251     * Loads and creates a serialized knearest from a file
252     *
253     * Use KNearest::save to serialize and store an KNearest to disk.
254     * Load the KNearest from this file again, by calling this function with the path to the file.
255     *
256     * @param filepath path to serialized KNearest
257     * @return automatically generated
258     */
259    public static KNearest load(String filepath) {
260        return KNearest.__fromPtr__(load_0(filepath));
261    }
262
263
264    @Override
265    protected void finalize() throws Throwable {
266        delete(nativeObj);
267    }
268
269
270
271    // C++:  int cv::ml::KNearest::getDefaultK()
272    private static native int getDefaultK_0(long nativeObj);
273
274    // C++:  void cv::ml::KNearest::setDefaultK(int val)
275    private static native void setDefaultK_0(long nativeObj, int val);
276
277    // C++:  bool cv::ml::KNearest::getIsClassifier()
278    private static native boolean getIsClassifier_0(long nativeObj);
279
280    // C++:  void cv::ml::KNearest::setIsClassifier(bool val)
281    private static native void setIsClassifier_0(long nativeObj, boolean val);
282
283    // C++:  int cv::ml::KNearest::getEmax()
284    private static native int getEmax_0(long nativeObj);
285
286    // C++:  void cv::ml::KNearest::setEmax(int val)
287    private static native void setEmax_0(long nativeObj, int val);
288
289    // C++:  int cv::ml::KNearest::getAlgorithmType()
290    private static native int getAlgorithmType_0(long nativeObj);
291
292    // C++:  void cv::ml::KNearest::setAlgorithmType(int val)
293    private static native void setAlgorithmType_0(long nativeObj, int val);
294
295    // C++:  float cv::ml::KNearest::findNearest(Mat samples, int k, Mat& results, Mat& neighborResponses = Mat(), Mat& dist = Mat())
296    private static native float findNearest_0(long nativeObj, long samples_nativeObj, int k, long results_nativeObj, long neighborResponses_nativeObj, long dist_nativeObj);
297    private static native float findNearest_1(long nativeObj, long samples_nativeObj, int k, long results_nativeObj, long neighborResponses_nativeObj);
298    private static native float findNearest_2(long nativeObj, long samples_nativeObj, int k, long results_nativeObj);
299
300    // C++: static Ptr_KNearest cv::ml::KNearest::create()
301    private static native long create_0();
302
303    // C++: static Ptr_KNearest cv::ml::KNearest::load(String filepath)
304    private static native long load_0(String filepath);
305
306    // native support for java finalize()
307    private static native void delete(long nativeObj);
308
309}