001//
002// This file is auto-generated. Please don't modify it!
003//
004package org.opencv.objdetect;
005
006import org.opencv.core.Mat;
007import org.opencv.core.Size;
008import org.opencv.objdetect.FaceDetectorYN;
009
010// C++: class FaceDetectorYN
011/**
012 * DNN-based face detector
013 *
014 * model download link: https://github.com/opencv/opencv_zoo/tree/master/models/face_detection_yunet
015 */
016public class FaceDetectorYN {
017
018    protected final long nativeObj;
019    protected FaceDetectorYN(long addr) { nativeObj = addr; }
020
021    public long getNativeObjAddr() { return nativeObj; }
022
023    // internal usage only
024    public static FaceDetectorYN __fromPtr__(long addr) { return new FaceDetectorYN(addr); }
025
026    //
027    // C++:  void cv::FaceDetectorYN::setInputSize(Size input_size)
028    //
029
030    /**
031     * Set the size for the network input, which overwrites the input size of creating model. Call this method when the size of input image does not match the input size when creating model
032     *
033     * @param input_size the size of the input image
034     */
035    public void setInputSize(Size input_size) {
036        setInputSize_0(nativeObj, input_size.width, input_size.height);
037    }
038
039
040    //
041    // C++:  Size cv::FaceDetectorYN::getInputSize()
042    //
043
044    public Size getInputSize() {
045        return new Size(getInputSize_0(nativeObj));
046    }
047
048
049    //
050    // C++:  void cv::FaceDetectorYN::setScoreThreshold(float score_threshold)
051    //
052
053    /**
054     * Set the score threshold to filter out bounding boxes of score less than the given value
055     *
056     * @param score_threshold threshold for filtering out bounding boxes
057     */
058    public void setScoreThreshold(float score_threshold) {
059        setScoreThreshold_0(nativeObj, score_threshold);
060    }
061
062
063    //
064    // C++:  float cv::FaceDetectorYN::getScoreThreshold()
065    //
066
067    public float getScoreThreshold() {
068        return getScoreThreshold_0(nativeObj);
069    }
070
071
072    //
073    // C++:  void cv::FaceDetectorYN::setNMSThreshold(float nms_threshold)
074    //
075
076    /**
077     * Set the Non-maximum-suppression threshold to suppress bounding boxes that have IoU greater than the given value
078     *
079     * @param nms_threshold threshold for NMS operation
080     */
081    public void setNMSThreshold(float nms_threshold) {
082        setNMSThreshold_0(nativeObj, nms_threshold);
083    }
084
085
086    //
087    // C++:  float cv::FaceDetectorYN::getNMSThreshold()
088    //
089
090    public float getNMSThreshold() {
091        return getNMSThreshold_0(nativeObj);
092    }
093
094
095    //
096    // C++:  void cv::FaceDetectorYN::setTopK(int top_k)
097    //
098
099    /**
100     * Set the number of bounding boxes preserved before NMS
101     *
102     * @param top_k the number of bounding boxes to preserve from top rank based on score
103     */
104    public void setTopK(int top_k) {
105        setTopK_0(nativeObj, top_k);
106    }
107
108
109    //
110    // C++:  int cv::FaceDetectorYN::getTopK()
111    //
112
113    public int getTopK() {
114        return getTopK_0(nativeObj);
115    }
116
117
118    //
119    // C++:  int cv::FaceDetectorYN::detect(Mat image, Mat& faces)
120    //
121
122    /**
123     * A simple interface to detect face from given image
124     *
125     * @param image an image to detect
126     * @param faces detection results stored in a cv::Mat
127     * @return automatically generated
128     */
129    public int detect(Mat image, Mat faces) {
130        return detect_0(nativeObj, image.nativeObj, faces.nativeObj);
131    }
132
133
134    //
135    // C++: static Ptr_FaceDetectorYN cv::FaceDetectorYN::create(String model, String config, Size input_size, float score_threshold = 0.9f, float nms_threshold = 0.3f, int top_k = 5000, int backend_id = 0, int target_id = 0)
136    //
137
138    /**
139     * Creates an instance of this class with given parameters
140     *
141     * @param model the path to the requested model
142     * @param config the path to the config file for compability, which is not requested for ONNX models
143     * @param input_size the size of the input image
144     * @param score_threshold the threshold to filter out bounding boxes of score smaller than the given value
145     * @param nms_threshold the threshold to suppress bounding boxes of IoU bigger than the given value
146     * @param top_k keep top K bboxes before NMS
147     * @param backend_id the id of backend
148     * @param target_id the id of target device
149     * @return automatically generated
150     */
151    public static FaceDetectorYN create(String model, String config, Size input_size, float score_threshold, float nms_threshold, int top_k, int backend_id, int target_id) {
152        return FaceDetectorYN.__fromPtr__(create_0(model, config, input_size.width, input_size.height, score_threshold, nms_threshold, top_k, backend_id, target_id));
153    }
154
155    /**
156     * Creates an instance of this class with given parameters
157     *
158     * @param model the path to the requested model
159     * @param config the path to the config file for compability, which is not requested for ONNX models
160     * @param input_size the size of the input image
161     * @param score_threshold the threshold to filter out bounding boxes of score smaller than the given value
162     * @param nms_threshold the threshold to suppress bounding boxes of IoU bigger than the given value
163     * @param top_k keep top K bboxes before NMS
164     * @param backend_id the id of backend
165     * @return automatically generated
166     */
167    public static FaceDetectorYN create(String model, String config, Size input_size, float score_threshold, float nms_threshold, int top_k, int backend_id) {
168        return FaceDetectorYN.__fromPtr__(create_1(model, config, input_size.width, input_size.height, score_threshold, nms_threshold, top_k, backend_id));
169    }
170
171    /**
172     * Creates an instance of this class with given parameters
173     *
174     * @param model the path to the requested model
175     * @param config the path to the config file for compability, which is not requested for ONNX models
176     * @param input_size the size of the input image
177     * @param score_threshold the threshold to filter out bounding boxes of score smaller than the given value
178     * @param nms_threshold the threshold to suppress bounding boxes of IoU bigger than the given value
179     * @param top_k keep top K bboxes before NMS
180     * @return automatically generated
181     */
182    public static FaceDetectorYN create(String model, String config, Size input_size, float score_threshold, float nms_threshold, int top_k) {
183        return FaceDetectorYN.__fromPtr__(create_2(model, config, input_size.width, input_size.height, score_threshold, nms_threshold, top_k));
184    }
185
186    /**
187     * Creates an instance of this class with given parameters
188     *
189     * @param model the path to the requested model
190     * @param config the path to the config file for compability, which is not requested for ONNX models
191     * @param input_size the size of the input image
192     * @param score_threshold the threshold to filter out bounding boxes of score smaller than the given value
193     * @param nms_threshold the threshold to suppress bounding boxes of IoU bigger than the given value
194     * @return automatically generated
195     */
196    public static FaceDetectorYN create(String model, String config, Size input_size, float score_threshold, float nms_threshold) {
197        return FaceDetectorYN.__fromPtr__(create_3(model, config, input_size.width, input_size.height, score_threshold, nms_threshold));
198    }
199
200    /**
201     * Creates an instance of this class with given parameters
202     *
203     * @param model the path to the requested model
204     * @param config the path to the config file for compability, which is not requested for ONNX models
205     * @param input_size the size of the input image
206     * @param score_threshold the threshold to filter out bounding boxes of score smaller than the given value
207     * @return automatically generated
208     */
209    public static FaceDetectorYN create(String model, String config, Size input_size, float score_threshold) {
210        return FaceDetectorYN.__fromPtr__(create_4(model, config, input_size.width, input_size.height, score_threshold));
211    }
212
213    /**
214     * Creates an instance of this class with given parameters
215     *
216     * @param model the path to the requested model
217     * @param config the path to the config file for compability, which is not requested for ONNX models
218     * @param input_size the size of the input image
219     * @return automatically generated
220     */
221    public static FaceDetectorYN create(String model, String config, Size input_size) {
222        return FaceDetectorYN.__fromPtr__(create_5(model, config, input_size.width, input_size.height));
223    }
224
225
226    @Override
227    protected void finalize() throws Throwable {
228        delete(nativeObj);
229    }
230
231
232
233    // C++:  void cv::FaceDetectorYN::setInputSize(Size input_size)
234    private static native void setInputSize_0(long nativeObj, double input_size_width, double input_size_height);
235
236    // C++:  Size cv::FaceDetectorYN::getInputSize()
237    private static native double[] getInputSize_0(long nativeObj);
238
239    // C++:  void cv::FaceDetectorYN::setScoreThreshold(float score_threshold)
240    private static native void setScoreThreshold_0(long nativeObj, float score_threshold);
241
242    // C++:  float cv::FaceDetectorYN::getScoreThreshold()
243    private static native float getScoreThreshold_0(long nativeObj);
244
245    // C++:  void cv::FaceDetectorYN::setNMSThreshold(float nms_threshold)
246    private static native void setNMSThreshold_0(long nativeObj, float nms_threshold);
247
248    // C++:  float cv::FaceDetectorYN::getNMSThreshold()
249    private static native float getNMSThreshold_0(long nativeObj);
250
251    // C++:  void cv::FaceDetectorYN::setTopK(int top_k)
252    private static native void setTopK_0(long nativeObj, int top_k);
253
254    // C++:  int cv::FaceDetectorYN::getTopK()
255    private static native int getTopK_0(long nativeObj);
256
257    // C++:  int cv::FaceDetectorYN::detect(Mat image, Mat& faces)
258    private static native int detect_0(long nativeObj, long image_nativeObj, long faces_nativeObj);
259
260    // C++: static Ptr_FaceDetectorYN cv::FaceDetectorYN::create(String model, String config, Size input_size, float score_threshold = 0.9f, float nms_threshold = 0.3f, int top_k = 5000, int backend_id = 0, int target_id = 0)
261    private static native long create_0(String model, String config, double input_size_width, double input_size_height, float score_threshold, float nms_threshold, int top_k, int backend_id, int target_id);
262    private static native long create_1(String model, String config, double input_size_width, double input_size_height, float score_threshold, float nms_threshold, int top_k, int backend_id);
263    private static native long create_2(String model, String config, double input_size_width, double input_size_height, float score_threshold, float nms_threshold, int top_k);
264    private static native long create_3(String model, String config, double input_size_width, double input_size_height, float score_threshold, float nms_threshold);
265    private static native long create_4(String model, String config, double input_size_width, double input_size_height, float score_threshold);
266    private static native long create_5(String model, String config, double input_size_width, double input_size_height);
267
268    // native support for java finalize()
269    private static native void delete(long nativeObj);
270
271}