我正在尝试使用图书馆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;
}
}