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/IScam.cs b/TIASshot/IScam.cs index 089a174..72cc8c5 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}"); } } @@ -148,6 +160,7 @@ var filename = Config.GetString("File/ShotTime"); using (var csv = new StreamWriter(Path.Combine(_saveFolder, filename))) { + WriteInfo(csv); csv.WriteLine("Shot,Time(ms)"); var watch = Stopwatch.StartNew(); diff --git a/TIASshot/config.xml b/TIASshot/config.xml index d94590d..ad08261 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