实现可见光图像
This commit is contained in:
@@ -62,12 +62,7 @@ namespace JoyD.Windows.CS.Toprie
|
|||||||
//
|
//
|
||||||
this.imageModeToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
this.imageModeToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||||
this.thermalModeToolStripMenuItem,
|
this.thermalModeToolStripMenuItem,
|
||||||
this.visibleModeToolStripMenuItem,
|
this.visibleModeToolStripMenuItem});
|
||||||
this.fusionMode1ToolStripMenuItem,
|
|
||||||
this.fusionMode2ToolStripMenuItem,
|
|
||||||
this.fusionMode3ToolStripMenuItem,
|
|
||||||
this.fusionMode4ToolStripMenuItem,
|
|
||||||
this.fusionMode5ToolStripMenuItem});
|
|
||||||
this.imageModeToolStripMenuItem.Name = "imageModeToolStripMenuItem";
|
this.imageModeToolStripMenuItem.Name = "imageModeToolStripMenuItem";
|
||||||
this.imageModeToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
|
this.imageModeToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
|
||||||
this.imageModeToolStripMenuItem.Text = "图像模式";
|
this.imageModeToolStripMenuItem.Text = "图像模式";
|
||||||
@@ -86,41 +81,6 @@ namespace JoyD.Windows.CS.Toprie
|
|||||||
this.visibleModeToolStripMenuItem.Text = "自然模式";
|
this.visibleModeToolStripMenuItem.Text = "自然模式";
|
||||||
this.visibleModeToolStripMenuItem.Click += new System.EventHandler(this.visibleModeToolStripMenuItem_Click);
|
this.visibleModeToolStripMenuItem.Click += new System.EventHandler(this.visibleModeToolStripMenuItem_Click);
|
||||||
//
|
//
|
||||||
// fusionMode1ToolStripMenuItem
|
|
||||||
//
|
|
||||||
this.fusionMode1ToolStripMenuItem.Name = "fusionMode1ToolStripMenuItem";
|
|
||||||
this.fusionMode1ToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
|
|
||||||
this.fusionMode1ToolStripMenuItem.Text = "融合模式1";
|
|
||||||
this.fusionMode1ToolStripMenuItem.Click += new System.EventHandler(this.fusionMode1ToolStripMenuItem_Click);
|
|
||||||
//
|
|
||||||
// fusionMode2ToolStripMenuItem
|
|
||||||
//
|
|
||||||
this.fusionMode2ToolStripMenuItem.Name = "fusionMode2ToolStripMenuItem";
|
|
||||||
this.fusionMode2ToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
|
|
||||||
this.fusionMode2ToolStripMenuItem.Text = "融合模式2";
|
|
||||||
this.fusionMode2ToolStripMenuItem.Click += new System.EventHandler(this.fusionMode2ToolStripMenuItem_Click);
|
|
||||||
//
|
|
||||||
// fusionMode3ToolStripMenuItem
|
|
||||||
//
|
|
||||||
this.fusionMode3ToolStripMenuItem.Name = "fusionMode3ToolStripMenuItem";
|
|
||||||
this.fusionMode3ToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
|
|
||||||
this.fusionMode3ToolStripMenuItem.Text = "融合模式3";
|
|
||||||
this.fusionMode3ToolStripMenuItem.Click += new System.EventHandler(this.fusionMode3ToolStripMenuItem_Click);
|
|
||||||
//
|
|
||||||
// fusionMode4ToolStripMenuItem
|
|
||||||
//
|
|
||||||
this.fusionMode4ToolStripMenuItem.Name = "fusionMode4ToolStripMenuItem";
|
|
||||||
this.fusionMode4ToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
|
|
||||||
this.fusionMode4ToolStripMenuItem.Text = "融合模式4";
|
|
||||||
this.fusionMode4ToolStripMenuItem.Click += new System.EventHandler(this.fusionMode4ToolStripMenuItem_Click);
|
|
||||||
//
|
|
||||||
// fusionMode5ToolStripMenuItem
|
|
||||||
//
|
|
||||||
this.fusionMode5ToolStripMenuItem.Name = "fusionMode5ToolStripMenuItem";
|
|
||||||
this.fusionMode5ToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
|
|
||||||
this.fusionMode5ToolStripMenuItem.Text = "融合模式5";
|
|
||||||
this.fusionMode5ToolStripMenuItem.Click += new System.EventHandler(this.fusionMode5ToolStripMenuItem_Click);
|
|
||||||
//
|
|
||||||
// colorModeToolStripMenuItem
|
// colorModeToolStripMenuItem
|
||||||
//
|
//
|
||||||
this.colorModeToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
this.colorModeToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||||
|
|||||||
@@ -1031,35 +1031,14 @@ namespace JoyD.Windows.CS.Toprie
|
|||||||
// 更新视频模式菜单项的选中状态
|
// 更新视频模式菜单项的选中状态
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var currentMode = _deviceManager.CurrentVideoMode;
|
// 更改为使用ImageMode枚举
|
||||||
switch (currentMode)
|
var currentImageMode = _deviceManager.CurrentImageMode;
|
||||||
{
|
thermalModeToolStripMenuItem.Checked = currentImageMode == ImageMode.Infrared;
|
||||||
case VideoMode.Infrared:
|
visibleModeToolStripMenuItem.Checked = currentImageMode == ImageMode.Natural;
|
||||||
thermalModeToolStripMenuItem.Checked = true;
|
|
||||||
break;
|
|
||||||
case VideoMode.VisibleLight:
|
|
||||||
visibleModeToolStripMenuItem.Checked = true;
|
|
||||||
break;
|
|
||||||
case VideoMode.Fusion1:
|
|
||||||
fusionMode1ToolStripMenuItem.Checked = true;
|
|
||||||
break;
|
|
||||||
case VideoMode.Fusion2:
|
|
||||||
fusionMode2ToolStripMenuItem.Checked = true;
|
|
||||||
break;
|
|
||||||
case VideoMode.Fusion3:
|
|
||||||
fusionMode3ToolStripMenuItem.Checked = true;
|
|
||||||
break;
|
|
||||||
case VideoMode.Fusion4:
|
|
||||||
fusionMode4ToolStripMenuItem.Checked = true;
|
|
||||||
break;
|
|
||||||
case VideoMode.Fusion5:
|
|
||||||
fusionMode5ToolStripMenuItem.Checked = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Console.WriteLine("获取当前视频模式失败: " + ex.Message);
|
Console.WriteLine("获取当前图像模式失败: " + ex.Message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1234,11 +1213,7 @@ namespace JoyD.Windows.CS.Toprie
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (_deviceManager != null)
|
_deviceManager.SetImageMode(ImageMode.Infrared);
|
||||||
{
|
|
||||||
Console.WriteLine("切换到红外模式");
|
|
||||||
_deviceManager.SetVideoMode(VideoMode.Infrared);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@@ -1247,18 +1222,11 @@ namespace JoyD.Windows.CS.Toprie
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 自然模式
|
|
||||||
/// </summary>
|
|
||||||
private void visibleModeToolStripMenuItem_Click(object sender, EventArgs e)
|
private void visibleModeToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (_deviceManager != null)
|
_deviceManager.SetImageMode(ImageMode.Natural);
|
||||||
{
|
|
||||||
Console.WriteLine("切换到自然模式");
|
|
||||||
_deviceManager.SetVideoMode(VideoMode.VisibleLight);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@@ -1267,106 +1235,6 @@ namespace JoyD.Windows.CS.Toprie
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 融合模式1
|
|
||||||
/// </summary>
|
|
||||||
private void fusionMode1ToolStripMenuItem_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (_deviceManager != null)
|
|
||||||
{
|
|
||||||
Console.WriteLine("切换到融合模式1");
|
|
||||||
_deviceManager.SetVideoMode(VideoMode.Fusion1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
Console.WriteLine("切换到融合模式1失败: " + ex.Message);
|
|
||||||
ShowError("切换到融合模式1失败");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 融合模式2
|
|
||||||
/// </summary>
|
|
||||||
private void fusionMode2ToolStripMenuItem_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (_deviceManager != null)
|
|
||||||
{
|
|
||||||
Console.WriteLine("切换到融合模式2");
|
|
||||||
_deviceManager.SetVideoMode(VideoMode.Fusion2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
Console.WriteLine("切换到融合模式2失败: " + ex.Message);
|
|
||||||
ShowError("切换到融合模式2失败");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 融合模式3
|
|
||||||
/// </summary>
|
|
||||||
private void fusionMode3ToolStripMenuItem_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (_deviceManager != null)
|
|
||||||
{
|
|
||||||
Console.WriteLine("切换到融合模式3");
|
|
||||||
_deviceManager.SetVideoMode(VideoMode.Fusion3);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
Console.WriteLine("切换到融合模式3失败: " + ex.Message);
|
|
||||||
ShowError("切换到融合模式3失败");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 融合模式4
|
|
||||||
/// </summary>
|
|
||||||
private void fusionMode4ToolStripMenuItem_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (_deviceManager != null)
|
|
||||||
{
|
|
||||||
Console.WriteLine("切换到融合模式4");
|
|
||||||
_deviceManager.SetVideoMode(VideoMode.Fusion4);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
Console.WriteLine("切换到融合模式4失败: " + ex.Message);
|
|
||||||
ShowError("切换到融合模式4失败");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 融合模式5
|
|
||||||
/// </summary>
|
|
||||||
private void fusionMode5ToolStripMenuItem_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (_deviceManager != null)
|
|
||||||
{
|
|
||||||
Console.WriteLine("切换到融合模式5");
|
|
||||||
_deviceManager.SetVideoMode(VideoMode.Fusion5);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
Console.WriteLine("切换到融合模式5失败: " + ex.Message);
|
|
||||||
ShowError("切换到融合模式5失败");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -262,7 +262,7 @@ namespace JoyD.Windows.CS.Toprie
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
private TcpClient _imageTcpClient;
|
private TcpClient _imageTcpClient;
|
||||||
private bool _isInfraredMode = true;
|
// 使用CurrentImageMode代替_isInfraredMode
|
||||||
private static readonly object _logLock = new object();
|
private static readonly object _logLock = new object();
|
||||||
|
|
||||||
#region 私有方法
|
#region 私有方法
|
||||||
@@ -1768,7 +1768,6 @@ namespace JoyD.Windows.CS.Toprie
|
|||||||
Console.WriteLine($"图像接收线程启动: 使用HTTP请求获取图像数据");
|
Console.WriteLine($"图像接收线程启动: 使用HTTP请求获取图像数据");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
string url = string.Format("http://{0}:8080{1}", DeviceIp, _isInfraredMode ? "/video/infrared.jpg" : "/video/optical.jpg");
|
|
||||||
while (_isReceivingImages)
|
while (_isReceivingImages)
|
||||||
{
|
{
|
||||||
// 确保连接状态正常
|
// 确保连接状态正常
|
||||||
@@ -1778,6 +1777,8 @@ namespace JoyD.Windows.CS.Toprie
|
|||||||
Thread.Sleep(500);
|
Thread.Sleep(500);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
// 根据当前图像模式构建URL,确保模式更改能实时生效
|
||||||
|
string url = string.Format("http://{0}:8080{1}", DeviceIp, CurrentImageMode == ImageMode.Infrared ? "/video/infrared.jpg" : "/video/optical.jpg");
|
||||||
// 添加时间戳避免缓存
|
// 添加时间戳避免缓存
|
||||||
string timestampUrl = url + "?t=" + DateTime.Now.Ticks;
|
string timestampUrl = url + "?t=" + DateTime.Now.Ticks;
|
||||||
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(timestampUrl);
|
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(timestampUrl);
|
||||||
|
|||||||
Reference in New Issue
Block a user