Commit 894b93d7 by liulongfei

1. 居中模式处理

parent ad452264
...@@ -25,5 +25,19 @@ namespace VIZ.H2V.Domain ...@@ -25,5 +25,19 @@ namespace VIZ.H2V.Domain
} }
#endregion #endregion
#region IsLocalStream -- 是否是本机流
private bool isLocalStream;
/// <summary>
/// 是否是本机流
/// </summary>
public bool IsLocalStream
{
get { return isLocalStream; }
set { isLocalStream = value; this.RaisePropertyChanged(nameof(IsLocalStream)); }
}
#endregion
} }
} }
...@@ -196,10 +196,13 @@ namespace VIZ.H2V.Module ...@@ -196,10 +196,13 @@ namespace VIZ.H2V.Module
if (ndiStream.StreamInfos != null && ndiStream.StreamInfos.Count > 0) if (ndiStream.StreamInfos != null && ndiStream.StreamInfos.Count > 0)
{ {
string localName = System.Net.Dns.GetHostName();
foreach (NDIStreamInfo info in ndiStream.StreamInfos) foreach (NDIStreamInfo info in ndiStream.StreamInfos)
{ {
NDIStreamInfoModel model = new NDIStreamInfoModel(); NDIStreamInfoModel model = new NDIStreamInfoModel();
model.FullName = info.FullName; model.FullName = info.FullName;
model.IsLocalStream = info.Machine == localName;
if (model.FullName == ndiStream.RemoteSenderName) if (model.FullName == ndiStream.RemoteSenderName)
{ {
selected = model; selected = model;
......
...@@ -23,17 +23,10 @@ namespace VIZ.H2V.Module ...@@ -23,17 +23,10 @@ namespace VIZ.H2V.Module
double ClipBoxTargetX { get; set; } double ClipBoxTargetX { get; set; }
/// <summary> /// <summary>
/// 裁切框居中模式下的X坐标
/// </summary>
double ClipBoxCenterX { get; set; }
/// <summary>
/// 移动至 /// 移动至
/// </summary> /// </summary>
/// <param name="min">最小值</param>
/// <param name="max">最大值</param>
/// <param name="targetX">目标值</param> /// <param name="targetX">目标值</param>
void MoveTo(double min, double max, double targetX); void MoveTo(double targetX);
/// <summary> /// <summary>
/// 获取映射值 /// 获取映射值
...@@ -54,10 +47,5 @@ namespace VIZ.H2V.Module ...@@ -54,10 +47,5 @@ namespace VIZ.H2V.Module
/// </summary> /// </summary>
/// <param name="clipX">剪切X值</param> /// <param name="clipX">剪切X值</param>
void Reset(double clipX); void Reset(double clipX);
/// <summary>
/// 重置自动移动
/// </summary>
void ResetAutoMoving();
} }
} }
...@@ -26,10 +26,5 @@ namespace VIZ.H2V.Module ...@@ -26,10 +26,5 @@ namespace VIZ.H2V.Module
/// 是否被激活 /// 是否被激活
/// </summary> /// </summary>
bool IsActive { get; } bool IsActive { get; }
/// <summary>
/// 居中模式移动至中间是否可用
/// </summary>
bool IsCenterModeMoveToCenterEnabled { get; set; }
} }
} }
...@@ -43,48 +43,19 @@ namespace VIZ.H2V.Module ...@@ -43,48 +43,19 @@ namespace VIZ.H2V.Module
public double ClipBoxTargetX { get; set; } = 555; public double ClipBoxTargetX { get; set; } = 555;
/// <summary> /// <summary>
/// 裁切框居中模式下的X坐标
/// </summary>
public double ClipBoxCenterX { get; set; } = 555;
/// <summary>
/// 支持 /// 支持
/// </summary> /// </summary>
public IManualSupport Support { get; private set; } public IManualSupport Support { get; private set; }
/// <summary> /// <summary>
/// 裁切框自动移动帧数
/// </summary>
private int ClipBoxAutoMovingFrame;
/// <summary>
/// 裁切框是否正在自动移动中
/// </summary>
private bool IsClipBoxAutoMoving;
/// <summary>
/// 剪切框自动移动速度(单位:像素/帧)
/// </summary>
private static readonly int VIDEO_CLIP_BOX_AUTO_MOVE_SPEED = ApplicationDomainEx.IniStorage.GetValue<VideoConfig, int>(p => p.VIDEO_CLIP_BOX_AUTO_MOVE_SPEED);
/// <summary>
/// 剪切框自动移动持续帧数(单位:帧数)
/// </summary>
private static readonly int VIDEO_CLIP_BOX_AUTO_MOVE_DURATION_FRAME = ApplicationDomainEx.IniStorage.GetValue<VideoConfig, int>(p => p.VIDEO_CLIP_BOX_AUTO_MOVE_DURATION_FRAME);
/// <summary>
/// 移动至 /// 移动至
/// </summary> /// </summary>
/// <param name="min">最小值</param> /// <param name="min">最小值</param>
/// <param name="max">最大值</param> /// <param name="max">最大值</param>
/// <param name="targetX">目标值</param> /// <param name="targetX">目标值</param>
public void MoveTo(double min, double max, double targetX) public void MoveTo(double targetX)
{ {
this.Support.IsCenterModeMoveToCenterEnabled = false; this.ClipBoxTargetX = targetX;
this.Reset(this.Support.ClipBoxX);
this.ClipBoxCenterX = MathHelper.Clip(min, max, targetX);
this.ClipBoxAutoMovingFrame = 0;
this.IsClipBoxAutoMoving = true;
} }
/// <summary> /// <summary>
...@@ -95,48 +66,21 @@ namespace VIZ.H2V.Module ...@@ -95,48 +66,21 @@ namespace VIZ.H2V.Module
/// <returns>计算值</returns> /// <returns>计算值</returns>
public double GetCalculationValue(double min, double max) public double GetCalculationValue(double min, double max)
{ {
if (this.IsClipBoxAutoMoving) // 居中模式直接返回居中位置
{
if (this.ClipBoxAutoMovingFrame == VIDEO_CLIP_BOX_AUTO_MOVE_DURATION_FRAME || (int)this.Support.ClipBoxX == (int)this.ClipBoxCenterX)
{
this.IsClipBoxAutoMoving = false;
this.ClipBoxAutoMovingFrame = 0;
// 重置手动裁切
this.Reset(this.Support.ClipBoxX);
this.Support.IsCenterModeMoveToCenterEnabled = true;
}
++this.ClipBoxAutoMovingFrame;
}
if (this.Support.StrategyMode == AlgorithmStrategyMode.center_mode) if (this.Support.StrategyMode == AlgorithmStrategyMode.center_mode)
{ {
// 居中模式自动移动过程 return this.GetCalculationValue_Auto(min, max);
if (this.IsClipBoxAutoMoving)
{
double result = this.GetCalculationValue_Center(min, max);
return result;
} }
if (this.Support.IsActive) // 手动模式 且 处于激活状态下进行计算
{ if (this.Support.StrategyMode == AlgorithmStrategyMode.manual_mode && this.Support.IsActive)
double result = this.GetCalculationValue_Manual(min, max);
return result;
}
else
{
return this.ClipBoxTargetX;
}
}
else if (this.Support.StrategyMode == AlgorithmStrategyMode.manual_mode && this.Support.IsActive)
{ {
return this.GetCalculationValue_Manual(min, max); return this.GetCalculationValue_Manual(min, max);
} }
else
{ // 其他情况不处理
return this.ClipBoxTargetX; return this.ClipBoxTargetX;
}
} }
/// <summary> /// <summary>
...@@ -185,36 +129,14 @@ namespace VIZ.H2V.Module ...@@ -185,36 +129,14 @@ namespace VIZ.H2V.Module
} }
/// <summary> /// <summary>
/// 重置自动移动 /// 获取手动模式计算值
/// </summary>
public void ResetAutoMoving()
{
this.IsClipBoxAutoMoving = false;
this.ClipBoxAutoMovingFrame = 0;
this.Support.IsCenterModeMoveToCenterEnabled = true;
}
/// <summary>
/// 获取居中模式计算值
/// </summary> /// </summary>
/// <param name="min">最小值</param> /// <param name="min">最小值</param>
/// <param name="max">最大值</param> /// <param name="max">最大值</param>
/// <returns>计算值</returns> /// <returns>计算值</returns>
private double GetCalculationValue_Center(double min, double max) private double GetCalculationValue_Manual(double min, double max)
{
double x = this.ClipBoxTargetX;
if ((int)x < (int)this.ClipBoxCenterX)
{
x += VIDEO_CLIP_BOX_AUTO_MOVE_SPEED;
x = x > this.ClipBoxCenterX ? this.ClipBoxCenterX : x;
}
else if ((int)x > (int)this.ClipBoxCenterX)
{ {
x -= VIDEO_CLIP_BOX_AUTO_MOVE_SPEED; double x = this.ClipBoxTargetX + this.GetMappingValue();
x = x < this.ClipBoxCenterX ? this.ClipBoxCenterX : x;
}
x = MathHelper.Clip(min, max, x); x = MathHelper.Clip(min, max, x);
this.ClipBoxTargetX = x; this.ClipBoxTargetX = x;
...@@ -224,17 +146,13 @@ namespace VIZ.H2V.Module ...@@ -224,17 +146,13 @@ namespace VIZ.H2V.Module
} }
/// <summary> /// <summary>
/// 获取手动模式计算值 /// 获取自动移动时的计算值
/// </summary> /// </summary>
/// <param name="min">最小值</param> /// <param name="min">最小值</param>
/// <param name="max">最大值</param> /// <param name="max">最大值</param>
/// <returns>计算值</returns> /// <returns>计算值</returns>
private double GetCalculationValue_Manual(double min, double max) private double GetCalculationValue_Auto(double min, double max)
{ {
double x = this.ClipBoxTargetX + this.GetMappingValue();
x = MathHelper.Clip(min, max, x);
this.ClipBoxTargetX = x;
double result = this.ClipBoxSmooth.Call(this.ClipBoxTargetX, 0.6d); double result = this.ClipBoxSmooth.Call(this.ClipBoxTargetX, 0.6d);
return result; return result;
......
...@@ -133,7 +133,7 @@ ...@@ -133,7 +133,7 @@
Style="{StaticResource CheckBox_NdiView}"></CheckBox> Style="{StaticResource CheckBox_NdiView}"></CheckBox>
<Rectangle Grid.Row="1" Grid.RowSpan="10" Fill="#ff181d2b"></Rectangle> <Rectangle Grid.Row="1" Grid.RowSpan="10" Fill="#ff181d2b"></Rectangle>
<Border Grid.Row="1" IsEnabled="{Binding IsUseClip,Mode=OneWay}"> <Border Grid.Row="1" IsEnabled="{Binding IsUseClip,Mode=OneWay}">
<Grid IsEnabled="{Binding Path=IsCenterModeMoveToCenterEnabled}"> <Grid>
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="60"></RowDefinition> <RowDefinition Height="60"></RowDefinition>
<RowDefinition Height="60"></RowDefinition> <RowDefinition Height="60"></RowDefinition>
...@@ -175,28 +175,6 @@ ...@@ -175,28 +175,6 @@
</MultiBinding> </MultiBinding>
</Button.Visibility> </Button.Visibility>
</Button> </Button>
<Grid HorizontalAlignment="Stretch" VerticalAlignment="Bottom">
<Grid.RowDefinitions>
<RowDefinition Height="50"></RowDefinition>
<RowDefinition Height="auto"></RowDefinition>
</Grid.RowDefinitions>
<!-- 居中模式 按钮组-->
<Grid Grid.Row="1" Background="{x:Null}">
<Grid.Visibility>
<MultiBinding Converter="{StaticResource NDIViewProperty2VisibilityConverter_CenterMode}">
<Binding Path="ViewStatus"></Binding>
<Binding Path="StrategyMode"></Binding>
<Binding Path="StrategyType"></Binding>
</MultiBinding>
</Grid.Visibility>
<Button Style="{StaticResource Button_Setting}" Content="裁切框居中"
IsEnabled="{Binding Path=IsCenterModeMoveToCenterEnabled,Mode=OneWay}"
Command="{Binding Path=CenterModeMoveToCenterCommand}"
Height="40" Width="120" HorizontalAlignment="Right" Margin="0,0,10,0"></Button>
</Grid>
</Grid>
</Grid> </Grid>
<!-- 视频区域 --> <!-- 视频区域 -->
<Border BorderBrush="Transparent" BorderThickness="0" Grid.Row="1" Grid.Column="1"> <Border BorderBrush="Transparent" BorderThickness="0" Grid.Row="1" Grid.Column="1">
...@@ -306,7 +284,6 @@ ...@@ -306,7 +284,6 @@
<!-- AI功能区 --> <!-- AI功能区 -->
<StackPanel Orientation="Vertical" VerticalAlignment="Bottom" Grid.Row="1"> <StackPanel Orientation="Vertical" VerticalAlignment="Bottom" Grid.Row="1">
<TextBlock Text="AI" Foreground="#AAFFFFFF" HorizontalAlignment="Center"></TextBlock>
<Rectangle Height="2" Width="30" Fill="#AAFFFFFF" Margin="0,2,0,0"></Rectangle> <Rectangle Height="2" Width="30" Fill="#AAFFFFFF" Margin="0,2,0,0"></Rectangle>
<Border Margin="0,10,0,0" ToolTip="重启算法" Background="Transparent"> <Border Margin="0,10,0,0" ToolTip="重启算法" Background="Transparent">
<Button Width="32" Height="32" <Button Width="32" Height="32"
......
...@@ -472,22 +472,5 @@ namespace VIZ.H2V.Module ...@@ -472,22 +472,5 @@ namespace VIZ.H2V.Module
} }
#endregion #endregion
#region CenterModeMoveToCenterCommand -- 居中模式移动裁切框至中间命令
/// <summary>
/// 居中模式移动裁切框至中间命令
/// </summary>
public VCommand CenterModeMoveToCenterCommand { get; set; }
/// <summary>
/// 居中模式移动裁切框至中间
/// </summary>
private void CenterModeMoveToCenter()
{
this.MoveClipBoxTo(555);
}
#endregion
} }
} }
...@@ -519,20 +519,6 @@ namespace VIZ.H2V.Module ...@@ -519,20 +519,6 @@ namespace VIZ.H2V.Module
#endregion #endregion
#region IsCenterModeMoveToCenterEnabled -- 居中模式移动至中间是否可用
private bool isCenterModeMoveToCenterEnabled = true;
/// <summary>
/// 居中模式移动至中间是否可用
/// </summary>
public bool IsCenterModeMoveToCenterEnabled
{
get { return isCenterModeMoveToCenterEnabled; }
set { isCenterModeMoveToCenterEnabled = value; this.RaisePropertySaveChanged(nameof(IsCenterModeMoveToCenterEnabled)); }
}
#endregion
// -------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------
#region ClipFPS -- NDI FPS #region ClipFPS -- NDI FPS
......
...@@ -71,7 +71,6 @@ namespace VIZ.H2V.Module ...@@ -71,7 +71,6 @@ namespace VIZ.H2V.Module
this.IsBorderEnabledChangedCommand = new VCommand(this.IsBorderEnabledChanged); this.IsBorderEnabledChangedCommand = new VCommand(this.IsBorderEnabledChanged);
this.IsAreaCorrectionEnabledChangedCommand = new VCommand(this.IsAreaCorrectionEnabledChanged); this.IsAreaCorrectionEnabledChangedCommand = new VCommand(this.IsAreaCorrectionEnabledChanged);
this.SaveAlgorithmConfigCommand = new VCommand(this.SaveAlgorithmConfig); this.SaveAlgorithmConfigCommand = new VCommand(this.SaveAlgorithmConfig);
this.CenterModeMoveToCenterCommand = new VCommand(this.CenterModeMoveToCenter);
} }
/// <summary> /// <summary>
...@@ -138,9 +137,6 @@ namespace VIZ.H2V.Module ...@@ -138,9 +137,6 @@ namespace VIZ.H2V.Module
// 停止3D鼠标更新 // 停止3D鼠标更新
this.ManualController.ClipBoxSmooth.IsEnabled = false; this.ManualController.ClipBoxSmooth.IsEnabled = false;
// 重置自动移动状态
this.ManualController.ResetAutoMoving();
// 如果之前的模式为居中模式,那么记录居中模式的裁切框位置 // 如果之前的模式为居中模式,那么记录居中模式的裁切框位置
if (this.StrategyMode == AlgorithmStrategyMode.center_mode) if (this.StrategyMode == AlgorithmStrategyMode.center_mode)
{ {
...@@ -248,24 +244,13 @@ namespace VIZ.H2V.Module ...@@ -248,24 +244,13 @@ namespace VIZ.H2V.Module
/// <summary> /// <summary>
/// 移动裁切框至X /// 移动裁切框至X
/// </summary> /// </summary>
/// <remarks>
/// 切换至居中模式时使用
/// </remarks>
/// <param name="targetX">目标X</param> /// <param name="targetX">目标X</param>
public void MoveClipBoxTo(double targetX) public void MoveClipBoxTo(double targetX)
{ {
NDIView view = this.GetView<NDIView>(); this.ManualController.MoveTo(targetX);
if (view == null)
{
this.IsCenterModeMoveToCenterEnabled = true;
return;
}
VideoRenderInfo renderInfo = view.video.GetRenderInfo();
if (renderInfo == null || renderInfo.Frame == null)
{
this.IsCenterModeMoveToCenterEnabled = true;
return;
}
this.ManualController.MoveTo(0, renderInfo.Frame.Width, targetX);
} }
/// <summary> /// <summary>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment