Package org.opencv.objdetect
Class FaceDetectorYN
- java.lang.Object
- 
- org.opencv.objdetect.FaceDetectorYN
 
- 
 public class FaceDetectorYN extends java.lang.ObjectDNN-based face detector model download link: https://github.com/opencv/opencv_zoo/tree/master/models/face_detection_yunet
- 
- 
Field SummaryFields Modifier and Type Field Description protected longnativeObj
 - 
Constructor SummaryConstructors Modifier Constructor Description protectedFaceDetectorYN(long addr)
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static FaceDetectorYN__fromPtr__(long addr)static FaceDetectorYNcreate(java.lang.String model, java.lang.String config, Size input_size)Creates an instance of face detector class with given parametersstatic FaceDetectorYNcreate(java.lang.String model, java.lang.String config, Size input_size, float score_threshold)Creates an instance of face detector class with given parametersstatic FaceDetectorYNcreate(java.lang.String model, java.lang.String config, Size input_size, float score_threshold, float nms_threshold)Creates an instance of face detector class with given parametersstatic FaceDetectorYNcreate(java.lang.String model, java.lang.String config, Size input_size, float score_threshold, float nms_threshold, int top_k)Creates an instance of face detector class with given parametersstatic FaceDetectorYNcreate(java.lang.String model, java.lang.String config, Size input_size, float score_threshold, float nms_threshold, int top_k, int backend_id)Creates an instance of face detector class with given parametersstatic FaceDetectorYNcreate(java.lang.String model, java.lang.String config, Size input_size, float score_threshold, float nms_threshold, int top_k, int backend_id, int target_id)Creates an instance of face detector class with given parametersstatic FaceDetectorYNcreate(java.lang.String framework, MatOfByte bufferModel, MatOfByte bufferConfig, Size input_size)static FaceDetectorYNcreate(java.lang.String framework, MatOfByte bufferModel, MatOfByte bufferConfig, Size input_size, float score_threshold)static FaceDetectorYNcreate(java.lang.String framework, MatOfByte bufferModel, MatOfByte bufferConfig, Size input_size, float score_threshold, float nms_threshold)static FaceDetectorYNcreate(java.lang.String framework, MatOfByte bufferModel, MatOfByte bufferConfig, Size input_size, float score_threshold, float nms_threshold, int top_k)static FaceDetectorYNcreate(java.lang.String framework, MatOfByte bufferModel, MatOfByte bufferConfig, Size input_size, float score_threshold, float nms_threshold, int top_k, int backend_id)static FaceDetectorYNcreate(java.lang.String framework, MatOfByte bufferModel, MatOfByte bufferConfig, Size input_size, float score_threshold, float nms_threshold, int top_k, int backend_id, int target_id)intdetect(Mat image, Mat faces)Detects faces in the input image.protected voidfinalize()SizegetInputSize()longgetNativeObjAddr()floatgetNMSThreshold()floatgetScoreThreshold()intgetTopK()voidsetInputSize(Size input_size)Set the size for the network input, which overwrites the input size of creating model.voidsetNMSThreshold(float nms_threshold)Set the Non-maximum-suppression threshold to suppress bounding boxes that have IoU greater than the given valuevoidsetScoreThreshold(float score_threshold)Set the score threshold to filter out bounding boxes of score less than the given valuevoidsetTopK(int top_k)Set the number of bounding boxes preserved before NMS
 
- 
- 
- 
Method Detail- 
getNativeObjAddrpublic long getNativeObjAddr() 
 - 
__fromPtr__public static FaceDetectorYN __fromPtr__(long addr) 
 - 
setInputSizepublic void setInputSize(Size input_size) 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
 
 - 
getInputSizepublic Size getInputSize() 
 - 
setScoreThresholdpublic void setScoreThreshold(float score_threshold) 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
 
 - 
getScoreThresholdpublic float getScoreThreshold() 
 - 
