update:立定跳远

This commit is contained in:
ltx 2025-11-28 09:12:46 +08:00
parent ec7b800c26
commit 1c1b0cce0d
17 changed files with 335 additions and 110 deletions

View File

@ -18,12 +18,10 @@
<!-- 2. 你的自定义资源 --> <!-- 2. 你的自定义资源 -->
<!-- 字体 --> <!-- 字体 -->
<FontFamily x:Key="AppFont">pack://application:,,,/YourApp;component/Resources/Fonts/#MyFontFamily</FontFamily>
<!-- 文本样式 --> <!-- 文本样式 -->
<Style TargetType="TextBlock" BasedOn="{StaticResource {x:Type TextBlock}}"> <Style TargetType="TextBlock" BasedOn="{StaticResource {x:Type TextBlock}}">
<Setter Property="FontFamily" Value="{StaticResource AppFont}"/> <!--<Setter Property="Foreground" Value="#333333"/>-->
<Setter Property="Foreground" Value="#333333"/> <Setter Property="FontFamily" Value="./Resoures/Fonts/myFontFamily"/>
<Setter Property="FontSize" Value="14"/> <Setter Property="FontSize" Value="14"/>
</Style> </Style>

View File

@ -1,16 +1,17 @@
using AiSportsMicrospaceDB.DBContext; using AiSportsMicrospaceDB.DBContext;
using Microsoft.Data.Sqlite;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Hosting;
using Microsoft.ML.Runtime; using Microsoft.ML.Runtime;
using System.Configuration; using System.Configuration;
using System.Data; using System.Data;
using System.IO; using System.IO;
using System.Windows; using System.Windows;
using Wpf_AiSportsMicrospace.Views;
using Yztob.AiSports.Common; using Yztob.AiSports.Common;
using Yztob.AiSports.Common.Implement; using Yztob.AiSports.Common.Implement;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using Wpf_AiSportsMicrospace.Views;
namespace Wpf_AiSportsMicrospace; namespace Wpf_AiSportsMicrospace;
@ -102,7 +103,6 @@ public partial class App : Application
TopPoint2 = new AiSportsMicrospaceDB.Entities.Point { X = 1498, Y = 730 }, TopPoint2 = new AiSportsMicrospaceDB.Entities.Point { X = 1498, Y = 730 },
TopPoint3 = new AiSportsMicrospaceDB.Entities.Point { X = 1689, Y = 724 }, TopPoint3 = new AiSportsMicrospaceDB.Entities.Point { X = 1689, Y = 724 },
BottomPoint1 = new AiSportsMicrospaceDB.Entities.Point { X = 191, Y = 918 }, BottomPoint1 = new AiSportsMicrospaceDB.Entities.Point { X = 191, Y = 918 },
BottomPoint2 = new AiSportsMicrospaceDB.Entities.Point { X = 1516, Y = 918 },
BottomPoint3 = new AiSportsMicrospaceDB.Entities.Point { X = 1722, Y = 909 }, BottomPoint3 = new AiSportsMicrospaceDB.Entities.Point { X = 1722, Y = 909 },
}); });
db.SaveChanges(); db.SaveChanges();
@ -129,9 +129,8 @@ public partial class App : Application
try try
{ {
// 使用原始SQL检查表是否存在 // 使用原始SQL检查表是否存在
var result = dbContext.Database.ExecuteSqlRaw(@" var sql = "SELECT count(*) FROM sqlite_master WHERE type='table' AND name=@name";
SELECT count(*) FROM sqlite_master var result = dbContext.Database.ExecuteSqlRaw(sql, new SqliteParameter("@name", name));
WHERE type='table' AND name='JumpLongPoints'");
return result > 0; return result > 0;
} }
catch catch

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 123 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 502 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 259 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 417 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 75 KiB

View File

@ -63,7 +63,7 @@
/> />
</Grid> </Grid>
<Image <Image
gif:ImageBehavior.AnimatedSource="/Resources/Img/Album/leight.gif" gif:ImageBehavior.AnimatedSource="/Resources/Img/Album/leight.gif"
@ -93,22 +93,58 @@
<Border CornerRadius="10" Width="420" Height="130" Background="#FFF"> <Border CornerRadius="10" Width="420" Height="130" Background="#FFF">
<Grid HorizontalAlignment="Center" hc:BorderElement.CornerRadius="10" VerticalAlignment="Center" Width="420" Height="130" > <Grid HorizontalAlignment="Center" hc:BorderElement.CornerRadius="10" VerticalAlignment="Center" Width="420" Height="130" >
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<TextBlock Text="请输入管理员密码:" FontSize="16" Margin="12" Grid.Row="0"/>
<hc:PasswordBox x:Name="AdminPasswordBox" Grid.Row="1" Margin="12,4,12,0" FontSize="16" KeyDown="AdminPasswordBox_KeyDown"/>
<TextBlock Text="请输入管理员密码:" FontSize="16" Margin="12" Grid.Row="0"/>
<hc:PasswordBox x:Name="AdminPasswordBox" Grid.Row="1" Margin="12,4,12,0" FontSize="16" KeyDown="AdminPasswordBox_KeyDown"/>
<StackPanel Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Right" Margin="12"> <StackPanel Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Right" Margin="12">
<RadioButton Style="{DynamicResource RadioGroupItemSingle}" Content="取消" x:Name="AdminCancelButton" Click="AdminCancelButton_Click" /> <RadioButton Style="{DynamicResource RadioGroupItemSingle}" Content="取消" x:Name="AdminCancelButton" Click="AdminCancelButton_Click" />
<hc:ButtonGroup Margin="30,0,0,0" Orientation="Vertical" Style="{StaticResource ButtonGroupSolid}"> <RadioButton Margin="10,0" Style="{StaticResource RadioButtonSameAsButtonPrimary}" Content="确定" x:Name="AdminOkButton" Click="AdminOkButton_Click"/>
<RadioButton Content="确定" IsChecked="True" x:Name="AdminOkButton" Click="AdminOkButton_Click"/> </StackPanel>
</hc:ButtonGroup> </Grid>
</StackPanel> </Border>
</Grid> </Grid>
<!-- 密码弹窗 -->
<Grid x:Name="SetDialogGrid" Visibility="Hidden" Background="#80000000">
<Border CornerRadius="10" Width="420" Height="330" Background="#FFF">
<Grid HorizontalAlignment="Center" hc:BorderElement.CornerRadius="10" VerticalAlignment="Top" Width="420" >
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBlock Text="基础配置" FontSize="18" Margin="12" FontWeight="Bold" Grid.Row="0"/>
<TextBlock Text="*重新配置摄像头后请ping测试通过再保存" FontSize="10" Margin="30,34,10,5" Foreground="red" Grid.RowSpan="1"/>
<hc:TextBox hc:InfoElement.TitlePlacement="Left" hc:InfoElement.Title="摄像头IP:" Width="400" Text="172.17.30.64" Grid.Row="2" x:Name="host" />
<hc:TextBox hc:InfoElement.TitlePlacement="Left" hc:InfoElement.Title="账号:" Width="400" Text="admin" Grid.Row="3" Margin="0,15" x:Name="name"/>
<hc:TextBox hc:InfoElement.TitlePlacement="Left" hc:InfoElement.Title="密码:" Width="400" Text="yd708090" Grid.Row="4" x:Name="password" />
<StackPanel Grid.Row="7" Orientation="Horizontal" HorizontalAlignment="Right" Margin="12">
<RadioButton Margin="0,0,220,0" Style="{DynamicResource RadioButtonSameAsButtonPrimary}" Content="Ping" Click="Ping_Click" />
<RadioButton Style="{DynamicResource RadioGroupItemSingle}" Content="取消" x:Name="SetCancelButton" Click="SetCancelButton_Click" />
<RadioButton Margin="10,0" Style="{StaticResource RadioButtonSameAsButtonPrimary}" Content="保存" Foreground="#fff" x:Name="SetOkButton1" Click="SetOkButton_Click"/>
</StackPanel>
<TextBlock Text="其他配置" FontSize="18" Margin="12,30,0,0" FontWeight="Bold" Grid.Row="8"/>
<StackPanel Grid.Row="9" Orientation="Horizontal" HorizontalAlignment="Center" Margin="12">
<RadioButton Style="{DynamicResource RadioButtonSameAsButtonPrimary}" Foreground="#fff" Content="多人跳绳" Click="GoRopeSet" />
<RadioButton Margin="30,0,0,0" Style="{StaticResource RadioButtonSameAsButtonPrimary}" Foreground="#fff" Content="立定跳远" Click="GoLongSet"/>
</StackPanel>
</Grid>
</Border> </Border>
</Grid> </Grid>
</Grid> </Grid>

View File

@ -1,4 +1,8 @@
using Microsoft.ML.Runtime; using AiSportsMicrospaceDB.DBContext;
using AiSportsMicrospaceDB.Entities;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.ML.Runtime;
using System; using System;
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.Collections.Generic; using System.Collections.Generic;
@ -7,6 +11,7 @@ using System.ComponentModel;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Net.NetworkInformation;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows; using System.Windows;
@ -77,6 +82,7 @@ namespace Wpf_AiSportsMicrospace
_mainWin.HumanFrameUpdated += OnHumanFrameUpdated; _mainWin.HumanFrameUpdated += OnHumanFrameUpdated;
_mainWin.WebcamClient.StartExtract(); _mainWin.WebcamClient.StartExtract();
Utils.PreloadGifs(); Utils.PreloadGifs();
Load_Base();
} }
private void Home_Unloaded(object sender, RoutedEventArgs e) private void Home_Unloaded(object sender, RoutedEventArgs e)
{ {
@ -203,8 +209,7 @@ namespace Wpf_AiSportsMicrospace
// 密码正确,打开管理员页面(已有 AdminWindow 或按需改为导航) // 密码正确,打开管理员页面(已有 AdminWindow 或按需改为导航)
try try
{ {
var mainWin = Application.Current.MainWindow as Main; SetDialogGrid.Visibility = Visibility.Visible;
mainWin.SwitchPageWithMaskAnimation(new LongSttting(), true);
//var adminWin = new Views.AdminWindow(); //var adminWin = new Views.AdminWindow();
//adminWin.Owner = Window.GetWindow(this); //adminWin.Owner = Window.GetWindow(this);
//adminWin.Show(); //adminWin.Show();
@ -244,5 +249,92 @@ namespace Wpf_AiSportsMicrospace
e.Handled = true; e.Handled = true;
} }
} }
private void SetCancelButton_Click(object sender, RoutedEventArgs e)
{
SetDialogGrid.Visibility = Visibility.Collapsed;
}
//加载配置
private async void Load_Base()
{
var app = (App)Application.Current;
using var scope = App.AppHost.Services.CreateScope();
var db = scope.ServiceProvider.GetRequiredService<AppDbContext>();
var baseData = await db.BasicConfig.FirstOrDefaultAsync();
if (baseData == null)
{
baseData = new BasicConfig { Id = 1 , Host = host.Text , UserName = name.Text , Password = password.Text};
db.BasicConfig.Add(baseData);
}
else
{
host.Text = baseData.Host;
name.Text = baseData.UserName;
password.Text = baseData.Password;
}
}
//保存基本配置
private async void SetOkButton_Click(object sender, RoutedEventArgs e)
{
var app = (App)Application.Current;
using var scope = App.AppHost.Services.CreateScope();
var db = scope.ServiceProvider.GetRequiredService<AppDbContext>();
var baseData = await db.BasicConfig.FirstOrDefaultAsync();
if (baseData == null)
{
baseData = new BasicConfig { Id = 1 };
db.BasicConfig.Add(baseData);
}
baseData.Host = host.Text;
baseData.UserName = name.Text;
baseData.Password = password.Text;
db.SaveChanges();
HandyControl.Controls.MessageBox.Show("保存成功!", "提示");
SetDialogGrid.Visibility = Visibility.Collapsed;
}
//多人跳绳
private void GoRopeSet(object sender, RoutedEventArgs e)
{
var app = (App)Application.Current;
using var scope = App.AppHost.Services.CreateScope();
var db = scope.ServiceProvider.GetRequiredService<AppDbContext>();
var mainWindow = new MainWindow(db);
mainWindow.Show();
}
//跳远
private void GoLongSet(object sender, RoutedEventArgs e)
{
var mainWin = Application.Current.MainWindow as Main;
mainWin.SwitchPageWithMaskAnimation(new LongSttting(), true);
}
private void Ping_Click(object sender, RoutedEventArgs e)
{
//var config = _context.BasicConfig.FirstOrDefault();
//if (config != null)
//{
// //var ip = config.Ip;
//}
var host = this.host.Text.Trim();
if (string.IsNullOrWhiteSpace(host))
{
this.ShowError("相机主机地址/IP不能为空。");
return;
}
var pinger = new Ping();
var reply = pinger.Send(host, 10);
if (reply.Status == IPStatus.Success)
this.ShowInformation("与相机通信正常。");
else
this.ShowError($"与相机通信失败,错误:{reply.Status}。");
}
} }
} }

