无法将类型'Emgu.CV.Structure.MCvObjectDetection []隐式转换为'System.Drawing.Rectangle []

时间:2019-07-11 14:00:48

标签: c# .net emgucv

我从emgu网站获得了该代码,我修复了一些错误,但我可以理解另外2个错误,我需要两个区域都提供帮助= bla bla bla给出了相同的错误:“无法隐式转换类型'Emgu.CV。从Structure.MCvObjectDetection []到'System.Drawing.Rectangle []“

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

        //check if there is a compatible GPU to run pedestrian detection
        if (CudaInvoke.HasCuda)
        {  //this is the GPU version

            using (HOGDescriptor des = new HOGDescriptor())
            {
                des.SetSVMDetector(HOGDescriptor.GetDefaultPeopleDetector());

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

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

        processingTime = watch.ElapsedMilliseconds;

        foreach (Rectangle pedestrain in regions)
        {
            image.Draw(pedestrain, new Bgr(Color.Red), 1);
        }
        return image;
    }

0 个答案:

没有答案