System.Drawing.Rectangle[] regions; if (GpuInvoke.HasCuda) { GpuHOGDescriptor des = new GpuHOGDescriptor(); des.SetSVMDetector(GpuHOGDescriptor.GetDefaultPeopleDetector()); using (GpuImage<Bgr, Byte> gpuImg = new GpuImage<Bgr, byte>(frame)) using (GpuImage<Bgra, Byte> gpuBgra = gpuImg.Convert<Bgra, Byte>()) { regions = des.DetectMultiScale(gpuBgra, 0, new Size(8, 8), new Size(0, 0), 1.04, 8); foreach (var item in regions) { frame.Draw(new Rectangle(item), new Bgr(Color.Red), 1); } } des.Dispose(); } else { //this is the CPU version using (HOGDescriptor des = new HOGDescriptor()) { des.SetSVMDetector(HOGDescriptor.GetDefaultPeopleDetector()); regions = des.DetectMultiScale(frame); } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)