diff --git a/ISCamRecorder/SensorData.cs b/ISCamRecorder/SensorData.cs index 2cd7c57..a16be47 100644 --- a/ISCamRecorder/SensorData.cs +++ b/ISCamRecorder/SensorData.cs @@ -33,7 +33,8 @@ MainForm _MF = null; // メインフォームインスタンス bool _IsRecoding = false; // 記録中フラグ bool _ClearPlot = false; // プロット消去フラグ - bool _ReverseBlood = false; // 逆血フラグ + bool _IsReverseBlood = false; // 逆血フラグ + int _ReverseBloodThreshold = -1; // 逆血検出閾値 public float FrameRate { get { return _Fps.FrameRate; } } // FPS値 @@ -138,14 +139,23 @@ Times.Dequeue(); } + // 逆血判定 + var minValue = ValuesG.Min(); + if (_ReverseBloodThreshold < 0 && ValuesG.Count >= NUM_SAMPLES_SET_THRES) { + _ReverseBloodThreshold = minValue - _MF.Setting.ReverseBloodThreshold; + } + if (minValue < _ReverseBloodThreshold) { + _IsReverseBlood = true; + } + // 表示 if (_MF.State != STATE.Exit) { _MF.SensorChart.Invoke((MethodInvoker)delegate { var an = (TextAnnotation)_MF.SensorChart.Annotations["AnnReverseBlood"]; an.Visible = _IsRecoding; if (_IsRecoding) { - an.Text = _ReverseBlood ? "逆血あり" : "逆血なし"; - an.ForeColor = _ReverseBlood ? Color.OrangeRed : Color.Black; + an.Text = _IsReverseBlood ? "逆血あり" : "逆血なし"; + an.ForeColor = _IsReverseBlood ? Color.OrangeRed : Color.Black; } _MF.SensorChart.Series[0].Points.Clear(); _MF.SensorChart.Series[0].Points.DataBindXY(Times, ValuesB); @@ -178,7 +188,8 @@ _CsvWriter.WriteLine($"Date,Time,elapsed,B,R,G,IR,switch"); } } - _ReverseBlood = false; + _ReverseBloodThreshold = -1; + _IsReverseBlood = false; _ClearPlot = true; _IsRecoding = true; } diff --git a/ISCamRecorder/Setting.Designer.cs b/ISCamRecorder/Setting.Designer.cs index 5adaba6..84005c2 100644 --- a/ISCamRecorder/Setting.Designer.cs +++ b/ISCamRecorder/Setting.Designer.cs @@ -65,6 +65,8 @@ this.groupBox4 = new System.Windows.Forms.GroupBox(); this.TxtSubjectList = new System.Windows.Forms.TextBox(); this.label12 = new System.Windows.Forms.Label(); + this.label13 = new System.Windows.Forms.Label(); + this.TxtReverseBloodThreshold = new System.Windows.Forms.TextBox(); this.groupBox1.SuspendLayout(); this.panel1.SuspendLayout(); this.groupBox2.SuspendLayout(); @@ -75,7 +77,7 @@ // label3 // this.label3.AutoSize = true; - this.label3.Location = new System.Drawing.Point(7, 63); + this.label3.Location = new System.Drawing.Point(7, 53); this.label3.Name = "label3"; this.label3.Size = new System.Drawing.Size(41, 12); this.label3.TabIndex = 16; @@ -85,13 +87,15 @@ // this.TxtOutputDir.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - this.TxtOutputDir.Location = new System.Drawing.Point(54, 60); + this.TxtOutputDir.Location = new System.Drawing.Point(54, 50); this.TxtOutputDir.Name = "TxtOutputDir"; this.TxtOutputDir.Size = new System.Drawing.Size(274, 19); this.TxtOutputDir.TabIndex = 15; // // groupBox1 // + this.groupBox1.Controls.Add(this.TxtReverseBloodThreshold); + this.groupBox1.Controls.Add(this.label13); this.groupBox1.Controls.Add(this.panel1); this.groupBox1.Controls.Add(this.label4); this.groupBox1.Controls.Add(this.TxtTriggerFPS); @@ -100,7 +104,7 @@ this.groupBox1.Controls.Add(this.TxtOutputDir); this.groupBox1.Location = new System.Drawing.Point(10, 12); this.groupBox1.Name = "groupBox1"; - this.groupBox1.Size = new System.Drawing.Size(343, 122); + this.groupBox1.Size = new System.Drawing.Size(343, 125); this.groupBox1.TabIndex = 17; this.groupBox1.TabStop = false; this.groupBox1.Text = "全体設定"; @@ -110,7 +114,7 @@ this.panel1.Controls.Add(this.label8); this.panel1.Controls.Add(this.RadSwitchImage); this.panel1.Controls.Add(this.RadSwitchMovie); - this.panel1.Location = new System.Drawing.Point(5, 22); + this.panel1.Location = new System.Drawing.Point(5, 17); this.panel1.Name = "panel1"; this.panel1.Size = new System.Drawing.Size(288, 30); this.panel1.TabIndex = 20; @@ -149,7 +153,7 @@ // label4 // this.label4.AutoSize = true; - this.label4.Location = new System.Drawing.Point(161, 95); + this.label4.Location = new System.Drawing.Point(151, 79); this.label4.Name = "label4"; this.label4.Size = new System.Drawing.Size(21, 12); this.label4.TabIndex = 34; @@ -158,7 +162,7 @@ // TxtTriggerFPS // this.TxtTriggerFPS.Enabled = false; - this.TxtTriggerFPS.Location = new System.Drawing.Point(121, 92); + this.TxtTriggerFPS.Location = new System.Drawing.Point(111, 76); this.TxtTriggerFPS.Name = "TxtTriggerFPS"; this.TxtTriggerFPS.Size = new System.Drawing.Size(34, 19); this.TxtTriggerFPS.TabIndex = 33; @@ -168,7 +172,7 @@ // ChkTrigger // this.ChkTrigger.AutoSize = true; - this.ChkTrigger.Location = new System.Drawing.Point(6, 94); + this.ChkTrigger.Location = new System.Drawing.Point(6, 78); this.ChkTrigger.Name = "ChkTrigger"; this.ChkTrigger.Size = new System.Drawing.Size(109, 16); this.ChkTrigger.TabIndex = 32; @@ -238,7 +242,7 @@ this.groupBox2.Controls.Add(this.ChkRecLeft); this.groupBox2.Controls.Add(this.ChkRecTop); this.groupBox2.Controls.Add(this.label9); - this.groupBox2.Location = new System.Drawing.Point(10, 149); + this.groupBox2.Location = new System.Drawing.Point(10, 153); this.groupBox2.Name = "groupBox2"; this.groupBox2.Size = new System.Drawing.Size(343, 156); this.groupBox2.TabIndex = 20; @@ -510,6 +514,25 @@ this.label12.TabIndex = 1; this.label12.Text = "非測定者名を1行1名で記入してください\r\n起動時 SubjectList.txt を読み込み"; // + // label13 + // + this.label13.AutoSize = true; + this.label13.Location = new System.Drawing.Point(7, 103); + this.label13.Name = "label13"; + this.label13.Size = new System.Drawing.Size(125, 12); + this.label13.TabIndex = 35; + this.label13.Text = "逆血検出信号変化閾値"; + // + // TxtReverseBloodThreshold + // + this.TxtReverseBloodThreshold.Location = new System.Drawing.Point(138, 100); + this.TxtReverseBloodThreshold.Name = "TxtReverseBloodThreshold"; + this.TxtReverseBloodThreshold.Size = new System.Drawing.Size(32, 19); + this.TxtReverseBloodThreshold.TabIndex = 58; + this.TxtReverseBloodThreshold.Text = "10"; + this.TxtReverseBloodThreshold.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; + this.TxtReverseBloodThreshold.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.NumberKeyOnly); + // // Setting // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); @@ -586,5 +609,7 @@ private System.Windows.Forms.GroupBox groupBox4; private System.Windows.Forms.Label label12; private System.Windows.Forms.TextBox TxtSubjectList; + private System.Windows.Forms.TextBox TxtReverseBloodThreshold; + private System.Windows.Forms.Label label13; } } \ No newline at end of file diff --git a/ISCamRecorder/Setting.cs b/ISCamRecorder/Setting.cs index 53179e6..57bd6b6 100644 --- a/ISCamRecorder/Setting.cs +++ b/ISCamRecorder/Setting.cs @@ -26,6 +26,8 @@ public bool[] SnapCameras { get; private set; } public float TotalConsumedMemoryPerSecond { get; set; } public List Subjects { get; private set; } + public int ReverseBloodThreshold { get; private set; } + /// /// コンストラクタ @@ -38,6 +40,7 @@ SWTriggerFPS = 40F; ButtonAction = ACTION.movie; SnapCameras = new bool[] { true, true, true, true, false }; + ReverseBloodThreshold = 10; #if DEBUG SaveDir = @"D:\DataDBG"; RecodingLimit = 5F; @@ -83,6 +86,7 @@ ChkSnapRight.Checked = SnapCameras[3]; ChkSnapNear.Checked = SnapCameras[4]; TxtSubjectList.Lines = Subjects.ToArray(); + TxtReverseBloodThreshold.Text = ReverseBloodThreshold.ToString(); this.UpdateMemoryInfo(); } @@ -111,6 +115,7 @@ SnapCameras[3] = ChkSnapRight.Checked; SnapCameras[4] = ChkSnapNear.Checked; Subjects = TxtSubjectList.Lines.Where(s => s.Trim().Length > 0).Select(s => s.Trim()).ToList(); + ReverseBloodThreshold = int.Parse(TxtReverseBloodThreshold.Text); this.Close(); }