diff --git a/ISCamRecorder/FPS.cs b/ISCamRecorder/FPS.cs
deleted file mode 100644
index 6190c34..0000000
--- a/ISCamRecorder/FPS.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-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/FrameRateCounter.cs b/ISCamRecorder/FrameRateCounter.cs
new file mode 100644
index 0000000..45f63d8
--- /dev/null
+++ b/ISCamRecorder/FrameRateCounter.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 FrameRateCounter {
+ Stopwatch _Swatch = new Stopwatch(); // 高精度時間計測
+ int _Count = 0; // FPSを計算する回数
+ int _Counter = 0; // 現在のカウント
+ public float FrameRate { get; private set; } = 0; // FPS値
+
+ ///
+ /// コンストラクタ
+ ///
+ ///
+ public FrameRateCounter(int count) {
+ _Count = count;
+ _Swatch.Start();
+ }
+
+ ///
+ /// 計時
+ ///
+ public void Shot() {
+ if (++_Counter >= _Count) {
+ var elapsed = _Swatch.ElapsedMilliseconds;
+ FrameRate = _Count * 1000F / elapsed;
+ _Counter = 0;
+ _Swatch.Restart();
+ }
+ }
+ }
+}
diff --git a/ISCamRecorder/ISCamRecorder.csproj b/ISCamRecorder/ISCamRecorder.csproj
index 2fcc38e..2df358e 100644
--- a/ISCamRecorder/ISCamRecorder.csproj
+++ b/ISCamRecorder/ISCamRecorder.csproj
@@ -70,7 +70,7 @@
-
+
Form
diff --git a/ISCamRecorder/ISCamera.cs b/ISCamRecorder/ISCamera.cs
index 44e0d51..a3434dd 100644
--- a/ISCamRecorder/ISCamera.cs
+++ b/ISCamRecorder/ISCamera.cs
@@ -11,21 +11,21 @@
namespace ISCamRecorder {
internal class ISCamera {
readonly string ICCF_FILE = @"dfk33ux290.iccf"; // 設定ファイル
- readonly string CAMERA_FORMAT = "RGB32 (1920x1080)";
- readonly float FRAME_RATE = 40F;
+ readonly string CAMERA_FORMAT = "RGB32 (1920x1080)"; // 設定ファイル無い時の解像度
+ readonly float FRAME_RATE = 40F; // 設定ファイル無い時のFPS
- ICImagingControl _iccs; // カメラオブジェクト
+ ICImagingControl _Cam; // カメラオブジェクト
string _SerialNumber; // シリアル番号
VCDButtonProperty _Trigger; // トリガー設定
- FPS _fps = new FPS(10); // FPS計測
+ FrameRateCounter _Fps = new FrameRateCounter(10); // フレームレート計測
///
/// コンストラクタ
///
- ///
+ ///
///
- public ISCamera(ICImagingControl iccs, string serialNumber) {
- _iccs = iccs;
+ public ISCamera(ICImagingControl cameraControl, string serialNumber) {
+ _Cam = cameraControl;
_SerialNumber = serialNumber;
}
@@ -34,25 +34,25 @@
///
///
public bool Connect() {
- if (_iccs.DeviceValid) return true;
+ if (_Cam.DeviceValid) return true;
// 接続
- _iccs.Device = _iccs.Devices.FirstOrDefault(
+ _Cam.Device = _Cam.Devices.FirstOrDefault(
c => c.GetSerialNumber().Equals(_SerialNumber));
- if (!_iccs.DeviceValid) return false;
+ if (!_Cam.DeviceValid) return false;
// 撮影条件設定
try {
if (File.Exists(ICCF_FILE)){
- _iccs.LoadDeviceState(ICCFImport.Import(ICCF_FILE), false);
+ _Cam.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(
+ _Cam.VideoFormat = _Cam.VideoFormats.FirstOrDefault(
c => c.Name.Equals(CAMERA_FORMAT));
- _iccs.DeviceFrameRate = _iccs.DeviceFrameRates.FirstOrDefault(
+ _Cam.DeviceFrameRate = _Cam.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");
+ Debug.WriteLine($"Camera #{_SerialNumber} sets {_Cam.VideoFormat}, {_Cam.DeviceFrameRate:0.0}fps");
}
} catch (ICException iex) {
MessageBox.Show(iex.Message, "Camera Error",
@@ -61,15 +61,15 @@
}
// 表示設定
- _iccs.LiveDisplayDefault = false;
- _iccs.LiveDisplayHeight = _iccs.Height;
- _iccs.LiveDisplayWidth = _iccs.Width;
+ _Cam.LiveDisplayDefault = false;
+ _Cam.LiveDisplayHeight = _Cam.Height;
+ _Cam.LiveDisplayWidth = _Cam.Width;
// ic.ImageRingBufferSize = 2;
- _Trigger = _iccs.VCDPropertyItems.Find(
+ _Trigger = _Cam.VCDPropertyItems.Find(
VCDGUIDs.VCDID_TriggerMode, VCDGUIDs.VCDElement_SoftwareTrigger);
- _iccs.Sink = new FrameQueueSink(CaptureFrame, MediaSubtypes.RGB32, 5);
+ _Cam.Sink = new FrameQueueSink(CaptureFrame, MediaSubtypes.RGB32, 5);
- _iccs.LiveStart();
+ _Cam.LiveStart();
return true;
}
@@ -80,7 +80,7 @@
///
///
private FrameQueuedResult CaptureFrame(IFrameQueueBuffer buffer) {
- _fps.Shot();
+ _Fps.Shot();
return FrameQueuedResult.ReQueue;
}
@@ -89,16 +89,16 @@
///
///
public void SetTriggerMode(bool enable) {
- _iccs.LiveStop();
- _iccs.DeviceTrigger = enable;
- _iccs.LiveStart();
+ _Cam.LiveStop();
+ _Cam.DeviceTrigger = enable;
+ _Cam.LiveStart();
}
///
/// ソフトウェアトリガー発信
///
public void SWTrigger() {
- if (_iccs.DeviceValid && _Trigger != null) _Trigger.Push();
+ if (_Cam.DeviceValid && _Trigger != null) _Trigger.Push();
}
///
@@ -106,9 +106,9 @@
///
///
public string SetProperty() {
- if (!_iccs.DeviceValid) return "";
- _iccs.ShowPropertyDialog();
- return _iccs.SaveDeviceState();
+ if (!_Cam.DeviceValid) return "";
+ _Cam.ShowPropertyDialog();
+ return _Cam.SaveDeviceState();
}
///
@@ -117,23 +117,19 @@
///
///
public string SetProperty(string config) {
- if (!_iccs.DeviceValid) return "";
- _iccs.LiveStop();
- _iccs.LoadDeviceState(config, false);
- _iccs.LiveStart();
+ if (!_Cam.DeviceValid) return "";
+ _Cam.LiveStop();
+ _Cam.LoadDeviceState(config, false);
+ _Cam.LiveStart();
return config;
}
///
- /// FPS取得
+ /// カメラ情報文字列
///
///
- public float Fps() {
- return _fps.fps;
- }
-
public string CameraInfo() {
- return $"({_SerialNumber}) {_fps.fps:0.0}fps";
+ return $"({_SerialNumber}) {_Fps.FrameRate:0.0}fps";
}
}
}
diff --git a/ISCamRecorder/MainForm.Designer.cs b/ISCamRecorder/MainForm.Designer.cs
index f09669d..e35aef1 100644
--- a/ISCamRecorder/MainForm.Designer.cs
+++ b/ISCamRecorder/MainForm.Designer.cs
@@ -23,22 +23,21 @@
/// コード エディターで変更しないでください。
///
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.TxtTop = new System.Windows.Forms.TextBox();
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.icLeft = new TIS.Imaging.ICImagingControl();
+ this.splitContainer5 = new System.Windows.Forms.SplitContainer();
this.TxtFront = new System.Windows.Forms.TextBox();
+ this.icFront = new TIS.Imaging.ICImagingControl();
this.TxtRight = new System.Windows.Forms.TextBox();
+ this.icRight = new TIS.Imaging.ICImagingControl();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.Panel2.SuspendLayout();
@@ -54,28 +53,18 @@
this.splitContainer4.Panel1.SuspendLayout();
this.splitContainer4.Panel2.SuspendLayout();
this.splitContainer4.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)(this.icLeft)).BeginInit();
((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.Location = new System.Drawing.Point(12, 12);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(102, 42);
this.button2.TabIndex = 5;
@@ -86,7 +75,7 @@
// ChkTrigger
//
this.ChkTrigger.AutoSize = true;
- this.ChkTrigger.Location = new System.Drawing.Point(228, 26);
+ this.ChkTrigger.Location = new System.Drawing.Point(120, 26);
this.ChkTrigger.Name = "ChkTrigger";
this.ChkTrigger.Size = new System.Drawing.Size(83, 16);
this.ChkTrigger.TabIndex = 6;
@@ -141,6 +130,14 @@
this.splitContainer3.SplitterDistance = 296;
this.splitContainer3.TabIndex = 0;
//
+ // 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;
+ //
// icTop
//
this.icTop.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
@@ -174,6 +171,29 @@
this.splitContainer4.SplitterDistance = 296;
this.splitContainer4.TabIndex = 0;
//
+ // 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;
+ //
+ // 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;
+ //
// splitContainer5
//
this.splitContainer5.Dock = System.Windows.Forms.DockStyle.Fill;
@@ -193,20 +213,13 @@
this.splitContainer5.SplitterDistance = 296;
this.splitContainer5.TabIndex = 0;
//
- // icLeft
+ // TxtFront
//
- 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;
+ 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;
//
// icFront
//
@@ -223,6 +236,14 @@
this.icFront.Size = new System.Drawing.Size(289, 213);
this.icFront.TabIndex = 9;
//
+ // 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;
+ //
// icRight
//
this.icRight.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
@@ -238,38 +259,6 @@
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);
@@ -278,7 +267,6 @@
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);
@@ -300,13 +288,13 @@
this.splitContainer4.Panel2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.splitContainer4)).EndInit();
this.splitContainer4.ResumeLayout(false);
+ ((System.ComponentModel.ISupportInitialize)(this.icLeft)).EndInit();
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);
@@ -315,7 +303,6 @@
}
#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;
diff --git a/ISCamRecorder/MainForm.cs b/ISCamRecorder/MainForm.cs
index 94fac23..161b628 100644
--- a/ISCamRecorder/MainForm.cs
+++ b/ISCamRecorder/MainForm.cs
@@ -12,8 +12,8 @@
namespace ISCamRecorder {
public partial class MainForm : Form {
- private System.Threading.Timer _timer;
- List _Cam = new List (); // カメラオブジェクト
+ private System.Threading.Timer _UITimer;
+ List _Cameras = new List (); // カメラオブジェクト
//private Stopwatch _Swatch = new Stopwatch(); // 高精度時間計測
///
@@ -31,14 +31,14 @@
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"));
+ _Cameras.Add(new ISCamera(icTop, "9220016"));
+ _Cameras.Add(new ISCamera(icLeft, "9220018"));
+ _Cameras.Add(new ISCamera(icFront, "9220021"));
+ _Cameras.Add(new ISCamera(icRight, "9220025"));
//_Swatch.Start();
- _Cam.ForEach(c => c.Connect());
- _timer = new System.Threading.Timer(TimerCB, this, 0, 2000);
+ _Cameras.ForEach(c => c.Connect());
+ _UITimer = new System.Threading.Timer(TimerCB, this, 0, 2000);
}
///
@@ -58,19 +58,10 @@
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());
+ TxtTop.Text = $"Top {_Cameras[0].CameraInfo()}";
+ TxtLeft.Text = $"Left {_Cameras[1].CameraInfo()}";
+ TxtFront.Text = $"Front {_Cameras[2].CameraInfo()}";
+ TxtRight.Text = $"Right {_Cameras[3].CameraInfo()}";
}
///
@@ -79,8 +70,8 @@
///
///
private void SetProperty_Click(object sender, EventArgs e) {
- var config =_Cam[0].SetProperty();
- _Cam.ForEach(c => c.SetProperty(config));
+ var config =_Cameras[0].SetProperty();
+ _Cameras.ForEach(c => c.SetProperty(config));
}
///
@@ -102,7 +93,7 @@
///
///
private void MainForm_FormClosing(object sender, FormClosingEventArgs e) {
- _timer.Dispose();
+ _UITimer.Dispose();
}
///
@@ -111,7 +102,7 @@
///
///
private void ChkTrigger_CheckedChanged(object sender, EventArgs e) {
- _Cam.ForEach(c => c.SetTriggerMode(((CheckBox)sender).Checked));
+ _Cameras.ForEach(c => c.SetTriggerMode(((CheckBox)sender).Checked));
}
}
}