diff --git a/TIASshot.sln b/TIASshot.sln index 343f189..f86d34a 100644 --- a/TIASshot.sln +++ b/TIASshot.sln @@ -12,14 +12,14 @@ EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU + Debug|x64 = Debug|x64 + Release|x64 = Release|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {1D3B69FE-D6B4-42B9-BBCC-B8CB9CF3DE4F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {1D3B69FE-D6B4-42B9-BBCC-B8CB9CF3DE4F}.Debug|Any CPU.Build.0 = Debug|Any CPU - {1D3B69FE-D6B4-42B9-BBCC-B8CB9CF3DE4F}.Release|Any CPU.ActiveCfg = Release|Any CPU - {1D3B69FE-D6B4-42B9-BBCC-B8CB9CF3DE4F}.Release|Any CPU.Build.0 = Release|Any CPU + {1D3B69FE-D6B4-42B9-BBCC-B8CB9CF3DE4F}.Debug|x64.ActiveCfg = Debug|x64 + {1D3B69FE-D6B4-42B9-BBCC-B8CB9CF3DE4F}.Debug|x64.Build.0 = Debug|x64 + {1D3B69FE-D6B4-42B9-BBCC-B8CB9CF3DE4F}.Release|x64.ActiveCfg = Release|x64 + {1D3B69FE-D6B4-42B9-BBCC-B8CB9CF3DE4F}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/TIASshot/Form1.Designer.cs b/TIASshot/Form1.Designer.cs index 3c2230f..8218abe 100644 --- a/TIASshot/Form1.Designer.cs +++ b/TIASshot/Form1.Designer.cs @@ -33,15 +33,16 @@ this.btnShotMulti = new System.Windows.Forms.Button(); this.btnCalib = new System.Windows.Forms.Button(); this.btnCheck = new System.Windows.Forms.Button(); + this.txtMessage = new System.Windows.Forms.TextBox(); ((System.ComponentModel.ISupportInitialize)(this.picPreview)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.picDisplay)).BeginInit(); this.SuspendLayout(); // // btnShotOne // - this.btnShotOne.Location = new System.Drawing.Point(12, 117); + this.btnShotOne.Location = new System.Drawing.Point(15, 116); this.btnShotOne.Name = "btnShotOne"; - this.btnShotOne.Size = new System.Drawing.Size(111, 37); + this.btnShotOne.Size = new System.Drawing.Size(271, 47); this.btnShotOne.TabIndex = 0; this.btnShotOne.Text = "1枚撮影"; this.btnShotOne.UseVisualStyleBackColor = true; @@ -50,40 +51,44 @@ // label1 // this.label1.AutoSize = true; + this.label1.Font = new System.Drawing.Font("MS UI Gothic", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(128))); this.label1.Location = new System.Drawing.Point(12, 9); this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(44, 12); + this.label1.Size = new System.Drawing.Size(60, 16); this.label1.TabIndex = 1; this.label1.Text = "Camera"; // // label2 // this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(12, 37); + this.label2.Font = new System.Drawing.Font("MS UI Gothic", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(128))); + this.label2.Location = new System.Drawing.Point(153, 9); this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(26, 12); + this.label2.Size = new System.Drawing.Size(35, 16); this.label2.TabIndex = 1; this.label2.Text = "S/N"; // // txtDeviceName // - this.txtDeviceName.Location = new System.Drawing.Point(62, 6); + this.txtDeviceName.Font = new System.Drawing.Font("MS UI Gothic", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(128))); + this.txtDeviceName.Location = new System.Drawing.Point(78, 6); this.txtDeviceName.Name = "txtDeviceName"; this.txtDeviceName.ReadOnly = true; - this.txtDeviceName.Size = new System.Drawing.Size(61, 19); + this.txtDeviceName.Size = new System.Drawing.Size(60, 23); this.txtDeviceName.TabIndex = 2; // // txtSerialNo // - this.txtSerialNo.Location = new System.Drawing.Point(51, 34); + this.txtSerialNo.Font = new System.Drawing.Font("MS UI Gothic", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(128))); + this.txtSerialNo.Location = new System.Drawing.Point(192, 6); this.txtSerialNo.Name = "txtSerialNo"; this.txtSerialNo.ReadOnly = true; - this.txtSerialNo.Size = new System.Drawing.Size(72, 19); + this.txtSerialNo.Size = new System.Drawing.Size(94, 23); this.txtSerialNo.TabIndex = 3; // // picPreview // - this.picPreview.Location = new System.Drawing.Point(15, 302); + this.picPreview.Location = new System.Drawing.Point(15, 377); this.picPreview.Name = "picPreview"; this.picPreview.Size = new System.Drawing.Size(108, 57); this.picPreview.TabIndex = 4; @@ -95,9 +100,9 @@ this.picDisplay.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - this.picDisplay.Location = new System.Drawing.Point(144, 6); + this.picDisplay.Location = new System.Drawing.Point(292, 6); this.picDisplay.Name = "picDisplay"; - this.picDisplay.Size = new System.Drawing.Size(488, 353); + this.picDisplay.Size = new System.Drawing.Size(340, 428); this.picDisplay.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom; this.picDisplay.TabIndex = 5; this.picDisplay.TabStop = false; @@ -105,9 +110,9 @@ // btnShotMulti // this.btnShotMulti.AllowDrop = true; - this.btnShotMulti.Location = new System.Drawing.Point(12, 160); + this.btnShotMulti.Location = new System.Drawing.Point(15, 195); this.btnShotMulti.Name = "btnShotMulti"; - this.btnShotMulti.Size = new System.Drawing.Size(111, 37); + this.btnShotMulti.Size = new System.Drawing.Size(271, 49); this.btnShotMulti.TabIndex = 6; this.btnShotMulti.Text = "連続撮影"; this.btnShotMulti.UseVisualStyleBackColor = true; @@ -116,30 +121,44 @@ // btnCalib // this.btnCalib.AllowDrop = true; - this.btnCalib.Location = new System.Drawing.Point(12, 74); + this.btnCalib.Location = new System.Drawing.Point(15, 324); this.btnCalib.Name = "btnCalib"; this.btnCalib.Size = new System.Drawing.Size(111, 37); this.btnCalib.TabIndex = 7; this.btnCalib.Text = "校正"; this.btnCalib.UseVisualStyleBackColor = true; + this.btnCalib.Visible = false; this.btnCalib.Click += new System.EventHandler(this.btnCalib_Click); // // btnCheck // this.btnCheck.AllowDrop = true; - this.btnCheck.Location = new System.Drawing.Point(12, 226); + this.btnCheck.Location = new System.Drawing.Point(144, 324); this.btnCheck.Name = "btnCheck"; this.btnCheck.Size = new System.Drawing.Size(111, 37); this.btnCheck.TabIndex = 8; this.btnCheck.Text = "チェック"; this.btnCheck.UseVisualStyleBackColor = true; + this.btnCheck.Visible = false; this.btnCheck.Click += new System.EventHandler(this.btnCheck_Click); // + // txtMessage + // + this.txtMessage.BackColor = System.Drawing.Color.LemonChiffon; + this.txtMessage.Font = new System.Drawing.Font("MS UI Gothic", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(128))); + this.txtMessage.Location = new System.Drawing.Point(15, 45); + this.txtMessage.Name = "txtMessage"; + this.txtMessage.ReadOnly = true; + this.txtMessage.Size = new System.Drawing.Size(271, 26); + this.txtMessage.TabIndex = 9; + this.txtMessage.Text = "舌診チャートを設置してください."; + // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(644, 377); + this.ClientSize = new System.Drawing.Size(644, 452); + this.Controls.Add(this.txtMessage); this.Controls.Add(this.btnCheck); this.Controls.Add(this.btnCalib); this.Controls.Add(this.btnShotMulti); @@ -173,6 +192,7 @@ private System.Windows.Forms.Button btnShotMulti; private System.Windows.Forms.Button btnCalib; private System.Windows.Forms.Button btnCheck; + private System.Windows.Forms.TextBox txtMessage; } } diff --git a/TIASshot/Form1.cs b/TIASshot/Form1.cs index 31d52af..dc69258 100644 --- a/TIASshot/Form1.cs +++ b/TIASshot/Form1.cs @@ -8,12 +8,13 @@ using System.Text; using System.Threading.Tasks; using System.Windows.Forms; +using System.Windows.Interop; namespace TIASshot { public partial class Form1 : Form { - const string APP_NAME = "TIAS Shot"; - Lucam _lucam; + public static string APP_NAME = "TIAS Shot"; + private Lucam _lucam; /// /// コンストラクタ @@ -44,6 +45,7 @@ } txtDeviceName.Text = _lucam.DeviceName; txtSerialNo.Text = _lucam.SerialNumber; + EnableShots(false); _lucam.StartStopPreview(); } @@ -91,5 +93,42 @@ private void btnCheck_Click(object sender, EventArgs e) { _lucam.Check(); } + + /// + /// 画像表示 + /// + /// + public void ShowImage(Bitmap bmp) { + //if (InvokeRequired) { + // Invoke((MethodInvoker)delegate { ShowImage(bmp); }); + // return; + //} + picDisplay.Image = bmp; + } + + /// + /// メッセージ表示 + /// + /// + public void ShowMessage(string msg) { + if (InvokeRequired) { + Invoke((MethodInvoker)delegate { ShowMessage(msg); }); + return; + } + txtMessage.Text = msg; + } + + /// + /// 撮影ボタン有効化 + /// + /// + public void EnableShots(bool enable = true) { + if (InvokeRequired) { + Invoke((MethodInvoker)delegate { EnableShots(enable); }); + return; + } + btnShotOne.Enabled = enable; + btnShotMulti.Enabled = enable; + } } } diff --git a/TIASshot/Lucam.cs b/TIASshot/Lucam.cs index 148b2c0..e50b63b 100644 --- a/TIASshot/Lucam.cs +++ b/TIASshot/Lucam.cs @@ -11,8 +11,11 @@ using System.Drawing; using System.Windows.Interop; using System.Threading; -using OpenCvSharp.Dnn; +using OpenCvSharp.Aruco; using System.Windows.Media.Animation; +using System.Configuration; +using System.Web.ModelBinding; +using System.Windows.Controls; namespace TIASshot { @@ -25,19 +28,30 @@ public string SerialNumber { get; private set; } public string ErrorMsg { get; private set; } - private IntPtr _hCam = IntPtr.Zero; - private PictureBox _picPreview, _picDisplay; - private Form1 _form; - private bool _isPreview = false; - private bool _check = false; - private int _calibrating = 0; - private dll.LucamSnapshot _snap; - private dll.LucamConversion _convert; - private dll.LucamRgbPreviewCallback _callbackHandler; - private int _callbackId; - //private int _count = 0; - private Bitmap[] _bmps = new Bitmap[2]; - private int _bmpIndex = 0; + readonly Dictionary ARDict = CvAruco.GetPredefinedDictionary(PredefinedDictionaryName.Dict4X4_50); + readonly float RefRGB = 230.0F; + readonly float UpdateRate = 0.5F; + readonly Point2f[] PointsDst40 = new Point2f[] { + new Point2f(345, 130),new Point2f(465, 130),new Point2f(465, 250),new Point2f(345, 250), + }; + readonly Point2f[] PointsDst41 = new Point2f[]{ + new Point2f(345, 1200), new Point2f(465, 1200), new Point2f(465, 1320), new Point2f(345, 1320), + }; + + IntPtr _hCam = IntPtr.Zero; + PictureBox _picPreview, _picDisplay; + Form1 _form; + bool _isPreview = false; + bool _check = false; + int _calibrating = 0; + bool _calibrated = false; + dll.LucamSnapshot _snap; + dll.LucamConversion _convert; + dll.LucamRgbPreviewCallback _callbackHandler; + int _callbackId; + Bitmap[] _bmps = new Bitmap[2]; + int _bmpIndex = 0; + List _chartMasks = new List(); /// /// コンストラクタ @@ -49,9 +63,9 @@ _picDisplay = display; _form = form; - // Default value for taking a snapshot. + // カメラパラメータの初期値 _snap.BufferLastFrame = false; - _snap.Exposure = 20; + _snap.Exposure = 60; _snap.ExposureDelay = 0; _snap.flReserved1 = 0; _snap.flReserved2 = 0; @@ -66,11 +80,11 @@ _snap.Format.Width = 1280; _snap.Format.X = 0; _snap.Format.Y = 0; - _snap.Gain = 2.0f; - _snap.GainBlue = 1; - _snap.GainGrn1 = 1; - _snap.GainGrn2 = 1; - _snap.GainRed = 1; + _snap.Gain = 1.5f; + _snap.GainBlue = 1.31f; + _snap.GainGrn1 = 1.57f; + _snap.GainGrn2 = _snap.GainGrn1; + _snap.GainRed = 3.0f; _snap.ShutterType = dll.LucamShutterType.GlobalShutter; _snap.StrobeDelay = 0.1f; _snap.StrobeFlags = 0; @@ -97,17 +111,21 @@ return false; } + // カメラのデバイス情報取得 var lumVersion = new dll.LucamVersion[numCam]; lumVersion = api.EnumCameras(); var id = 0; if (lumVersion[id].CameraId == 0x49f) DeviceName = "Lw110"; SerialNumber = lumVersion[id].SerialNumber.ToString(); + // カメラを開く _hCam = api.CameraOpen(1); if (_hCam == IntPtr.Zero) { + ErrorMsg = "カメラの接続に失敗しました.\r\n他のアプリケーションでカメラを使用していないか確認してください.\r\n終了します."; return false; } + // プレビューコールバックの登録 _callbackHandler = new dll.LucamRgbPreviewCallback(PreviewCallback); _callbackId = dll.LucamAddRgbPreviewCallback(_hCam, _callbackHandler, IntPtr.Zero, dll.LucamPixelFormat.PF_24); if (_callbackId == -1) { @@ -115,6 +133,8 @@ return false; } + SetCameraParam(); // カメラパラメータの設定 + return true; } @@ -124,34 +144,85 @@ /// public bool StartStopPreview() { if (_isPreview) { - //dll.LucamRemoveRgbPreviewCallback(_hCam, _callbackId); - //Debug.WriteLine("CB解除"); + // プレビュー停止 var ret = dll.LucamStreamVideoControl(_hCam, dll.LucamStreamMode.STOP_STREAMING, _picPreview.Handle.ToInt32()); Debug.WriteLine("プレビュー停止"); - if (!ret) { - return false; - } + if (!ret) return false; _isPreview = false; return true; } else { + // プレビュー開始 var ret = dll.LucamStreamVideoControl(_hCam, dll.LucamStreamMode.START_DISPLAY, _picPreview.Handle.ToInt32()); - if (!ret) { - return false; - } + if (!ret) return false; _isPreview = true; return true; } } /// - /// 画像表示(スレッドセーフ) + /// ゲイン値の更新比率計算 /// - void SafeDisplay() { - if (_picDisplay.InvokeRequired) { - _picDisplay.Invoke((MethodInvoker)delegate { SafeDisplay(); }); - return; + /// + /// + private float GetRatio(float value) { + float ratio = RefRGB / value; + ratio = (ratio - 1.0f) * (value == 255.0f ? 1.0f : UpdateRate) + 1.0f; + return ratio; + } + + /// + /// チャートの検出 + /// + /// + private void DetectChart(Mat img) { + + CvAruco.DetectMarkers(img, ARDict, out var corners, out var ids, + new DetectorParameters(), out var rejectedImgPoints); + if (ids.Length < 1) return; + + var ptsPict = new List(); + var ptsModel = new List(); + + for (int i = 0; i < ids.Length; i++) { + if (ids[i] == 40) { + ptsPict.AddRange(corners[i]); + ptsModel.AddRange(PointsDst40); + } + if (ids[i] == 41) { + ptsPict.AddRange(corners[i]); + ptsModel.AddRange(PointsDst41); + } } - _picDisplay.Image = _bmps[_bmpIndex]; + if (ptsPict.Count < 8) return; + + var matPtsPict = Mat.FromArray(ptsPict); + var matPtsModel = Mat.FromArray(ptsModel); + var matH = Cv2.FindHomography(matPtsModel, matPtsPict); + + var imgF = new Mat(1545, 810, MatType.CV_8UC3); + Cv2.WarpPerspective(img, imgF, matH, imgF.Size()); + + _chartMasks.Clear(); + var roiSize = ptsPict.Count < 8 ? 60 : 80; + for (int i = 0; i < 24; i++) { + var row = i % 6; + var col = i / 6; + var x = 581 - col * 144 + (ptsPict.Count < 8 ? 10 : 0); + var y = 318 + row * 144 + (ptsPict.Count < 8 ? 10 : 0); + var roi = new Rect(x, y, roiSize, roiSize); + using (var mask = new Mat(1545, 810, MatType.CV_8U)) { + Cv2.Rectangle(mask, roi, new Scalar(255), Cv2.FILLED); + var maskF = new Mat(img.Size(), MatType.CV_8U); + Cv2.WarpPerspective(mask, maskF, matH, maskF.Size()); + _chartMasks.Add(maskF); + } + } + img.SetTo(new Scalar(0, 200, 0), _chartMasks[12]); + Cv2.ImWrite("チャート検出結果.jpg", img); + Debug.WriteLine("チャート検出結果.jpg 保存"); + + _form.ShowMessage("舌診チャート検出 校正中"); + _calibrating = 30; } /// @@ -162,54 +233,34 @@ /// データサイズ /// void PreviewCallback(IntPtr pContext, IntPtr pData, int n, uint unused) { - //Debug.WriteLine(n); using (Mat img = Mat.FromPixelData(1024, 1280, MatType.CV_8UC3, pData)) { using (Mat imgt = img.T()) { _bmps[_bmpIndex] = imgt.ToBitmap(); - Scalar m; - using (Mat mask = new Mat(imgt.Size(), MatType.CV_8UC1)) { - Cv2.Rectangle(mask, new Rect(300, 165, 100, 100), new Scalar(255), Cv2.FILLED); - m = Cv2.Mean(imgt, mask); - } - if (_check || _calibrating > 0) { - Debug.WriteLine(m); - _check = false; + if (_calibrating > 0) { + var whitePatch = Cv2.Mean(imgt, _chartMasks[12]); + Debug.WriteLine($"White patch R {whitePatch.Val2:.00} G {whitePatch.Val1:.00} B {whitePatch.Val0:.00}"); + if (_calibrating % 5 == 0) { + _snap.GainBlue *= GetRatio((float)whitePatch.Val0); + _snap.GainGrn1 *= GetRatio((float)whitePatch.Val1); + _snap.GainGrn2 = _snap.GainGrn1; + _snap.GainRed *= GetRatio((float)whitePatch.Val2); + SetCameraParam(); + } + _calibrating--; + if (_calibrating == 0) { + _form.ShowMessage("自動校正完了"); + _form.EnableShots(); + _calibrated = true; + } } - if (_calibrating > 0 && _calibrating % 5 == 0) { - float target = 230; - float rate = 0.5F; - float mb = target / (float)m.Val0; - float mg = target / (float)m.Val1; - float mr = target / (float)m.Val2; - mb = (mb - 1.0F) * (m.Val0 > 254 ? 1.0F : rate) + 1.0F; - mg = (mg - 1.0F) * (m.Val1 > 254 ? 1.0F : rate) + 1.0F; - mr = (mr - 1.0F) * (m.Val2 > 254 ? 1.0F : rate) + 1.0F; - float value; - dll.LucamPropertyFlag flag; - dll.LucamGetProperty(_hCam, dll.LucamProperty.GAIN_BLUE, out value, out flag); - Debug.WriteLine($"Gain Blue {value} * {mb} -> {value * mb} ({flag})"); - value *= mb; - dll.LucamSetProperty(_hCam, dll.LucamProperty.GAIN_BLUE, value, flag); - dll.LucamGetProperty(_hCam, dll.LucamProperty.GAIN_GREEN1, out value, out flag); - Debug.WriteLine($"Gain Green1 {value} * {mg} -> {value * mg}"); - value *= mg; - dll.LucamSetProperty(_hCam, dll.LucamProperty.GAIN_GREEN1, value, flag); - dll.LucamGetProperty(_hCam, dll.LucamProperty.GAIN_GREEN2, out value, out flag); - Debug.WriteLine($"Gain Green2 {value} * {mg} -> {value * mg}"); - value *= mg; - dll.LucamSetProperty(_hCam, dll.LucamProperty.GAIN_GREEN2, value, flag); - dll.LucamGetProperty(_hCam, dll.LucamProperty.GAIN_RED, out value, out flag); - Debug.WriteLine($"Gain Red {value} * {mr} -> {value * mr}"); - value *= mr; - dll.LucamSetProperty(_hCam, dll.LucamProperty.GAIN_RED, value, flag); + if (!_calibrated && _calibrating == 0) { + DetectChart(imgt); } - if (_calibrating > 0) _calibrating--; } } - //SafeDisplay(); - _picDisplay.Image = _bmps[_bmpIndex]; + _form.ShowImage(_bmps[_bmpIndex]); _bmpIndex = (_bmpIndex + 1) % 2; if (_bmps[_bmpIndex] != null) _bmps[_bmpIndex].Dispose(); } @@ -258,43 +309,46 @@ dll.LucamDisableFastFrames(_hCam); } + /// + /// 校正 露光時間とホワイトバランスの自動調整 + /// public void Calibration() { Debug.WriteLine("校正前"); SetSnapParam(); - - dll.LucamOneShotAutoExposure(_hCam, 150, 0, 0, _snap.Format.Width, _snap.Format.Height); - //dll.LucamOneShotAutoExposure(_hCam, 100, 165, 300, 100, 100); - //Thread.Sleep(1000); - //dll.LucamOneShotAutoExposure(_hCam, 200, 165, 300, 100, 100); - //Thread.Sleep(1000); - //dll.LucamOneShotAutoExposure(_hCam, 200, 165, 300, 100, 100); - dll.LucamOneShotAutoWhiteBalance(_hCam, 0, 0, _snap.Format.Width, _snap.Format.Height); - //dll.LucamOneShotAutoWhiteBalance(_hCam, 165, 300, 100, 100); - - Debug.WriteLine("校正後"); - SetSnapParam(); - _calibrating = 30; } + /// + /// 撮影パラメータの設定 + /// private void SetSnapParam() { dll.LucamPropertyFlag flag; - float value = 0; - dll.LucamGetProperty(_hCam, dll.LucamProperty.EXPOSURE, out value, out flag); - _snap.Exposure = value; - dll.LucamGetProperty(_hCam, dll.LucamProperty.GAIN, out value, out flag); - _snap.Gain = value; - dll.LucamGetProperty(_hCam, dll.LucamProperty.GAIN_BLUE, out value, out flag); - _snap.GainBlue = value; - dll.LucamGetProperty(_hCam, dll.LucamProperty.GAIN_GREEN1, out value, out flag); - _snap.GainGrn1 = value; - dll.LucamGetProperty(_hCam, dll.LucamProperty.GAIN_GREEN2, out value, out flag); - _snap.GainGrn2 = value; - dll.LucamGetProperty(_hCam, dll.LucamProperty.GAIN_RED, out value, out flag); - _snap.GainRed = value; - Debug.WriteLine($"Exp {_snap.Exposure} Gain {_snap.Gain} GainBlue {_snap.GainBlue} GainGrn1 {_snap.GainGrn1} GainGrn2 {_snap.GainGrn2} GainRed {_snap.GainRed}"); + dll.LucamGetProperty(_hCam, dll.LucamProperty.EXPOSURE, out _snap.Exposure, out flag); + dll.LucamGetProperty(_hCam, dll.LucamProperty.GAIN, out _snap.Gain, out flag); + dll.LucamGetProperty(_hCam, dll.LucamProperty.GAIN_BLUE, out _snap.GainBlue, out flag); + dll.LucamGetProperty(_hCam, dll.LucamProperty.GAIN_GREEN1, out _snap.GainGrn1, out flag); + dll.LucamGetProperty(_hCam, dll.LucamProperty.GAIN_GREEN2, out _snap.GainGrn2, out flag); + dll.LucamGetProperty(_hCam, dll.LucamProperty.GAIN_RED, out _snap.GainRed, out flag); + Debug.WriteLine($"SetSnapParam Exp {_snap.Exposure} Gain {_snap.Gain} GainBlue {_snap.GainBlue} GainGrn1 {_snap.GainGrn1} GainGrn2 {_snap.GainGrn2} GainRed {_snap.GainRed}"); } + /// + /// カメラパラメータの設定 + /// + private void SetCameraParam() { + var flag = dll.LucamPropertyFlag.NONE; + dll.LucamSetProperty(_hCam, dll.LucamProperty.EXPOSURE, _snap.Exposure, flag); + dll.LucamSetProperty(_hCam, dll.LucamProperty.GAIN, _snap.Gain, flag); + dll.LucamSetProperty(_hCam, dll.LucamProperty.GAIN_BLUE, _snap.GainBlue, flag); + dll.LucamSetProperty(_hCam, dll.LucamProperty.GAIN_GREEN1, _snap.GainGrn1, flag); + dll.LucamSetProperty(_hCam, dll.LucamProperty.GAIN_GREEN2, _snap.GainGrn2, flag); + dll.LucamSetProperty(_hCam, dll.LucamProperty.GAIN_RED, _snap.GainRed, flag); + Debug.WriteLine($"SetCameraParam Exp {_snap.Exposure} Gain {_snap.Gain} GainBlue {_snap.GainBlue} GainGrn1 {_snap.GainGrn1} GainGrn2 {_snap.GainGrn2} GainRed {_snap.GainRed}"); + } + + /// + /// 動作チェック有効化 + /// public void Check() { _check = true; } diff --git a/TIASshot/TIASshot.csproj b/TIASshot/TIASshot.csproj index 29971ff..1d1e1d2 100644 --- a/TIASshot/TIASshot.csproj +++ b/TIASshot/TIASshot.csproj @@ -35,6 +35,26 @@ prompt 4 + + true + bin\x64\Debug\ + DEBUG;TRACE + full + x64 + 7.3 + prompt + true + + + bin\x64\Release\ + TRACE + true + pdbonly + x64 + 7.3 + prompt + true + .\lumenera.api.dll