我正在做一个车牌识别系统。我已将相机设置为每 10 秒捕获一次图像并将其存储在一个文件夹中。我可以知道如何获取或捕获日期和时间,并将其显示在文件夹中捕获的每张图像的标签中。我正在使用 C# 进行编码,并且还使用我的 USB 相机来捕获图像
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private FilterInfoCollection CaptureDevices;
private VideoCaptureDevice videoSource;
private Int32 pictureCount = 0;
private void Form1_Load(object sender, EventArgs e)
{
CaptureDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);
foreach (FilterInfo Device in CaptureDevices)
{
cboDevice.Items.Add(Device.Name);
}
cboDevice.SelectedIndex = 0;
videoSource = new VideoCaptureDevice();
timer1.Tick += new EventHandler(this.timer1_Tick);
timer1.Interval = (100) * (100);
timer1.Enabled = true;
timer1.Start();
videoSource = new VideoCaptureDevice(CaptureDevices[cboDevice.SelectedIndex].MonikerString);
videoSource.NewFrame += new NewFrameEventHandler(videoSource_NewFrame);
videoSource.Start();
}
void videoSource_NewFrame(object sender, AForge.Video.NewFrameEventArgs eventArgs)
{
pictureBox1.Image = (Bitmap)eventArgs.Frame.Clone();
}
private void timer1_Tick(object sender, EventArgs e)
{
pictureBox1.Image.Save(pictureCount.ToString() + ".jpg", ImageFormat.Jpeg);
pictureCount++;
}
}
我希望在它捕获图像时,它会自动在标签上显示捕获图像的日期和时间。