setNMSThresholdpublic void setNMSThreshold(float nms_threshold) 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
 
 - 
getNMSThresholdpublic float getNMSThreshold() 
 - 
setTopKpublic void setTopK(int top_k) 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
 
 - 
getTopKpublic int getTopK() 
 - 
detectpublic int detect(Mat image, Mat faces) Detects faces in the input image. Following is an example output. - Parameters:
- image- an image to detect
- faces- detection results stored in a 2D cv::Mat of shape [num_faces, 15] - 0-1: x, y of bbox top left corner - 2-3: width, height of bbox - 4-5: x, y of right eye (blue point in the example image) - 6-7: x, y of left eye (red point in the example image) - 8-9: x, y of nose tip (green point in the example image) - 10-11: x, y of right corner of mouth (pink point in the example image) - 12-13: x, y of left corner of mouth (yellow point in the example image) - 14: face score
- Returns:
- automatically generated
 
 - 
createpublic static FaceDetectorYN create(java.lang.String model, java.lang.String config, Size input_size, float score_threshold, float nms_threshold, int top_k, int backend_id, int target_id) Creates an instance of face detector class with given parameters- Parameters:
- model- the path to the requested model
- config- the path to the config file for compability, which is not requested for ONNX models
- input_size- the size of the input image
- score_threshold- the threshold to filter out bounding boxes of score smaller than the given value
- nms_threshold- the threshold to suppress bounding boxes of IoU bigger than the given value
- top_k- keep top K bboxes before NMS
- backend_id- the id of backend
- target_id- the id of target device
- Returns:
- automatically generated
 
 - 
createpublic static FaceDetectorYN create(java.lang.String model, java.lang.String config, Size input_size, float score_threshold, float nms_threshold, int top_k, int backend_id) Creates an instance of face detector class with given parameters- Parameters:
- model- the path to the requested model
- config- the path to the config file for compability, which is not requested for ONNX models
- input_size- the size of the input image
- score_threshold- the threshold to filter out bounding boxes of score smaller than the given value
- nms_threshold- the threshold to suppress bounding boxes of IoU bigger than the given value
- top_k- keep top K bboxes before NMS
- backend_id- the id of backend
- Returns:
- automatically generated
 
 - 
createpublic static FaceDetectorYN create(java.lang.String model, java.lang.String config, Size input_size, float score_threshold, float nms_threshold, int top_k) Creates an instance of face detector class with given parameters- Parameters:
- model- the path to the requested model
- config- the path to the config file for compability, which is not requested for ONNX models
- input_size- the size of the input image
- score_threshold- the threshold to filter out bounding boxes of score smaller than the given value
- nms_threshold- the threshold to suppress bounding boxes of IoU bigger than the given value
- top_k- keep top K bboxes before NMS
- Returns:
- automatically generated
 
 - 
createpublic static FaceDetectorYN create(java.lang.String model, java.lang.String config, Size input_size, float score_threshold, float nms_threshold) Creates an instance of face detector class with given parameters- Parameters:
- model- the path to the requested model
- config- the path to the config file for compability, which is not requested for ONNX models
- input_size- the size of the input image
- score_threshold- the threshold to filter out bounding boxes of score smaller than the given value
- nms_threshold- the threshold to suppress bounding boxes of IoU bigger than the given value
- Returns:
- automatically generated
 
 - 
createpublic static FaceDetectorYN create(java.lang.String model, java.lang.String config, Size input_size, float score_threshold) Creates an instance of face detector class with given parameters- Parameters:
- model- the path to the requested model
- config- the path to the config file for compability, which is not requested for ONNX models
- input_size- the size of the input image
- score_threshold- the threshold to filter out bounding boxes of score smaller than the given value
- Returns:
- automatically generated
 
 - 
