Package org.opencv.objdetect
Class FaceDetectorYN
java.lang.Object
org.opencv.objdetect.FaceDetectorYN
public class FaceDetectorYN extends Object
DNN-based face detector
model download link: https://github.com/opencv/opencv_zoo/tree/master/models/face_detection_yunet
-
Field Summary
Fields Modifier and Type Field Description protected long
nativeObj
-
Constructor Summary
Constructors Modifier Constructor Description protected
FaceDetectorYN(long addr)
-
Method Summary
Modifier and Type Method Description static FaceDetectorYN
__fromPtr__(long addr)
static FaceDetectorYN
create(String model, String config, Size input_size)
Creates an instance of this class with given parametersstatic FaceDetectorYN
create(String model, String config, Size input_size, float score_threshold)
Creates an instance of this class with given parametersstatic FaceDetectorYN
create(String model, String config, Size input_size, float score_threshold, float nms_threshold)
Creates an instance of this class with given parametersstatic FaceDetectorYN
create(String model, String config, Size input_size, float score_threshold, float nms_threshold, int top_k)
Creates an instance of this class with given parametersstatic FaceDetectorYN
create(String model, String config, Size input_size, float score_threshold, float nms_threshold, int top_k, int backend_id)
Creates an instance of this class with given parametersstatic FaceDetectorYN
create(String model, String config, Size input_size, float score_threshold, float nms_threshold, int top_k, int backend_id, int target_id)
Creates an instance of this class with given parametersint
detect(Mat image, Mat faces)
A simple interface to detect face from given imageprotected void
finalize()
Size
getInputSize()
long
getNativeObjAddr()
float
getNMSThreshold()
float
getScoreThreshold()
int
getTopK()
void
setInputSize(Size input_size)
Set the size for the network input, which overwrites the input size of creating model.void
setNMSThreshold(float nms_threshold)
Set the Non-maximum-suppression threshold to suppress bounding boxes that have IoU greater than the given valuevoid
setScoreThreshold(float score_threshold)
Set the score threshold to filter out bounding boxes of score less than the given valuevoid
setTopK(int top_k)
Set the number of bounding boxes preserved before NMS
-
Field Details
-
Constructor Details
-
Method Details
-
getNativeObjAddr
-
__fromPtr__
-
setInputSize
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- Parameters:
input_size
- the size of the input image
-
getInputSize
-
setScoreThreshold
Set the score threshold to filter out bounding boxes of score less than the given value- Parameters:
score_threshold
- threshold for filtering out bounding boxes
-
getScoreThreshold
-
setNMSThreshold
Set the Non-maximum-suppression threshold to suppress bounding boxes that have IoU greater than the given value- Parameters:
nms_threshold
- threshold for NMS operation
-
getNMSThreshold
-
setTopK
Set the number of bounding boxes preserved before NMS- Parameters:
top_k
- the number of bounding boxes to preserve from top rank based on score
-
getTopK
-
detect
A simple interface to detect face from given image- Parameters:
image
- an image to detectfaces
- detection results stored in a cv::Mat- Returns:
- automatically generated
-
create
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)Creates an instance of this class with given parameters- Parameters:
model
- the path to the requested modelconfig
- the path to the config file for compability, which is not requested for ONNX modelsinput_size
- the size of the input imagescore_threshold
- the threshold to filter out bounding boxes of score smaller than the given valuenms_threshold
- the threshold to suppress bounding boxes of IoU bigger than the given valuetop_k
- keep top K bboxes before NMSbackend_id
- the id of backendtarget_id
- the id of target device- Returns:
- automatically generated
-
create
public static FaceDetectorYN create(String model, String config, Size input_size, float score_threshold, float nms_threshold, int top_k, int backend_id)Creates an instance of this class with given parameters- Parameters:
model
- the path to the requested modelconfig
- the path to the config file for compability, which is not requested for ONNX modelsinput_size
- the size of the input imagescore_threshold
- the threshold to filter out bounding boxes of score smaller than the given valuenms_threshold
- the threshold to suppress bounding boxes of IoU bigger than the given valuetop_k
- keep top K bboxes before NMSbackend_id
- the id of backend- Returns:
- automatically generated
-
create
public static FaceDetectorYN create(String model, String config, Size input_size, float score_threshold, float nms_threshold, int top_k)Creates an instance of this class with given parameters- Parameters:
model
- the path to the requested modelconfig
- the path to the config file for compability, which is not requested for ONNX modelsinput_size
- the size of the input imagescore_threshold
- the threshold to filter out bounding boxes of score smaller than the given valuenms_threshold
- the threshold to suppress bounding boxes of IoU bigger than the given valuetop_k
- keep top K bboxes before NMS- Returns:
- automatically generated
-
create
public static FaceDetectorYN create(String model, String config, Size input_size, float score_threshold, float nms_threshold)Creates an instance of this class with given parameters- Parameters:
model
- the path to the requested modelconfig
- the path to the config file for compability, which is not requested for ONNX modelsinput_size
- the size of the input imagescore_threshold
- the threshold to filter out bounding boxes of score smaller than the given valuenms_threshold
- the threshold to suppress bounding boxes of IoU bigger than the given value- Returns:
- automatically generated
-
create
public static FaceDetectorYN create(String model, String config, Size input_size, float score_threshold)Creates an instance of this class with given parameters- Parameters:
model
- the path to the requested modelconfig
- the path to the config file for compability, which is not requested for ONNX modelsinput_size
- the size of the input imagescore_threshold
- the threshold to filter out bounding boxes of score smaller than the given value- Returns:
- automatically generated
-
create
Creates an instance of this class with given parameters- Parameters:
model
- the path to the requested modelconfig
- the path to the config file for compability, which is not requested for ONNX modelsinput_size
- the size of the input image- Returns:
- automatically generated
-
finalize
-