C# 如何在Emgucv中检测猪的身体上部(肩部和头部)

C# 如何在Emgucv中检测猪的身体上部(肩部和头部),c#,emgucv,C#,Emgucv,我用Emgucv检测整个身体。请帮助我,当人类坐着时,我无法发现任何人。这就是为什么我想检测上半身,这样当人类坐在椅子上时,就可以检测到人类。我也想 数人 了解在图像的哪个部分检测到人类 public Image<Bgr, Byte> Search(Image<Bgr, Byte> image, out long processingTime) { processingTime = 0; Stopwatch watch; Rectangle[] r

我用Emgucv检测整个身体。请帮助我,当人类坐着时,我无法发现任何人。这就是为什么我想检测上半身,这样当人类坐在椅子上时,就可以检测到人类。我也想

数人 了解在图像的哪个部分检测到人类

public Image<Bgr, Byte> Search(Image<Bgr, Byte> image, out long processingTime)
{
    processingTime = 0;
    Stopwatch watch;
    Rectangle[] regions;

    check if there is a compatible GPU to run pedestrian detection
    if (GpuInvoke.HasCuda)
    {  //this is the GPU version
        using (GpuHOGDescriptor des = new GpuHOGDescriptor())
        {
            des.SetSVMDetector(GpuHOGDescriptor.GetDefaultPeopleDetector());

            watch = Stopwatch.StartNew();
            using (GpuImage<Bgr, Byte> gpuImg = new GpuImage<Bgr, byte>(image))
            using (GpuImage<Bgra, Byte> gpuBgra = gpuImg.Convert<Bgra, Byte>())
            {
                regions = des.DetectMultiScale(gpuBgra);
            }
        }
    }
    else
    {  //this is the CPU version
    using (Emgu.CV.HOGDescriptor des = new HOGDescriptor())
    {
        des.SetSVMDetector(HOGDescriptor.GetDefaultPeopleDetector());

        watch = Stopwatch.StartNew();
        regions = des.DetectMultiScale(image);
    }
    }
    watch.Stop();

    processingTime = watch.ElapsedMilliseconds;
    LblProcessingTime.Text = processingTime.ToString();
    foreach (Rectangle pedestrain in regions)
    {
        image.Draw(pedestrain, new Bgr(Color.Red), 6);
    }
    return image;

}

下载并安装haarcascade_upperbody.xml并将其复制到bin/debug文件夹。并使用

     Image<Gray, byte> grayframe = capture.RetrieveBgrFrame().Convert<Gray, byte>();

    static string HCSUpperBody = "haarcascade_upperbody.xml";

      var faces = grayframe.DetectHaarCascade(hcBodyDetector, 1.2, 6, HAAR_DETECTION_TYPE.DO_CANNY_PRUNING, new Size())[0];




                     foreach (var face in faces)
                     {
                         image.Draw(face.rect, new Bgr(0, double.MaxValue, 0), 3);
                     }
picturebox1.image=image.toBitmap