diff --git a/ISCamRecorder/CvCamera.cs b/ISCamRecorder/CvCamera.cs index c42276b..6c7035a 100644 --- a/ISCamRecorder/CvCamera.cs +++ b/ISCamRecorder/CvCamera.cs @@ -88,7 +88,7 @@ if (_Snap) { var outDir = Path.Combine(_MF.Setting.SaveDir, "image"); var filename = Path.Combine(outDir, - $"{_CamID}_{DateTime.Now.ToString("yyyyMMdd_HHmmss")}.{_MF.Setting.ImageTypeL}"); + $"{_CamID}_{DateTime.Now.ToString("yyyyMMdd_HHmmss")}.{_MF.Setting.ImageType.ToLower()}"); Cv2.ImWrite(filename, frame); _Snap = false; } @@ -126,7 +126,7 @@ 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}"; + var fileName = $"{_CamID}_{strSampleTime}.{_MF.Setting.FrameType}"; var filePath = Path.Combine(outDir2, fileName); _RecFrames[i].FrameImage.SaveImage(filePath); writer.Write(_RecFrames[i].FrameImage); diff --git a/ISCamRecorder/ISCamera.cs b/ISCamRecorder/ISCamera.cs index 95d93da..f3bfe9c 100644 --- a/ISCamRecorder/ISCamera.cs +++ b/ISCamRecorder/ISCamera.cs @@ -110,15 +110,15 @@ TIS.Imaging.IFrameQueueBuffer frm = snapSink.SnapSingle(TimeSpan.FromSeconds(5)); var outDir = Path.Combine(_MF.Setting.SaveDir, "image"); - var filename = Path.Combine(outDir, $"{_CamID}_{DateTime.Now.ToString("yyyyMMdd_HHmmss")}.{_MF.Setting.ImageTypeL}"); + var filename = Path.Combine(outDir, $"{_CamID}_{DateTime.Now.ToString("yyyyMMdd_HHmmss")}.{_MF.Setting.ImageType}"); switch (_MF.Setting.ImageType) { - case "JPG": + case "jpg": frm.SaveAsJpeg(filename, JPEG_QUALITY); break; - case "BMP": + case "bmp": frm.SaveAsBitmap(filename); break; - case "TIFF": + case "tif": frm.SaveAsTiff(filename); break; } @@ -169,17 +169,17 @@ var driverTime = _bufferlist[i].FrameMetadata.DriverFrameFirstPacketTime; var frameTime = _MF.RecodingTime.Add(driverTime - firstDriverTime); // パケットをドライバが受信した時刻 string strSampleTime = frameTime.ToString(@"HHmmss\.fff"); - var fileName = $"{_CamID}_{strSampleTime}.{_MF.Setting.ImageTypeL}"; + var fileName = $"{_CamID}_{strSampleTime}.{_MF.Setting.FrameType}"; var filePath = Path.Combine(outDir2, fileName); try { - switch (_MF.Setting.ImageType) { - case "JPG": + switch (_MF.Setting.FrameType) { + case "jpg": FrameExtensions.SaveAsJpeg(_bufferlist[i], filePath, JPEG_QUALITY); break; - case "BMP": + case "bmp": FrameExtensions.SaveAsBitmap(_bufferlist[i], filePath); break; - case "TIFF": + case "tif": FrameExtensions.SaveAsTiff(_bufferlist[i], filePath); break; } diff --git a/ISCamRecorder/MainForm.cs b/ISCamRecorder/MainForm.cs index 82da567..9b6d7e2 100644 --- a/ISCamRecorder/MainForm.cs +++ b/ISCamRecorder/MainForm.cs @@ -221,6 +221,7 @@ TxtCounter.ReadOnly = true; break; } + BtnSnapImage.Text = $"{ButtonSymbol(Setting.ACTION.image)}撮影"; } /// @@ -237,7 +238,6 @@ Setting.ShowDialog(); this.UpdateStateLabel(); - BtnSnapImage.Text = $"{ButtonSymbol(Setting.ACTION.image)}撮影"; if (Setting.SWTrigger != lastTriggerSetting) { _Cameras.ForEach(c => c.SetTriggerMode(Setting.SWTrigger)); } diff --git a/ISCamRecorder/Setting.Designer.cs b/ISCamRecorder/Setting.Designer.cs index 94e974f..7ac344e 100644 --- a/ISCamRecorder/Setting.Designer.cs +++ b/ISCamRecorder/Setting.Designer.cs @@ -60,6 +60,8 @@ this.ChkSnapLeft = new System.Windows.Forms.CheckBox(); this.ChkSnapTop = new System.Windows.Forms.CheckBox(); this.label10 = new System.Windows.Forms.Label(); + this.CboFrameType = new System.Windows.Forms.ComboBox(); + this.label11 = new System.Windows.Forms.Label(); this.groupBox1.SuspendLayout(); this.panel1.SuspendLayout(); this.groupBox2.SuspendLayout(); @@ -77,9 +79,11 @@ // // TxtOutputDir // + 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(53, 69); this.TxtOutputDir.Name = "TxtOutputDir"; - this.TxtOutputDir.Size = new System.Drawing.Size(239, 19); + this.TxtOutputDir.Size = new System.Drawing.Size(274, 19); this.TxtOutputDir.TabIndex = 15; // // groupBox1 @@ -92,7 +96,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(308, 145); + this.groupBox1.Size = new System.Drawing.Size(343, 145); this.groupBox1.TabIndex = 17; this.groupBox1.TabStop = false; this.groupBox1.Text = "全体設定"; @@ -104,38 +108,38 @@ this.panel1.Controls.Add(this.RadSwitchMovie); this.panel1.Location = new System.Drawing.Point(5, 22); this.panel1.Name = "panel1"; - this.panel1.Size = new System.Drawing.Size(229, 30); + this.panel1.Size = new System.Drawing.Size(288, 30); this.panel1.TabIndex = 20; // // label8 // this.label8.AutoSize = true; - this.label8.Location = new System.Drawing.Point(3, 9); + this.label8.Location = new System.Drawing.Point(8, 9); this.label8.Name = "label8"; - this.label8.Size = new System.Drawing.Size(56, 12); + this.label8.Size = new System.Drawing.Size(80, 12); this.label8.TabIndex = 0; - this.label8.Text = "ボタン連動"; + this.label8.Text = "外部ボタン連動"; // // RadSwitchImage // this.RadSwitchImage.AutoSize = true; - this.RadSwitchImage.Location = new System.Drawing.Point(142, 7); + this.RadSwitchImage.Location = new System.Drawing.Point(192, 7); this.RadSwitchImage.Name = "RadSwitchImage"; - this.RadSwitchImage.Size = new System.Drawing.Size(47, 16); + this.RadSwitchImage.Size = new System.Drawing.Size(83, 16); this.RadSwitchImage.TabIndex = 37; - this.RadSwitchImage.Text = "撮影"; + this.RadSwitchImage.Text = "静止画撮影"; this.RadSwitchImage.UseVisualStyleBackColor = true; // // RadSwitchMovie // this.RadSwitchMovie.AutoSize = true; this.RadSwitchMovie.Checked = true; - this.RadSwitchMovie.Location = new System.Drawing.Point(75, 7); + this.RadSwitchMovie.Location = new System.Drawing.Point(107, 7); this.RadSwitchMovie.Name = "RadSwitchMovie"; - this.RadSwitchMovie.Size = new System.Drawing.Size(47, 16); + this.RadSwitchMovie.Size = new System.Drawing.Size(71, 16); this.RadSwitchMovie.TabIndex = 36; this.RadSwitchMovie.TabStop = true; - this.RadSwitchMovie.Text = "録画"; + this.RadSwitchMovie.Text = "映像録画"; this.RadSwitchMovie.UseVisualStyleBackColor = true; // // label4 @@ -169,16 +173,16 @@ // // CboImageType // + this.CboImageType.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.CboImageType.FormattingEnabled = true; this.CboImageType.Items.AddRange(new object[] { "JPG", "BMP", - "TIFF"}); + "TIF"}); this.CboImageType.Location = new System.Drawing.Point(70, 55); this.CboImageType.Name = "CboImageType"; this.CboImageType.Size = new System.Drawing.Size(52, 20); this.CboImageType.TabIndex = 23; - this.CboImageType.Text = "JPG"; // // label7 // @@ -213,6 +217,8 @@ // // groupBox2 // + this.groupBox2.Controls.Add(this.CboFrameType); + this.groupBox2.Controls.Add(this.label11); this.groupBox2.Controls.Add(this.LblAvailableMemory); this.groupBox2.Controls.Add(this.LblRecodingMemory); this.groupBox2.Controls.Add(this.label2); @@ -229,7 +235,7 @@ this.groupBox2.Controls.Add(this.label9); this.groupBox2.Location = new System.Drawing.Point(10, 177); this.groupBox2.Name = "groupBox2"; - this.groupBox2.Size = new System.Drawing.Size(308, 122); + this.groupBox2.Size = new System.Drawing.Size(343, 156); this.groupBox2.TabIndex = 20; this.groupBox2.TabStop = false; this.groupBox2.Text = "映像録画設定"; @@ -238,7 +244,7 @@ // 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(154, 74); + this.LblAvailableMemory.Location = new System.Drawing.Point(154, 80); this.LblAvailableMemory.Name = "LblAvailableMemory"; this.LblAvailableMemory.Size = new System.Drawing.Size(89, 12); this.LblAvailableMemory.TabIndex = 54; @@ -248,7 +254,7 @@ // 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(154, 96); + this.LblRecodingMemory.Location = new System.Drawing.Point(154, 102); this.LblRecodingMemory.Name = "LblRecodingMemory"; this.LblRecodingMemory.Size = new System.Drawing.Size(89, 12); this.LblRecodingMemory.TabIndex = 53; @@ -257,7 +263,7 @@ // label2 // this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(128, 96); + this.label2.Location = new System.Drawing.Point(128, 102); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(17, 12); this.label2.TabIndex = 52; @@ -266,7 +272,7 @@ // label1 // this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(13, 96); + this.label1.Location = new System.Drawing.Point(13, 102); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(77, 12); this.label1.TabIndex = 51; @@ -274,7 +280,7 @@ // // TxtRecodingDulation // - this.TxtRecodingDulation.Location = new System.Drawing.Point(90, 93); + this.TxtRecodingDulation.Location = new System.Drawing.Point(90, 99); this.TxtRecodingDulation.Name = "TxtRecodingDulation"; this.TxtRecodingDulation.Size = new System.Drawing.Size(32, 19); this.TxtRecodingDulation.TabIndex = 50; @@ -283,7 +289,7 @@ // // TxtMovieRate // - this.TxtMovieRate.Location = new System.Drawing.Point(68, 58); + this.TxtMovieRate.Location = new System.Drawing.Point(68, 126); this.TxtMovieRate.Name = "TxtMovieRate"; this.TxtMovieRate.Size = new System.Drawing.Size(40, 19); this.TxtMovieRate.TabIndex = 49; @@ -293,7 +299,7 @@ // label5 // this.label5.AutoSize = true; - this.label5.Location = new System.Drawing.Point(13, 61); + this.label5.Location = new System.Drawing.Point(13, 129); this.label5.Name = "label5"; this.label5.Size = new System.Drawing.Size(56, 12); this.label5.TabIndex = 48; @@ -302,7 +308,7 @@ // label6 // this.label6.AutoSize = true; - this.label6.Location = new System.Drawing.Point(114, 61); + this.label6.Location = new System.Drawing.Point(114, 129); this.label6.Name = "label6"; this.label6.Size = new System.Drawing.Size(29, 12); this.label6.TabIndex = 47; @@ -377,9 +383,9 @@ this.groupBox3.Controls.Add(this.ChkSnapTop); this.groupBox3.Controls.Add(this.label7); this.groupBox3.Controls.Add(this.label10); - this.groupBox3.Location = new System.Drawing.Point(10, 314); + this.groupBox3.Location = new System.Drawing.Point(10, 351); this.groupBox3.Name = "groupBox3"; - this.groupBox3.Size = new System.Drawing.Size(308, 122); + this.groupBox3.Size = new System.Drawing.Size(343, 97); this.groupBox3.TabIndex = 21; this.groupBox3.TabStop = false; this.groupBox3.Text = "静止画撮影設定"; @@ -443,6 +449,28 @@ this.label10.TabIndex = 47; this.label10.Text = "撮影カメラ"; // + // CboFrameType + // + this.CboFrameType.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.CboFrameType.FormattingEnabled = true; + this.CboFrameType.Items.AddRange(new object[] { + "JPG", + "BMP", + "TIF"}); + this.CboFrameType.Location = new System.Drawing.Point(72, 58); + this.CboFrameType.Name = "CboFrameType"; + this.CboFrameType.Size = new System.Drawing.Size(52, 20); + this.CboFrameType.TabIndex = 56; + // + // label11 + // + this.label11.AutoSize = true; + this.label11.Location = new System.Drawing.Point(13, 61); + this.label11.Name = "label11"; + this.label11.Size = new System.Drawing.Size(53, 12); + this.label11.TabIndex = 55; + this.label11.Text = "画像形式"; + // // Setting // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); @@ -511,5 +539,7 @@ private System.Windows.Forms.CheckBox ChkSnapLeft; private System.Windows.Forms.CheckBox ChkSnapTop; private System.Windows.Forms.Label label10; + private System.Windows.Forms.ComboBox CboFrameType; + private System.Windows.Forms.Label label11; } } \ No newline at end of file diff --git a/ISCamRecorder/Setting.cs b/ISCamRecorder/Setting.cs index f3feb97..5d8c6a6 100644 --- a/ISCamRecorder/Setting.cs +++ b/ISCamRecorder/Setting.cs @@ -13,8 +13,8 @@ public enum ACTION { movie, image} public string SaveDir { get; private set; } - public string ImageType { get; private set; } - public string ImageTypeL { get { return ImageType.ToLower(); } } + public string ImageType { get; private set; } // フォーム表示は大文字,変数は小文字で記録 + public string FrameType { get; private set; } // フォーム表示は大文字,変数は小文字で記録 public int MovieRate { get; private set; } public float RecodingLimit { get; private set; } public bool SWTrigger { get; private set; } @@ -29,7 +29,8 @@ /// public Setting() { InitializeComponent(); - ImageType = "JPG"; + ImageType = "jpg"; + FrameType = "tif"; SWTrigger = false; SWTriggerFPS = 40F; ButtonAction = ACTION.movie; @@ -42,7 +43,7 @@ #else SaveDir = @"D:\Data"; RecodingLimit = 30F; - MovieRate = 3000; + MovieRate = 5000; #endif } @@ -53,7 +54,8 @@ /// private void Setting_Activated(object sender, EventArgs e) { TxtOutputDir.Text = SaveDir; - CboImageType.Text = ImageType; + CboImageType.SelectedItem = ImageType.ToUpper(); + CboFrameType.SelectedItem = FrameType.ToUpper(); TxtMovieRate.Text = MovieRate.ToString(); TxtRecodingDulation.Text = RecodingLimit.ToString("0.0"); ChkTrigger.Checked = SWTrigger; @@ -80,7 +82,8 @@ /// private void BtnApply_Click(object sender, EventArgs e) { SaveDir = TxtOutputDir.Text; - ImageType = CboImageType.Text; + ImageType = CboImageType.Text.ToLower(); + FrameType = CboFrameType.Text.ToLower(); MovieRate = int.Parse(TxtMovieRate.Text); RecodingLimit = float.Parse(TxtRecodingDulation.Text); SWTrigger = ChkTrigger.Checked;