Emgu下的HOG行人检测算法示例

采用opencv自带的svm分类器,演示采用HOG算法的行人检测

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Emgu.CV;
using Emgu.CV.Structure;

namespace HOGtest
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Image<Bgr, Byte> img = new Image<Bgr, Byte>("001.jpg");//测试图片
            Emgu.CV.HOGDescriptor hog = new HOGDescriptor();//建立HOG描述子
            hog.SetSVMDetector(HOGDescriptor.GetDefaultPeopleDetector());//设置分类器模型数据,这里是opencv默认的模型
            MCvObjectDetection[] vec = hog.DetectMultiScale(img);//获得检测结果
            Image<Bgr, Byte> ss = new Image<Bgr, Byte>(img.ToBitmap());//在新图像上表示结果
            for (int i = 0; i < vec.GetLength(0); i++)
            {
                Rectangle r = vec[i].Rect;
                MCvScalar s = new MCvScalar(0,0,0);
                CvInvoke.Rectangle(ss,r,s);
            }
            pictureBox1.Image = ss.ToBitmap();
        }
    }
}

转载于:https://www.cnblogs.com/RegressionWorldLine/p/5753801.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值