Difference between revisions of "Talk:Pedestrian Detection in CSharp"

From Emgu CV: OpenCV in .NET (C#, VB, C++ and more)
Jump to navigation Jump to search
(Created page with "I'm learning to program pedestrian detection with a webcam, but I found the problem, when the program is run the video is slow, help me to solve this problem, thanks. source c...")
 
Line 2: Line 2:
 
source code that I use like this
 
source code that I use like this
  
using System;
+
<nowiki>using System;
 
using System.Collections.Generic;
 
using System.Collections.Generic;
 
using System.ComponentModel;
 
using System.ComponentModel;
Line 106: Line 106:
 
     }
 
     }
 
}
 
}
 +
</nowiki>

Revision as of 12:19, 28 February 2013

I'm learning to program pedestrian detection with a webcam, but I found the problem, when the program is run the video is slow, help me to solve this problem, thanks. source code that I use like this

using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using Emgu.CV; using Emgu.CV.Structure; using Emgu.Util; using Emgu.CV.UI; using Emgu.CV.GPU; namespace PedestrianDetection { public partial class CameraCapture : Form { //declaring global variables private Capture capture; //takes images from camera as image frames Boolean camFlip = true; public CameraCapture() { InitializeComponent(); } private void ProcessFrame(object sender, EventArgs arg) { Image<Bgr, Byte> ImageFrame = capture.QueryFrame(); if (ImageFrame != null) // confirm that image is valid { Image<Gray, byte> grayframe = ImageFrame.Convert<Gray, byte>(); long processingTime; Rectangle[] results = FindPedestrian.Find(ImageFrame, out processingTime); foreach (Rectangle rect in results) ImageFrame.Draw(rect, new Bgr(Color.Red), 10); } CamImageBox.Image = ImageFrame; } private void btnStart_Click(object sender, EventArgs e) { if (capture != null) { if (btnStart.Text == "Pause") { //if camera is getting frames then pause the capture and set button Text to // "Resume" for resuming capture btnStart.Text = "Resume"; // Application.Idle -= ProcessFrame; } else { //if camera is NOT getting frames then start the capture and set button // Text to "Pause" for pausing capture btnStart.Text = "Pause"; Application.Idle += ProcessFrame; } } } private void ReleaseData() { if (capture != null) capture.Dispose(); } private void cbCamIndex_SelectedIndexChanged(object sender, EventArgs e) { //Set the camera number to the one selected via combo box int CamNumber = -1; CamNumber = int.Parse(cbCamIndex.Text); //Start the selected camera #region if capture is not created, create it now if (capture == null) { try { capture = new Emgu.CV.Capture(CamNumber); } catch (NullReferenceException excpt) { MessageBox.Show(excpt.Message); } } #endregion //Start showing the stream from camera btnStart_Click(sender, e); btnStart.Enabled = true; if (camFlip == true) { capture.FlipHorizontal = !capture.FlipHorizontal; camFlip = false; } } } }