This commit is contained in:
tanglong 2025-09-16 16:12:15 +08:00
parent 0cdfe7c23d
commit f0662fbda7
2 changed files with 36 additions and 10 deletions

View File

@ -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
{
/// <summary>横坐标归一化0~1相对于视频显示宽度</summary>
public double XNorm { get; set; }
/// <summary>纵坐标归一化0~1相对于视频显示高度</summary>
public double YNorm { get; set; }
/// <summary>圆半径,可选,单位像素</summary>
public double Radius { get; set; }
}
}

View File

@ -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)
@ -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
}
/// <summary>
/// 添加带渐变光的圆圈
/// 添加带渐变光的圆圈(中心红色,边缘蓝色)
/// </summary>
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);