我想让录制视频时加上时间信息,部分代码如下:
DateTime now = new DateTime();
now = DateTime.Now;
int timeStampCurrent = now.Minute * 6000 + now.Second * 100 + (int)now.Millisecond / 10;
string drawDate4 = now.ToString(timeStampCurrent.ToString("00000000"));
CvInvoke.PutText(frame, drawDate4, new Point(0, 40), Emgu.CV.CvEnum.FontFace.HersheyTriplex, 1, new Emgu.CV.Structure.MCvScalar(255, 0, 255), 2);
运行时发现能把时间加在视频上,但不是从零开始计时。由于能力不足解决不好,又用另一种方法,部分代码如下:
TimeCount = DateTime.Now - now;
drawDate5 =string.Format("{0:00}:{1:00}:{2:00}:{3:00}", TimeCount.Hours, TimeCount.Minutes, TimeCount.Seconds,TimeCount .Millisecond) ;
CvInvoke.PutText(frame, drawDate5, new Point(0, 100), Emgu.CV.CvEnum.FontFace.HersheyTriplex, 1, new Emgu.CV.Structure.MCvScalar(255, 0, 255), 2);
videoWriter.Write(frame);
运行发现时间停在零,不能走。小白希望有人帮助我,谢谢!
|