【发布时间】:2019-09-28 18:10:10
【问题描述】:
我正在做一个车牌识别系统。我已将相机设置为每 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++;
}
}
我希望在它拍摄图像时,它会自动在标签上显示拍摄图像的日期和时间。
【问题讨论】:
-
您的意思是在表单中添加标签并将其设置为拍摄图像的当前日期和时间?
-
是的,类似的。拍摄图像时,标签将显示拍摄图像的当前日期和时间。这个过程将针对当时捕获的每张图像重复执行@stuartd
-
DateTime.Now... -
如果想获取上次修改图片文件的时间,可以使用
File.GetLastWriteTime(filePath) -
您还可以在图像本身上绘制当前日期/时间。
标签: c# visual-studio-2013 camera image-capture alpr