diff --git a/ISCamRecorder/CvCamera.cs b/ISCamRecorder/CvCamera.cs index 36b330d..c42276b 100644 --- a/ISCamRecorder/CvCamera.cs +++ b/ISCamRecorder/CvCamera.cs @@ -80,7 +80,7 @@ var bmp = BitmapConverter.ToBitmap(frame); // 録画 - if (_MF.State == STATE.Recoding) { + if (_MF.State == STATE.Recoding && _MF.Setting.RecCameras[4]) { _RecFrames.Add(new FrameInfo(frame.Clone())); } diff --git a/ISCamRecorder/MainForm.Designer.cs b/ISCamRecorder/MainForm.Designer.cs index 5414c4f..3e1e84d 100644 --- a/ISCamRecorder/MainForm.Designer.cs +++ b/ISCamRecorder/MainForm.Designer.cs @@ -144,7 +144,7 @@ this.TxtCvCamera.ReadOnly = true; this.TxtCvCamera.Size = new System.Drawing.Size(330, 19); this.TxtCvCamera.TabIndex = 3; - this.TxtCvCamera.Text = "追加カメラ"; + this.TxtCvCamera.Text = "近接カメラ"; // // PicCvCamera // diff --git a/ISCamRecorder/MainForm.cs b/ISCamRecorder/MainForm.cs index 4401c26..82da567 100644 --- a/ISCamRecorder/MainForm.cs +++ b/ISCamRecorder/MainForm.cs @@ -300,25 +300,27 @@ /// private void RecodingThread() { - // 録画開始サウンド + // 録画開始 _Sounds[0].Play(); - - // 録画モードへ変更 this.Invoke((MethodInvoker)delegate { - _Cameras.ForEach(c => c.ChangeSink(true)); + for (var i = 0; i < _Cameras.Count; i++) { + if (Setting.RecCameras[i]) _Cameras[i].ChangeSink(true); + } State = STATE.Recoding; this.UpdateStateLabel(); }); - - // 録画開始 RecodingTime = DateTime.Now; Directory.CreateDirectory(OutputDir); // 録画 - Task[] tasks = new Task[4]; + Task[] tasks = new Task[_Cameras.Count]; for (var i = 0; i < _Cameras.Count; i++) { - var cam = _Cameras[i]; - tasks[i] = Task.Run(() => cam.RecordToMemory(Setting.RecodingLimit)); + if (Setting.RecCameras[i]) { + var cam = _Cameras[i]; + tasks[i] = Task.Run(() => cam.RecordToMemory(Setting.RecodingLimit)); + } else { + tasks[i] = Task.Run(() => { }); + } } Task.WaitAll(tasks); @@ -332,15 +334,21 @@ // 保存 for (var i = 0; i < _Cameras.Count; i++) { - var cam = _Cameras[i]; - tasks[i] = Task.Run(() => cam.SaveToFile()); + if (Setting.RecCameras[i]) { + var cam = _Cameras[i]; + tasks[i] = Task.Run(() => cam.SaveToFile()); + } else { + tasks[i] = Task.Run(() => { }); + } } Task.WaitAll(tasks); - _CvCamera.SaveToFile(); + if (Setting.RecCameras[4]) _CvCamera.SaveToFile(); // プレビューモードへ変更 this.Invoke((MethodInvoker)delegate { - _Cameras.ForEach(c => c.ChangeSink(false)); + for (var i = 0; i < _Cameras.Count; i++) { + if (Setting.RecCameras[i]) _Cameras[i].ChangeSink(false); + } TxtCounter.Text = (int.Parse(TxtCounter.Text) + 1).ToString(); State = STATE.Idle; this.UpdateStateLabel(); @@ -358,9 +366,11 @@ var outDir = Path.Combine(Setting.SaveDir, "image"); Directory.CreateDirectory(outDir); this.Invoke((MethodInvoker)delegate { - _Cameras.ForEach(c => c.SnapImage()); + for (var i = 0; i < _Cameras.Count; i++) { + if (Setting.SnapCameras[i]) _Cameras[i].SnapImage(); + } }); - _CvCamera.Snap(); + if (Setting.SnapCameras[4]) _CvCamera.Snap(); } /// diff --git a/ISCamRecorder/Setting.Designer.cs b/ISCamRecorder/Setting.Designer.cs index 9cb3cb2..4669454 100644 --- a/ISCamRecorder/Setting.Designer.cs +++ b/ISCamRecorder/Setting.Designer.cs @@ -46,6 +46,18 @@ this.RadSwitchImage = new System.Windows.Forms.RadioButton(); this.panel1 = new System.Windows.Forms.Panel(); this.label8 = new System.Windows.Forms.Label(); + this.label9 = new System.Windows.Forms.Label(); + this.ChkRecTop = new System.Windows.Forms.CheckBox(); + this.ChkRecLeft = new System.Windows.Forms.CheckBox(); + this.ChkRecFront = new System.Windows.Forms.CheckBox(); + this.ChkRecRight = new System.Windows.Forms.CheckBox(); + this.ChkRecNear = new System.Windows.Forms.CheckBox(); + this.ChkSnapNear = new System.Windows.Forms.CheckBox(); + this.ChkSnapRight = new System.Windows.Forms.CheckBox(); + this.ChkSnapFront = new System.Windows.Forms.CheckBox(); + this.ChkSnapLeft = new System.Windows.Forms.CheckBox(); + this.ChkSnapTop = new System.Windows.Forms.CheckBox(); + this.label10 = new System.Windows.Forms.Label(); this.groupBox1.SuspendLayout(); this.panel1.SuspendLayout(); this.SuspendLayout(); @@ -68,6 +80,18 @@ // // groupBox1 // + this.groupBox1.Controls.Add(this.ChkSnapNear); + this.groupBox1.Controls.Add(this.ChkSnapRight); + this.groupBox1.Controls.Add(this.ChkSnapFront); + this.groupBox1.Controls.Add(this.ChkSnapLeft); + this.groupBox1.Controls.Add(this.ChkSnapTop); + this.groupBox1.Controls.Add(this.label10); + this.groupBox1.Controls.Add(this.ChkRecNear); + this.groupBox1.Controls.Add(this.ChkRecRight); + this.groupBox1.Controls.Add(this.ChkRecFront); + this.groupBox1.Controls.Add(this.ChkRecLeft); + this.groupBox1.Controls.Add(this.ChkRecTop); + this.groupBox1.Controls.Add(this.label9); this.groupBox1.Controls.Add(this.panel1); this.groupBox1.Controls.Add(this.label4); this.groupBox1.Controls.Add(this.TxtTriggerFPS); @@ -243,12 +267,12 @@ // this.RadSwitchMovie.AutoSize = true; this.RadSwitchMovie.Checked = true; - this.RadSwitchMovie.Location = new System.Drawing.Point(65, 7); + this.RadSwitchMovie.Location = new System.Drawing.Point(75, 7); this.RadSwitchMovie.Name = "RadSwitchMovie"; - this.RadSwitchMovie.Size = new System.Drawing.Size(71, 16); + this.RadSwitchMovie.Size = new System.Drawing.Size(47, 16); this.RadSwitchMovie.TabIndex = 36; this.RadSwitchMovie.TabStop = true; - this.RadSwitchMovie.Text = "動画撮影"; + this.RadSwitchMovie.Text = "録画"; this.RadSwitchMovie.UseVisualStyleBackColor = true; // // RadSwitchImage @@ -256,9 +280,9 @@ this.RadSwitchImage.AutoSize = true; this.RadSwitchImage.Location = new System.Drawing.Point(142, 7); this.RadSwitchImage.Name = "RadSwitchImage"; - this.RadSwitchImage.Size = new System.Drawing.Size(83, 16); + this.RadSwitchImage.Size = new System.Drawing.Size(47, 16); this.RadSwitchImage.TabIndex = 37; - this.RadSwitchImage.Text = "静止画撮影"; + this.RadSwitchImage.Text = "撮影"; this.RadSwitchImage.UseVisualStyleBackColor = true; // // panel1 @@ -280,6 +304,124 @@ this.label8.TabIndex = 0; this.label8.Text = "ボタン連動"; // + // label9 + // + this.label9.AutoSize = true; + this.label9.Location = new System.Drawing.Point(6, 220); + this.label9.Name = "label9"; + this.label9.Size = new System.Drawing.Size(54, 12); + this.label9.TabIndex = 35; + this.label9.Text = "録画カメラ"; + // + // ChkRecTop + // + this.ChkRecTop.AutoSize = true; + this.ChkRecTop.Location = new System.Drawing.Point(65, 219); + this.ChkRecTop.Name = "ChkRecTop"; + this.ChkRecTop.Size = new System.Drawing.Size(36, 16); + this.ChkRecTop.TabIndex = 36; + this.ChkRecTop.Text = "上"; + this.ChkRecTop.UseVisualStyleBackColor = true; + // + // ChkRecLeft + // + this.ChkRecLeft.AutoSize = true; + this.ChkRecLeft.Location = new System.Drawing.Point(107, 219); + this.ChkRecLeft.Name = "ChkRecLeft"; + this.ChkRecLeft.Size = new System.Drawing.Size(36, 16); + this.ChkRecLeft.TabIndex = 37; + this.ChkRecLeft.Text = "左"; + this.ChkRecLeft.UseVisualStyleBackColor = true; + // + // ChkRecFront + // + this.ChkRecFront.AutoSize = true; + this.ChkRecFront.Location = new System.Drawing.Point(149, 219); + this.ChkRecFront.Name = "ChkRecFront"; + this.ChkRecFront.Size = new System.Drawing.Size(36, 16); + this.ChkRecFront.TabIndex = 38; + this.ChkRecFront.Text = "前"; + this.ChkRecFront.UseVisualStyleBackColor = true; + // + // ChkRecRight + // + this.ChkRecRight.AutoSize = true; + this.ChkRecRight.Location = new System.Drawing.Point(191, 219); + this.ChkRecRight.Name = "ChkRecRight"; + this.ChkRecRight.Size = new System.Drawing.Size(36, 16); + this.ChkRecRight.TabIndex = 39; + this.ChkRecRight.Text = "右"; + this.ChkRecRight.UseVisualStyleBackColor = true; + // + // ChkRecNear + // + this.ChkRecNear.AutoSize = true; + this.ChkRecNear.Location = new System.Drawing.Point(233, 219); + this.ChkRecNear.Name = "ChkRecNear"; + this.ChkRecNear.Size = new System.Drawing.Size(36, 16); + this.ChkRecNear.TabIndex = 40; + this.ChkRecNear.Text = "近"; + this.ChkRecNear.UseVisualStyleBackColor = true; + // + // ChkSnapNear + // + this.ChkSnapNear.AutoSize = true; + this.ChkSnapNear.Location = new System.Drawing.Point(233, 247); + this.ChkSnapNear.Name = "ChkSnapNear"; + this.ChkSnapNear.Size = new System.Drawing.Size(36, 16); + this.ChkSnapNear.TabIndex = 46; + this.ChkSnapNear.Text = "近"; + this.ChkSnapNear.UseVisualStyleBackColor = true; + // + // ChkSnapRight + // + this.ChkSnapRight.AutoSize = true; + this.ChkSnapRight.Location = new System.Drawing.Point(191, 247); + this.ChkSnapRight.Name = "ChkSnapRight"; + this.ChkSnapRight.Size = new System.Drawing.Size(36, 16); + this.ChkSnapRight.TabIndex = 45; + this.ChkSnapRight.Text = "右"; + this.ChkSnapRight.UseVisualStyleBackColor = true; + // + // ChkSnapFront + // + this.ChkSnapFront.AutoSize = true; + this.ChkSnapFront.Location = new System.Drawing.Point(149, 247); + this.ChkSnapFront.Name = "ChkSnapFront"; + this.ChkSnapFront.Size = new System.Drawing.Size(36, 16); + this.ChkSnapFront.TabIndex = 44; + this.ChkSnapFront.Text = "前"; + this.ChkSnapFront.UseVisualStyleBackColor = true; + // + // ChkSnapLeft + // + this.ChkSnapLeft.AutoSize = true; + this.ChkSnapLeft.Location = new System.Drawing.Point(107, 247); + this.ChkSnapLeft.Name = "ChkSnapLeft"; + this.ChkSnapLeft.Size = new System.Drawing.Size(36, 16); + this.ChkSnapLeft.TabIndex = 43; + this.ChkSnapLeft.Text = "左"; + this.ChkSnapLeft.UseVisualStyleBackColor = true; + // + // ChkSnapTop + // + this.ChkSnapTop.AutoSize = true; + this.ChkSnapTop.Location = new System.Drawing.Point(65, 247); + this.ChkSnapTop.Name = "ChkSnapTop"; + this.ChkSnapTop.Size = new System.Drawing.Size(36, 16); + this.ChkSnapTop.TabIndex = 42; + this.ChkSnapTop.Text = "上"; + this.ChkSnapTop.UseVisualStyleBackColor = true; + // + // label10 + // + this.label10.AutoSize = true; + this.label10.Location = new System.Drawing.Point(6, 248); + this.label10.Name = "label10"; + this.label10.Size = new System.Drawing.Size(54, 12); + this.label10.TabIndex = 41; + this.label10.Text = "撮影カメラ"; + // // Setting // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); @@ -328,5 +470,17 @@ private System.Windows.Forms.RadioButton RadSwitchImage; private System.Windows.Forms.Panel panel1; private System.Windows.Forms.Label label8; + private System.Windows.Forms.Label label9; + private System.Windows.Forms.CheckBox ChkRecRight; + private System.Windows.Forms.CheckBox ChkRecFront; + private System.Windows.Forms.CheckBox ChkRecLeft; + private System.Windows.Forms.CheckBox ChkRecTop; + private System.Windows.Forms.CheckBox ChkRecNear; + private System.Windows.Forms.CheckBox ChkSnapNear; + private System.Windows.Forms.CheckBox ChkSnapRight; + private System.Windows.Forms.CheckBox ChkSnapFront; + private System.Windows.Forms.CheckBox ChkSnapLeft; + private System.Windows.Forms.CheckBox ChkSnapTop; + private System.Windows.Forms.Label label10; } } \ No newline at end of file diff --git a/ISCamRecorder/Setting.cs b/ISCamRecorder/Setting.cs index e00167a..f3feb97 100644 --- a/ISCamRecorder/Setting.cs +++ b/ISCamRecorder/Setting.cs @@ -20,6 +20,8 @@ public bool SWTrigger { get; private set; } public float SWTriggerFPS { get; private set; } public ACTION ButtonAction { get; private set; } + public bool[] RecCameras { get; private set; } + public bool[] SnapCameras { get; private set; } public float TotalConsumedMemoryPerSecond { get; set; } /// @@ -31,6 +33,8 @@ SWTrigger = false; SWTriggerFPS = 40F; ButtonAction = ACTION.movie; + RecCameras = new bool[] { true, true, true, true, true }; + SnapCameras = new bool[] { true, true, true, true, false }; #if DEBUG SaveDir = @"D:\DataDBG"; RecodingLimit = 3F; @@ -56,6 +60,16 @@ TxtTriggerFPS.Text = SWTriggerFPS.ToString("0.0"); RadSwitchMovie.Checked = ButtonAction == ACTION.movie; RadSwitchImage.Checked = ButtonAction == ACTION.image; + ChkRecTop.Checked = RecCameras[0]; + ChkRecLeft.Checked = RecCameras[1]; + ChkRecFront.Checked = RecCameras[2]; + ChkRecRight.Checked = RecCameras[3]; + ChkRecNear.Checked = RecCameras[4]; + ChkSnapTop.Checked = SnapCameras[0]; + ChkSnapLeft.Checked = SnapCameras[1]; + ChkSnapFront.Checked = SnapCameras[2]; + ChkSnapRight.Checked = SnapCameras[3]; + ChkSnapNear.Checked = SnapCameras[4]; this.UpdateMemoryInfo(); } @@ -72,6 +86,16 @@ SWTrigger = ChkTrigger.Checked; SWTriggerFPS = float.Parse(TxtTriggerFPS.Text); ButtonAction = RadSwitchMovie.Checked ? ACTION.movie : ACTION.image; + RecCameras[0] = ChkRecTop.Checked; + RecCameras[1] = ChkRecLeft.Checked; + RecCameras[2] = ChkRecFront.Checked; + RecCameras[3] = ChkRecRight.Checked; + RecCameras[4] = ChkRecNear.Checked; + SnapCameras[0] = ChkSnapTop.Checked; + SnapCameras[1] = ChkSnapLeft.Checked; + SnapCameras[2] = ChkSnapFront.Checked; + SnapCameras[3] = ChkSnapRight.Checked; + SnapCameras[4] = ChkSnapNear.Checked; this.Close(); }