类 FaceDetectorYN


  • public class FaceDetectorYN
    extends java.lang.Object
    基于DNN的人脸检测器模型下载链接:https://github.com/opencv/opencv_zoo/tree/master/models/face_detection_yunet
    • 字段摘要

      字段 
      修饰符和类型 字段 描述
      protected long nativeObj  
    • 构造函数摘要

      构造函数 
      修饰符 构造函数 描述
      保护 FaceDetectorYN​(long addr)  
    • 方法摘要

      所有方法 静态方法 实例方法 具体方法 
      修饰符和类型 方法 描述
      static FaceDetectorYN __fromPtr__​(long addr)  
      static FaceDetectorYN create​(java.lang.String model, java.lang.String config, Size input_size)
      使用给定参数创建人脸检测器类的一个实例
      static FaceDetectorYN create​(java.lang.String model, java.lang.String config, Size input_size, float score_threshold)
      使用给定参数创建人脸检测器类的一个实例
      static FaceDetectorYN create​(java.lang.String model, java.lang.String config, Size input_size, float score_threshold, float nms_threshold)
      使用给定参数创建人脸检测器类的一个实例
      static FaceDetectorYN create​(java.lang.String model, java.lang.String config, Size input_size, float score_threshold, float nms_threshold, int top_k)
      使用给定参数创建人脸检测器类的一个实例
      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)
      使用给定参数创建人脸检测器类的一个实例
      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)
      使用给定参数创建人脸检测器类的一个实例
      static FaceDetectorYN create​(java.lang.String framework, MatOfByte bufferModel, MatOfByte bufferConfig, Size input_size)  
      static FaceDetectorYN create​(java.lang.String framework, MatOfByte bufferModel, MatOfByte bufferConfig, Size input_size, float score_threshold)  
      static FaceDetectorYN create​(java.lang.String framework, MatOfByte bufferModel, MatOfByte bufferConfig, Size input_size, float score_threshold, float nms_threshold)  
      static FaceDetectorYN create​(java.lang.String framework, MatOfByte bufferModel, MatOfByte bufferConfig, Size input_size, float score_threshold, float nms_threshold, int top_k)  
      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)  
      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)  
      int detect​(Mat image, Mat faces)
      检测输入图像中的人脸。
      protected void finalize()  
      Size getInputSize()  
      long getNativeObjAddr()  
      float getNMSThreshold()  
      float getScoreThreshold()  
      int getTopK()  
      void setInputSize​(Size input_size)
      设置网络输入尺寸,此尺寸将覆盖模型创建时的输入尺寸。
      void setNMSThreshold​(float nms_threshold)
      设置非极大值抑制 (Non-maximum-suppression) 阈值,用于抑制 IoU 大于给定值的边界框
      void setScoreThreshold​(float score_threshold)
      设置分数阈值,用于过滤掉分数小于给定值的边界框
      void setTopK​(int top_k)
      设置在NMS之前保留的边界框数量
      • 从类继承的方法 java.lang.Object

        clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 字段详细信息

      • nativeObj

        protected final long nativeObj
    • 构造函数详细信息

      • FaceDetectorYN

        protected FaceDetectorYN​(long addr)
    • 方法详细信息

      • getNativeObjAddr

        public long getNativeObjAddr()
      • __fromPtr__

        public static FaceDetectorYN __fromPtr__​(long addr)
      • setInputSize

        public void setInputSize​(Size input_size)
        设置网络输入尺寸,此尺寸将覆盖模型创建时的输入尺寸。当输入图像尺寸与创建模型时的输入尺寸不匹配时,请调用此方法
        参数
        input_size - 输入图像的尺寸
      • getInputSize

        public Size getInputSize()
      • setScoreThreshold

        public void setScoreThreshold​(float score_threshold)
        设置分数阈值,用于过滤掉分数小于给定值的边界框
        参数
        score_threshold - 用于过滤边界框的阈值
      • getScoreThreshold

        public float getScoreThreshold()
      • setNMSThreshold

        public void setNMSThreshold​(float nms_threshold)
        设置非极大值抑制 (Non-maximum-suppression) 阈值,用于抑制 IoU 大于给定值的边界框
        参数
        nms_threshold - 非极大值抑制 (NMS) 操作的阈值
      • getNMSThreshold

        public float getNMSThreshold()
      • setTopK

        public void setTopK​(int top_k)
        设置在NMS之前保留的边界框数量
        参数
        top_k - 根据分数保留的排名靠前的边界框数量
      • getTopK

        public int getTopK()
      • detect

        public int detect​(Mat image,
                          Mat faces)
        在输入图像中检测人脸。下面是一个输出示例。![image](pics/lena-face-detection.jpg)
        参数
        image - 要检测的图像
        faces - 检测结果,存储在形状为 [num_faces, 15] 的二维 cv::Mat 中 - 0-1: 边界框左上角的 x、y 坐标 - 2-3: 边界框的宽度、高度 - 4-5: 右眼的 x、y 坐标(示例图像中的蓝色点)- 6-7: 左眼的 x、y 坐标(示例图像中的红色点)- 8-9: 鼻尖的 x、y 坐标(示例图像中的绿色点)- 10-11: 嘴角右角的 x、y 坐标(示例图像中的粉色点)- 12-13: 嘴角左角的 x、y 坐标(示例图像中的黄色点)- 14: 人脸得分
        返回
        自动生成
      • create

        public 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)
        使用给定参数创建人脸检测器类的一个实例
        参数
        model - 所需模型的路径
        config - 配置文件路径(用于兼容性,ONNX 模型不需要此项)
        input_size - 输入图像的尺寸
        score_threshold - 用于过滤掉分数小于给定值的边界框的阈值
        nms_threshold - 用于抑制 IoU 大于给定值的边界框的阈值
        top_k - 在 NMS 之前保留前 K 个边界框
        backend_id - 后端 ID
        target_id - 目标设备 ID
        返回
        自动生成
      • create

        public 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)
        使用给定参数创建人脸检测器类的一个实例
        参数
        model - 所需模型的路径
        config - 配置文件路径(用于兼容性,ONNX 模型不需要此项)
        input_size - 输入图像的尺寸
        score_threshold - 用于过滤掉分数小于给定值的边界框的阈值
        nms_threshold - 用于抑制 IoU 大于给定值的边界框的阈值
        top_k - 在 NMS 之前保留前 K 个边界框
        backend_id - 后端 ID
        返回
        自动生成
      • create

        public static FaceDetectorYN create​(java.lang.String model,
                                            java.lang.String config,
                                            Size input_size,
                                            float score_threshold,
                                            float nms_threshold,
                                            int top_k)
        使用给定参数创建人脸检测器类的一个实例
        参数
        model - 所需模型的路径
        config - 配置文件路径(用于兼容性,ONNX 模型不需要此项)
        input_size - 输入图像的尺寸
        score_threshold - 用于过滤掉分数小于给定值的边界框的阈值
        nms_threshold - 用于抑制 IoU 大于给定值的边界框的阈值
        top_k - 在 NMS 之前保留前 K 个边界框
        返回
        自动生成
      • create

        public static FaceDetectorYN create​(java.lang.String model,
                                            java.lang.String config,
                                            Size input_size,
                                            float score_threshold,
                                            float nms_threshold)
        使用给定参数创建人脸检测器类的一个实例
        参数
        model - 所需模型的路径
        config - 配置文件路径(用于兼容性,ONNX 模型不需要此项)
        input_size - 输入图像的尺寸
        score_threshold - 用于过滤掉分数小于给定值的边界框的阈值
        nms_threshold - 用于抑制 IoU 大于给定值的边界框的阈值
        返回
        自动生成
      • create

        public static FaceDetectorYN create​(java.lang.String model,
                                            java.lang.String config,
                                            Size input_size,
                                            float score_threshold)
        使用给定参数创建人脸检测器类的一个实例
        参数
        model - 所需模型的路径
        config - 配置文件路径(用于兼容性,ONNX 模型不需要此项)
        input_size - 输入图像的尺寸
        score_threshold - 用于过滤掉分数小于给定值的边界框的阈值
        返回
        自动生成
      • create

        public static FaceDetectorYN create​(java.lang.String model,
                                            java.lang.String config,
                                            Size input_size)
        使用给定参数创建人脸检测器类的一个实例
        参数
        model - 所需模型的路径
        config - 配置文件路径(用于兼容性,ONNX 模型不需要此项)
        input_size - 输入图像的尺寸
        返回
        自动生成
      • create

        public 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)
        参数
        framework - 原始框架名称
        bufferModel - 包含二进制权重文件内容的缓冲区
        bufferConfig - 包含网络配置文本文件内容的缓冲区
        input_size - 输入图像的尺寸
        score_threshold - 用于过滤掉分数小于给定值的边界框的阈值
        nms_threshold - 用于抑制 IoU 大于给定值的边界框的阈值
        top_k - 在 NMS 之前保留前 K 个边界框
        backend_id - 后端 ID
        target_id - 目标设备 ID
        返回
        自动生成
      • create

        public 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)
        参数
        framework - 原始框架名称
        bufferModel - 包含二进制权重文件内容的缓冲区
        bufferConfig - 包含网络配置文本文件内容的缓冲区
        input_size - 输入图像的尺寸
        score_threshold - 用于过滤掉分数小于给定值的边界框的阈值
        nms_threshold - 用于抑制 IoU 大于给定值的边界框的阈值
        top_k - 在 NMS 之前保留前 K 个边界框
        backend_id - 后端 ID
        返回
        自动生成
      • create

        public static FaceDetectorYN create​(java.lang.String framework,
                                            MatOfByte bufferModel,
                                            MatOfByte bufferConfig,
                                            Size input_size,
                                            float score_threshold,
                                            float nms_threshold,
                                            int top_k)
        参数
        framework - 原始框架名称
        bufferModel - 包含二进制权重文件内容的缓冲区
        bufferConfig - 包含网络配置文本文件内容的缓冲区
        input_size - 输入图像的尺寸
        score_threshold - 用于过滤掉分数小于给定值的边界框的阈值
        nms_threshold - 用于抑制 IoU 大于给定值的边界框的阈值
        top_k - 在 NMS 之前保留前 K 个边界框
        返回
        自动生成
      • create

        public static FaceDetectorYN create​(java.lang.String framework,
                                            MatOfByte bufferModel,
                                            MatOfByte bufferConfig,
                                            Size input_size,
                                            float score_threshold,
                                            float nms_threshold)
        参数
        framework - 原始框架名称
        bufferModel - 包含二进制权重文件内容的缓冲区
        bufferConfig - 包含网络配置文本文件内容的缓冲区
        input_size - 输入图像的尺寸
        score_threshold - 用于过滤掉分数小于给定值的边界框的阈值
        nms_threshold - 用于抑制 IoU 大于给定值的边界框的阈值
        返回
        自动生成
      • create

        public static FaceDetectorYN create​(java.lang.String framework,
                                            MatOfByte bufferModel,
                                            MatOfByte bufferConfig,
                                            Size input_size,
                                            float score_threshold)
        参数
        framework - 原始框架名称
        bufferModel - 包含二进制权重文件内容的缓冲区
        bufferConfig - 包含网络配置文本文件内容的缓冲区
        input_size - 输入图像的尺寸
        score_threshold - 用于过滤掉分数小于给定值的边界框的阈值
        返回
        自动生成
      • create

        public static FaceDetectorYN create​(java.lang.String framework,
                                            MatOfByte bufferModel,
                                            MatOfByte bufferConfig,
                                            Size input_size)
        参数
        framework - 原始框架名称
        bufferModel - 包含二进制权重文件内容的缓冲区
        bufferConfig - 包含网络配置文本文件内容的缓冲区
        input_size - 输入图像的尺寸
        返回
        自动生成
      • finalize

        protected void finalize()
                         throws java.lang.Throwable
        重写
        java.lang.Object 类中的 finalize 方法
        抛出
        java.lang.Throwable