diff --git a/ISCamRecorder/CvCamera.cs b/ISCamRecorder/CvCamera.cs index fa1c1d8..36b330d 100644 --- a/ISCamRecorder/CvCamera.cs +++ b/ISCamRecorder/CvCamera.cs @@ -35,11 +35,11 @@ VideoCapture camera = null; // カメラオブジェクト FrameRateCounter _Fps = new FrameRateCounter(10); // フレームレート計測 List _RecFrames = new List(); // 録画画像 - //float _RecFrameRate = 0; // 録画フレームレート MainForm _MF = null; // メインフォームインスタンス bool _Snap = false; // 静止画撮影フラグ public float CameraFPS { get; private set; } = 0; + public float CurrentFPS { get { return _Fps.FrameRate; } } /// /// コンストラクタ diff --git a/ISCamRecorder/MainForm.Designer.cs b/ISCamRecorder/MainForm.Designer.cs index 85330ad..ae42866 100644 --- a/ISCamRecorder/MainForm.Designer.cs +++ b/ISCamRecorder/MainForm.Designer.cs @@ -55,6 +55,8 @@ this.BtnPrevSubject = new System.Windows.Forms.Button(); this.TxtCounter = new System.Windows.Forms.TextBox(); this.label9 = new System.Windows.Forms.Label(); + this.LblState = new System.Windows.Forms.Label(); + this.PnlState = new System.Windows.Forms.Panel(); ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); this.splitContainer1.Panel1.SuspendLayout(); this.splitContainer1.Panel2.SuspendLayout(); @@ -81,11 +83,12 @@ this.splitContainer5.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.icFront)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.icRight)).BeginInit(); + this.PnlState.SuspendLayout(); this.SuspendLayout(); // // BtnSetProperty // - this.BtnSetProperty.Location = new System.Drawing.Point(244, 12); + this.BtnSetProperty.Location = new System.Drawing.Point(295, 12); this.BtnSetProperty.Name = "BtnSetProperty"; this.BtnSetProperty.Size = new System.Drawing.Size(75, 34); this.BtnSetProperty.TabIndex = 5; @@ -381,7 +384,7 @@ // // BtnRecodeMovie // - this.BtnRecodeMovie.Location = new System.Drawing.Point(82, 12); + this.BtnRecodeMovie.Location = new System.Drawing.Point(133, 12); this.BtnRecodeMovie.Name = "BtnRecodeMovie"; this.BtnRecodeMovie.Size = new System.Drawing.Size(75, 34); this.BtnRecodeMovie.TabIndex = 15; @@ -391,7 +394,7 @@ // // BtnSnapImage // - this.BtnSnapImage.Location = new System.Drawing.Point(163, 12); + this.BtnSnapImage.Location = new System.Drawing.Point(214, 12); this.BtnSnapImage.Name = "BtnSnapImage"; this.BtnSnapImage.Size = new System.Drawing.Size(75, 34); this.BtnSnapImage.TabIndex = 18; @@ -465,11 +468,32 @@ this.label9.TabIndex = 29; this.label9.Text = "回"; // + // LblState + // + this.LblState.BackColor = System.Drawing.Color.Transparent; + this.LblState.Font = new System.Drawing.Font("MS UI Gothic", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(128))); + this.LblState.Location = new System.Drawing.Point(3, 4); + this.LblState.Name = "LblState"; + this.LblState.Size = new System.Drawing.Size(110, 23); + this.LblState.TabIndex = 30; + this.LblState.Text = "初期化中"; + this.LblState.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // PnlState + // + this.PnlState.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; + this.PnlState.Controls.Add(this.LblState); + this.PnlState.Location = new System.Drawing.Point(12, 12); + this.PnlState.Name = "PnlState"; + this.PnlState.Size = new System.Drawing.Size(115, 37); + this.PnlState.TabIndex = 31; + // // MainForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(1016, 555); + this.Controls.Add(this.PnlState); this.Controls.Add(this.label9); this.Controls.Add(this.TxtCounter); this.Controls.Add(this.BtnSetProperty); @@ -519,6 +543,7 @@ this.splitContainer5.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.icFront)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.icRight)).EndInit(); + this.PnlState.ResumeLayout(false); this.ResumeLayout(false); this.PerformLayout(); @@ -552,6 +577,8 @@ private System.Windows.Forms.Button BtnPrevSubject; private System.Windows.Forms.TextBox TxtCounter; private System.Windows.Forms.Label label9; + private System.Windows.Forms.Label LblState; + private System.Windows.Forms.Panel PnlState; } } diff --git a/ISCamRecorder/MainForm.cs b/ISCamRecorder/MainForm.cs index 8eef749..72c930a 100644 --- a/ISCamRecorder/MainForm.cs +++ b/ISCamRecorder/MainForm.cs @@ -93,8 +93,7 @@ #if DEBUG TxtSubjectName.Text = "デバッグ"; #endif - - State = STATE.Idle; + this.UpdateStateLabel(); } /// @@ -154,6 +153,34 @@ TxtRight.Text = $"右方カメラ {_Cameras[3].CameraInfo()}"; TxtSensor.Text = $"逆血センサー {_Sensor.FrameRate:0.0} Hz"; TxtCvCamera.Text = $"追加カメラ {_CvCamera.CameraInfo()}"; + if (State == STATE.Init && _CvCamera.CurrentFPS>0) { + State = STATE.Idle; + this.UpdateStateLabel(); + } + } + } + + /// + /// 状態表示の更新 + /// + private void UpdateStateLabel() { + switch (State) { + case STATE.Init: + LblState.Text = "初期化中"; + PnlState.BackColor = Color.LightBlue; + break; + case STATE.Idle: + LblState.Text = "待機中"; + PnlState.BackColor = Color.MediumSpringGreen; + break; + case STATE.Recoding: + LblState.Text = "録画中"; + PnlState.BackColor = Color.OrangeRed; + break; + case STATE.Saving: + LblState.Text = "保存中"; + PnlState.BackColor = Color.Goldenrod; + break; } } @@ -237,20 +264,18 @@ player.Play(); // 録画モードへ変更 - Color originalButtonColor = Color.Gray; this.Invoke((MethodInvoker)delegate { _Cameras.ForEach(c => c.ChangeSink(true)); BtnSetProperty.Enabled = false; - BtnRecodeMovie.Text = "撮影中"; - originalButtonColor = BtnRecodeMovie.BackColor; - BtnRecodeMovie.BackColor = Color.Orange; + BtnRecodeMovie.Text = "停止"; + State = STATE.Recoding; + this.UpdateStateLabel(); }); // 録画開始 RecodingTime = DateTime.Now; Directory.CreateDirectory(OutputDir); - State = STATE.Recoding; // 録画 Task[] tasks = new Task[4]; @@ -266,8 +291,7 @@ player.Play(); this.Invoke((MethodInvoker)delegate { BtnRecodeMovie.Enabled = false; - BtnRecodeMovie.Text = "保存中"; - BtnRecodeMovie.BackColor = Color.Aqua; + this.UpdateStateLabel(); }); // 保存 @@ -283,12 +307,12 @@ this.Invoke((MethodInvoker)delegate { _Cameras.ForEach(c => c.ChangeSink(false)); BtnRecodeMovie.Text = "動画撮影"; - BtnRecodeMovie.BackColor = originalButtonColor; BtnRecodeMovie.Enabled = true; BtnSetProperty.Enabled = true; TxtCounter.Text = (int.Parse(TxtCounter.Text) + 1).ToString(); + State = STATE.Idle; + this.UpdateStateLabel(); }); - State = STATE.Idle; } ///