[英]Running the camera using Emgu CV
我想制作面部识别系统。 现在,我正在尝试运行相机,但是我很难进入相机。 这是我的代码:
public partial class Camera : Form
{
private Capture capture;
private HaarCascade haarCascade;
Timer timer;
public Camera()
{
InitializeComponent();
}
private void pictureBox1_Click(object sender, EventArgs e)
{
capture = new Capture();
haarCascade = new HaarCascade(@"haarcascade_frontalface_alt_tree.xml");
timer = new Timer();
timer.Tick += new EventHandler(timer1_Tick);
timer.Interval = new TimeSpan(0, 0, 0, 0, 1);
timer.Start();
}
}
timer.Interval = new TimeSpan(0, 0, 0, 0, 1);
。
这是错误:
严重级代码描述项目文件行抑制状态错误CS0029无法将类型'System.TimeSpan'隐式转换为'int'Attendance_Marking_System c:\\ users \\ redpranger \\ documents \\ visual studio 2017 \\ Projects \\ Attendance_Marking_System \\ Attendance_Marking_System \\ Camera.cs 34 Active
Timer.Interval属性是Double
类型的属性,而不是Timespan
。
这是属性的定义:
获取或设置引发Elapsed事件的间隔(以毫秒为单位)。
要将间隔设置为1秒(1000毫秒),请将其设置为:
timer.Interval = 1000;
或者在你的例子中,1毫秒:
timer.Interval = 1;
timer.Interval = new TimeSpan(0, 0, 0, 0, 1).TotalMilliseconds;
或者你可以试试
timer.Interval = 1; // 1ms
你不需要每1ms更新一次相机我不认为你的相机有那么多的fps所以你的情况下30ms就没问题所以试试
timer.Interval = 30; // for 30 ms
答案很简单,你所要做的就是
要将间隔设置为1秒(1000毫秒),请将其设置为:
timer.Interval = 1000;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.