View File

@ -5,11 +5,80 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Views.JumpLong" xmlns:local="clr-namespace:Views.JumpLong"
mc:Ignorable="d" mc:Ignorable="d"
xmlns:gif="http://wpfanimatedgif.codeplex.com" xmlns:hc="https://handyorg.github.io/handycontrol"
Height="1080" Width="1920" Loaded="UserControl_Loaded" Unloaded="UserControl_Unloaded"> Height="1080" Width="1920" Loaded="UserControl_Loaded" Unloaded="UserControl_Unloaded">
<Grid> <Grid>
<Grid Height="1080" Width="1920" x:Name="userBox"> <Grid.Background>
<ImageBrush ImageSource="/Resources/Img/test_img/test_home_bg.png" Stretch="UniformToFill"/>
</Grid.Background>
<Grid Height="1080" Width="1920" x:Name="userBox" >
<Image Source="/Resources/Img/test_img/jump_long/title.png" HorizontalAlignment="Center" VerticalAlignment="Top" Width="615" Margin="0,0,0,0"/>
<Image Source="/Resources/Img/test_img/jump_long/mat.png" HorizontalAlignment="Center" VerticalAlignment="Top" Width="1190" Margin="0,600,0,0"/>
<Image Source="/Resources/Img/test_img/jump_long/people.png" HorizontalAlignment="Left" VerticalAlignment="Top" Width="244" Margin="1278,282,0,0" Height="458"/>
<Label x:Name="sportCounts" Height="50" Width="200" HorizontalAlignment="Left" BorderBrush="Black" BorderThickness="2"></Label> <Label x:Name="sportCounts" Height="50" Width="200" HorizontalAlignment="Left" BorderBrush="Black" BorderThickness="2"></Label>
<Label x:Name="sportTimes" Height="50" Width="200" HorizontalAlignment="Center" BorderBrush="Black" BorderThickness="2" ></Label> <Label x:Name="sportTimes" Height="50" Width="200" HorizontalAlignment="Center" BorderBrush="Black" BorderThickness="2" ></Label>
<Grid Width="1920" Height="1080" Background="#80000000" x:Name="TipBox" Opacity="0">
<Image Source="/Resources/Img/test_img/jump_long/tip.png" HorizontalAlignment="Center" VerticalAlignment="Center" Width="1416" Margin="0,0,0,-700"/>
</Grid>
<!--成绩-->
<Grid x:Name="RankingGrid" Margin="0,0,0,0" Height="1080" Width="1920" Opacity="0">
<Image
Source="/Resources/Img/test_img/one_rope/finish_img/finish_bg.png"
HorizontalAlignment="Center"
VerticalAlignment="Top"
Width="1920"
Height="1080"
/>
<Grid Width="1380" Height="697" HorizontalAlignment="Center" VerticalAlignment="Top" Margin="0,180,0,0" x:Name="ScoreGrid">
<!--<Border Background="#FEDE50" CornerRadius="20"/>-->
<Image Source="/Resources/Img/test_img/jump_long/head_top.png" HorizontalAlignment="Center" VerticalAlignment="Top" Height="110" Margin="0,-104,0,0" />
<Image Source="/Resources/Img/test_img/jump_long/win_bg.png" HorizontalAlignment="Center" VerticalAlignment="Center" Width="1530" Height="770" />
<Border Background="#ff8600" CornerRadius="20" Width="300" Height="90" HorizontalAlignment="Center" VerticalAlignment="Top" Margin="0,20,0,0" >
<Grid>
<TextBlock Text="跳远成绩" FontSize="22" TextAlignment="Center" Padding="0,10,0,0" FontWeight="Bold" Foreground="#80ffffff" />
<TextBlock Text="165cm" FontSize="49" TextAlignment="Center" Padding="0,35,0,0" FontWeight="Bold" Foreground="#fff" FontStyle="Italic" />
</Grid>
</Border>
<StackPanel Margin="60,130,50,30" Orientation="Horizontal">
<Grid Width="600">
<Border Background="#fff" CornerRadius="20"></Border>
<Border Background="#e54229" CornerRadius="20 ,20,0,0" VerticalAlignment="Top" Padding="0,15,0,0" Width="600" Height="60">
<TextBlock TextAlignment="Center" Width="600" FontWeight="Bold" Text="违规记录" Foreground="#fff" FontSize="26"/>
</Border>
<Border Background="#fcece9" CornerRadius="10" VerticalAlignment="Top" Padding="0,12,0,0" Width="580" Height="50" Margin="0,70,0,0">
<TextBlock TextAlignment="Center" Width="600" FontWeight="Bold" Text="无" Foreground="#e54229" FontSize="22"/>
</Border>
<Border Background="#fcece9" CornerRadius="10" VerticalAlignment="Top" Padding="0,12,0,0" Width="580" Height="50" Margin="0,130,0,0">
<TextBlock TextAlignment="Center" Width="600" FontWeight="Bold" Text="无" Foreground="#e54229" FontSize="22"/>
</Border>
</Grid>
<Grid Width="640" Margin="50,0,0,0">
<Image Source="/Resources/Img/test_img/jump_long/top.png" VerticalAlignment="Top" Height="500"/>
<Image Source="/Resources/Img/test_img/jump_long/bottom.png" VerticalAlignment="Bottom" Height="500" />
<TextBlock Text="380°" FontSize="55" FontWeight="Bold" FontStyle="Italic" Margin="54,81,-54,-81" />
<TextBlock Text="2" FontSize="55" FontWeight="Bold" FontStyle="Italic" Margin="432,81,-432,-81" />
<TextBlock Text="105cm" FontSize="55" FontWeight="Bold" FontStyle="Italic" Margin="54,373,-54,-373" />
<TextBlock Text="00:11" FontSize="55" FontWeight="Bold" FontStyle="Italic" Margin="397,373,-397,-373" />
</Grid>
</StackPanel>
</Grid>
<Grid Margin="0,0,0,50" VerticalAlignment="Bottom" Height="182" Width="340" >
<Image Source="/Resources/Img/Album/change_left.png" HorizontalAlignment="Left" VerticalAlignment="Top" Width="330" Margin="0,103,0,0" />
<Image gif:ImageBehavior.AnimatedSource="/Resources/Img/Album/3.gif" gif:ImageBehavior.RepeatBehavior="Forever" gif:ImageBehavior.AnimateInDesignMode="True" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="-20,10,30,20" />
</Grid>
</Grid>
</Grid> </Grid>
</Grid> </Grid>
</UserControl> </UserControl>

