【发布时间】:2012-12-04 16:53:02
【问题描述】:
我正在开发一个 C# windows 窗体应用程序。当我的网络摄像头检测到超过 2 个面孔时,我如何编辑我的代码。
更多信息:
当 "FaceDetectedLabel.Text = "检测到人脸:" + cam.facesdetected.ToString();"变为检测到人脸:2 或更多...
我该怎么做:
- 最小化所有正在运行的程序,除了我的应用程序。
这是我的代码:
namespace PBD
{
public partial class MainPage : Form
{
//declaring global variables
private Capture capture; //takes images from camera as image frames
public MainPage()
{
InitializeComponent();
}
private void ProcessFrame(object sender, EventArgs arg)
{
Wrapper cam = new Wrapper();
//show the image in the EmguCV ImageBox
WebcamPictureBox.Image = cam.start_cam(capture).Resize(390, 243, Emgu.CV.CvEnum.INTER.CV_INTER_CUBIC).ToBitmap();
FaceDetectedLabel.Text = "Faces Detected : " + cam.facesdetected.ToString();
}
private void MainPage_Load(object sender, EventArgs e)
{
#region if capture is not created, create it now
if (capture == null)
{
try
{
capture = new Capture();
}
catch (NullReferenceException excpt)
{
MessageBox.Show(excpt.Message);
}
}
#endregion
Application.Idle += ProcessFrame;
}
【问题讨论】:
-
我不确定当检测到两个以上的面孔时如何调用该函数。我该怎么做?
-
@Derek 这个问题很可能会被关闭,因为它太宽泛了。我建议您将问题分解为单独的逻辑/功能问题并单独解决它们 - 然后才尝试将它们组合成最终解决方案。