hi i'm doing project for human detection using HOG approach.But,i can't detect human
Here is the code
namespace HumanActiviyDetection
{
public partial class Form1 : Form
{
Capture _capture;
Image<bgr,> frame;
Image<bgr,> previous_frame;
public Form1()
{
InitializeComponent();
_capture = new Capture();
_capture.ImageGrabbed += processframe;
_capture.Start();
}
public Bitmap Find(Image<bgr,> image, ref System.Drawing.Rectangle[] regionsg)
{
Rectangle[] regions;
if (GpuInvoke.HasCuda)
{
GpuHOGDescriptor des = new GpuHOGDescriptor();
des.SetSVMDetector(GpuHOGDescriptor.GetDefaultPeopleDetector());
using (GpuImage<bgr,> gpuImg = new GpuImage<bgr,>(image))
using (GpuImage<bgra,> gpuBgra = gpuImg.Convert<bgra,>())
{
regions = des.DetectMultiScale(gpuBgra, 0, new Size(8, 8), new Size(0, 0), 1.04, 8);
}
}
else
{
using (HOGDescriptor des = new HOGDescriptor())
{
des.SetSVMDetector(HOGDescriptor.GetDefaultPeopleDetector());
regions = des.DetectMultiScale(image);
}
}
regionsg = regions;
foreach (Rectangle pedestrain in regions)
{
MCvFont font = new MCvFont(Emgu.CV.CvEnum.FONT.CV_FONT_HERSHEY_COMPLEX, 1.0, 1.0);
image.Draw(new LineSegment2D(new Point(pedestrain.X + ((int)pedestrain.Width / 2), pedestrain.Y + (int)(pedestrain.Height / 4)), new Point(pedestrain.X + ((int)pedestrain.Width / 2), pedestrain.Y + pedestrain.Height - (int)(pedestrain.Height / 6))), new Bgr(Color.Red), 3);
}
return image.ToBitmap();
}
private void processframe(object sender, EventArgs e)
{
if (frame == null)
{
frame = _capture.RetrieveBgrFrame();
displayimage(frame.ToBitmap(), DisplayBox);
previous_frame = frame.Copy();
}
else
{
frame = _capture.RetrieveBgrFrame();
previous_frame = frame.Copy();
displayimage(previous_frame.ToBitmap(), DisplayBox);
displayimage(frame.ToBitmap(), CaptureBox);
}
}
private delegate void displaydelegate(Bitmap image, PictureBox contol);
private void displayimage(Bitmap image, PictureBox control)
{
if (CaptureBox.InvokeRequired)
{
try
{
displaydelegate di = new displaydelegate(displayimage);
this.BeginInvoke(di, new object[] { image, control });
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
else
{
control.Image = image;
}
}