C# 百度人脸识别

1、到百度官方网站购买Key,和下载C#人脸识别项目

2、本地绑定Key

// sdk初始化
        [DllImport("BaiduFaceApi.dll", EntryPoint = "sdk_init", CharSet = CharSet.Ansi
            , CallingConvention = CallingConvention.Cdecl)]
        public static extern int sdk_init(string model_path);
        // 特征值比对(传2个人脸的特征值,所有的1:1比对归根结底都是特征值比对,都可通过提取特征值来比对)
        [DllImport("BaiduFaceApi.dll", EntryPoint = "compare_feature", CharSet = CharSet.Ansi
            , CallingConvention = CallingConvention.Cdecl)]
        // type为0表示提取生活照的特征值,1表示证件照的特征值,2表示nir的特征值
        private static extern float compare_feature(ref BDFaceFeature f1, ref BDFaceFeature f2, int type = 0);

        //人脸检测 type 0: 表示rgb 人脸检测 1:表示nir人脸检测
        [DllImport("BaiduFaceApi.dll", EntryPoint = "detect", CharSet = CharSet.Ansi
           , CallingConvention = CallingConvention.Cdecl)]
        public static extern int detect(IntPtr ptr, IntPtr mat, int type);

        [DllImport("BaiduFaceApi.dll", EntryPoint = "face_blur", CharSet = CharSet.Ansi
       , CallingConvention = CallingConvention.Cdecl)]
        private static extern int face_blur(IntPtr ptr, IntPtr mat);
        // 单目RGB静默活体检测
        [DllImport("BaiduFaceApi.dll", EntryPoint = "rgb_liveness", CharSet = CharSet.Ansi
           , CallingConvention = CallingConvention.Cdecl)]
        private static extern int rgb_liveness(IntPtr ptr_trackinfo, IntPtr ptr_score, IntPtr mat);

        // 提取人脸特征值
        [DllImport("BaiduFaceApi.dll", EntryPoint = "face_feature", CharSet = CharSet.Ansi
            , CallingConvention = CallingConvention.Cdecl)]
        // 返回num为特征值的人数,type为0表示提取生活照的特征值,1表示证件照的特征值,2表示nir的特征值
        public static extern int face_feature(IntPtr feature, IntPtr box, IntPtr mat, int type);
        // 返回num为特征值的人数,通过rgb+depth双面摄像头提取特征值
        [DllImport("BaiduFaceApi.dll", EntryPoint = "rgbd_feature", CharSet = CharSet.Ansi
           , CallingConvention = CallingConvention.Cdecl)]
        public static extern int rgbd_feature(IntPtr feature, IntPtr box, IntPtr rgb_mat, IntPtr depth_mat);
        // 是否授权
        [DllImport("BaiduFaceApi.dll", EntryPoint = "is_auth", CharSet = CharSet.Ansi
               , CallingConvention = CallingConvention.Cdecl)]
        public static extern bool is_auth();
        // sdk销毁
        [DllImport("BaiduFaceApi.dll", EntryPoint = "sdk_destroy", CharSet = CharSet.Ansi
            , CallingConvention = CallingConvention.Cdecl)]

 

你可能感兴趣的:(C#,c#,java,算法)