我想制作面部识别系统。现在,我试图运行相机,但是我很难进入相机。这里是我的代码:使用Emgu CV运行相机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);
的错误。
以下是错误:
Severity Code Description Project File Line Suppression State Error CS0029 Cannot implicitly convert type 'System.TimeSpan' to 'int' Attendance_Marking_System c:\users\redpranger\documents\visual studio 2017\Projects\Attendance_Marking_System\Attendance_Marking_System\Camera.cs 34 Active
尽管您的答案在技术上是正确的,但我没有看到使用创建结构来获得毫秒。 – Abbas
你说得对,实际上他不需要使用TimeSpan。 我只是写了它,让他明白,如果他想给这个间隔的值,他需要使用TotalMiliseconds属性来转换它 – Esperadoce