C# Onnx Dense Face 3D人脸重建,人脸Mesh

效果

C# Onnx Dense Face 3D人脸重建,人脸Mesh_第1张图片

C# Onnx Dense Face 3D人脸重建,人脸Mesh_第2张图片

项目

C# Onnx Dense Face 3D人脸重建,人脸Mesh_第3张图片

代码

using OpenCvSharp;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;

namespace Onnx_Demo
{
    public partial class frmMain : Form
    {
        public frmMain()
        {
            InitializeComponent();
        }

        string fileFilter = "*.*|*.bmp;*.jpg;*.jpeg;*.tiff;*.tiff;*.png";
        string image_path = "";

        DateTime dt1 = DateTime.Now;
        DateTime dt2 = DateTime.Now;

        Mat image;

        private void button1_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();
            ofd.Filter = fileFilter;
            if (ofd.ShowDialog() != DialogResult.OK) return;

            pictureBox1.Image = null;
            pictureBox2.Image = null;
            textBox1.Text = "";

            image_path = ofd.FileName;
            pictureBox1.Image = new Bitmap(image_path);
            image = new Mat(image_path);
        }

        private void Form1_Load(object sender, EventArgs e)
        {
           
        }

        private void button2_Click(object sender, EventArgs e)
        {
            if (image_path == "")
            {
                return;
            }
            textBox1.Text = "检测中,请稍等……";
            pictureBox2.Image = null;
            Application.DoEvents();

            image = new Mat(image_path);

            Detect_Face detect_net = new Detect_Face(0.7f);
            Face_Mesh mesh_net = new Face_Mesh("mesh");//choices=["dense", "mesh"]

            dt1 = DateTime.Now;
            List bboxes = detect_net.detect(image);

            foreach (var item in bboxes)
            {
                mesh_net.detect(image, new List() { item });
            }
            dt2 = DateTime.Now;

            pictureBox2.Image = new Bitmap(image.ToMemoryStream());
            textBox1.Text = "推理耗时:" + (dt2 - dt1).TotalMilliseconds + "ms";
        }

        private void pictureBox2_DoubleClick(object sender, EventArgs e)
        {
            Common.ShowNormalImg(pictureBox2.Image);
        }

        private void pictureBox1_DoubleClick(object sender, EventArgs e)
        {
            Common.ShowNormalImg(pictureBox1.Image);
        }
    }
}

下载

源码下载

其他

C++ 3D人脸重建,人头姿势估计,人脸Mesh-CSDN博客

你可能感兴趣的:(Onnx,AI,C#,3D人脸重建,人脸Mesh)