首页 > 其他分享 >ViewFaceCore

ViewFaceCore

时间:2023-09-18 23:22:20浏览次数:37  
标签:faceRecognizer faceImage0 faceImage1 ViewFaceCore static using

https://github.com/ViewFaceCore/ViewFaceCore

 

using SkiaSharp;
using System.Diagnostics;
using System.Drawing;
using ViewFaceCore.Core;
using ViewFaceCore.Models;
using static System.Net.Mime.MediaTypeNames;

namespace ConsoleApp16
{
    internal class Program
    {

        private readonly static string imagePath0 = @"d:\\img\mm.jpg";
        private readonly static string imagePath1 = @"d:\\img\timg.jpg";

        static void Main(string[] args)
        {
            Stopwatch sw = Stopwatch.StartNew();
            sw.Start();

            using var faceImage0 = SKBitmap.Decode(imagePath0).ToFaceImage();
            using var faceImage1 = SKBitmap.Decode(imagePath1).ToFaceImage();
            //检测人脸信息
            using FaceDetector faceDetector = new FaceDetector();
            FaceInfo[] infos0 = faceDetector.Detect(faceImage0);
            FaceInfo[] infos1 = faceDetector.Detect(faceImage1);
            //标记人脸位置
            using FaceLandmarker faceMark = new FaceLandmarker();
            FaceMarkPoint[] points0 = faceMark.Mark(faceImage0, infos0[0]);
            FaceMarkPoint[] points1 = faceMark.Mark(faceImage1, infos1[0]);
            //提取特征值
            using FaceRecognizer faceRecognizer = new FaceRecognizer();
            float[] data0 = faceRecognizer.Extract(faceImage0, points0);
            float[] data1 = faceRecognizer.Extract(faceImage1, points1);
            //对比特征值
            bool isSelf = faceRecognizer.IsSelf(data0, data1);

            Console.WriteLine($"识别到的人脸是否为同一人:{isSelf},对比耗时:{sw.ElapsedMilliseconds}ms");
            Console.WriteLine();
            sw.Stop();
        }
    }
}

  

标签:faceRecognizer,faceImage0,faceImage1,ViewFaceCore,static,using
From: https://www.cnblogs.com/chinasoft/p/17713423.html

相关文章