View File

@ -1,5 +1,7 @@
using Dto; using AiSportsMicrospaceDB.DBContext;
using Dto;
using Enum; using Enum;
using Microsoft.Extensions.DependencyInjection;
using System; using System;
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.Collections.Generic; using System.Collections.Generic;
@ -113,7 +115,6 @@ namespace Views.JumpLong
// 获取项目根目录 // 获取项目根目录
string projectRoot = System.IO.Path.Combine(AppContext.BaseDirectory, @"..\..\.."); string projectRoot = System.IO.Path.Combine(AppContext.BaseDirectory, @"..\..\..");
string musicPath = System.IO.Path.Combine(projectRoot, "Resources", "Music", musicFileName); string musicPath = System.IO.Path.Combine(projectRoot, "Resources", "Music", musicFileName);
string imgPath = System.IO.Path.Combine(projectRoot, "Resources", "Img", "提示图.png");
if (!File.Exists(musicPath)) if (!File.Exists(musicPath))
{ {
@ -123,31 +124,15 @@ namespace Views.JumpLong
_mediaPlayer.Open(new Uri(musicPath, UriKind.Absolute)); _mediaPlayer.Open(new Uri(musicPath, UriKind.Absolute));
ShowCenterTip(imgPath, TimeSpan.FromSeconds(3)); ShowCenterTip(TimeSpan.FromSeconds(3));
// 监听播放完成事件 // 监听播放完成事件
_mediaPlayer.MediaEnded += MediaPlayer_MediaEnded; _mediaPlayer.MediaEnded += MediaPlayer_MediaEnded;
//_mainWin.WebcamClient.StartExtract(); //_mainWin.WebcamClient.StartExtract();
_mediaPlayer.Play(); _mediaPlayer.Play();
} }
private void ShowCenterTip(string imagePath, TimeSpan duration) private void ShowCenterTip(TimeSpan duration)
{ {
var tipImage = new Image
{
Source = new BitmapImage(new Uri(imagePath, UriKind.Absolute)),
HorizontalAlignment = HorizontalAlignment.Center,
VerticalAlignment = VerticalAlignment.Center,
Opacity = 0,
Margin = new Thickness(0, -100, 0, 0),
};
// 增加图片的大小,调整比例
tipImage.Width = 1920 * 0.9; // 宽度为 Canvas 宽度的 90%
tipImage.Height = 1080 * 0.6; // 高度为 Canvas 高度的 60%
// 将图片添加到 Overlay Canvas
userBox.Children.Add(tipImage);
// 渐变出现动画 // 渐变出现动画
var fadeInAnimation = new DoubleAnimation var fadeInAnimation = new DoubleAnimation
{ {
@ -155,7 +140,7 @@ namespace Views.JumpLong
To = 1, To = 1,
Duration = TimeSpan.FromSeconds(1.5) Duration = TimeSpan.FromSeconds(1.5)
}; };
tipImage.BeginAnimation(UIElement.OpacityProperty, fadeInAnimation); TipBox.BeginAnimation(UIElement.OpacityProperty, fadeInAnimation);
// 定时移除,并且渐变消失 // 定时移除,并且渐变消失
Task.Delay(duration).ContinueWith(_ => Task.Delay(duration).ContinueWith(_ =>
@ -169,13 +154,8 @@ namespace Views.JumpLong
To = 0, To = 0,
Duration = TimeSpan.FromSeconds(1.5) Duration = TimeSpan.FromSeconds(1.5)
}; };
tipImage.BeginAnimation(UIElement.OpacityProperty, fadeOutAnimation); TipBox.BeginAnimation(UIElement.OpacityProperty, fadeOutAnimation);
// 完成后移除图片
fadeOutAnimation.Completed += (s, e) =>
{
userBox.Children.Remove(tipImage);
};
}); });
}); });
} }
@ -190,9 +170,11 @@ namespace Views.JumpLong
var ts = TimeSpan.FromSeconds(times); var ts = TimeSpan.FromSeconds(times);
Dispatcher.BeginInvoke(() => Dispatcher.BeginInvoke(() =>
{ {
sportCounts.Content = _sport.GetFormatCounts(); //counts.ToString(); //sportCounts.Content = _sport.GetFormatCounts(); //counts.ToString();
sportTimes.Content = _sport.GetFormatTimes();//ts.ToString(@"mm\'ss\"""); //sportTimes.Content = _sport.GetFormatTimes();//ts.ToString(@"mm\'ss\""");
count.Text = _sport.GetFormatCounts();
time.Text = _sport.GetFormatTimes();
ShowRope();
//触发停止 //触发停止
if (!_sport.IsCounting) if (!_sport.IsCounting)
{ {
@ -201,8 +183,29 @@ namespace Views.JumpLong
} }
}); });
} }
private bool ReactangleCalibrating(int frameWidth, int frameHeight)
//展示成绩
private void ShowRope()
{ {
// 渐变出现动画
var fadeInAnimation = new DoubleAnimation
{
From = 0,
To = 1,
Duration = TimeSpan.FromSeconds(1.5)
};
RankingGrid.BeginAnimation(UIElement.OpacityProperty, fadeInAnimation);
}
private bool ReactangleCalibrating(int frameWidth, int frameHeight)
{
var mainWin = Application.Current.MainWindow as Main;
var app = (App)Application.Current;
using var scope = App.AppHost.Services.CreateScope();
var db = scope.ServiceProvider.GetRequiredService<AppDbContext>();
var points = db.JumpLongPoints.FirstOrDefault();
var boxes = new List<BoundingBox>() var boxes = new List<BoundingBox>()
{ {
new BoundingBox(){ new BoundingBox(){
@ -212,10 +215,10 @@ namespace Views.JumpLong
Key = "begin" Key = "begin"
}, },
MaskLayer = new MaskLayer(){ MaskLayer = new MaskLayer(){
Contours = new List<SixLabors.ImageSharp.PointF>(){ Contours = [
new SixLabors.ImageSharp.PointF(1722, 909), new ((float)points.BottomPoint3.X, (float)points.BottomPoint3.Y),
new SixLabors.ImageSharp.PointF(1689, 724), new ((float)points.TopPoint3.X, (float)points.TopPoint3.Y),
} ]
} }
}, },
new BoundingBox(){ new BoundingBox(){
@ -225,10 +228,10 @@ namespace Views.JumpLong
Key = "end" Key = "end"
}, },
MaskLayer = new MaskLayer(){ MaskLayer = new MaskLayer(){
Contours = new List<SixLabors.ImageSharp.PointF>(){ Contours = [
new SixLabors.ImageSharp.PointF(1516, 918), new((float)points.BottomPoint2.X, (float)points.BottomPoint2.Y),
new SixLabors.ImageSharp.PointF(1498, 730) new((float)points.TopPoint2.X, (float)points.TopPoint2.Y),
} ]
} }
} }
}; };
@ -244,10 +247,10 @@ namespace Views.JumpLong
}, },
MaskLayer = new MaskLayer() MaskLayer = new MaskLayer()
{ {
Contours = new List<SixLabors.ImageSharp.PointF>(){ Contours = [
new SixLabors.ImageSharp.PointF(191, 918), new ((float)points.BottomPoint1.X, (float)points.BottomPoint1.Y),
new SixLabors.ImageSharp.PointF(245, 741) new ((float)points.TopPoint1.X, (float)points.TopPoint1.Y),
} ]
} }
}); });

