gpt4 book ai didi

c# - 使用 Emgu CV 运行相机

转载 作者:太空宇宙 更新时间:2023-11-03 22:56:37 25 4
gpt4 key购买 nike

我想做人脸识别系统。现在,我正在尝试运行相机,但是我很难运行访问相机。这是我的代码:

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

最佳答案

Timer.Interval PropertyDouble 类型的属性,而不是 Timespan

这是属性的定义:

Gets or sets the interval, expressed in milliseconds, at which to raise the Elapsed event.

要将间隔设置为 1 秒(1000 毫秒),请这样设置:

timer.Interval = 1000;

或者在您的示例中,1 毫秒:

timer.Interval = 1;

关于c# - 使用 Emgu CV 运行相机,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45081564/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com