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.core.TermCriteria;
008import org.opencv.ml.DTrees;
009import org.opencv.ml.RTrees;
010
011// C++: class RTrees
012/**
013 * The class implements the random forest predictor.
014 *
015 * SEE: REF: ml_intro_rtrees
016 */
017public class RTrees extends DTrees {
018
019    protected RTrees(long addr) { super(addr); }
020
021    // internal usage only
022    public static RTrees __fromPtr__(long addr) { return new RTrees(addr); }
023
024    //
025    // C++:  bool cv::ml::RTrees::getCalculateVarImportance()
026    //
027
028    /**
029     * SEE: setCalculateVarImportance
030     * @return automatically generated
031     */
032    public boolean getCalculateVarImportance() {
033        return getCalculateVarImportance_0(nativeObj);
034    }
035
036
037    //
038    // C++:  void cv::ml::RTrees::setCalculateVarImportance(bool val)
039    //
040
041    /**
042     *  getCalculateVarImportance SEE: getCalculateVarImportance
043     * @param val automatically generated
044     */
045    public void setCalculateVarImportance(boolean val) {
046        setCalculateVarImportance_0(nativeObj, val);
047    }
048
049
050    //
051    // C++:  int cv::ml::RTrees::getActiveVarCount()
052    //
053
054    /**
055     * SEE: setActiveVarCount
056     * @return automatically generated
057     */
058    public int getActiveVarCount() {
059        return getActiveVarCount_0(nativeObj);
060    }
061
062
063    //
064    // C++:  void cv::ml::RTrees::setActiveVarCount(int val)
065    //
066
067    /**
068     *  getActiveVarCount SEE: getActiveVarCount
069     * @param val automatically generated
070     */
071    public void setActiveVarCount(int val) {
072        setActiveVarCount_0(nativeObj, val);
073    }
074
075
076    //
077    // C++:  TermCriteria cv::ml::RTrees::getTermCriteria()
078    //
079
080    /**
081     * SEE: setTermCriteria
082     * @return automatically generated
083     */
084    public TermCriteria getTermCriteria() {
085        return new TermCriteria(getTermCriteria_0(nativeObj));
086    }
087
088
089    //
090    // C++:  void cv::ml::RTrees::setTermCriteria(TermCriteria val)
091    //
092
093    /**
094     *  getTermCriteria SEE: getTermCriteria
095     * @param val automatically generated
096     */
097    public void setTermCriteria(TermCriteria val) {
098        setTermCriteria_0(nativeObj, val.type, val.maxCount, val.epsilon);
099    }
100
101
102    //
103    // C++:  Mat cv::ml::RTrees::getVarImportance()
104    //
105
106    /**
107     * Returns the variable importance array.
108     *     The method returns the variable importance vector, computed at the training stage when
109     *     CalculateVarImportance is set to true. If this flag was set to false, the empty matrix is
110     *     returned.
111     * @return automatically generated
112     */
113    public Mat getVarImportance() {
114        return new Mat(getVarImportance_0(nativeObj));
115    }
116
117
118    //
119    // C++:  void cv::ml::RTrees::getVotes(Mat samples, Mat& results, int flags)
120    //
121
122    /**
123     * Returns the result of each individual tree in the forest.
124     *     In case the model is a regression problem, the method will return each of the trees'
125     *     results for each of the sample cases. If the model is a classifier, it will return
126     *     a Mat with samples + 1 rows, where the first row gives the class number and the
127     *     following rows return the votes each class had for each sample.
128     *         @param samples Array containing the samples for which votes will be calculated.
129     *         @param results Array where the result of the calculation will be written.
130     *         @param flags Flags for defining the type of RTrees.
131     */
132    public void getVotes(Mat samples, Mat results, int flags) {
133        getVotes_0(nativeObj, samples.nativeObj, results.nativeObj, flags);
134    }
135
136
137    //
138    // C++:  double cv::ml::RTrees::getOOBError()
139    //
140
141    /**
142     * Returns the OOB error value, computed at the training stage when calcOOBError is set to true.
143     * If this flag was set to false, 0 is returned. The OOB error is also scaled by sample weighting.
144     * @return automatically generated
145     */
146    public double getOOBError() {
147        return getOOBError_0(nativeObj);
148    }
149
150
151    //
152    // C++: static Ptr_RTrees cv::ml::RTrees::create()
153    //
154
155    /**
156     * Creates the empty model.
157     *     Use StatModel::train to train the model, StatModel::train to create and train the model,
158     *     Algorithm::load to load the pre-trained model.
159     * @return automatically generated
160     */
161    public static RTrees create() {
162        return RTrees.__fromPtr__(create_0());
163    }
164
165
166    //
167    // C++: static Ptr_RTrees cv::ml::RTrees::load(String filepath, String nodeName = String())
168    //
169
170    /**
171     * Loads and creates a serialized RTree from a file
172     *
173     * Use RTree::save to serialize and store an RTree to disk.
174     * Load the RTree from this file again, by calling this function with the path to the file.
175     * Optionally specify the node for the file containing the classifier
176     *
177     * @param filepath path to serialized RTree
178     * @param nodeName name of node containing the classifier
179     * @return automatically generated
180     */
181    public static RTrees load(String filepath, String nodeName) {
182        return RTrees.__fromPtr__(load_0(filepath, nodeName));
183    }
184
185    /**
186     * Loads and creates a serialized RTree from a file
187     *
188     * Use RTree::save to serialize and store an RTree to disk.
189     * Load the RTree from this file again, by calling this function with the path to the file.
190     * Optionally specify the node for the file containing the classifier
191     *
192     * @param filepath path to serialized RTree
193     * @return automatically generated
194     */
195    public static RTrees load(String filepath) {
196        return RTrees.__fromPtr__(load_1(filepath));
197    }
198
199
200    @Override
201    protected void finalize() throws Throwable {
202        delete(nativeObj);
203    }
204
205
206
207    // C++:  bool cv::ml::RTrees::getCalculateVarImportance()
208    private static native boolean getCalculateVarImportance_0(long nativeObj);
209
210    // C++:  void cv::ml::RTrees::setCalculateVarImportance(bool val)
211    private static native void setCalculateVarImportance_0(long nativeObj, boolean val);
212
213    // C++:  int cv::ml::RTrees::getActiveVarCount()
214    private static native int getActiveVarCount_0(long nativeObj);
215
216    // C++:  void cv::ml::RTrees::setActiveVarCount(int val)
217    private static native void setActiveVarCount_0(long nativeObj, int val);
218
219    // C++:  TermCriteria cv::ml::RTrees::getTermCriteria()
220    private static native double[] getTermCriteria_0(long nativeObj);
221
222    // C++:  void cv::ml::RTrees::setTermCriteria(TermCriteria val)
223    private static native void setTermCriteria_0(long nativeObj, int val_type, int val_maxCount, double val_epsilon);
224
225    // C++:  Mat cv::ml::RTrees::getVarImportance()
226    private static native long getVarImportance_0(long nativeObj);
227
228    // C++:  void cv::ml::RTrees::getVotes(Mat samples, Mat& results, int flags)
229    private static native void getVotes_0(long nativeObj, long samples_nativeObj, long results_nativeObj, int flags);
230
231    // C++:  double cv::ml::RTrees::getOOBError()
232    private static native double getOOBError_0(long nativeObj);
233
234    // C++: static Ptr_RTrees cv::ml::RTrees::create()
235    private static native long create_0();
236
237    // C++: static Ptr_RTrees cv::ml::RTrees::load(String filepath, String nodeName = String())
238    private static native long load_0(String filepath, String nodeName);
239    private static native long load_1(String filepath);
240
241    // native support for java finalize()
242    private static native void delete(long nativeObj);
243
244}