diff --git a/TIASshot/CameraBase.cs b/TIASshot/CameraBase.cs index caa1714..808e917 100644 --- a/TIASshot/CameraBase.cs +++ b/TIASshot/CameraBase.cs @@ -39,6 +39,7 @@ protected Dictionary _convRGB2SRGB = new Dictionary(); protected string _saveFolder = ""; protected List _shots = new List(); + protected Dictionary _ShotInfo = new Dictionary(); // 設定値保存用 // プライベートメンバ readonly Dictionary ARDict = CvAruco.GetPredefinedDictionary(PredefinedDictionaryName.Dict4X4_50); @@ -119,6 +120,8 @@ /// public void ShotOne() { SetSaveFolder(_form.GetDataName()); + SetInfo("データ名", _form.GetDataName()); + SetInfo("撮影枚数", "1"); Shot(); _form.ShowMessage("撮影終了"); } @@ -128,6 +131,9 @@ /// public void ShotMulti() { SetSaveFolder(_form.GetDataName()); + SetInfo("データ名", _form.GetDataName()); + SetInfo("撮影枚数", $"{_form.GetNumMultiShots()}"); + SetInfo("撮影間隔(ms)", $"{_form.GetMultiShotsInterval()}"); Shot(_form.GetNumMultiShots(), _form.GetMultiShotsInterval()); _form.ShowMessage("撮影終了"); } @@ -268,6 +274,7 @@ // データ保存 SetSaveFolder("校正"); + SetInfo("校正データ", _saveFolder); Cv2.ImWrite(Path.Combine(_saveFolder, Config.GetString("File/TccSave")), img); Cv2.ImWrite(Path.Combine(_saveFolder, Config.GetString("File/TccRois")), imgRois); SaveMatToCsv(Path.Combine(_saveFolder, Config.GetString("File/TccRgb")), tccRgb); @@ -485,5 +492,28 @@ Directory.CreateDirectory(_saveFolder); } + /// + /// 設定値を保存する + /// + /// + /// + protected void SetInfo(string key, string value) { + if (_ShotInfo.ContainsKey(key)) { + _ShotInfo[key] = value; + } else { + _ShotInfo.Add(key, value); + } + } + + /// + /// 設定値をCSVファイルに書き込む + /// + /// + protected void WriteInfo(StreamWriter sw) { + sw.WriteLine($"撮影日時,{DateTime.Now:yyyy/MM/dd HH:mm:ss}"); // 撮影日時を追加 + foreach (var kvp in _ShotInfo) { + sw.WriteLine($"{kvp.Key},{kvp.Value}"); + } + } } } diff --git a/TIASshot/DBK33UX178.xml b/TIASshot/DBK33UX178.xml deleted file mode 100644 index 38c40fc..0000000 --- a/TIASshot/DBK33UX178.xml +++ /dev/null @@ -1,144 +0,0 @@ - - - RGB24 (3072x2048) - 30.000030 - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/TIASshot/DFK33UX178.xml b/TIASshot/DFK33UX178.xml new file mode 100644 index 0000000..6c33e9c --- /dev/null +++ b/TIASshot/DFK33UX178.xml @@ -0,0 +1,141 @@ + + + RGB24 (3072x2048) + 30.000030 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/TIASshot/Form1.cs b/TIASshot/Form1.cs index 04b9c8d..df72fae 100644 --- a/TIASshot/Form1.cs +++ b/TIASshot/Form1.cs @@ -89,6 +89,7 @@ /// /// private void Form1_FormClosing(object sender, FormClosingEventArgs e) { + if (_camera == null) return; _camera.Disconnect(); } diff --git a/TIASshot/IScam.cs b/TIASshot/IScam.cs index 089a174..e70e7f0 100644 --- a/TIASshot/IScam.cs +++ b/TIASshot/IScam.cs @@ -60,7 +60,9 @@ _snapSink = new FrameSnapSink(MediaSubtypes.RGB24); _ic.Sink = _queueSink; DeviceName = _ic.DeviceCurrent.Name; + SetInfo("カメラ型番", DeviceName); SerialNumber = _ic.DeviceCurrent.GetSerialNumber(); + SetInfo("カメラSN", SerialNumber); _brightness = _ic.VCDPropertyItems.Find(VCDGUIDs.VCDID_Brightness, VCDGUIDs.VCDElement_Value); _gain = _ic.VCDPropertyItems.Find(VCDGUIDs.VCDID_Gain, VCDGUIDs.VCDElement_Value); _exposure = _ic.VCDPropertyItems.Find(VCDGUIDs.VCDID_Exposure, VCDGUIDs.VCDElement_Value); @@ -114,6 +116,16 @@ Debug.WriteLine($"White Balance Red range: {_whiteBalanceRed.RangeMin} to {_whiteBalanceRed.RangeMax} value={_whiteBalanceRed.Value}"); CalcTcc(imgt); + + SetInfo("Exposure(ms)", $"{(float)_exposure.Value/10}"); + SetInfo("Brightness", $"{_brightness.Value}"); + SetInfo("Gamma", $"{_gamma.Value}"); + SetInfo("Gain", $"{_gain.Value}"); + SetInfo("Gain B", $"{_whiteBalanceBlue.Value}"); + SetInfo("Gain G", $"{_whiteBalanceGreen.Value}"); + SetInfo("Gain R", $"{_whiteBalanceRed.Value}"); + SetInfo("画像幅", $"{imgt.Width}"); + SetInfo("画像高さ", $"{imgt.Height}"); } } @@ -146,8 +158,9 @@ var thread = new Thread(() => SaveThread(numImages)); thread.Start(); - var filename = Config.GetString("File/ShotTime"); + var filename = Config.GetString("File/Info"); using (var csv = new StreamWriter(Path.Combine(_saveFolder, filename))) { + WriteInfo(csv); csv.WriteLine("Shot,Time(ms)"); var watch = Stopwatch.StartNew(); diff --git a/TIASshot/Lucam.cs b/TIASshot/Lucam.cs index add9d28..517a409 100644 --- a/TIASshot/Lucam.cs +++ b/TIASshot/Lucam.cs @@ -110,7 +110,9 @@ lumVersion = api.EnumCameras(); var id = 0; if (lumVersion[id].CameraId == 0x49f) DeviceName = "Lw110"; + SetInfo("カメラ型番", DeviceName); SerialNumber = lumVersion[id].SerialNumber.ToString(); + SetInfo("カメラSN", SerialNumber); // カメラを開く _hCam = api.CameraOpen(1); @@ -179,7 +181,19 @@ } _calibrating--; if (_calibrating == 0) { + Debug.WriteLine($"Gain Blue : {_snap.GainBlue}"); + Debug.WriteLine($"Gain Green: {_snap.GainGrn1}"); + Debug.WriteLine($"Gain Red : {_snap.GainRed}"); + CalcTcc(imgt); + + SetInfo("Exposure(ms)", $"{_snap.Exposure}"); + SetInfo("Gain", $"{_snap.Gain}"); + SetInfo("Gain B", $"{_snap.GainBlue}"); + SetInfo("Gain G", $"{_snap.GainGrn1}"); + SetInfo("Gain R", $"{_snap.GainRed}"); + SetInfo("画像幅", $"{imgt.Width}"); + SetInfo("画像高さ", $"{imgt.Height}"); } } @@ -210,8 +224,9 @@ var rawImage = new byte[imageSize]; var rgbImage = new byte[imageSize * 3]; - var filename = Config.GetString("File/ShotTime"); + var filename = Config.GetString("File/Info"); using (var csv = new StreamWriter(Path.Combine(_saveFolder, filename))) { + WriteInfo(csv); csv.WriteLine("Shot,Time(ms)"); var watch = Stopwatch.StartNew(); diff --git a/TIASshot/TIASshot.csproj b/TIASshot/TIASshot.csproj index c973a16..7a736a4 100644 --- a/TIASshot/TIASshot.csproj +++ b/TIASshot/TIASshot.csproj @@ -172,7 +172,7 @@ copy /Y $(ProjectDir)config.xml $(TargetDir) copy /Y $(ProjectDir)tcc_srgb.csv $(TargetDir) copy /Y $(ProjectDir)tcc_xyz.csv $(TargetDir) -copy /Y $(ProjectDir)DBK33UX178.xml $(TargetDir) +copy /Y $(ProjectDir)DFK33UX178.xml $(TargetDir) copy /Y $(ProjectDir)DFK23UX249.xml $(TargetDir) diff --git a/TIASshot/config.xml b/TIASshot/config.xml index d94590d..bebe4b6 100644 --- a/TIASshot/config.xml +++ b/TIASshot/config.xml @@ -33,7 +33,7 @@ TCC_ROIs.jpg Shot{NO}.png sRGB{CN}_{NO}.jpg - Record.csv + Info.csv TCC_RGB.csv TCC_sRGB{CN}.csv Conv_RGB-sRGB{CN}.csv