diff --git a/ISCamRecorder/CvCamera.cs b/ISCamRecorder/CvCamera.cs index a052f01..fa1c1d8 100644 --- a/ISCamRecorder/CvCamera.cs +++ b/ISCamRecorder/CvCamera.cs @@ -35,10 +35,12 @@ VideoCapture camera = null; // カメラオブジェクト FrameRateCounter _Fps = new FrameRateCounter(10); // フレームレート計測 List _RecFrames = new List(); // 録画画像 - float _RecFrameRate = 0; // 録画フレームレート + //float _RecFrameRate = 0; // 録画フレームレート MainForm _MF = null; // メインフォームインスタンス bool _Snap = false; // 静止画撮影フラグ + public float CameraFPS { get; private set; } = 0; + /// /// コンストラクタ /// @@ -62,6 +64,7 @@ } camera.FrameWidth = frameWidth; camera.FrameHeight = frameHeight; + CameraFPS = (float)camera.Fps; return true; } @@ -79,7 +82,6 @@ // 録画 if (_MF.State == STATE.Recoding) { _RecFrames.Add(new FrameInfo(frame.Clone())); - if (_RecFrameRate == 0) _RecFrameRate = _Fps.FrameRate; } // 静止画保存 @@ -114,14 +116,14 @@ /// public void SaveToFile() { if (_RecFrames.Count < 1) return; - Debug.WriteLine($"{_CamID} starts saving with {_RecFrameRate:0.0}fps."); + Debug.WriteLine($"{_CamID} starts saving with {CameraFPS:0.0}fps."); // 保存先確保 var outDir2 = Path.Combine(_MF.OutputDir, _CamID); Directory.CreateDirectory(outDir2); // 動画保存準備 var movieFile = Path.Combine(_MF.OutputDir, $"{_CamID}_{_MF.RecodingTimeStr}.mp4"); - var writer = new VideoWriter(movieFile, FourCC.H264, - _RecFrameRate, _RecFrames[0].FrameImage.Size()); + var writer = new VideoWriter(movieFile, FourCC.H264, + CameraFPS, _RecFrames[0].FrameImage.Size()); for (int i = 0; i < _RecFrames.Count; i++) { string strSampleTime = _RecFrames[i].FrameTime.ToString(@"HHmmss\.fff"); var fileName = $"{_CamID}_{strSampleTime}.{_MF.Setting.ImageTypeL}"; @@ -132,7 +134,6 @@ writer.Release(); _RecFrames.Clear(); - _RecFrameRate = 0; Debug.WriteLine($"{_CamID} ends saving."); } @@ -149,11 +150,11 @@ /// 1秒録画に要するメモリ量 /// /// - public float MemoryFor1SecRecoding() { + public float ConsumedMemoryPerSecond() { if (camera == null) return 0; int frameSize = 3 * camera.FrameWidth * camera.FrameHeight; int bcs = 1024 * 1024; - return _Fps.FrameRate * frameSize / bcs; + return CameraFPS * frameSize / bcs; } /// diff --git a/ISCamRecorder/ISCamera.cs b/ISCamRecorder/ISCamera.cs index a881c45..5a851da 100644 --- a/ISCamRecorder/ISCamera.cs +++ b/ISCamRecorder/ISCamera.cs @@ -27,7 +27,7 @@ IFrameQueueBuffer[] _bufferlist = null; // 録画バッファ bool _Recoding = false; // 録画中フラグ - public float FrameRate { get { return _Fps.FrameRate; } } // フレームレート + public float CameraFPS { get; private set; } = 0; /// /// コンストラクタ @@ -73,6 +73,7 @@ MessageBoxButtons.OK, MessageBoxIcon.Warning); return false; } + CameraFPS = _Cam.DeviceFrameRate; // 表示設定 _Cam.LiveDisplayDefault = false; @@ -129,11 +130,12 @@ /// /// 録画 /// - public void RecordToMemory(int framesToCapture) { + public void RecordToMemory(float recodingLimit) { Debug.WriteLine($"{_CamID} starts recoding."); _Recoding = true; ClearBuffer(); // メモリ確保 + var framesToCapture = (int)(recodingLimit * CameraFPS) + 1; _RecSink.AllocAndQueueBuffers(framesToCapture); // 撮影 while (_Recoding) { @@ -149,15 +151,15 @@ /// ファイル保存 /// /// - public void SaveToFile(float frameRate) { - Debug.WriteLine($"{_CamID} starts saving with {frameRate}fps."); + public void SaveToFile() { + Debug.WriteLine($"{_CamID} starts saving with {CameraFPS}fps."); // 保存先確保 var outDir2 = Path.Combine(_MF.OutputDir, _CamID); Directory.CreateDirectory(outDir2); // 動画保存準備 var movieFile = Path.Combine(_MF.OutputDir, $"{_CamID}_{_MF.RecodingTimeStr}.mp4"); var writer = new H264Writer(movieFile, - _RecSink.OutputFrameType, (int)frameRate, _MF.Setting.MovieRate * 1000); + _RecSink.OutputFrameType, (int)CameraFPS, _MF.Setting.MovieRate * 1000); writer.Begin(); // ファイル保存 var firstDriverTime = _bufferlist[0].FrameMetadata.DriverFrameFirstPacketTime; @@ -291,7 +293,7 @@ /// 1秒録画に要するメモリ量 /// /// - public float MemoryFor1SecRecoding() { + public float ConsumedMemoryPerSecond() { if (!_Cam.DeviceValid) return 0; var vf = _Cam.VideoFormatCurrent; int frameSize = vf.BitsPerPixel / 8 * vf.Width * vf.Height; diff --git a/ISCamRecorder/MainForm.Designer.cs b/ISCamRecorder/MainForm.Designer.cs index 7a2fcbd..75b3a8f 100644 --- a/ISCamRecorder/MainForm.Designer.cs +++ b/ISCamRecorder/MainForm.Designer.cs @@ -47,11 +47,6 @@ this.icFront = new TIS.Imaging.ICImagingControl(); this.TxtRight = new System.Windows.Forms.TextBox(); this.icRight = new TIS.Imaging.ICImagingControl(); - this.TxtRecodingDulation = new System.Windows.Forms.TextBox(); - this.label1 = new System.Windows.Forms.Label(); - this.label2 = new System.Windows.Forms.Label(); - this.LblAvailableMemory = new System.Windows.Forms.Label(); - this.LblRecodingMemory = new System.Windows.Forms.Label(); this.BtnRecodeMovie = new System.Windows.Forms.Button(); this.TxtTriggerFPS = new System.Windows.Forms.TextBox(); this.label4 = new System.Windows.Forms.Label(); @@ -399,53 +394,6 @@ this.icRight.Size = new System.Drawing.Size(331, 213); this.icRight.TabIndex = 5; // - // TxtRecodingDulation - // - this.TxtRecodingDulation.Location = new System.Drawing.Point(176, 27); - this.TxtRecodingDulation.Name = "TxtRecodingDulation"; - this.TxtRecodingDulation.Size = new System.Drawing.Size(34, 19); - this.TxtRecodingDulation.TabIndex = 8; - this.TxtRecodingDulation.Text = "30"; - this.TxtRecodingDulation.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; - this.TxtRecodingDulation.TextChanged += new System.EventHandler(this.TxtRecodingDulation_TextChanged); - this.TxtRecodingDulation.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.NumberKeyOnly); - // - // label1 - // - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(174, 12); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(53, 12); - this.label1.TabIndex = 9; - this.label1.Text = "記録時間"; - // - // label2 - // - this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(210, 30); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(17, 12); - this.label2.TabIndex = 10; - this.label2.Text = "秒"; - // - // LblAvailableMemory - // - this.LblAvailableMemory.AutoSize = true; - this.LblAvailableMemory.Location = new System.Drawing.Point(245, 12); - this.LblAvailableMemory.Name = "LblAvailableMemory"; - this.LblAvailableMemory.Size = new System.Drawing.Size(101, 12); - this.LblAvailableMemory.TabIndex = 11; - this.LblAvailableMemory.Text = "利用可能物理メモリ"; - // - // LblRecodingMemory - // - this.LblRecodingMemory.AutoSize = true; - this.LblRecodingMemory.Location = new System.Drawing.Point(245, 30); - this.LblRecodingMemory.Name = "LblRecodingMemory"; - this.LblRecodingMemory.Size = new System.Drawing.Size(96, 12); - this.LblRecodingMemory.TabIndex = 12; - this.LblRecodingMemory.Text = "消費する物理メモリ"; - // // BtnRecodeMovie // this.BtnRecodeMovie.Location = new System.Drawing.Point(383, 8); @@ -581,11 +529,6 @@ this.Controls.Add(this.label4); this.Controls.Add(this.TxtTriggerFPS); this.Controls.Add(this.BtnRecodeMovie); - this.Controls.Add(this.LblRecodingMemory); - this.Controls.Add(this.LblAvailableMemory); - this.Controls.Add(this.label2); - this.Controls.Add(this.label1); - this.Controls.Add(this.TxtRecodingDulation); this.Controls.Add(this.splitContainer1); this.Controls.Add(this.ChkTrigger); this.Controls.Add(this.BtnSetProperty); @@ -648,11 +591,6 @@ private System.Windows.Forms.TextBox TxtLeft; private System.Windows.Forms.TextBox TxtFront; private System.Windows.Forms.TextBox TxtRight; - private System.Windows.Forms.TextBox TxtRecodingDulation; - private System.Windows.Forms.Label label1; - private System.Windows.Forms.Label label2; - private System.Windows.Forms.Label LblAvailableMemory; - private System.Windows.Forms.Label LblRecodingMemory; private System.Windows.Forms.Button BtnRecodeMovie; private System.Windows.Forms.TextBox TxtTriggerFPS; private System.Windows.Forms.Label label4; diff --git a/ISCamRecorder/MainForm.cs b/ISCamRecorder/MainForm.cs index e2b82fd..681502c 100644 --- a/ISCamRecorder/MainForm.cs +++ b/ISCamRecorder/MainForm.cs @@ -48,8 +48,6 @@ Task _CvCameraThread; // opencvカメラスレッド Task _RecodingThread; // 録画スレッド float _TriggerFrameRate = 30.0F; // トリガーフレームレート - float _RecodingDulation = 0; // 録画時間 - private ulong _availablePhysicalMemory; //合計物理メモリ SubjectList _SubjectList; // 非測定者一覧フォーム public Setting Setting { get; private set; } // 設定ダイアログ @@ -95,11 +93,9 @@ _CvCameraThread = Task.Run(CvCameraThread); // コントロール変数初期化 - _RecodingDulation = float.Parse(TxtRecodingDulation.Text); SwitchEnabled = ChkStartSW.Checked; #if DEBUG TxtSubjectName.Text = "デバッグ"; - TxtRecodingDulation.Text = "3"; #endif State = STATE.Idle; @@ -162,8 +158,6 @@ TxtRight.Text = $"右方カメラ {_Cameras[3].CameraInfo()}"; TxtSensor.Text = $"逆血センサー {_Sensor.FrameRate:0.0} Hz"; TxtCvCamera.Text = $"追加カメラ {_CvCamera.CameraInfo()}"; - TotalPhysicalMemory(); - MemoryToUse(); _TriggerFrameRate = float.Parse(TxtTriggerFPS.Text); } } @@ -174,7 +168,12 @@ /// /// private void SetProperty_Click(object sender, EventArgs e) { + Setting.TotalConsumedMemoryPerSecond = + _Cameras.Select(c => c.ConsumedMemoryPerSecond()).Sum() + + _CvCamera.ConsumedMemoryPerSecond(); + Setting.ShowDialog(); + Debug.WriteLine("end"); //var config =_Cameras[0].SetProperty(); //_Cameras.ForEach(c => c.SetProperty(config)); } @@ -216,29 +215,6 @@ } /// - /// 利用可能なメモリ量をラベルに表示 - /// - private void TotalPhysicalMemory() { - - Microsoft.VisualBasic.Devices.ComputerInfo info = - new Microsoft.VisualBasic.Devices.ComputerInfo(); - ulong bcs = 1024 * 1024; - _availablePhysicalMemory = info.AvailablePhysicalMemory / bcs; //利用可能な物理メモリ - LblAvailableMemory.Text = "利用可能メモリ:" + _availablePhysicalMemory.ToString("#,0") + "MB"; - } - - /// - /// 消費メモリ量をラベルに表示 - /// - private void MemoryToUse() { - var memoryConsumption = (_Cameras.Select(c => c.MemoryFor1SecRecoding()).Sum() - + _CvCamera.MemoryFor1SecRecoding()) * float.Parse(TxtRecodingDulation.Text); - LblRecodingMemory.Text = "消費するメモリ:" + memoryConsumption.ToString("#,0") + "MB"; - if (memoryConsumption > _availablePhysicalMemory && _availablePhysicalMemory != 0) LblRecodingMemory.ForeColor = Color.Red; - else LblRecodingMemory.ForeColor = Color.Black; - } - - /// /// 動画撮影 /// /// @@ -281,8 +257,6 @@ }); // 録画開始 - var frameRate = _Cameras.Select(c => c.FrameRate).Average(); - var framesToCapture = (int)(_RecodingDulation * frameRate + 1.0F); RecodingTime = DateTime.Now; Directory.CreateDirectory(OutputDir); State = STATE.Recoding; @@ -291,7 +265,7 @@ Task[] tasks = new Task[4]; for (var i = 0; i < _Cameras.Count; i++) { var cam = _Cameras[i]; - tasks[i] = Task.Run(() => cam.RecordToMemory(framesToCapture)); + tasks[i] = Task.Run(() => cam.RecordToMemory(Setting.RecodingLimit)); } Task.WaitAll(tasks); @@ -309,7 +283,7 @@ for (var i = 0; i < _Cameras.Count; i++) { var cam = _Cameras[i]; - tasks[i] = Task.Run(() => cam.SaveToFile(frameRate)); + tasks[i] = Task.Run(() => cam.SaveToFile()); } Task.WaitAll(tasks); _CvCamera.SaveToFile(); @@ -390,15 +364,6 @@ } /// - /// 記録時間変更時 - /// - /// - /// - private void TxtRecodingDulation_TextChanged(object sender, EventArgs e) { - _RecodingDulation = float.Parse(TxtRecodingDulation.Text); - } - - /// /// SW連動チェック変更 /// /// diff --git a/ISCamRecorder/Setting.Designer.cs b/ISCamRecorder/Setting.Designer.cs index ddc700c..3d0ef0a 100644 --- a/ISCamRecorder/Setting.Designer.cs +++ b/ISCamRecorder/Setting.Designer.cs @@ -27,13 +27,18 @@ this.label3 = new System.Windows.Forms.Label(); this.TxtOutputDir = new System.Windows.Forms.TextBox(); this.groupBox1 = new System.Windows.Forms.GroupBox(); - this.BtnApply = new System.Windows.Forms.Button(); - this.BtnCancel = new System.Windows.Forms.Button(); - this.CboImageType = new System.Windows.Forms.ComboBox(); - this.label7 = new System.Windows.Forms.Label(); this.TxtMovieRate = new System.Windows.Forms.TextBox(); this.label5 = new System.Windows.Forms.Label(); this.label6 = new System.Windows.Forms.Label(); + this.CboImageType = new System.Windows.Forms.ComboBox(); + this.label7 = new System.Windows.Forms.Label(); + this.BtnApply = new System.Windows.Forms.Button(); + this.BtnCancel = new System.Windows.Forms.Button(); + this.label2 = new System.Windows.Forms.Label(); + this.label1 = new System.Windows.Forms.Label(); + this.TxtRecodingDulation = new System.Windows.Forms.TextBox(); + this.LblRecodingMemory = new System.Windows.Forms.Label(); + this.LblAvailableMemory = new System.Windows.Forms.Label(); this.groupBox1.SuspendLayout(); this.SuspendLayout(); // @@ -55,6 +60,11 @@ // // groupBox1 // + this.groupBox1.Controls.Add(this.LblAvailableMemory); + this.groupBox1.Controls.Add(this.LblRecodingMemory); + this.groupBox1.Controls.Add(this.label2); + this.groupBox1.Controls.Add(this.label1); + this.groupBox1.Controls.Add(this.TxtRecodingDulation); this.groupBox1.Controls.Add(this.TxtMovieRate); this.groupBox1.Controls.Add(this.label5); this.groupBox1.Controls.Add(this.label6); @@ -62,55 +72,13 @@ this.groupBox1.Controls.Add(this.label7); this.groupBox1.Controls.Add(this.label3); this.groupBox1.Controls.Add(this.TxtOutputDir); - this.groupBox1.Location = new System.Drawing.Point(21, 151); + this.groupBox1.Location = new System.Drawing.Point(12, 12); this.groupBox1.Name = "groupBox1"; - this.groupBox1.Size = new System.Drawing.Size(320, 193); + this.groupBox1.Size = new System.Drawing.Size(371, 289); this.groupBox1.TabIndex = 17; this.groupBox1.TabStop = false; this.groupBox1.Text = "保存設定"; // - // BtnApply - // - this.BtnApply.Location = new System.Drawing.Point(248, 432); - this.BtnApply.Name = "BtnApply"; - this.BtnApply.Size = new System.Drawing.Size(93, 31); - this.BtnApply.TabIndex = 18; - this.BtnApply.Text = "適用"; - this.BtnApply.UseVisualStyleBackColor = true; - this.BtnApply.Click += new System.EventHandler(this.BtnApply_Click); - // - // BtnCancel - // - this.BtnCancel.Location = new System.Drawing.Point(358, 432); - this.BtnCancel.Name = "BtnCancel"; - this.BtnCancel.Size = new System.Drawing.Size(93, 31); - this.BtnCancel.TabIndex = 19; - this.BtnCancel.Text = "キャンセル"; - this.BtnCancel.UseVisualStyleBackColor = true; - this.BtnCancel.Click += new System.EventHandler(this.BtnCancel_Click); - // - // CboImageType - // - this.CboImageType.FormattingEnabled = true; - this.CboImageType.Items.AddRange(new object[] { - "JPG", - "BMP", - "TIFF"}); - this.CboImageType.Location = new System.Drawing.Point(65, 56); - this.CboImageType.Name = "CboImageType"; - this.CboImageType.Size = new System.Drawing.Size(52, 20); - this.CboImageType.TabIndex = 23; - this.CboImageType.Text = "JPG"; - // - // label7 - // - this.label7.AutoSize = true; - this.label7.Location = new System.Drawing.Point(6, 59); - this.label7.Name = "label7"; - this.label7.Size = new System.Drawing.Size(53, 12); - this.label7.TabIndex = 22; - this.label7.Text = "画像形式"; - // // TxtMovieRate // this.TxtMovieRate.Location = new System.Drawing.Point(61, 88); @@ -139,6 +107,96 @@ this.label6.TabIndex = 24; this.label6.Text = "kbps"; // + // CboImageType + // + this.CboImageType.FormattingEnabled = true; + this.CboImageType.Items.AddRange(new object[] { + "JPG", + "BMP", + "TIFF"}); + this.CboImageType.Location = new System.Drawing.Point(65, 56); + this.CboImageType.Name = "CboImageType"; + this.CboImageType.Size = new System.Drawing.Size(52, 20); + this.CboImageType.TabIndex = 23; + this.CboImageType.Text = "JPG"; + // + // label7 + // + this.label7.AutoSize = true; + this.label7.Location = new System.Drawing.Point(6, 59); + this.label7.Name = "label7"; + this.label7.Size = new System.Drawing.Size(53, 12); + this.label7.TabIndex = 22; + this.label7.Text = "画像形式"; + // + // BtnApply + // + this.BtnApply.Location = new System.Drawing.Point(248, 432); + this.BtnApply.Name = "BtnApply"; + this.BtnApply.Size = new System.Drawing.Size(93, 31); + this.BtnApply.TabIndex = 18; + this.BtnApply.Text = "適用"; + this.BtnApply.UseVisualStyleBackColor = true; + this.BtnApply.Click += new System.EventHandler(this.BtnApply_Click); + // + // BtnCancel + // + this.BtnCancel.Location = new System.Drawing.Point(358, 432); + this.BtnCancel.Name = "BtnCancel"; + this.BtnCancel.Size = new System.Drawing.Size(93, 31); + this.BtnCancel.TabIndex = 19; + this.BtnCancel.Text = "キャンセル"; + this.BtnCancel.UseVisualStyleBackColor = true; + this.BtnCancel.Click += new System.EventHandler(this.BtnCancel_Click); + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(123, 126); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(17, 12); + this.label2.TabIndex = 29; + this.label2.Text = "秒"; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(6, 126); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(77, 12); + this.label1.TabIndex = 28; + this.label1.Text = "記録時間上限"; + // + // TxtRecodingDulation + // + this.TxtRecodingDulation.Location = new System.Drawing.Point(83, 123); + this.TxtRecodingDulation.Name = "TxtRecodingDulation"; + this.TxtRecodingDulation.Size = new System.Drawing.Size(34, 19); + this.TxtRecodingDulation.TabIndex = 27; + this.TxtRecodingDulation.Text = "30"; + this.TxtRecodingDulation.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; + this.TxtRecodingDulation.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.NumberKeyOnly); + // + // LblRecodingMemory + // + this.LblRecodingMemory.AutoSize = true; + this.LblRecodingMemory.Font = new System.Drawing.Font("MS ゴシック", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(128))); + this.LblRecodingMemory.Location = new System.Drawing.Point(170, 126); + this.LblRecodingMemory.Name = "LblRecodingMemory"; + this.LblRecodingMemory.Size = new System.Drawing.Size(89, 12); + this.LblRecodingMemory.TabIndex = 30; + this.LblRecodingMemory.Text = "最大消費メモリ"; + // + // LblAvailableMemory + // + this.LblAvailableMemory.AutoSize = true; + this.LblAvailableMemory.Font = new System.Drawing.Font("MS ゴシック", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(128))); + this.LblAvailableMemory.Location = new System.Drawing.Point(170, 105); + this.LblAvailableMemory.Name = "LblAvailableMemory"; + this.LblAvailableMemory.Size = new System.Drawing.Size(89, 12); + this.LblAvailableMemory.TabIndex = 31; + this.LblAvailableMemory.Text = "利用可能メモリ"; + // // Setting // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); @@ -173,5 +231,10 @@ private System.Windows.Forms.TextBox TxtMovieRate; private System.Windows.Forms.Label label5; private System.Windows.Forms.Label label6; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.TextBox TxtRecodingDulation; + private System.Windows.Forms.Label LblRecodingMemory; + private System.Windows.Forms.Label LblAvailableMemory; } } \ No newline at end of file diff --git a/ISCamRecorder/Setting.cs b/ISCamRecorder/Setting.cs index 98060e4..ca106b6 100644 --- a/ISCamRecorder/Setting.cs +++ b/ISCamRecorder/Setting.cs @@ -11,16 +11,28 @@ namespace ISCamRecorder { public partial class Setting : Form { - public string SaveDir { get; private set; } = @"D:\Data"; - public string ImageType { get; private set; } = "JPG"; + public string SaveDir { get; private set; } + public string ImageType { get; private set; } public string ImageTypeL { get { return ImageType.ToLower(); } } - public int MovieRate { get; private set; } = 3000; + public int MovieRate { get; private set; } + public float RecodingLimit { get; private set; } + public float TotalConsumedMemoryPerSecond { get; set; } /// /// コンストラクタ /// public Setting() { InitializeComponent(); + ImageType = "JPG"; +#if DEBUG + SaveDir = @"D:\DataDBG"; + RecodingLimit = 3F; + MovieRate = 1000; +#else + SaveDir = @"D:\Data"; + RecodingLimit = 30F; + MovieRate = 3000; +#endif } /// @@ -32,6 +44,23 @@ TxtOutputDir.Text = SaveDir; CboImageType.Text = ImageType; TxtMovieRate.Text = MovieRate.ToString(); + TxtRecodingDulation.Text = RecodingLimit.ToString("0.0"); + this.UpdateMemoryInfo(); + } + + /// + /// メモリー情報の更新 + /// + private void UpdateMemoryInfo() { + var info = new Microsoft.VisualBasic.Devices.ComputerInfo(); + ulong bcs = 1024 * 1024; + var availableMemory = (int)(info.AvailablePhysicalMemory / bcs); //利用可能な物理メモリ + LblAvailableMemory.Text = $"利用可能メモリー:{availableMemory.ToString("#,0").PadLeft(7)}MB"; + + var totalConsumedMemory = (int)(TotalConsumedMemoryPerSecond * RecodingLimit); + LblRecodingMemory.Text = $"最大消費メモリー:{totalConsumedMemory.ToString("#,0").PadLeft(7)}MB"; + if (totalConsumedMemory > availableMemory) LblRecodingMemory.ForeColor = Color.Red; + else LblRecodingMemory.ForeColor = Color.Black; } /// @@ -43,6 +72,7 @@ SaveDir = TxtOutputDir.Text; ImageType = CboImageType.Text; MovieRate = int.Parse(TxtMovieRate.Text); + RecodingLimit = float.Parse(TxtRecodingDulation.Text); this.Close(); }