diff --git a/ISCamRecorder/FPS.cs b/ISCamRecorder/FPS.cs new file mode 100644 index 0000000..6190c34 --- /dev/null +++ b/ISCamRecorder/FPS.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading; +using System.Diagnostics; + +namespace ISCamRecorder { + internal class FPS { + Stopwatch _Swatch = new Stopwatch(); // 高精度時間計測 + int _Count = 0; // FPSを算出する回数 + int _Counter = 0; // 現在のカウント + public float fps { get; private set; } = 0; // FPS値 + + /// + /// コンストラクタ + /// + /// + public FPS(int count) { + _Count = count; + _Swatch.Start(); + } + + /// + /// 計時 + /// + public void Shot() { + if (++_Counter >= _Count) { + var elapsed = _Swatch.ElapsedMilliseconds; + fps = _Count * 1000F / elapsed; + _Counter = 0; + _Swatch.Restart(); + } + } + } +} diff --git a/ISCamRecorder/Form1.Designer.cs b/ISCamRecorder/Form1.Designer.cs deleted file mode 100644 index e3f1abd..0000000 --- a/ISCamRecorder/Form1.Designer.cs +++ /dev/null @@ -1,144 +0,0 @@ -namespace ISCamRecorder { - partial class Form1 { - /// - /// 必要なデザイナー変数です。 - /// - private System.ComponentModel.IContainer components = null; - - /// - /// 使用中のリソースをすべてクリーンアップします。 - /// - /// マネージド リソースを破棄する場合は true を指定し、その他の場合は false を指定します。 - protected override void Dispose(bool disposing) { - if (disposing && (components != null)) { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows フォーム デザイナーで生成されたコード - - /// - /// デザイナー サポートに必要なメソッドです。このメソッドの内容を - /// コード エディターで変更しないでください。 - /// - private void InitializeComponent() { - this.icTop = new TIS.Imaging.ICImagingControl(); - this.BtnStartPreview = new System.Windows.Forms.Button(); - this.icLeft = new TIS.Imaging.ICImagingControl(); - this.icFront = new TIS.Imaging.ICImagingControl(); - this.icRight = new TIS.Imaging.ICImagingControl(); - this.button2 = new System.Windows.Forms.Button(); - ((System.ComponentModel.ISupportInitialize)(this.icTop)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.icLeft)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.icFront)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.icRight)).BeginInit(); - this.SuspendLayout(); - // - // icTop - // - this.icTop.BackColor = System.Drawing.Color.White; - this.icTop.DeviceListChangedExecutionMode = TIS.Imaging.EventExecutionMode.Invoke; - this.icTop.DeviceLostExecutionMode = TIS.Imaging.EventExecutionMode.AsyncInvoke; - this.icTop.ImageAvailableExecutionMode = TIS.Imaging.EventExecutionMode.MultiThreaded; - this.icTop.LiveDisplayPosition = new System.Drawing.Point(0, 0); - this.icTop.Location = new System.Drawing.Point(391, 15); - this.icTop.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); - this.icTop.Name = "icTop"; - this.icTop.Size = new System.Drawing.Size(349, 312); - this.icTop.TabIndex = 0; - // - // BtnStartPreview - // - this.BtnStartPreview.Location = new System.Drawing.Point(16, 15); - this.BtnStartPreview.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); - this.BtnStartPreview.Name = "BtnStartPreview"; - this.BtnStartPreview.Size = new System.Drawing.Size(136, 52); - this.BtnStartPreview.TabIndex = 1; - this.BtnStartPreview.Text = "Start Preview"; - this.BtnStartPreview.UseVisualStyleBackColor = true; - this.BtnStartPreview.Click += new System.EventHandler(this.BtnStartPreview_Click); - // - // icLeft - // - this.icLeft.BackColor = System.Drawing.Color.White; - this.icLeft.DeviceListChangedExecutionMode = TIS.Imaging.EventExecutionMode.Invoke; - this.icLeft.DeviceLostExecutionMode = TIS.Imaging.EventExecutionMode.AsyncInvoke; - this.icLeft.ImageAvailableExecutionMode = TIS.Imaging.EventExecutionMode.MultiThreaded; - this.icLeft.LiveDisplayPosition = new System.Drawing.Point(0, 0); - this.icLeft.Location = new System.Drawing.Point(16, 335); - this.icLeft.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); - this.icLeft.Name = "icLeft"; - this.icLeft.Size = new System.Drawing.Size(349, 312); - this.icLeft.TabIndex = 2; - // - // icFront - // - this.icFront.BackColor = System.Drawing.Color.White; - this.icFront.DeviceListChangedExecutionMode = TIS.Imaging.EventExecutionMode.Invoke; - this.icFront.DeviceLostExecutionMode = TIS.Imaging.EventExecutionMode.AsyncInvoke; - this.icFront.ImageAvailableExecutionMode = TIS.Imaging.EventExecutionMode.MultiThreaded; - this.icFront.LiveDisplayPosition = new System.Drawing.Point(0, 0); - this.icFront.Location = new System.Drawing.Point(391, 335); - this.icFront.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); - this.icFront.Name = "icFront"; - this.icFront.Size = new System.Drawing.Size(349, 312); - this.icFront.TabIndex = 3; - // - // icRight - // - this.icRight.BackColor = System.Drawing.Color.White; - this.icRight.DeviceListChangedExecutionMode = TIS.Imaging.EventExecutionMode.Invoke; - this.icRight.DeviceLostExecutionMode = TIS.Imaging.EventExecutionMode.AsyncInvoke; - this.icRight.ImageAvailableExecutionMode = TIS.Imaging.EventExecutionMode.MultiThreaded; - this.icRight.LiveDisplayPosition = new System.Drawing.Point(0, 0); - this.icRight.Location = new System.Drawing.Point(764, 335); - this.icRight.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); - this.icRight.Name = "icRight"; - this.icRight.Size = new System.Drawing.Size(349, 312); - this.icRight.TabIndex = 4; - // - // button2 - // - this.button2.Location = new System.Drawing.Point(175, 15); - this.button2.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); - this.button2.Name = "button2"; - this.button2.Size = new System.Drawing.Size(136, 52); - this.button2.TabIndex = 5; - this.button2.Text = "Property"; - this.button2.UseVisualStyleBackColor = true; - this.button2.Click += new System.EventHandler(this.SetProperty_Click); - // - // Form1 - // - this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(1132, 664); - this.Controls.Add(this.button2); - this.Controls.Add(this.icRight); - this.Controls.Add(this.icFront); - this.Controls.Add(this.icLeft); - this.Controls.Add(this.BtnStartPreview); - this.Controls.Add(this.icTop); - this.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); - this.Name = "Form1"; - this.Text = "Form1"; - ((System.ComponentModel.ISupportInitialize)(this.icTop)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.icLeft)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.icFront)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.icRight)).EndInit(); - this.ResumeLayout(false); - - } - - #endregion - - private TIS.Imaging.ICImagingControl icTop; - private System.Windows.Forms.Button BtnStartPreview; - private TIS.Imaging.ICImagingControl icLeft; - private TIS.Imaging.ICImagingControl icFront; - private TIS.Imaging.ICImagingControl icRight; - private System.Windows.Forms.Button button2; - } -} - diff --git a/ISCamRecorder/Form1.cs b/ISCamRecorder/Form1.cs deleted file mode 100644 index 373424b..0000000 --- a/ISCamRecorder/Form1.cs +++ /dev/null @@ -1,119 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; -using System.Diagnostics; -using TIS.Imaging; - - -namespace ISCamRecorder { - public partial class Form1 : Form { - - private List _iccs; - private int _count = 0; - private Stopwatch _sw = new Stopwatch(); - private System.Threading.Timer _timer; - public VCDButtonProperty SoftwareTrigger; - - /// - /// フォームロード時 - /// - public Form1() { - InitializeComponent(); - icTop.Tag = "9220016"; - icTop.Sink = new FrameQueueSink(CaptureFrame, MediaSubtypes.RGB32, 5); - icLeft.Tag = "9220018"; - icFront.Tag = "9220021"; - icRight.Tag = "9220025"; - _iccs = new List { - icTop, icLeft, icFront, icRight - }; - } - - static void TimerCB(object obj) { - - ((Form1)obj).SoftwareTrigger.Push(); - } - - private FrameQueuedResult CaptureFrame(IFrameQueueBuffer buffer) { - if (++_count >= 10) { - var elapsed = _sw.ElapsedMilliseconds; - _sw.Reset(); - _sw.Start(); - Debug.WriteLine($"{_count * 1000 / elapsed} fps"); - _count = 0; - } - return FrameQueuedResult.ReQueue; - } - - /// - /// プレビュー開始 - /// - /// - /// - private void BtnStartPreview_Click(object sender, EventArgs e) { - - try { - var devs = _iccs[0].Devices; - _iccs.ForEach(ic => { - if (!ic.DeviceValid) { - // カメラ接続 - ic.Device = devs.FirstOrDefault( - c => c.GetSerialNumber().Equals(ic.Tag)); - } - - if (ic.DeviceValid) { - if (ic.LiveVideoRunning) ic.LiveStop(); - - // 撮影条件設定 - //readonly string CAMERA_FORMAT = "RGB24 (640x480)"; - //readonly float FRAME_RATE = 30F; - //ic.VideoFormat = ic.VideoFormats.FirstOrDefault( - // c => c.Name.Equals(CAMERA_FORMAT)); - //ic.DeviceFrameRate = ic.DeviceFrameRates.FirstOrDefault( - // c => (c > FRAME_RATE - 0.1F && c < FRAME_RATE + 0.1F)); - // カメラ設定読み込み - ic.LoadDeviceState(ICCFImport.ICCFImport.Import( - $"dfk33ux290.iccf"), false); - - // プレビュー設定 - ic.LiveDisplayDefault = false; - ic.LiveDisplayHeight = icTop.Height; - ic.LiveDisplayWidth = icTop.Width; - ic.LiveStart(); - _sw.Reset(); - _sw.Start(); - } - }); - SoftwareTrigger = icTop.VCDPropertyItems.Find(VCDGUIDs.VCDID_TriggerMode, - VCDGUIDs.VCDElement_SoftwareTrigger);//宣言 - _timer = new System.Threading.Timer(TimerCB, this, 0, 30); - - } catch (ICException iex) { - MessageBox.Show("Import of ICCF file failed:\n" + iex.Message, - "Import IC Capture File", MessageBoxButtons.OK, MessageBoxIcon.Warning); - } - } - - /// - /// カメラプロパティの設定 - /// - /// - /// - private void SetProperty_Click(object sender, EventArgs e) { - _iccs.ForEach(ic => ic.LiveStop()); - _iccs.ForEach(ic => ic.DeviceTrigger = true); - //_iccs[0].ShowPropertyDialog(); - //var setting = _iccs[0].SaveDeviceState(); - //_iccs.Skip(1).ToList().ForEach(ic => { - // ic.LoadDeviceState(setting, false); - //}); - _iccs.ForEach(ic => ic.LiveStart()); - } - } -} diff --git a/ISCamRecorder/Form1.resx b/ISCamRecorder/Form1.resx deleted file mode 100644 index 1af7de1..0000000 --- a/ISCamRecorder/Form1.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/ISCamRecorder/ICCFImport.cs b/ISCamRecorder/ICCFImport.cs index bdd5587..4f1dc7d 100644 --- a/ISCamRecorder/ICCFImport.cs +++ b/ISCamRecorder/ICCFImport.cs @@ -5,8 +5,7 @@ using System.Xml; using TIS.Imaging; -namespace ICCFImport -{ +namespace ISCamRecorder { class ICCFImport { private static void AddXmlAttribute(XmlDocument xmldoc, XmlNode xmlnode, string Name, string Value) diff --git a/ISCamRecorder/ISCamRecorder.csproj b/ISCamRecorder/ISCamRecorder.csproj index f83586a..2fcc38e 100644 --- a/ISCamRecorder/ISCamRecorder.csproj +++ b/ISCamRecorder/ISCamRecorder.csproj @@ -70,17 +70,19 @@ - + + Form - - Form1.cs + + MainForm.cs + - - Form1.cs + + MainForm.cs ResXFileCodeGenerator @@ -105,4 +107,7 @@ + + copy $(ProjectDir)*.iccf $(TargetDir) + \ No newline at end of file diff --git a/ISCamRecorder/ISCamera.cs b/ISCamRecorder/ISCamera.cs new file mode 100644 index 0000000..44e0d51 --- /dev/null +++ b/ISCamRecorder/ISCamera.cs @@ -0,0 +1,139 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.IO; +using System.Diagnostics; +using TIS.Imaging; +using System.Windows.Forms; + +namespace ISCamRecorder { + internal class ISCamera { + readonly string ICCF_FILE = @"dfk33ux290.iccf"; // 設定ファイル + readonly string CAMERA_FORMAT = "RGB32 (1920x1080)"; + readonly float FRAME_RATE = 40F; + + ICImagingControl _iccs; // カメラオブジェクト + string _SerialNumber; // シリアル番号 + VCDButtonProperty _Trigger; // トリガー設定 + FPS _fps = new FPS(10); // FPS計測 + + /// + /// コンストラクタ + /// + /// + /// + public ISCamera(ICImagingControl iccs, string serialNumber) { + _iccs = iccs; + _SerialNumber = serialNumber; + } + + /// + /// カメラ接続とプレビュー開始 + /// + /// + public bool Connect() { + if (_iccs.DeviceValid) return true; + + // 接続 + _iccs.Device = _iccs.Devices.FirstOrDefault( + c => c.GetSerialNumber().Equals(_SerialNumber)); + if (!_iccs.DeviceValid) return false; + + // 撮影条件設定 + try { + if (File.Exists(ICCF_FILE)){ + _iccs.LoadDeviceState(ICCFImport.Import(ICCF_FILE), false); + Debug.WriteLine($"Camera #{_SerialNumber} loaded config {ICCF_FILE}"); + } else { + //Debug.WriteLine($"Can't find config {ICCF_FILE}"); + _iccs.VideoFormat = _iccs.VideoFormats.FirstOrDefault( + c => c.Name.Equals(CAMERA_FORMAT)); + _iccs.DeviceFrameRate = _iccs.DeviceFrameRates.FirstOrDefault( + c => (c > FRAME_RATE - 0.1F && c < FRAME_RATE + 0.1F)); + Debug.WriteLine($"Camera #{_SerialNumber} sets {_iccs.VideoFormat}, {_iccs.DeviceFrameRate:0.0}fps"); + } + } catch (ICException iex) { + MessageBox.Show(iex.Message, "Camera Error", + MessageBoxButtons.OK, MessageBoxIcon.Warning); + return false; + } + + // 表示設定 + _iccs.LiveDisplayDefault = false; + _iccs.LiveDisplayHeight = _iccs.Height; + _iccs.LiveDisplayWidth = _iccs.Width; + // ic.ImageRingBufferSize = 2; + _Trigger = _iccs.VCDPropertyItems.Find( + VCDGUIDs.VCDID_TriggerMode, VCDGUIDs.VCDElement_SoftwareTrigger); + _iccs.Sink = new FrameQueueSink(CaptureFrame, MediaSubtypes.RGB32, 5); + + _iccs.LiveStart(); + + return true; + } + + /// + /// フレーム取得時 + /// + /// + /// + private FrameQueuedResult CaptureFrame(IFrameQueueBuffer buffer) { + _fps.Shot(); + return FrameQueuedResult.ReQueue; + } + + /// + /// トリガーモード変更 + /// + /// + public void SetTriggerMode(bool enable) { + _iccs.LiveStop(); + _iccs.DeviceTrigger = enable; + _iccs.LiveStart(); + } + + /// + /// ソフトウェアトリガー発信 + /// + public void SWTrigger() { + if (_iccs.DeviceValid && _Trigger != null) _Trigger.Push(); + } + + /// + /// プロパティ設定(ダイアログ) + /// + /// + public string SetProperty() { + if (!_iccs.DeviceValid) return ""; + _iccs.ShowPropertyDialog(); + return _iccs.SaveDeviceState(); + } + + /// + /// プロパティ設定(条件指定) + /// + /// + /// + public string SetProperty(string config) { + if (!_iccs.DeviceValid) return ""; + _iccs.LiveStop(); + _iccs.LoadDeviceState(config, false); + _iccs.LiveStart(); + return config; + } + + /// + /// FPS取得 + /// + /// + public float Fps() { + return _fps.fps; + } + + public string CameraInfo() { + return $"({_SerialNumber}) {_fps.fps:0.0}fps"; + } + } +} diff --git a/ISCamRecorder/MainForm.Designer.cs b/ISCamRecorder/MainForm.Designer.cs new file mode 100644 index 0000000..f09669d --- /dev/null +++ b/ISCamRecorder/MainForm.Designer.cs @@ -0,0 +1,336 @@ +namespace ISCamRecorder { + partial class MainForm { + /// + /// 必要なデザイナー変数です。 + /// + private System.ComponentModel.IContainer components = null; + + /// + /// 使用中のリソースをすべてクリーンアップします。 + /// + /// マネージド リソースを破棄する場合は true を指定し、その他の場合は false を指定します。 + protected override void Dispose(bool disposing) { + if (disposing && (components != null)) { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows フォーム デザイナーで生成されたコード + + /// + /// デザイナー サポートに必要なメソッドです。このメソッドの内容を + /// コード エディターで変更しないでください。 + /// + private void InitializeComponent() { + this.BtnStartPreview = new System.Windows.Forms.Button(); + this.button2 = new System.Windows.Forms.Button(); + this.ChkTrigger = new System.Windows.Forms.CheckBox(); + this.splitContainer1 = new System.Windows.Forms.SplitContainer(); + this.splitContainer2 = new System.Windows.Forms.SplitContainer(); + this.splitContainer3 = new System.Windows.Forms.SplitContainer(); + this.icTop = new TIS.Imaging.ICImagingControl(); + this.splitContainer4 = new System.Windows.Forms.SplitContainer(); + this.splitContainer5 = new System.Windows.Forms.SplitContainer(); + this.icLeft = new TIS.Imaging.ICImagingControl(); + this.icFront = new TIS.Imaging.ICImagingControl(); + this.icRight = new TIS.Imaging.ICImagingControl(); + this.TxtTop = new System.Windows.Forms.TextBox(); + this.TxtLeft = new System.Windows.Forms.TextBox(); + this.TxtFront = new System.Windows.Forms.TextBox(); + this.TxtRight = new System.Windows.Forms.TextBox(); + ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); + this.splitContainer1.Panel1.SuspendLayout(); + this.splitContainer1.Panel2.SuspendLayout(); + this.splitContainer1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).BeginInit(); + this.splitContainer2.Panel2.SuspendLayout(); + this.splitContainer2.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.splitContainer3)).BeginInit(); + this.splitContainer3.Panel1.SuspendLayout(); + this.splitContainer3.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.icTop)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.splitContainer4)).BeginInit(); + this.splitContainer4.Panel1.SuspendLayout(); + this.splitContainer4.Panel2.SuspendLayout(); + this.splitContainer4.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.splitContainer5)).BeginInit(); + this.splitContainer5.Panel1.SuspendLayout(); + this.splitContainer5.Panel2.SuspendLayout(); + this.splitContainer5.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.icLeft)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.icFront)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.icRight)).BeginInit(); + this.SuspendLayout(); + // + // BtnStartPreview + // + this.BtnStartPreview.Location = new System.Drawing.Point(12, 12); + this.BtnStartPreview.Name = "BtnStartPreview"; + this.BtnStartPreview.Size = new System.Drawing.Size(102, 42); + this.BtnStartPreview.TabIndex = 1; + this.BtnStartPreview.Text = "Start Preview"; + this.BtnStartPreview.UseVisualStyleBackColor = true; + this.BtnStartPreview.Click += new System.EventHandler(this.BtnStartPreview_Click); + // + // button2 + // + this.button2.Location = new System.Drawing.Point(120, 12); + this.button2.Name = "button2"; + this.button2.Size = new System.Drawing.Size(102, 42); + this.button2.TabIndex = 5; + this.button2.Text = "Property"; + this.button2.UseVisualStyleBackColor = true; + this.button2.Click += new System.EventHandler(this.SetProperty_Click); + // + // ChkTrigger + // + this.ChkTrigger.AutoSize = true; + this.ChkTrigger.Location = new System.Drawing.Point(228, 26); + this.ChkTrigger.Name = "ChkTrigger"; + this.ChkTrigger.Size = new System.Drawing.Size(83, 16); + this.ChkTrigger.TabIndex = 6; + this.ChkTrigger.Text = "トリガー使用"; + this.ChkTrigger.UseVisualStyleBackColor = true; + this.ChkTrigger.CheckedChanged += new System.EventHandler(this.ChkTrigger_CheckedChanged); + // + // splitContainer1 + // + this.splitContainer1.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.splitContainer1.Location = new System.Drawing.Point(0, 60); + this.splitContainer1.Name = "splitContainer1"; + this.splitContainer1.Orientation = System.Windows.Forms.Orientation.Horizontal; + // + // splitContainer1.Panel1 + // + this.splitContainer1.Panel1.Controls.Add(this.splitContainer2); + // + // splitContainer1.Panel2 + // + this.splitContainer1.Panel2.Controls.Add(this.splitContainer4); + this.splitContainer1.Size = new System.Drawing.Size(892, 496); + this.splitContainer1.SplitterDistance = 248; + this.splitContainer1.TabIndex = 7; + // + // splitContainer2 + // + this.splitContainer2.Dock = System.Windows.Forms.DockStyle.Fill; + this.splitContainer2.Location = new System.Drawing.Point(0, 0); + this.splitContainer2.Name = "splitContainer2"; + // + // splitContainer2.Panel2 + // + this.splitContainer2.Panel2.Controls.Add(this.splitContainer3); + this.splitContainer2.Size = new System.Drawing.Size(892, 248); + this.splitContainer2.SplitterDistance = 296; + this.splitContainer2.TabIndex = 0; + // + // splitContainer3 + // + this.splitContainer3.Dock = System.Windows.Forms.DockStyle.Fill; + this.splitContainer3.Location = new System.Drawing.Point(0, 0); + this.splitContainer3.Name = "splitContainer3"; + // + // splitContainer3.Panel1 + // + this.splitContainer3.Panel1.Controls.Add(this.TxtTop); + this.splitContainer3.Panel1.Controls.Add(this.icTop); + this.splitContainer3.Size = new System.Drawing.Size(592, 248); + this.splitContainer3.SplitterDistance = 296; + this.splitContainer3.TabIndex = 0; + // + // icTop + // + this.icTop.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.icTop.BackColor = System.Drawing.Color.White; + this.icTop.DeviceListChangedExecutionMode = TIS.Imaging.EventExecutionMode.Invoke; + this.icTop.DeviceLostExecutionMode = TIS.Imaging.EventExecutionMode.AsyncInvoke; + this.icTop.ImageAvailableExecutionMode = TIS.Imaging.EventExecutionMode.MultiThreaded; + this.icTop.LiveDisplayPosition = new System.Drawing.Point(0, 0); + this.icTop.Location = new System.Drawing.Point(4, 28); + this.icTop.Name = "icTop"; + this.icTop.Size = new System.Drawing.Size(290, 218); + this.icTop.TabIndex = 1; + // + // splitContainer4 + // + this.splitContainer4.Dock = System.Windows.Forms.DockStyle.Fill; + this.splitContainer4.Location = new System.Drawing.Point(0, 0); + this.splitContainer4.Name = "splitContainer4"; + // + // splitContainer4.Panel1 + // + this.splitContainer4.Panel1.Controls.Add(this.TxtLeft); + this.splitContainer4.Panel1.Controls.Add(this.icLeft); + // + // splitContainer4.Panel2 + // + this.splitContainer4.Panel2.Controls.Add(this.splitContainer5); + this.splitContainer4.Size = new System.Drawing.Size(892, 244); + this.splitContainer4.SplitterDistance = 296; + this.splitContainer4.TabIndex = 0; + // + // splitContainer5 + // + this.splitContainer5.Dock = System.Windows.Forms.DockStyle.Fill; + this.splitContainer5.Location = new System.Drawing.Point(0, 0); + this.splitContainer5.Name = "splitContainer5"; + // + // splitContainer5.Panel1 + // + this.splitContainer5.Panel1.Controls.Add(this.TxtFront); + this.splitContainer5.Panel1.Controls.Add(this.icFront); + // + // splitContainer5.Panel2 + // + this.splitContainer5.Panel2.Controls.Add(this.TxtRight); + this.splitContainer5.Panel2.Controls.Add(this.icRight); + this.splitContainer5.Size = new System.Drawing.Size(592, 244); + this.splitContainer5.SplitterDistance = 296; + this.splitContainer5.TabIndex = 0; + // + // icLeft + // + this.icLeft.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.icLeft.BackColor = System.Drawing.Color.White; + this.icLeft.DeviceListChangedExecutionMode = TIS.Imaging.EventExecutionMode.Invoke; + this.icLeft.DeviceLostExecutionMode = TIS.Imaging.EventExecutionMode.AsyncInvoke; + this.icLeft.ImageAvailableExecutionMode = TIS.Imaging.EventExecutionMode.MultiThreaded; + this.icLeft.LiveDisplayPosition = new System.Drawing.Point(0, 0); + this.icLeft.Location = new System.Drawing.Point(3, 28); + this.icLeft.Name = "icLeft"; + this.icLeft.Size = new System.Drawing.Size(291, 213); + this.icLeft.TabIndex = 3; + // + // icFront + // + this.icFront.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.icFront.BackColor = System.Drawing.Color.White; + this.icFront.DeviceListChangedExecutionMode = TIS.Imaging.EventExecutionMode.Invoke; + this.icFront.DeviceLostExecutionMode = TIS.Imaging.EventExecutionMode.AsyncInvoke; + this.icFront.ImageAvailableExecutionMode = TIS.Imaging.EventExecutionMode.MultiThreaded; + this.icFront.LiveDisplayPosition = new System.Drawing.Point(0, 0); + this.icFront.Location = new System.Drawing.Point(3, 28); + this.icFront.Name = "icFront"; + this.icFront.Size = new System.Drawing.Size(289, 213); + this.icFront.TabIndex = 9; + // + // icRight + // + this.icRight.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.icRight.BackColor = System.Drawing.Color.White; + this.icRight.DeviceListChangedExecutionMode = TIS.Imaging.EventExecutionMode.Invoke; + this.icRight.DeviceLostExecutionMode = TIS.Imaging.EventExecutionMode.AsyncInvoke; + this.icRight.ImageAvailableExecutionMode = TIS.Imaging.EventExecutionMode.MultiThreaded; + this.icRight.LiveDisplayPosition = new System.Drawing.Point(0, 0); + this.icRight.Location = new System.Drawing.Point(1, 28); + this.icRight.Name = "icRight"; + this.icRight.Size = new System.Drawing.Size(291, 213); + this.icRight.TabIndex = 5; + // + // TxtTop + // + this.TxtTop.Location = new System.Drawing.Point(4, 3); + this.TxtTop.Name = "TxtTop"; + this.TxtTop.ReadOnly = true; + this.TxtTop.Size = new System.Drawing.Size(288, 19); + this.TxtTop.TabIndex = 2; + // + // TxtLeft + // + this.TxtLeft.Location = new System.Drawing.Point(3, 3); + this.TxtLeft.Name = "TxtLeft"; + this.TxtLeft.ReadOnly = true; + this.TxtLeft.Size = new System.Drawing.Size(288, 19); + this.TxtLeft.TabIndex = 4; + // + // TxtFront + // + this.TxtFront.Location = new System.Drawing.Point(3, 3); + this.TxtFront.Name = "TxtFront"; + this.TxtFront.ReadOnly = true; + this.TxtFront.Size = new System.Drawing.Size(288, 19); + this.TxtFront.TabIndex = 10; + // + // TxtRight + // + this.TxtRight.Location = new System.Drawing.Point(1, 3); + this.TxtRight.Name = "TxtRight"; + this.TxtRight.ReadOnly = true; + this.TxtRight.Size = new System.Drawing.Size(288, 19); + this.TxtRight.TabIndex = 11; + // + // MainForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(892, 555); + this.Controls.Add(this.splitContainer1); + this.Controls.Add(this.ChkTrigger); + this.Controls.Add(this.button2); + this.Controls.Add(this.BtnStartPreview); + this.Name = "MainForm"; + this.Text = "マルチカメラ撮影ソフトウェア by フロンティア医工学センター"; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.MainForm_FormClosing); + this.Load += new System.EventHandler(this.MainForm_Load); + this.splitContainer1.Panel1.ResumeLayout(false); + this.splitContainer1.Panel2.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit(); + this.splitContainer1.ResumeLayout(false); + this.splitContainer2.Panel2.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).EndInit(); + this.splitContainer2.ResumeLayout(false); + this.splitContainer3.Panel1.ResumeLayout(false); + this.splitContainer3.Panel1.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.splitContainer3)).EndInit(); + this.splitContainer3.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.icTop)).EndInit(); + this.splitContainer4.Panel1.ResumeLayout(false); + this.splitContainer4.Panel1.PerformLayout(); + this.splitContainer4.Panel2.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.splitContainer4)).EndInit(); + this.splitContainer4.ResumeLayout(false); + this.splitContainer5.Panel1.ResumeLayout(false); + this.splitContainer5.Panel1.PerformLayout(); + this.splitContainer5.Panel2.ResumeLayout(false); + this.splitContainer5.Panel2.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.splitContainer5)).EndInit(); + this.splitContainer5.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.icLeft)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.icFront)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.icRight)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + private System.Windows.Forms.Button BtnStartPreview; + private System.Windows.Forms.Button button2; + private System.Windows.Forms.CheckBox ChkTrigger; + private System.Windows.Forms.SplitContainer splitContainer1; + private System.Windows.Forms.SplitContainer splitContainer2; + private System.Windows.Forms.SplitContainer splitContainer3; + private TIS.Imaging.ICImagingControl icTop; + private System.Windows.Forms.SplitContainer splitContainer4; + private TIS.Imaging.ICImagingControl icLeft; + private System.Windows.Forms.SplitContainer splitContainer5; + private TIS.Imaging.ICImagingControl icFront; + private TIS.Imaging.ICImagingControl icRight; + private System.Windows.Forms.TextBox TxtTop; + private System.Windows.Forms.TextBox TxtLeft; + private System.Windows.Forms.TextBox TxtFront; + private System.Windows.Forms.TextBox TxtRight; + } +} + diff --git a/ISCamRecorder/MainForm.cs b/ISCamRecorder/MainForm.cs new file mode 100644 index 0000000..94fac23 --- /dev/null +++ b/ISCamRecorder/MainForm.cs @@ -0,0 +1,117 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using System.Diagnostics; +using System.Reflection; + +namespace ISCamRecorder { + public partial class MainForm : Form { + private System.Threading.Timer _timer; + List _Cam = new List (); // カメラオブジェクト + //private Stopwatch _Swatch = new Stopwatch(); // 高精度時間計測 + + /// + /// コンストラクタ + /// + public MainForm() { + InitializeComponent(); + } + + /// + /// フォームロード時 + /// + /// + /// + private void MainForm_Load(object sender, EventArgs e) { + SetTitle(this.Text); + + _Cam.Add(new ISCamera(icTop, "9220016")); + _Cam.Add(new ISCamera(icLeft, "9220018")); + _Cam.Add(new ISCamera(icFront, "9220021")); + _Cam.Add(new ISCamera(icRight, "9220025")); + //_Swatch.Start(); + + _Cam.ForEach(c => c.Connect()); + _timer = new System.Threading.Timer(TimerCB, this, 0, 2000); + } + + /// + /// タイマーイベント + /// + /// + static void TimerCB(object obj) { + ((MainForm)obj).SoftwareTrigger(); + } + + /// + /// トリガー発生 + /// + public void SoftwareTrigger() { + if (this.InvokeRequired) { + this.Invoke((MethodInvoker)delegate { SoftwareTrigger(); }); + return; + } + //_Cam.ForEach(c => c.SWTrigger()); + TxtTop.Text = $"Top {_Cam[0].CameraInfo()}"; + TxtLeft.Text = $"Left {_Cam[1].CameraInfo()}"; + TxtFront.Text = $"Front {_Cam[2].CameraInfo()}"; + TxtRight.Text = $"Right {_Cam[3].CameraInfo()}"; + } + + /// + /// カメラ接続とプレビュー開始 + /// + /// + /// + private void BtnStartPreview_Click(object sender, EventArgs e) { + _Cam.ForEach(c => c.Connect()); + } + + /// + /// カメラプロパティの設定 + /// + /// + /// + private void SetProperty_Click(object sender, EventArgs e) { + var config =_Cam[0].SetProperty(); + _Cam.ForEach(c => c.SetProperty(config)); + } + + /// + /// フォームタイトルを設定 + /// + private void SetTitle(string title) { + var version = Assembly.GetExecutingAssembly().GetName().Version; +#if DEBUG + var debug = " [DEBUG]"; +#else + var debug = ""; +#endif + Text = $"{title} ver {version.Major}.{version.Minor}{debug}"; + } + + /// + /// フォームを閉じる時 + /// + /// + /// + private void MainForm_FormClosing(object sender, FormClosingEventArgs e) { + _timer.Dispose(); + } + + /// + /// トリガー使用チェック変更時 + /// + /// + /// + private void ChkTrigger_CheckedChanged(object sender, EventArgs e) { + _Cam.ForEach(c => c.SetTriggerMode(((CheckBox)sender).Checked)); + } + } +} diff --git a/ISCamRecorder/MainForm.resx b/ISCamRecorder/MainForm.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/ISCamRecorder/MainForm.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/ISCamRecorder/Program.cs b/ISCamRecorder/Program.cs index 95909ca..59eb4ff 100644 --- a/ISCamRecorder/Program.cs +++ b/ISCamRecorder/Program.cs @@ -13,7 +13,7 @@ static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); - Application.Run(new Form1()); + Application.Run(new MainForm()); } } } diff --git a/ISCamRecorder/dfk33ux290.iccf b/ISCamRecorder/dfk33ux290.iccf new file mode 100644 index 0000000..8b3c20f --- /dev/null +++ b/ISCamRecorder/dfk33ux290.iccf @@ -0,0 +1,205 @@ + + 2C0000000000000001000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFAD010000C10000002D090000C0040000 + + + + + + + + + + + + + + DFK 33UX290 9220016 + RGB32 (1920x1080) + 0 + 40.00 + 0 + 0 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 100 + 0 + 0 + + + 0 + 100 + 0 + 1 + 20 + 0 + 0 + 60 + 10 + + C:\Users\nakag\OneDrive\画像\ + Image + 1 + 1 + 0 + 0 + + + + + + + + 0 + C:\Users\nakag\Videos\video.avi + 0 + 60 + 0 + 100 + + + + 2C0000000000000001000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000000000006C0700008F030000 + + + +