createpublic static FaceDetectorYN create(java.lang.String model, java.lang.String config, Size input_size) Creates an instance of face detector class with given parameters- Parameters:
- model- the path to the requested model
- config- the path to the config file for compability, which is not requested for ONNX models
- input_size- the size of the input image
- Returns:
- automatically generated
 
 - 
createpublic static FaceDetectorYN create(java.lang.String framework, MatOfByte bufferModel, MatOfByte bufferConfig, Size input_size, float score_threshold, float nms_threshold, int top_k, int backend_id, int target_id) - Parameters:
- framework- Name of origin framework
- bufferModel- A buffer with a content of binary file with weights
- bufferConfig- A buffer with a content of text file contains network configuration
- input_size- the size of the input image
- score_threshold- the threshold to filter out bounding boxes of score smaller than the given value
- nms_threshold- the threshold to suppress bounding boxes of IoU bigger than the given value
- top_k- keep top K bboxes before NMS
- backend_id- the id of backend
- target_id- the id of target device
- Returns:
- automatically generated
 
 - 
createpublic static FaceDetectorYN create(java.lang.String framework, MatOfByte bufferModel, MatOfByte bufferConfig, Size input_size, float score_threshold, float nms_threshold, int top_k, int backend_id) - Parameters:
- framework- Name of origin framework
- bufferModel- A buffer with a content of binary file with weights
- bufferConfig- A buffer with a content of text file contains network configuration
- input_size- the size of the input image
- score_threshold- the threshold to filter out bounding boxes of score smaller than the given value
- nms_threshold- the threshold to suppress bounding boxes of IoU bigger than the given value
- top_k- keep top K bboxes before NMS
- backend_id- the id of backend
- Returns:
- automatically generated
 
 - 
createpublic static FaceDetectorYN create(java.lang.String framework, MatOfByte bufferModel, MatOfByte bufferConfig, Size input_size, float score_threshold, float nms_threshold, int top_k) - Parameters:
- framework- Name of origin framework
- bufferModel- A buffer with a content of binary file with weights
- bufferConfig- A buffer with a content of text file contains network configuration
- input_size- the size of the input image
- score_threshold- the threshold to filter out bounding boxes of score smaller than the given value
- nms_threshold- the threshold to suppress bounding boxes of IoU bigger than the given value
- top_k- keep top K bboxes before NMS
- Returns:
- automatically generated
 
 - 
createpublic static FaceDetectorYN create(java.lang.String framework, MatOfByte bufferModel, MatOfByte bufferConfig, Size input_size, float score_threshold, float nms_threshold) - Parameters:
- framework- Name of origin framework
- bufferModel- A buffer with a content of binary file with weights
- bufferConfig- A buffer with a content of text file contains network configuration
- input_size- the size of the input image
- score_threshold- the threshold to filter out bounding boxes of score smaller than the given value
- nms_threshold- the threshold to suppress bounding boxes of IoU bigger than the given value
- Returns:
- automatically generated
 
 - 
createpublic static FaceDetectorYN create(java.lang.String framework, MatOfByte bufferModel, MatOfByte bufferConfig, Size input_size, float score_threshold) - Parameters:
- framework- Name of origin framework
- bufferModel- A buffer with a content of binary file with weights
- bufferConfig- A buffer with a content of text file contains network configuration
- input_size- the size of the input image
- score_threshold- the threshold to filter out bounding boxes of score smaller than the given value
- Returns:
- automatically generated
 
 - 
createpublic static FaceDetectorYN create(java.lang.String framework, MatOfByte bufferModel, MatOfByte bufferConfig, Size input_size) - Parameters:
- framework- Name of origin framework
- bufferModel- A buffer with a content of binary file with weights
- bufferConfig- A buffer with a content of text file contains network configuration
- input_size- the size of the input image
- Returns:
- automatically generated
 
 - 
finalizeprotected void finalize() throws java.lang.Throwable- Overrides:
- finalizein class- java.lang.Object
- Throws:
- java.lang.Throwable
 
 
- 
 
-