用于人员检测的 Emgu 训练 SVM - C#

Emgu Train SVM for people detection - C#

我在网上搜索了很多,找不到任何简单的解决方案。

我正在尝试创建一个人物检测器,为此我选择了 Emgu 库。

目前我能够检测到人,但成功率不高。

我正在尝试训练我的 SVM,我看到了这个 post:SVM classifier based on HOG features for “object detection” in OpenCV 我需要训练的过程:

Step 1) Prepare some training images of the objects you want to detect (positive samples). Also you will need to prepare some images with no objects of interest (negative samples).

Step 2) Detect HOG features of the training sample and use this features to train an SVM classifier (also provided in OpenCV).

Step 3) Use the coefficients of the trained SVM classifier in HOGDescriptor::setSVMDetector() method.

我有一些训练图像,我正在使用这行代码来提取 HOG 特征:

public static Image<Bgr, Byte> Resize(Image<Bgr, Byte> im)
    {
        return im.Resize(64, 128,   Inter.Linear);
    }
    public static float[] GetVector(Image<Bgr, Byte> im)
    {
        HOGDescriptor hog = new HOGDescriptor();    // with defaults values
        Image<Bgr, Byte> imageOfInterest = Resize(im);
        Point[] p = new Point[imageOfInterest.Width * imageOfInterest.Height];
        int k = 0;
        for (int i = 0; i < imageOfInterest.Width; i++)
        {
            for (int j = 0; j < imageOfInterest.Height; j++)
            {
                Point p1 = new Point(i, j);
                p[k++] = p1;
            }
        }

        return hog.Compute(imageOfInterest, new Size(8, 8), new Size(0, 0), p);
    }

但我找不到如何训练我的 SVM(上述步骤中的第 2 步)。

使用 OpenCV 进行人物检测并不简单(EmguCV 只是它的 C# 包装器)。人们可以采取不同的姿势:正面、侧面、手 up/down 等。这比使用 HAAR Cascade (http://docs.opencv.org/3.1.0/d7/d8b/tutorial_py_face_detection.html#gsc.tab=0) 检测人脸的任务还要复杂。

您需要重新考虑您的方法,因为您使用 XBox Kinect 的机会要大得多。 Kinect SDK 具有检测人的必要功能。查看此答案:

我已经做到了。 注意:它有一些问题我还没有用太多的 HoG 特性解决。

密码是:

//GetVector - function from people detection file 
float[] hog = GetVector(new Image<Bgr, byte>(image));

 svm.TrainAuto(new TrainData(training_mat, Emgu.CV.ML.MlEnum.DataLayoutType.RowSample, lables));