[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 小时前
置身AI内
人工智能
IT_陈寒3 小时前
JavaScript项目实战经验分享
前端·人工智能·后端
vanuan4 小时前
两个AI智能体第一次对话-A2A双Agent协作实战
人工智能
kfaino6 小时前
码农的AI翻身(四)你好,我叫 Attention
人工智能·后端
雨落Re8 小时前
如何设计一个高质量Skill
人工智能
Token炼金师8 小时前
大模型权重文件全指南:从格式选择到优化实战
人工智能
阿牛哥_GX8 小时前
CDP 浏览器操控原理:让脚本接管你的浏览器
人工智能
ThreeS8 小时前
手搓MiniVLA全实战教程-一步一步用pytorch解释原理与思路
人工智能·python
米小虾9 小时前
Loop Engineering —— 循环的设计与自主执行
人工智能·agent
米小虾9 小时前
Harness Engineering —— 系统的安全护栏
人工智能·agent