資源簡介
C# 打開攝像頭錄像,錄像文件保存到本地, 支持時間戳,支持 64位
代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.ComponentModel;
using?System.Data;
using?System.Drawing;
using?System.Linq;
using?System.Text;
using?System.Threading.Tasks;
using?System.Windows.Forms;
using?Emgu.CV;
using?Emgu.CV.CvEnum;
using?Emgu.CV.Structure;
using?System.IO;
using?System.Diagnostics;
using?System.Collections.Concurrent;
using?System.Threading;
namespace?TEST_CV3._2
{
????public?partial?class?Form1?:?Form
????{
????????private?ConcurrentQueueameDataModel>?_queframes?=?null;
????????//private?Task?_taskWriter?=?null;
????????private?CancellationTokenSource?_ctsTaskWriter?=?new?CancellationTokenSource();
????????public?Form1()
????????{
????????????InitializeComponent();
????????????Image?image?=?new?Image(1280?720?new?Bgr(50?10?1));???//創建一張320*240尺寸顏色為紅色的圖像。??????????????????????????????????????????????????????????????????????????????????????????//??????Image?image?=?new?Image(@“D:\2.jpg“);?//從文件加載圖片
????????????imageBox1.Image?=?image;
????????????videoSize?=?new?Size(640?480);
????????????//videoOutput?=?new?VideoWriter(videoPath?4?120?videoSize?true);
????????????_queframes?=?new?ConcurrentQueueameDataModel>();
????????}
????????private?bool?_captureStoped?=?true;
????????private?string?videoPath;
????????VideoCapture?Cap_cam;
????????Size?videoSize;
????????VideoWriter?videoOutput;
????????private?string?drawDate3;
????????Mat?frame;
????????private?void?Form1_Load(object?sender?EventArgs?e)
????????{
????????????//_taskWriter?=?new?Task(()?=>
????????????//{
????????????//????WriteVideo();
????????????//});
???????????
????????}
????????private?DateTime?_playTime?=?DateTime.Now;
????????private?double?_frameTimeSpan?=?0;
????????private?void?Capture_ImageGrabbed(object?sender?EventArgs?e)
????????{
????????????if?(!_captureStoped)
????????????{
????????????????frame?=?new?Mat();
????????????????Cap_cam.Retrieve(frame?0);????//接收數據
???????????????????????????????????????????????//VideoWriter.
????????????????imageBox1.Image?=?frame;???????//顯示圖像
????????????????//寫到屏幕上的時間
????????????????DateTime?now?=?DateTime.Now;
????????????????//_queframes.Enqueue(new?frameDataModel()?{?frameTime?=?DateTime.Now?frame?=?frame?});
????????????????int?timeStampCurrent?=?now.Hour?*?360000?+?now.Minute?*?6000?+?now.Second?*?100?+?(int)now.Millisecond?/?10;
????????????????string?drawDate1?=?now.ToString(“HH:mm:ss“);
????????????????string?drawDate2?=?now.ToString(timeStampCurrent.ToString(“00000000“));
????????????????CvInvoke.PutText(frame?drawDate1?new?Point(0?40)?FontFace.HersheyTriplex?1?new?MCvScalar(255?0?255)?2);
????????????????CvInvoke.PutText(frame?drawDate2?new?Point(0?100)?FontFace.HersheyTriplex?1?new?MCvScalar(255?0?255)?2);
????????????????_frameTimeSpan?=?(DateTime.Now?-?_playTime).TotalMilliseconds;
????????????????_playTime?=?DateTime.
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2018-12-28?11:36??時間戳、攝像頭\
?????目錄???????????0??2018-12-28?11:36??時間戳、攝像頭\.vs\
?????目錄???????????0??2018-12-28?11:36??時間戳、攝像頭\.vs\TEST_CV3.2\
?????目錄???????????0??2018-12-28?11:36??時間戳、攝像頭\.vs\TEST_CV3.2\v14\
?????文件???????42496??2018-12-28?11:36??時間戳、攝像頭\.vs\TEST_CV3.2\v14\.suo
?????目錄???????????0??2018-12-28?11:35??時間戳、攝像頭\TEST_CV3.2\
?????文件?????????189??2018-10-23?16:15??時間戳、攝像頭\TEST_CV3.2\App.config
?????文件????????4936??2018-12-28?11:30??時間戳、攝像頭\TEST_CV3.2\Form1.Designer.cs
?????文件????????7059??2018-12-28?11:35??時間戳、攝像頭\TEST_CV3.2\Form1.cs
?????文件????????5817??2018-12-28?11:30??時間戳、攝像頭\TEST_CV3.2\Form1.resx
?????文件?????????601??2018-11-02?09:23??時間戳、攝像頭\TEST_CV3.2\fr
?????文件?????????523??2018-10-23?16:15??時間戳、攝像頭\TEST_CV3.2\Program.cs
?????目錄???????????0??2018-10-24?15:52??時間戳、攝像頭\TEST_CV3.2\Properties\
?????文件????????1328??2018-10-23?16:15??時間戳、攝像頭\TEST_CV3.2\Properties\AssemblyInfo.cs
?????文件????????2835??2018-10-23?16:15??時間戳、攝像頭\TEST_CV3.2\Properties\Resources.Designer.cs
?????文件????????5612??2018-10-23?16:15??時間戳、攝像頭\TEST_CV3.2\Properties\Resources.resx
?????文件????????1098??2018-10-23?16:15??時間戳、攝像頭\TEST_CV3.2\Properties\Settings.Designer.cs
?????文件?????????249??2018-10-23?16:15??時間戳、攝像頭\TEST_CV3.2\Properties\Settings.settings
?????文件????????4834??2018-10-29?14:26??時間戳、攝像頭\TEST_CV3.2\TEST_CV3.2.csproj
?????目錄???????????0??2018-10-24?15:52??時間戳、攝像頭\TEST_CV3.2\bin\
?????目錄???????????0??2018-11-13?15:38??時間戳、攝像頭\TEST_CV3.2\bin\Debug\
?????文件????????8192??2017-05-07?06:40??時間戳、攝像頭\TEST_CV3.2\bin\Debug\Emgu.CV.DebuggerVisualizers.VS2015.dll
?????文件???????27136??2017-05-07?06:40??時間戳、攝像頭\TEST_CV3.2\bin\Debug\Emgu.CV.UI.GL.dll
?????文件??????118272??2017-05-07?06:39??時間戳、攝像頭\TEST_CV3.2\bin\Debug\Emgu.CV.UI.dll
?????文件??????609280??2017-05-07?06:39??時間戳、攝像頭\TEST_CV3.2\bin\Debug\Emgu.CV.World.dll
?????文件???????56624??2015-07-07?00:51??時間戳、攝像頭\TEST_CV3.2\bin\Debug\Microsoft.VisualStudio.DebuggerVisualizers.dll
?????文件???????11776??2018-12-28?11:35??時間戳、攝像頭\TEST_CV3.2\bin\Debug\TEST_CV3.2.exe
?????文件?????????189??2018-10-23?16:15??時間戳、攝像頭\TEST_CV3.2\bin\Debug\TEST_CV3.2.exe.config
?????文件???????24064??2018-12-28?11:35??時間戳、攝像頭\TEST_CV3.2\bin\Debug\TEST_CV3.2.pdb
?????文件???????22688??2018-12-28?11:36??時間戳、攝像頭\TEST_CV3.2\bin\Debug\TEST_CV3.2.vshost.exe
?????文件?????????189??2018-10-23?16:15??時間戳、攝像頭\TEST_CV3.2\bin\Debug\TEST_CV3.2.vshost.exe.config
............此處省略26個文件信息
評論
共有 條評論