[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

 视频演示:

源码下载:

最近更新

  1. TCP协议是安全的吗?

    2024-01-01 10:20:02       16 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-01-01 10:20:02       16 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-01-01 10:20:02       15 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-01-01 10:20:02       18 阅读

热门阅读

  1. Python求特殊a串数列和

    2024-01-01 10:20:02       38 阅读
  2. 使用some 或者 every 方法遇到异常没有return

    2024-01-01 10:20:02       41 阅读
  3. 全连接层:神经网络的桥梁

    2024-01-01 10:20:02       43 阅读
  4. Excel数据写入Word 轻松套打通知书、证书、票据等

    2024-01-01 10:20:02       41 阅读
  5. udp进行数据发送与接收

    2024-01-01 10:20:02       33 阅读