[C#]利用opencvsharp实现深度学习caffe模型人脸检测

【官方框架地址】

https://github.com/opencv/opencv/blob/master/samples/dnn/face_detector/deploy.prototxt

采用的是官方caffe模型res10_300x300_ssd_iter_140000.caffemodel进行人脸检测

【算法原理】

使用caffe-ssd目标检测框架训练的caffe模型进行深度学习模型检测

【效果】 

【实现部分代码】

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 result = fd.Inference(src);
            var resultMat = fd.DrawImage(src, result);
            pictureBox2.Image= OpenCvSharp.Extensions.BitmapConverter.ToBitmap(resultMat); //Mat转Bitmap
        }

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

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


【源码下载】

https://download.csdn.net/download/FL1623863129/88705587
【测试环境】

vs2019

netframework4.7.2

opencvsharp4.8.0

最近更新

  1. TCP协议是安全的吗?

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

    2024-01-06 08:16:03       16 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-01-06 08:16:03       15 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-01-06 08:16:03       18 阅读

热门阅读

  1. 【华为OD真题 Python】日志采集系统

    2024-01-06 08:16:03       39 阅读
  2. AUTOSAR从入门到精通-漫谈autosar软件架构(七)

    2024-01-06 08:16:03       41 阅读
  3. Python循环语句

    2024-01-06 08:16:03       37 阅读
  4. 怎么让视频进行加速处理并保存

    2024-01-06 08:16:03       36 阅读
  5. ElasticSearch——01全文检索

    2024-01-06 08:16:03       31 阅读
  6. 5.2 Android BCC环境搭建(eadb版 上)

    2024-01-06 08:16:03       32 阅读
  7. clickonce excel 插件发布安装的原理

    2024-01-06 08:16:03       35 阅读
  8. 贪心算法Day02

    2024-01-06 08:16:03       41 阅读