diff --git a/ISCamRecorder/MainForm.Designer.cs b/ISCamRecorder/MainForm.Designer.cs index 7a7c367..0091c69 100644 --- a/ISCamRecorder/MainForm.Designer.cs +++ b/ISCamRecorder/MainForm.Designer.cs @@ -182,7 +182,7 @@ this.splitContainer3.Panel2.Controls.Add(this.TxtSensor); this.splitContainer3.Panel2.Controls.Add(this.chart1); this.splitContainer3.Size = new System.Drawing.Size(695, 291); - this.splitContainer3.SplitterDistance = 346; + this.splitContainer3.SplitterDistance = 345; this.splitContainer3.TabIndex = 0; this.splitContainer3.SplitterMoved += new System.Windows.Forms.SplitterEventHandler(this.SplitterMoved); // @@ -194,7 +194,7 @@ this.TxtTop.Location = new System.Drawing.Point(4, 3); this.TxtTop.Name = "TxtTop"; this.TxtTop.ReadOnly = true; - this.TxtTop.Size = new System.Drawing.Size(336, 19); + this.TxtTop.Size = new System.Drawing.Size(335, 19); this.TxtTop.TabIndex = 2; // // icTop @@ -209,7 +209,7 @@ this.icTop.LiveDisplayPosition = new System.Drawing.Point(0, 0); this.icTop.Location = new System.Drawing.Point(4, 28); this.icTop.Name = "icTop"; - this.icTop.Size = new System.Drawing.Size(338, 259); + this.icTop.Size = new System.Drawing.Size(337, 259); this.icTop.TabIndex = 1; // // TxtSensor @@ -220,7 +220,7 @@ this.TxtSensor.Location = new System.Drawing.Point(3, 3); this.TxtSensor.Name = "TxtSensor"; this.TxtSensor.ReadOnly = true; - this.TxtSensor.Size = new System.Drawing.Size(339, 19); + this.TxtSensor.Size = new System.Drawing.Size(340, 19); this.TxtSensor.TabIndex = 3; this.TxtSensor.Text = "逆血センサー"; // @@ -235,6 +235,7 @@ textAnnotation1.Name = "AnnReverseBlood"; textAnnotation1.ShadowOffset = 4; textAnnotation1.Text = "逆血未検出"; + textAnnotation1.Visible = false; this.chart1.Annotations.Add(textAnnotation1); chartArea1.AxisX.IsLabelAutoFit = false; chartArea1.AxisX.LabelStyle.Angle = 90; @@ -287,7 +288,7 @@ this.chart1.Series.Add(series2); this.chart1.Series.Add(series3); this.chart1.Series.Add(series4); - this.chart1.Size = new System.Drawing.Size(337, 261); + this.chart1.Size = new System.Drawing.Size(338, 261); this.chart1.TabIndex = 0; this.chart1.Text = "chart1"; // @@ -354,7 +355,7 @@ this.splitContainer5.Panel2.Controls.Add(this.TxtRight); this.splitContainer5.Panel2.Controls.Add(this.icRight); this.splitContainer5.Size = new System.Drawing.Size(695, 287); - this.splitContainer5.SplitterDistance = 346; + this.splitContainer5.SplitterDistance = 345; this.splitContainer5.TabIndex = 0; this.splitContainer5.SplitterMoved += new System.Windows.Forms.SplitterEventHandler(this.SplitterMoved); // @@ -366,7 +367,7 @@ this.TxtFront.Location = new System.Drawing.Point(3, 3); this.TxtFront.Name = "TxtFront"; this.TxtFront.ReadOnly = true; - this.TxtFront.Size = new System.Drawing.Size(336, 19); + this.TxtFront.Size = new System.Drawing.Size(335, 19); this.TxtFront.TabIndex = 10; // // icFront @@ -381,7 +382,7 @@ this.icFront.LiveDisplayPosition = new System.Drawing.Point(0, 0); this.icFront.Location = new System.Drawing.Point(3, 28); this.icFront.Name = "icFront"; - this.icFront.Size = new System.Drawing.Size(337, 254); + this.icFront.Size = new System.Drawing.Size(336, 254); this.icFront.TabIndex = 9; // // TxtRight @@ -392,7 +393,7 @@ this.TxtRight.Location = new System.Drawing.Point(1, 3); this.TxtRight.Name = "TxtRight"; this.TxtRight.ReadOnly = true; - this.TxtRight.Size = new System.Drawing.Size(339, 19); + this.TxtRight.Size = new System.Drawing.Size(340, 19); this.TxtRight.TabIndex = 11; // // icRight @@ -407,7 +408,7 @@ this.icRight.LiveDisplayPosition = new System.Drawing.Point(0, 0); this.icRight.Location = new System.Drawing.Point(1, 28); this.icRight.Name = "icRight"; - this.icRight.Size = new System.Drawing.Size(339, 254); + this.icRight.Size = new System.Drawing.Size(340, 254); this.icRight.TabIndex = 5; // // BtnRecodeMovie diff --git a/ISCamRecorder/SensorData.cs b/ISCamRecorder/SensorData.cs index 2897827..f989d44 100644 --- a/ISCamRecorder/SensorData.cs +++ b/ISCamRecorder/SensorData.cs @@ -36,6 +36,7 @@ bool _ClearPlot = false; // プロット消去フラグ bool _IsReverseBlood = false; // 逆血フラグ int _ReverseBloodThreshold = -1; // 逆血検出閾値 + TextAnnotation _AnnoRB; public float FrameRate { get { return _Fps.FrameRate; } } // FPS値 @@ -46,6 +47,7 @@ public SensorData(MainForm mf, int queueLength) { _MF = mf; _QueueLength = queueLength; + _AnnoRB = (TextAnnotation)_MF.SensorChart.Annotations["AnnReverseBlood"]; } /// @@ -122,14 +124,14 @@ } // 彩度計算 - var sat = 0; + var wbvals = new float[] { 1F, 1F, 1F }; if (_ReverseBloodThreshold >= 0) { - var wbvals = new float[] { values[0] / baseline[0], values[1] / baseline[1], values[2] / baseline[2] }; - var vmax = wbvals.Max(); - var vmin = wbvals.Min(); - sat = (int)(1000F * (vmax - vmin) / vmax); - //Debug.WriteLine($"{baseline[0]}, {baseline[1]}, {baseline[2]}, {vmax}, {vmin}, {sat}"); + for (var i = 0; i < 3; i++) wbvals[i] = Math.Min(values[i] / baseline[i], 1F); } + var sat = (int)(1000F * (1F - wbvals.Min() / wbvals.Max())); + _MF.SensorChart.Invoke((MethodInvoker)delegate { + _MF.SensorChart.ChartAreas[0].BackColor = Color.FromArgb((int)(wbvals[1]*255F), (int)(wbvals[2] * 255F), (int)(wbvals[0] * 255F)); + }); // プロット追加 if (_ClearPlot) { @@ -186,8 +188,7 @@ _IsReverseBlood = true; _MF.ReverseBlood(); _MF.SensorChart.Invoke((MethodInvoker)delegate { - var an = (TextAnnotation)_MF.SensorChart.Annotations["AnnReverseBlood"]; - an.Text = "逆血あり"; + _AnnoRB.Text = "逆血あり"; _MF.SensorChart.ChartAreas[0].BackColor = Color.LightPink; }); } @@ -238,7 +239,8 @@ _CsvWriter.WriteLine($"Date,Time,elapsed,B,R,G,IR,Sat,Switch,ReverseBlood"); } _MF.SensorChart.Invoke((MethodInvoker)delegate { - _MF.SensorChart.Annotations["AnnReverseBlood"].Visible = true; + _AnnoRB.Visible = true; + _AnnoRB.Text = "逆血なし"; }); _ReverseBloodThreshold = -1; _IsReverseBlood = false; @@ -260,9 +262,8 @@ _CsvReader = null; } _MF.SensorChart.Invoke((MethodInvoker)delegate { - var an = (TextAnnotation)_MF.SensorChart.Annotations["AnnReverseBlood"]; - an.Text = "逆血なし"; - an.Visible = false; + _AnnoRB.Text = "逆血なし"; + _AnnoRB.Visible = false; _MF.SensorChart.ChartAreas[0].BackColor = Color.LemonChiffon; }); } diff --git a/ISCamRecorder/Setting.Designer.cs b/ISCamRecorder/Setting.Designer.cs index a8978f7..87ab9aa 100644 --- a/ISCamRecorder/Setting.Designer.cs +++ b/ISCamRecorder/Setting.Designer.cs @@ -75,6 +75,7 @@ this.groupBox5 = new System.Windows.Forms.GroupBox(); this.CboRBDetectCh = new System.Windows.Forms.ComboBox(); this.label17 = new System.Windows.Forms.Label(); + this.ChkSensorColorBG = new System.Windows.Forms.CheckBox(); this.groupBox1.SuspendLayout(); this.panel1.SuspendLayout(); this.groupBox2.SuspendLayout(); @@ -601,6 +602,7 @@ // // groupBox5 // + this.groupBox5.Controls.Add(this.ChkSensorColorBG); this.groupBox5.Controls.Add(this.CboRBDetectCh); this.groupBox5.Controls.Add(this.label17); this.groupBox5.Controls.Add(this.label16); @@ -640,6 +642,16 @@ this.label17.TabIndex = 64; this.label17.Text = "検出チャネル"; // + // ChkSensorColorBG + // + this.ChkSensorColorBG.AutoSize = true; + this.ChkSensorColorBG.Location = new System.Drawing.Point(152, 23); + this.ChkSensorColorBG.Name = "ChkSensorColorBG"; + this.ChkSensorColorBG.Size = new System.Drawing.Size(156, 16); + this.ChkSensorColorBG.TabIndex = 66; + this.ChkSensorColorBG.Text = "センサ色をグラフ背景に反映"; + this.ChkSensorColorBG.UseVisualStyleBackColor = true; + // // Setting // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); @@ -729,5 +741,6 @@ private System.Windows.Forms.GroupBox groupBox5; private System.Windows.Forms.ComboBox CboRBDetectCh; private System.Windows.Forms.Label label17; + private System.Windows.Forms.CheckBox ChkSensorColorBG; } } \ No newline at end of file diff --git a/ISCamRecorder/Setting.cs b/ISCamRecorder/Setting.cs index 464cccd..604ccc2 100644 --- a/ISCamRecorder/Setting.cs +++ b/ISCamRecorder/Setting.cs @@ -30,6 +30,7 @@ public int RBDetectSize { get; private set; } // 直近信号検出ウインドウサイズ public int RBDetectCount { get; private set; } // 直近信号検出数 public string RBDetectCh { get; private set; } + public bool SensorColorBG { get; private set; } // センサ色をグラフ背景に反映するかどうか public float[] ConsumedMemoryPerSecond { get; set; } @@ -49,7 +50,8 @@ RBThreshold = 100; RBDetectSize = 10; RBDetectCount = 5; - RBDetectCh = "G"; + RBDetectCh = "Sat"; + SensorColorBG = true; #if DEBUG SaveDir = @"D:\DataDBG"; RecodingLimit = 10F; @@ -99,6 +101,7 @@ TxtRBDetectSize.Text = RBDetectSize.ToString(); TxtRBDetectCount.Text = RBDetectCount.ToString(); CboRBDetectCh.SelectedItem = RBDetectCh; + ChkSensorColorBG.Checked = SensorColorBG; this.UpdateMemoryInfo(); } @@ -139,6 +142,7 @@ RBDetectSize = int.Parse(TxtRBDetectSize.Text); RBDetectCount = int.Parse(TxtRBDetectCount.Text); RBDetectCh = CboRBDetectCh.Text; + SensorColorBG = ChkSensorColorBG.Checked; this.Close(); }