项目介绍
ViewFaceCore是一个基于 SeetaFace6 的 .NET 人脸识别解决方案。
项目特点
-
开源(MIT license)、免费、简单的离线人脸识别库。
-
跨平台(适用于 Windows、MacOS 和 Linux )。
.NET 框架 和 操作系统
封装完善的NuGet包
获取人脸信息示例代码
更多案例可以下载源码查看Demo。
using SkiaSharp;
using System;
using ViewFaceCore.Core;
using ViewFaceCore.Model;namespace ViewFaceCore.Demo.ConsoleApp
{internal class Program{private readonly static string imagePath = @"images/Jay_3.jpg";static void Main(string[] args){using var bitmap = SKBitmap.Decode(imagePath);using FaceDetector faceDetector = new FaceDetector();FaceInfo[] infos = faceDetector.Detect(bitmap);Console.WriteLine($"识别到的人脸数量:{infos.Length} 个人脸信息:\n");Console.WriteLine($"No.\t人脸置信度\t位置信息");for (int i = 0; i < infos.Length; i++){Console.WriteLine($"{i}\t{infos[i].Score:f8}\t{infos[i].Location}");}Console.ReadKey();}}
}
识别人脸并标记出来示例代码
using System;
using System.Drawing;
using System.Linq;
using ViewFaceCore;
using ViewFaceCore.Core;
using ViewFaceCore.Model;namespace Demo
{internal class Program{private readonly static string imagePath = @"images/Jay_3.jpg";private readonly static string outputPath = @"images/Jay_out.jpg";static void Main(string[] args){using var bitmap = (Bitmap)Image.FromFile(imagePath);using FaceDetector faceDetector = new FaceDetector();FaceInfo[] infos = faceDetector.Detect(bitmap);//输出人脸信息Console.WriteLine($"识别到的人脸数量:{infos.Length} 个人脸信息:\n");Console.WriteLine($"No.\t人脸置信度\t位置信息");for (int i = 0; i < infos.Length; i++){Console.WriteLine($"{i}\t{infos[i].Score:f8}\t{infos[i].Location}");}//画方框,标记人脸using (Graphics g = Graphics.FromImage(bitmap)){g.DrawRectangles(new Pen(Color.Red, 4), infos.Select(p => new RectangleF(p.Location.X, p.Location.Y, p.Location.Width, p.Location.Height)).ToArray());}bitmap.Save(outputPath);Console.WriteLine($"输出图片已保存至:{outputPath}");Console.WriteLine();}}
}
功能截图
开源地址
https://github.com/ViewFaceCore/ViewFaceCore