zoukankan      html  css  js  c++  java
  • 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();
            }
        }
    }
    
  • 相关阅读:
    sql,linq基础再一次学习
    position与aop
    java基础常用类!
    JNI初步!
    java基础动态代理!
    java基础面向对象!
    php初步!
    java基础泛型!
    java基础对象多态性!
    java基础io流!
  • 原文地址:https://www.cnblogs.com/RegressionWorldLine/p/5753801.html
Copyright © 2011-2022 走看看