View File

@ -57,10 +57,11 @@
Canvas.Left="1722" Canvas.Top="909" Tag="BottomPoint3"/> Canvas.Left="1722" Canvas.Top="909" Tag="BottomPoint3"/>
<!-- 坐标显示标签 --> <!-- 坐标显示标签 -->
<hc:Tag ShowCloseButton="False" IsSelected="True" x:Name="CoordinateDisplay" Content="你是" <hc:Tag ShowCloseButton="False" IsSelected="True" x:Name="CoordinateDisplay" Content="位置点"
Padding="18,0" FontSize="14" Visibility="Visible"/> Padding="18,0" FontSize="14" Visibility="Visible"/>
</Canvas> </Canvas>
<Button Content="返回首页" Click="Label_MouseDown" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="20" Width="100" Height="30" />
<!-- 控制面板 --> <!-- 控制面板 -->
<StackPanel HorizontalAlignment="Right" VerticalAlignment="Top" Margin="20" Width="200"> <StackPanel HorizontalAlignment="Right" VerticalAlignment="Top" Margin="20" Width="200">
<Border Background="#F0F0F0" Padding="15" CornerRadius="8"> <Border Background="#F0F0F0" Padding="15" CornerRadius="8">

View File

@ -51,7 +51,27 @@ namespace Wpf_AiSportsMicrospace.Views
InitializeComponent(); InitializeComponent();
SetupDragEvents(); SetupDragEvents();
LoadPointsFromDatabase(); LoadPointsFromDatabase();
var _webcamClient = WebcamClient.CreateRTSP("172.17.30.64", "admin", "yd708090", 554u); LoadSetting();
}
private async void LoadSetting()
{
//加载本地配置信息
var app = (App)Application.Current;
using var scope = App.AppHost.Services.CreateScope();
var db = scope.ServiceProvider.GetRequiredService<AppDbContext>();
var BaseData = await db.BasicConfig.FirstOrDefaultAsync();
var host = "172.17.30.64";
var name = "admin";
var password = "yd708090";
if (BaseData != null) {
host = BaseData.Host;
name = BaseData.UserName;
password = BaseData.Password;
}
var _webcamClient = WebcamClient.CreateRTSP( host, name, password, 554u);
//处理抽帧回调 //处理抽帧回调
_webcamClient.OnExtractFrame += this.OnFrameExtracted; _webcamClient.OnExtractFrame += this.OnFrameExtracted;
@ -59,7 +79,6 @@ namespace Wpf_AiSportsMicrospace.Views
} }
private void Window_Loaded(object sender, RoutedEventArgs e) private void Window_Loaded(object sender, RoutedEventArgs e)
{ {
@ -112,41 +131,6 @@ namespace Wpf_AiSportsMicrospace.Views
_videoBitmap.AddDirtyRect(new Int32Rect(0, 0, bitmap.PixelWidth, bitmap.PixelHeight)); _videoBitmap.AddDirtyRect(new Int32Rect(0, 0, bitmap.PixelWidth, bitmap.PixelHeight));
_videoBitmap.Unlock(); _videoBitmap.Unlock();
}); });
//var actualPositions = new List<(double X, double Y)>
//{
// (290, 510),
// (500, 700),
// (810, 710),
// (120, 880),
// (350, 880),
// (660, 880)
//};
////判断是否出圈
//if (configService.ConfigDic.TryGetValue("JumpRope", out var obj) && obj is ConfigSet cfg)
//{
// for (int i = 0; i < actualPositions.Count && i < cfg.Points.Count; i++)
// {
// var (ax, ay) = actualPositions[i];
// var pointCfg = cfg.Points[i];
// if (!IsInsideCircle(ax, ay, pointCfg))
// {
// Console.WriteLine($"⚠️ 学生{i + 1} 已经出圈!(坐标 {ax},{ay}");
// }
// else
// {
// Console.WriteLine($"✅ 学生{i + 1} 在圈内。");
// }
// }
//}
//可以进一步进行人体识别等
//var humanResult = await Task.Run(() => _humanPredictor.Predicting(buffer, frame.Number));
//var human = humanResult?.Humans?.FirstOrDefault();
//_detectQueue.Enqueue(frame.Number, human, null);
} }
private void SetupDragEvents() private void SetupDragEvents()
@ -411,5 +395,13 @@ namespace Wpf_AiSportsMicrospace.Views
pointsData = defaultPoints; pointsData = defaultPoints;
await db.SaveChangesAsync(); await db.SaveChangesAsync();
} }
private void Label_MouseDown(object sender, RoutedEventArgs e)
{
var mainWin = Application.Current.MainWindow as Main;
var newPage = new Home();
mainWin?.SwitchPageWithMaskAnimation(newPage, true);
}
} }
} }

