【发布时间】:2018-10-04 06:50:48
【问题描述】:
我想制作一部 30 帧的电影。
用相机花一分钟看视频,视频长度只有 42 秒。
作为时间测量的结果,输出为 21 帧。
如何制作 30 帧视频?
下面是运行时间的描述。
....
00:00:01.0339097
00:00:01.0788484
00:00:01.1256316
00:00:01.1741762
00:00:01.2210662
00:00:01.2660053
00:00:01.3138742
00:00:01.3605831
00:00:01.4084542
00:00:01.4543680
00:00:01.5004309
00:00:01.5492773
00:00:01.5951540
00:00:01.6420466
00:00:01.6899155
00:00:01.7348539
00:00:01.7827228
00:00:01.8282291
00:00:01.8760989
00:00:01.9239678
00:00:01.9718930
....
以下是源代码。
private void StartTimer()
{
if (writer == null)
{
Utilitys.TStimeD = DateTime.Now;
TStimeS = Utilitys.TStimeD.ToString("yyyyMMddHHmmss");
aviPath = TStimeS + ".avi";
writer = Cv.CreateVideoWriter(aviPath, "XVID", 30, new CvSize(640, 240));
}
timer1.Interval = 33;
timer1.Enabled = true;
}
private void timer1_Tick(object sender, EventArgs e)
{
if (_captureInProgress)
{
_image = _capture.QueryFrame();
try {
writer.WriteFrame(_image);
Console.WriteLine((DateTime.Now - Utilitys.TStimeD).ToString());
//Cv.ReleaseImage(_image);
}
catch(System.AccessViolationException ex)
{
Console.WriteLine("System.AccessViolationException");
}catch(System.ObjectDisposedException ex)
{
Console.Write("System.ObjectDisposedException");
}
}
}
【问题讨论】:
标签: c# opencv video camera opencvsharp