diff --git a/TIASshot/Form1.Designer.cs b/TIASshot/Form1.Designer.cs index f48df48..3469127 100644 --- a/TIASshot/Form1.Designer.cs +++ b/TIASshot/Form1.Designer.cs @@ -35,13 +35,22 @@ this.txtMessage = new System.Windows.Forms.TextBox(); this.txtSaveFolder = new System.Windows.Forms.TextBox(); this.label3 = new System.Windows.Forms.Label(); + this.label4 = new System.Windows.Forms.Label(); + this.txtDataName = new System.Windows.Forms.TextBox(); + this.label5 = new System.Windows.Forms.Label(); + this.label6 = new System.Windows.Forms.Label(); + this.txtNumMultiShots = new System.Windows.Forms.TextBox(); + this.label7 = new System.Windows.Forms.Label(); + this.txtMultiShotsInterval = new System.Windows.Forms.TextBox(); + this.label8 = new System.Windows.Forms.Label(); ((System.ComponentModel.ISupportInitialize)(this.picPreview)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.picDisplay)).BeginInit(); this.SuspendLayout(); // // btnShotOne // - this.btnShotOne.Location = new System.Drawing.Point(15, 116); + this.btnShotOne.Font = new System.Drawing.Font("MS UI Gothic", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(128))); + this.btnShotOne.Location = new System.Drawing.Point(12, 176); this.btnShotOne.Name = "btnShotOne"; this.btnShotOne.Size = new System.Drawing.Size(271, 47); this.btnShotOne.TabIndex = 0; @@ -111,7 +120,8 @@ // btnShotMulti // this.btnShotMulti.AllowDrop = true; - this.btnShotMulti.Location = new System.Drawing.Point(15, 195); + this.btnShotMulti.Font = new System.Drawing.Font("MS UI Gothic", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(128))); + this.btnShotMulti.Location = new System.Drawing.Point(12, 316); this.btnShotMulti.Name = "btnShotMulti"; this.btnShotMulti.Size = new System.Drawing.Size(271, 49); this.btnShotMulti.TabIndex = 6; @@ -161,11 +171,98 @@ this.label3.TabIndex = 11; this.label3.Text = "データ保存フォルダ"; // + // label4 + // + this.label4.AutoSize = true; + this.label4.Font = new System.Drawing.Font("MS UI Gothic", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(128))); + this.label4.Location = new System.Drawing.Point(12, 95); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(60, 16); + this.label4.TabIndex = 12; + this.label4.Text = "データ名"; + // + // txtDataName + // + this.txtDataName.Font = new System.Drawing.Font("MS UI Gothic", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(128))); + this.txtDataName.Location = new System.Drawing.Point(15, 114); + this.txtDataName.Name = "txtDataName"; + this.txtDataName.Size = new System.Drawing.Size(268, 23); + this.txtDataName.TabIndex = 13; + this.txtDataName.Text = "なし"; + // + // label5 + // + this.label5.AutoSize = true; + this.label5.Font = new System.Drawing.Font("MS UI Gothic", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(128))); + this.label5.Location = new System.Drawing.Point(12, 261); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(103, 16); + this.label5.TabIndex = 14; + this.label5.Text = "連続撮影枚数"; + // + // label6 + // + this.label6.AutoSize = true; + this.label6.Font = new System.Drawing.Font("MS UI Gothic", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(128))); + this.label6.Location = new System.Drawing.Point(12, 290); + this.label6.Name = "label6"; + this.label6.Size = new System.Drawing.Size(71, 16); + this.label6.TabIndex = 15; + this.label6.Text = "撮影間隔"; + // + // txtNumMultiShots + // + this.txtNumMultiShots.Font = new System.Drawing.Font("MS UI Gothic", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(128))); + this.txtNumMultiShots.Location = new System.Drawing.Point(121, 258); + this.txtNumMultiShots.Name = "txtNumMultiShots"; + this.txtNumMultiShots.Size = new System.Drawing.Size(67, 23); + this.txtNumMultiShots.TabIndex = 16; + this.txtNumMultiShots.Text = "5"; + this.txtNumMultiShots.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; + // + // label7 + // + this.label7.AutoSize = true; + this.label7.Font = new System.Drawing.Font("MS UI Gothic", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(128))); + this.label7.Location = new System.Drawing.Point(194, 261); + this.label7.Name = "label7"; + this.label7.Size = new System.Drawing.Size(23, 16); + this.label7.TabIndex = 17; + this.label7.Text = "枚"; + // + // txtMultiShotsInterval + // + this.txtMultiShotsInterval.Font = new System.Drawing.Font("MS UI Gothic", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(128))); + this.txtMultiShotsInterval.Location = new System.Drawing.Point(121, 287); + this.txtMultiShotsInterval.Name = "txtMultiShotsInterval"; + this.txtMultiShotsInterval.Size = new System.Drawing.Size(67, 23); + this.txtMultiShotsInterval.TabIndex = 18; + this.txtMultiShotsInterval.Text = "1000"; + this.txtMultiShotsInterval.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; + // + // label8 + // + this.label8.AutoSize = true; + this.label8.Font = new System.Drawing.Font("MS UI Gothic", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(128))); + this.label8.Location = new System.Drawing.Point(194, 290); + this.label8.Name = "label8"; + this.label8.Size = new System.Drawing.Size(42, 16); + this.label8.TabIndex = 19; + this.label8.Text = "ミリ秒"; + // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(753, 634); + this.Controls.Add(this.label8); + this.Controls.Add(this.txtMultiShotsInterval); + this.Controls.Add(this.label7); + this.Controls.Add(this.txtNumMultiShots); + this.Controls.Add(this.label6); + this.Controls.Add(this.label5); + this.Controls.Add(this.txtDataName); + this.Controls.Add(this.label4); this.Controls.Add(this.label3); this.Controls.Add(this.txtSaveFolder); this.Controls.Add(this.txtMessage); @@ -203,6 +300,14 @@ private System.Windows.Forms.TextBox txtMessage; private System.Windows.Forms.TextBox txtSaveFolder; private System.Windows.Forms.Label label3; + private System.Windows.Forms.Label label4; + private System.Windows.Forms.TextBox txtDataName; + private System.Windows.Forms.Label label5; + private System.Windows.Forms.Label label6; + private System.Windows.Forms.TextBox txtNumMultiShots; + private System.Windows.Forms.Label label7; + private System.Windows.Forms.TextBox txtMultiShotsInterval; + private System.Windows.Forms.Label label8; } } diff --git a/TIASshot/Form1.cs b/TIASshot/Form1.cs index d4d0d8a..6f4208e 100644 --- a/TIASshot/Form1.cs +++ b/TIASshot/Form1.cs @@ -112,6 +112,33 @@ } /// + /// データ名取得 + /// + /// + public string GetDataName() { + if (InvokeRequired) { + return (string)Invoke((MethodInvoker)delegate { GetDataName(); }); + } + return txtDataName.Text; + } + + public int GetNumMultiShots() { + if (InvokeRequired) { + return (int)Invoke((MethodInvoker)delegate { GetNumMultiShots(); }); + } + if (int.TryParse(txtNumMultiShots.Text, out int result)) return result; + return 1; + } + + public int GetMultiShotsInterval() { + if (InvokeRequired) { + return (int)Invoke((MethodInvoker)delegate { GetMultiShotsInterval(); }); + } + if (int.TryParse(txtMultiShotsInterval.Text, out int result)) return result; + return 1000; + } + + /// /// 撮影ボタン有効化 /// /// diff --git a/TIASshot/Lucam.cs b/TIASshot/Lucam.cs index 061d861..e88b9ed 100644 --- a/TIASshot/Lucam.cs +++ b/TIASshot/Lucam.cs @@ -363,7 +363,7 @@ /// 複数画像撮影 /// public void ShotMulti() { - Shot(Config.GetInt("MultiShotCount"), Config.GetInt("MultiShotInterval")); + Shot(_form.GetNumMultiShots(), _form.GetMultiShotsInterval()); } /// @@ -371,8 +371,10 @@ /// /// /// - private void Shot(int numImages = 1, int interval = 1000) { + private void Shot(int numImages=1, int interval=0) { SetSnapParam(); + var folder = GetSaveFolder(_form.GetDataName()); + dll.LucamEnableFastFrames(_hCam, ref _snap); var imageSize = _snap.Format.Width * _snap.Format.Height; var rawImage = new byte[imageSize]; @@ -386,9 +388,8 @@ using (Mat img = Mat.FromPixelData(_snap.Format.Height, _snap.Format.Width, MatType.CV_8UC3, rgbImage)) { //Cv2.ImWrite($"orig_{i:00}.jpg", img); using (Mat imgt = img.T()) { - Cv2.ImWrite($"conv0_{i:00}.jpg", imgt); using (var converted = ConvertImage(imgt, _convRGB2SRGB)) { - Cv2.ImWrite($"conv1_{i:00}.jpg", converted); + Cv2.ImWrite(Path.Combine(folder, $"Shot{i+1:0000}.bmp"), converted); } } }