View File

@ -66,6 +66,14 @@
<None Remove="Resources\Img\play_img\play_jump.png" /> <None Remove="Resources\Img\play_img\play_jump.png" />
<None Remove="Resources\Img\play_img\play_music.png" /> <None Remove="Resources\Img\play_img\play_music.png" />
<None Remove="Resources\Img\play_img\play_vs.png" /> <None Remove="Resources\Img\play_img\play_vs.png" />
<None Remove="Resources\Img\test_img\jump_long\bottom.png" />
<None Remove="Resources\Img\test_img\jump_long\head_top.png" />
<None Remove="Resources\Img\test_img\jump_long\mat.png" />
<None Remove="Resources\Img\test_img\jump_long\people.png" />
<None Remove="Resources\Img\test_img\jump_long\tip.png" />
<None Remove="Resources\Img\test_img\jump_long\title.png" />
<None Remove="Resources\Img\test_img\jump_long\top.png" />
<None Remove="Resources\Img\test_img\jump_long\win_bg.png" />
<None Remove="Resources\Img\test_img\one_rope\finish_img\1.png" /> <None Remove="Resources\Img\test_img\one_rope\finish_img\1.png" />
<None Remove="Resources\Img\test_img\one_rope\finish_img\2.png" /> <None Remove="Resources\Img\test_img\one_rope\finish_img\2.png" />
<None Remove="Resources\Img\test_img\one_rope\finish_img\3.png" /> <None Remove="Resources\Img\test_img\one_rope\finish_img\3.png" />
@ -104,6 +112,24 @@
</Content> </Content>
</ItemGroup> </ItemGroup>
<ItemGroup>
<Resource Include="Resources\Img\test_img\jump_long\bottom.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
<Resource Include="Resources\Img\test_img\jump_long\head_top.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
<Resource Include="Resources\Img\test_img\jump_long\mat.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
<Resource Include="Resources\Img\test_img\jump_long\people.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
<Resource Include="Resources\Img\test_img\jump_long\tip.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
</ItemGroup>
<ItemGroup> <ItemGroup>
<Resource Include="Resources\Img\Album\leight.gif"> <Resource Include="Resources\Img\Album\leight.gif">
<CopyToOutputDirectory>Always</CopyToOutputDirectory> <CopyToOutputDirectory>Always</CopyToOutputDirectory>
@ -323,6 +349,15 @@
<Resource Include="Resources\Img\play_img\play_vs.png"> <Resource Include="Resources\Img\play_img\play_vs.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory> <CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource> </Resource>
<Resource Include="Resources\Img\test_img\jump_long\title.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
<Resource Include="Resources\Img\test_img\jump_long\top.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
<Resource Include="Resources\Img\test_img\jump_long\win_bg.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
<Resource Include="Resources\Img\test_img\one_rope\finish_img\1.png"> <Resource Include="Resources\Img\test_img\one_rope\finish_img\1.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory> <CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource> </Resource>