1

我正在尝试使用库 emgucv 开发一个自动制服试衣应用程序,在该应用程序中,用户将被要求站在相机前拍摄他们的整个身体,并且从图片中系统将给出他们的标准尺寸(S, M、L、XL、...等)。所以我所做的是使用 haarcascade 来检测用户的上半身。

我的问题是它不能精确检测如何提高系统的检测性能?(对不起我的英语不好)

这是我的代码:

    void viewImage(object sender, EventArgs e)
    {
        img = camera.QueryFrame();
        if (img == null)
            return;
        CamImageBox.Image = img;
    }

    private void btnCapture_Click(object sender, EventArgs e)
    {
        if (captureProcess == true)
        {
            string data;

            Application.Idle -= viewImage;
            captureProcess = false;
            SaveFileDialog dlg = new SaveFileDialog();
            //dlg="Image|*.jpg;*png";
            if (dlg.ShowDialog() == DialogResult.OK)
            {
                img.ToBitmap().Save(dlg.FileName + ".jpg");
                data = dlg.FileName + ".jpg";
            }
            measureImage();
        }
    }

    void measureImage()
    {
        OpenFileDialog dlg2 = new OpenFileDialog();
        dlg2.Filter = "Image|*.jpg;*png";
        if (dlg2.ShowDialog() == DialogResult.OK)
        {
            Image<Bgr, Byte> frame = new Image<Bgr, byte>(dlg2.FileName);
            Image<Gray, Byte> Gray_Frame = frame.Convert<Gray, Byte>();

            MCvAvgComp[][] LowerBodyDetect = Gray_Frame.DetectHaarCascade(
                LowerBody,
                1.0,
                10,
                Emgu.CV.CvEnum.HAAR_DETECTION_TYPE.DO_CANNY_PRUNING,
                new Size());

            MCvAvgComp[][] UpperBodyDetect = Gray_Frame.DetectHaarCascade(
                UpperBody,
                2.1,
                5,
                Emgu.CV.CvEnum.HAAR_DETECTION_TYPE.DO_CANNY_PRUNING,
                new Size());


            foreach (MCvAvgComp Upp_Body in UpperBodyDetect[0])
            {
                frame.Draw(Upp_Body.rect, new Bgr(Color.Red), 2);
                double width=(Upp_Body.rect.Width*0.264583333);
                textBox1.Text = (Convert.ToString(width));
            }

            foreach (MCvAvgComp Low_Body in LowerBodyDetect[0])
            {
                frame.Draw(Low_Body.rect, new Bgr(Color.Green), 2);
            }
            CamImageBox.Image = frame;
        }

    }

    private void Form1_Load(object sender, EventArgs e)
    {
        try
        {
            camera = new Capture();
        }
        catch (Exception exc)
        {
            MessageBox.Show(exc.Message);
            return;
        }
        Application.Idle += viewImage;
        captureProcess = true;
    }
}
4

0 回答 0