c# 人脸检测(典型方法)
2014-09-25 13:29
232 查看
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.CV.UI;
using System.IO;
using System.Xml;
namespace projectname
{
public partial class
Form1 : Form
{
int abc = 0;
public Form1()
{
InitializeComponent();
}
private Capture _capture;
private bool _captureInProgress;
private void ProcessFrame(object sender,
EventArgs arg)
{
Image<Bgr, Byte> frame =
_capture.QueryFrame();
frame =
frame.Flip(Emgu.CV.CvEnum.FLIP.HORIZONTAL);
Image<Gray, Byte> gray =
frame.Convert<Gray, Byte>();
//Convert it to Grayscale
gray._EqualizeHist();
HaarCascade face = new
HaarCascade("haarcascade_frontalface_alt2.xml");
MCvAvgComp[][] facesDetected = gray.DetectHaarCascade(face, 1.1, 2,
Emgu.CV.CvEnum.HAAR_DETECTION_TYPE.DO_CANNY_PRUNING, new Size(30,
30));
foreach
(MCvAvgComp f in facesDetected[0])
{
frame.Draw(f.rect, new
Bgr(Color.Red), 3);
}
imageBox1.Image = frame;
}
private void buttonOpenCapture_Click(object
sender, EventArgs e)
{
#region if
capture is not created, create it now
if
(_capture == null)
{
try
{
_capture = new Capture(0);
}
catch (NullReferenceException
excpt)
{
MessageBox.Show(excpt.Message);
}
}
#endregion
if
(_capture != null)
{
if (_captureInProgress)
{ //stop
the capture
buttonOpenCapture.Text = "打开视频";
Application.Idle -= ProcessFrame;
}
else
{
//start the capture
buttonOpenCapture.Text = "关闭视频";
Application.Idle += ProcessFrame;
}
_captureInProgress =
!_captureInProgress;
}
}
}
}
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.CV.UI;
using System.IO;
using System.Xml;
namespace projectname
{
public partial class
Form1 : Form
{
int abc = 0;
public Form1()
{
InitializeComponent();
}
private Capture _capture;
private bool _captureInProgress;
private void ProcessFrame(object sender,
EventArgs arg)
{
Image<Bgr, Byte> frame =
_capture.QueryFrame();
frame =
frame.Flip(Emgu.CV.CvEnum.FLIP.HORIZONTAL);
Image<Gray, Byte> gray =
frame.Convert<Gray, Byte>();
//Convert it to Grayscale
gray._EqualizeHist();
HaarCascade face = new
HaarCascade("haarcascade_frontalface_alt2.xml");
MCvAvgComp[][] facesDetected = gray.DetectHaarCascade(face, 1.1, 2,
Emgu.CV.CvEnum.HAAR_DETECTION_TYPE.DO_CANNY_PRUNING, new Size(30,
30));
foreach
(MCvAvgComp f in facesDetected[0])
{
frame.Draw(f.rect, new
Bgr(Color.Red), 3);
}
imageBox1.Image = frame;
}
private void buttonOpenCapture_Click(object
sender, EventArgs e)
{
#region if
capture is not created, create it now
if
(_capture == null)
{
try
{
_capture = new Capture(0);
}
catch (NullReferenceException
excpt)
{
MessageBox.Show(excpt.Message);
}
}
#endregion
if
(_capture != null)
{
if (_captureInProgress)
{ //stop
the capture
buttonOpenCapture.Text = "打开视频";
Application.Idle -= ProcessFrame;
}
else
{
//start the capture
buttonOpenCapture.Text = "关闭视频";
Application.Idle += ProcessFrame;
}
_captureInProgress =
!_captureInProgress;
}
}
}
}
相关文章推荐
- c#&nbsp;人脸检测(典型方法)
- C#&nbsp;方法中的this参数
- 人脸关键点检测数据库&人脸关键点检测最新方法调研
- C#&nbsp;子窗体调用父窗体的方法
- 人脸关键点检测数据库&人脸关键点检测最新方法调研
- C#&nbsp;判断批处理是否完成&nbsp;方法
- c# keybd_event使用方法
- C# winform退出方法
- C#发邮件&nbsp;两种方法&nbsp;实例
- C# B/S程序中出现“异常详细信息: System.Data.SqlClient.SqlException: 用户 'XXX/ASPNET' 登录失败。”的处理方法
- C#==>虚方法
- C#非托管资源释放(Finalize&Dispose)方法
- C#==>匿名方法
- C#==>密封类,密封方法
- MHDD不识别被检测的硬盘解决方法 (BIOS)可识别
- 快速获得Altera&nbsp;NIOS技术支持的方法
- MHDD不识别被检测的硬盘解决方法 (BIOS)可识别
- tapestry不支持 等html特殊符号的解决方法
- “由于未能创建 Microsoft Visual C# 2008 编译器,因此未能打开项目 "xxx" ”的解决方法
- C#字符串拼接 "+"连接与Append()方法 速度比较