-2

我正在开发一个 C# windows 窗体应用程序。当我的网络摄像头检测到超过 2 个面孔时,我如何编辑我的代码。

更多信息:

当 "FaceDetectedLabel.Text = "检测到人脸:" + cam.facesdetected.ToString();" 变为Face Detected: 2 or more...

我该怎么做:

  • 最小化除我的应用程序之外的所有程序运行。

这是我的代码:

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;
        }
4

1 回答 1

3

检查这篇文章:

如何以编程方式最小化打开的窗口文件夹

您必须枚举所有进程并排除当前进程(您的进程),而不是获取“资源管理器”进程。我建议还进行异常处理和一些检查,因为并非所有进程都有要最小化的窗口

还有这篇关于注销部分的帖子:

Log off user from Win XP programmatically in C#

于 2012-12-04T17:03:04.297 回答