本文主要是介绍[C#]OpenCvSharp实现Yolov8 Face Landmarks 人脸关键点检测,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
介绍:
github地址:https://github.com/derronqi/yolov8-face
效果:
项目:
代码:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using OpenCvSharp;namespace FIRC
{public partial class Form1 : Form{Mat src = new Mat();FaceDetector fd = new FaceDetector();public Form1(){InitializeComponent();}private void button1_Click(object sender, EventArgs e){OpenFileDialog openFileDialog = new OpenFileDialog();openFileDialog.Filter = "图文件(*.*)|*.jpg;*.png;*.jpeg;*.bmp";openFileDialog.RestoreDirectory = true;openFileDialog.Multiselect = false;if (openFileDialog.ShowDialog() == DialogResult.OK){src = Cv2.ImRead(openFileDialog.FileName);pictureBox1.Image = OpenCvSharp.Extensions.BitmapConverter.ToBitmap(src);}}private void button2_Click(object sender, EventArgs e){if(pictureBox1.Image==null){return;}var results = fd.Inference(src);var resultMat = fd.DrawImage(src,results);pictureBox2.Image= OpenCvSharp.Extensions.BitmapConverter.ToBitmap(resultMat); //Mat转Bitmap}private void Form1_Load(object sender, EventArgs e){fd.LoadWeights(Application.StartupPath+"\\weights\\yolov8n-face.onnx");}private void btn_video_Click(object sender, EventArgs e){}}
}
测试环境:
vs2019
net framework4.7.2
opencvsharp4.8
视频演示:
源码下载:
这篇关于[C#]OpenCvSharp实现Yolov8 Face Landmarks 人脸关键点检测的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!