diff --git a/Wpf_AiSportsMicrospace/JumpRopePoint.cs b/Wpf_AiSportsMicrospace/JumpRopePoint.cs new file mode 100644 index 0000000..14d20f1 --- /dev/null +++ b/Wpf_AiSportsMicrospace/JumpRopePoint.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Wpf_AiSportsMicrospace +{ + public class JumpRopePoint + { + /// 横坐标归一化(0~1,相对于视频显示宽度) + public double XNorm { get; set; } + + /// 纵坐标归一化(0~1,相对于视频显示高度) + public double YNorm { get; set; } + + /// 圆半径,可选,单位像素 + public double Radius { get; set; } + } + +} diff --git a/Wpf_AiSportsMicrospace/MainWindow.xaml.cs b/Wpf_AiSportsMicrospace/MainWindow.xaml.cs index 3f40171..46030dd 100644 --- a/Wpf_AiSportsMicrospace/MainWindow.xaml.cs +++ b/Wpf_AiSportsMicrospace/MainWindow.xaml.cs @@ -76,9 +76,9 @@ public partial class MainWindow : Window base.OnClosed(e); // 释放 WriteableBitmap - _videoBitmap = null; - videoImage.Source = null; - overlayCanvas = null; + //_videoBitmap = null; + //videoImage.Source = null; + //overlayCanvas = null; } private void sportList_SelectionChanged(object sender, SelectionChangedEventArgs e) @@ -185,6 +185,8 @@ public partial class MainWindow : Window // UI 线程显示 Application.Current.Dispatcher.Invoke(() => { + if (videoImage == null) return; + if (_videoBitmap == null || _videoBitmap.PixelWidth != bitmap.PixelWidth || _videoBitmap.PixelHeight != bitmap.PixelHeight) @@ -209,7 +211,7 @@ public partial class MainWindow : Window //}, System.Windows.Threading.DispatcherPriority.Loaded); }); - + //可以进一步进行人体识别等 //var humanResult = await Task.Run(() => _humanPredictor.Predicting(buffer, frame.Number)); @@ -249,10 +251,10 @@ public partial class MainWindow : Window overlayCanvas.Height = imgHeight; // 前排 3 人(近景) - double frontRadius = 40; + double frontRadius = 60; var frontPositions = new List<(double XNorm, double YNorm)> { - (0.2, 0.70), (0.5, 0.70), (0.8, 0.70) // 前排略高 + (0.2, 0.50), (0.5, 0.50), (0.8, 0.50) // 前排略高 }; foreach (var pos in frontPositions) @@ -263,7 +265,7 @@ public partial class MainWindow : Window } // 后排 4 人(远景,更靠下面,大一点) - double backRadius = 50; + double backRadius = 60; var backPositions = new List<(double XNorm, double YNorm)> { (0.1, 0.88), (0.35, 0.88), (0.65, 0.88), (0.9, 0.88) // 后排靠底 @@ -278,7 +280,7 @@ public partial class MainWindow : Window } /// - /// 添加带渐变光的圆圈 + /// 添加带渐变光的圆圈(中心红色,边缘蓝色) /// private void AddGlowEllipse(double centerX, double centerY, double radius, double opacity, Canvas canvas) { @@ -297,12 +299,15 @@ public partial class MainWindow : Window RadiusY = 0.5, GradientStops = new GradientStopCollection { - new GradientStop(Color.FromArgb(180, 255, 0, 0), 0), // 中心红色 - new GradientStop(Color.FromArgb(0, 255, 0, 0), 1) // 外部透明 + new GradientStop(Color.FromArgb(200, 255, 0, 0), 0.0), // 中心红 + new GradientStop(Color.FromArgb(150, 255, 0, 0), 0.4), // 中间仍是红 + new GradientStop(Color.FromArgb(180, 0, 128, 255), 0.7), // 边缘蓝 + new GradientStop(Color.FromArgb(0, 0, 128, 255), 1.0) // 最外透明 } } }; + // 定位到中心 Canvas.SetLeft(ellipse, centerX - radius); Canvas.SetTop(ellipse, centerY - radius / 2); canvas.Children.Add(ellipse);