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 * Detects faces in the input image. Following is an example output. 124 * 125 * ![image](pics/lena-face-detection.jpg) 126 * 127 * @param image an image to detect 128 * @param faces detection results stored in a 2D cv::Mat of shape [num_faces, 15] 129 * - 0-1: x, y of bbox top left corner 130 * - 2-3: width, height of bbox 131 * - 4-5: x, y of right eye (blue point in the example image) 132 * - 6-7: x, y of left eye (red point in the example image) 133 * - 8-9: x, y of nose tip (green point in the example image) 134 * - 10-11: x, y of right corner of mouth (pink point in the example image) 135 * - 12-13: x, y of left corner of mouth (yellow point in the example image) 136 * - 14: face score 137 * @return automatically generated 138 */ 139 public int detect(Mat image, Mat faces) { 140 return detect_0(nativeObj, image.nativeObj, faces.nativeObj); 141 } 142 143 144 // 145 // 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) 146 // 147 148 /** 149 * Creates an instance of this class with given parameters 150 * 151 * @param model the path to the requested model 152 * @param config the path to the config file for compability, which is not requested for ONNX models 153 * @param input_size the size of the input image 154 * @param score_threshold the threshold to filter out bounding boxes of score smaller than the given value 155 * @param nms_threshold the threshold to suppress bounding boxes of IoU bigger than the given value 156 * @param top_k keep top K bboxes before NMS 157 * @param backend_id the id of backend 158 * @param target_id the id of target device 159 * @return automatically generated 160 */ 161 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) { 162 return FaceDetectorYN.__fromPtr__(create_0(model, config, input_size.width, input_size.height, score_threshold, nms_threshold, top_k, backend_id, target_id)); 163 } 164 165 /** 166 * Creates an instance of this class with given parameters 167 * 168 * @param model the path to the requested model 169 * @param config the path to the config file for compability, which is not requested for ONNX models 170 * @param input_size the size of the input image 171 * @param score_threshold the threshold to filter out bounding boxes of score smaller than the given value 172 * @param nms_threshold the threshold to suppress bounding boxes of IoU bigger than the given value 173 * @param top_k keep top K bboxes before NMS 174 * @param backend_id the id of backend 175 * @return automatically generated 176 */ 177 public static FaceDetectorYN create(String model, String config, Size input_size, float score_threshold, float nms_threshold, int top_k, int backend_id) { 178 return FaceDetectorYN.__fromPtr__(create_1(model, config, input_size.width, input_size.height, score_threshold, nms_threshold, top_k, backend_id)); 179 } 180 181 /** 182 * Creates an instance of this class with given parameters 183 * 184 * @param model the path to the requested model 185 * @param config the path to the config file for compability, which is not requested for ONNX models 186 * @param input_size the size of the input image 187 * @param score_threshold the threshold to filter out bounding boxes of score smaller than the given value 188 * @param nms_threshold the threshold to suppress bounding boxes of IoU bigger than the given value 189 * @param top_k keep top K bboxes before NMS 190 * @return automatically generated 191 */ 192 public static FaceDetectorYN create(String model, String config, Size input_size, float score_threshold, float nms_threshold, int top_k) { 193 return FaceDetectorYN.__fromPtr__(create_2(model, config, input_size.width, input_size.height, score_threshold, nms_threshold, top_k)); 194 } 195 196 /** 197 * Creates an instance of this class with given parameters 198 * 199 * @param model the path to the requested model 200 * @param config the path to the config file for compability, which is not requested for ONNX models 201 * @param input_size the size of the input image 202 * @param score_threshold the threshold to filter out bounding boxes of score smaller than the given value 203 * @param nms_threshold the threshold to suppress bounding boxes of IoU bigger than the given value 204 * @return automatically generated 205 */ 206 public static FaceDetectorYN create(String model, String config, Size input_size, float score_threshold, float nms_threshold) { 207 return FaceDetectorYN.__fromPtr__(create_3(model, config, input_size.width, input_size.height, score_threshold, nms_threshold)); 208 } 209 210 /** 211 * Creates an instance of this class with given parameters 212 * 213 * @param model the path to the requested model 214 * @param config the path to the config file for compability, which is not requested for ONNX models 215 * @param input_size the size of the input image 216 * @param score_threshold the threshold to filter out bounding boxes of score smaller than the given value 217 * @return automatically generated 218 */ 219 public static FaceDetectorYN create(String model, String config, Size input_size, float score_threshold) { 220 return FaceDetectorYN.__fromPtr__(create_4(model, config, input_size.width, input_size.height, score_threshold)); 221 } 222 223 /** 224 * Creates an instance of this class with given parameters 225 * 226 * @param model the path to the requested model 227 * @param config the path to the config file for compability, which is not requested for ONNX models 228 * @param input_size the size of the input image 229 * @return automatically generated 230 */ 231 public static FaceDetectorYN create(String model, String config, Size input_size) { 232 return FaceDetectorYN.__fromPtr__(create_5(model, config, input_size.width, input_size.height)); 233 } 234 235 236 @Override 237 protected void finalize() throws Throwable { 238 delete(nativeObj); 239 } 240 241 242 243 // C++: void cv::FaceDetectorYN::setInputSize(Size input_size) 244 private static native void setInputSize_0(long nativeObj, double input_size_width, double input_size_height); 245 246 // C++: Size cv::FaceDetectorYN::getInputSize() 247 private static native double[] getInputSize_0(long nativeObj); 248 249 // C++: void cv::FaceDetectorYN::setScoreThreshold(float score_threshold) 250 private static native void setScoreThreshold_0(long nativeObj, float score_threshold); 251 252 // C++: float cv::FaceDetectorYN::getScoreThreshold() 253 private static native float getScoreThreshold_0(long nativeObj); 254 255 // C++: void cv::FaceDetectorYN::setNMSThreshold(float nms_threshold) 256 private static native void setNMSThreshold_0(long nativeObj, float nms_threshold); 257 258 // C++: float cv::FaceDetectorYN::getNMSThreshold() 259 private static native float getNMSThreshold_0(long nativeObj); 260 261 // C++: void cv::FaceDetectorYN::setTopK(int top_k) 262 private static native void setTopK_0(long nativeObj, int top_k); 263 264 // C++: int cv::FaceDetectorYN::getTopK() 265 private static native int getTopK_0(long nativeObj); 266 267 // C++: int cv::FaceDetectorYN::detect(Mat image, Mat& faces) 268 private static native int detect_0(long nativeObj, long image_nativeObj, long faces_nativeObj); 269 270 // 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) 271 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); 272 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); 273 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); 274 private static native long create_3(String model, String config, double input_size_width, double input_size_height, float score_threshold, float nms_threshold); 275 private static native long create_4(String model, String config, double input_size_width, double input_size_height, float score_threshold); 276 private static native long create_5(String model, String config, double input_size_width, double input_size_height); 277 278 // native support for java finalize() 279 private static native void delete(long nativeObj); 280 281}