- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
正如您在图片中看到的(链接在下面给出),当左手举起时,它会显示一个角度我想要的是。一个人应该握住他的 ARM 5 秒(在图像中显示的位置),如果这个人改变他的 ARM 位置(这意味着如果角度低于 70 度或高于 80 度)在 5 秒内,应显示一些消息以将 ARM 放回原位并重新启动计时器!
http://postimage.org/image/hpfl41nzp/
主窗口.xaml文件
<Window x:Class="shoulder_joint.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="511" Width="525" Loaded="Window_Loaded"
Closing="Window_Closing" >
<Grid Height="479" Width="510">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="6*" />
<ColumnDefinition Width="497*" />
</Grid.ColumnDefinitions>
<Image Height="479" HorizontalAlignment="Left" Name="frame_image" Stretch="Fill"
VerticalAlignment="Top" Width="503" Grid.Column="1" Grid.ColumnSpan="2" />
<Image Height="131" Margin="14,14,319,0" Name="Color_image" Stretch="Fill"
VerticalAlignment="Top" Grid.Column="2" />
</Grid>
</Window>
主窗口.xaml.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using Microsoft.Xna.Framework;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Microsoft.Kinect;
namespace shoulder_joint
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
bool flag = false;
angle angle1 = new angle();
Draw_joint draw = new Draw_joint();
int joint_thick =10;
private readonly Brush detect_brush = Brushes.GreenYellow;
private readonly Brush inferred_brush = Brushes.Indigo;
private readonly Pen detect_pen = new Pen( Brushes.Black,6);
private readonly Pen inferred_pen = new Pen (Brushes.DarkOliveGreen,2);
KinectSensor sensor;
Skeleton[] skelton;
int width =491;
int height =470;
DrawingGroup drawing_group;
DrawingImage draw_image;
byte[] color_pixel;
WriteableBitmap bitmap;
public MainWindow()
{
InitializeComponent();
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
foreach (var potential_sensor in KinectSensor.KinectSensors)
{
if (potential_sensor.Status == KinectStatus.Connected)
{
sensor = potential_sensor;
break;
}
}
sensor.ColorStream.Enable(ColorImageFormat.RgbResolution640x480Fps30);
sensor.SkeletonStream.Enable();
color_pixel = new byte [sensor.ColorStream.FramePixelDataLength];
bitmap = new WriteableBitmap(sensor.ColorStream.FrameWidth,
sensor.ColorStream.FrameHeight,96,96,PixelFormats.Bgr32,null);
Color_image.Source = bitmap;
drawing_group = new DrawingGroup();
draw_image = new DrawingImage(drawing_group);
frame_image.Source = draw_image;
sensor.SkeletonFrameReady += SensorSkeltonFrameReady;
sensor.ColorFrameReady += SensorColorFrameReady;
sensor.Start();
}
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
if (sensor != null)
{
sensor.Stop();
}
}
private void SensorColorFrameReady(object sender, ColorImageFrameReadyEventArgs e)
{
ColorImageFrame color_frame;
using (color_frame = e.OpenColorImageFrame())
{
if (color_frame != null)
{
color_frame.CopyPixelDataTo(color_pixel);
bitmap.WritePixels(new Int32Rect(0,
0,bitmap.PixelWidth,bitmap.PixelHeight),
this.color_pixel,
this.bitmap.PixelWidth* sizeof(int),
0);
}
}
}
private void SensorSkeltonFrameReady(object sender, SkeletonFrameReadyEventArgs e)
{
SkeletonFrame skelton_frame;
using (skelton_frame = e.OpenSkeletonFrame())
{
if (skelton_frame != null)
{
skelton = new Skeleton[skelton_frame.SkeletonArrayLength];
skelton_frame.CopySkeletonDataTo(skelton);
using (DrawingContext dc = drawing_group.Open())
{
dc.DrawRectangle(Brushes.Gray, null, new Rect(0, 0, width,
height));
if (skelton != null)
{
foreach (Skeleton skel in skelton)
{
if (skel.TrackingState == SkeletonTrackingState.Tracked)
{
this.find_pos_joints(skel, dc);
// this.angle_between(dc);
}
}
}
drawing_group.ClipGeometry = new RectangleGeometry(new
Rect(0,0,width,height));
}
}
}
}
private void find_pos_joints(Skeleton sk, DrawingContext draw_contex)
{
draw.Draw_joint1(sk, draw_contex, JointType.ShoulderCenter,
JointType.ShoulderRight,
JointType.ElbowRight,JointType.WristRight,
JointType.ShoulderLeft,JointType.ElbowLeft,JointType.WristLeft,
JointType.Head,JointType.HipCenter,JointType.HipLeft,
JointType.KneeLeft,JointType.AnkleLeft,
detect_brush,inferred_brush,joint_thick,inferred_pen,detect_pen,sensor);
angle1.angle_between_right_shoulder(sk,
draw_contex,JointType.Head,JointType.Spine ,JointType.ShoulderCenter,
JointType.ShoulderRight,JointType.ElbowRight,sensor);
angle1.angle_between_left_shoulder(sk, draw_contex, JointType.ShoulderCenter,
JointType.ShoulderLeft, JointType.ElbowLeft, sensor);
angle1.angle_between_left_leg(sk,
draw_contex,JointType.HipLeft,JointType.KneeLeft,JointType.AnkleLeft,sensor);
}
}
}
绘制联合类
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Kinect;
using System.Windows.Media;
namespace shoulder_joint
{
class Draw_joint
{
angle angle1 = new angle();
public void Draw_joint1(Skeleton sk1, DrawingContext dc1, JointType joint1,
JointType joint2,
JointType joint3, JointType joint4, JointType joint5, JointType joint6,
JointType joint7,
JointType joint8 ,JointType joint9,JointType joint100,JointType joint101,
JointType joint102
,Brush det_brush,
Brush infer_brush,int thick, Pen det_pen,Pen infer_pen,KinectSensor sensor)
{
Joint joint11 = sk1.Joints[joint1];
Joint joint22 = sk1.Joints[joint2];
Joint joint33 = sk1.Joints[joint3];
Joint joint44 = sk1.Joints[joint4];
Joint joint55 = sk1.Joints[joint5];
Joint joint66 = sk1.Joints[joint6];
Joint joint77 = sk1.Joints[joint7];
Joint joint88 = sk1.Joints[joint8];
Joint joint99 = sk1.Joints[joint9];
Joint joint10 = sk1.Joints[joint100];
Joint joint1011 = sk1.Joints[joint101];
Joint joint1022 = sk1.Joints[joint102];
if (joint11.TrackingState == JointTrackingState.Tracked &&
joint22.TrackingState == JointTrackingState.Tracked &&
joint33.TrackingState == JointTrackingState.Tracked &&
joint44.TrackingState == JointTrackingState.Tracked &&
joint55.TrackingState == JointTrackingState.Tracked &&
joint66.TrackingState == JointTrackingState.Tracked &&
joint77.TrackingState == JointTrackingState.Tracked &&
joint88.TrackingState == JointTrackingState.Tracked &&
joint99.TrackingState == JointTrackingState.Tracked &&
joint10.TrackingState == JointTrackingState.Tracked &&
joint1011.TrackingState == JointTrackingState.Tracked &&
joint1022.TrackingState == JointTrackingState.Tracked
)
{
dc1.DrawEllipse(det_brush, det_pen, angle1.point_toScreen(joint11.Position,
sensor), thick, thick);
dc1.DrawEllipse(det_brush, det_pen, angle1.point_toScreen(joint22.Position,
sensor), thick, thick);
dc1.DrawEllipse(det_brush, det_pen, angle1.point_toScreen(joint33.Position,
sensor), thick, thick);
dc1.DrawEllipse(det_brush, det_pen, angle1.point_toScreen(joint44.Position,
sensor), thick, thick);
dc1.DrawEllipse(det_brush, det_pen, angle1.point_toScreen(joint55.Position,
sensor), thick, thick);
dc1.DrawEllipse(det_brush, det_pen, angle1.point_toScreen(joint66.Position,
sensor), thick, thick);
dc1.DrawEllipse(det_brush, det_pen, angle1.point_toScreen(joint77.Position,
sensor), thick, thick);
dc1.DrawEllipse(det_brush, det_pen, angle1.point_toScreen(joint88.Position,
sensor), thick, thick);
dc1.DrawEllipse(det_brush, det_pen, angle1.point_toScreen(joint99.Position,
sensor), thick, thick);
dc1.DrawEllipse(det_brush, det_pen, angle1.point_toScreen(joint10.Position,
sensor), thick, thick);
dc1.DrawEllipse(det_brush, det_pen,
angle1.point_toScreen(joint1011.Position, sensor), thick, thick);
dc1.DrawEllipse(det_brush, det_pen,
angle1.point_toScreen(joint1022.Position, sensor), thick, thick);
dc1.DrawLine(infer_pen, angle1.point_toScreen(joint11.Position, sensor),
angle1.point_toScreen(joint22.Position, sensor));
dc1.DrawLine(infer_pen, angle1.point_toScreen(joint11.Position, sensor),
angle1.point_toScreen(joint88.Position, sensor));
dc1.DrawLine(infer_pen, angle1.point_toScreen(joint11.Position, sensor),
angle1.point_toScreen(joint99.Position, sensor));
dc1.DrawLine(infer_pen, angle1.point_toScreen(joint22.Position, sensor),
angle1.point_toScreen(joint33.Position, sensor));
dc1.DrawLine(infer_pen, angle1.point_toScreen(joint33.Position, sensor),
angle1.point_toScreen(joint44.Position, sensor));
dc1.DrawLine(infer_pen, angle1.point_toScreen(joint11.Position, sensor),
angle1.point_toScreen(joint55.Position, sensor));
dc1.DrawLine(infer_pen, angle1.point_toScreen(joint55.Position, sensor),
angle1.point_toScreen(joint66.Position, sensor));
dc1.DrawLine(infer_pen, angle1.point_toScreen(joint66.Position, sensor),
angle1.point_toScreen(joint77.Position, sensor));
dc1.DrawLine(infer_pen, angle1.point_toScreen(joint99.Position, sensor),
angle1.point_toScreen(joint10.Position, sensor));
dc1.DrawLine(infer_pen, angle1.point_toScreen(joint10.Position, sensor),
angle1.point_toScreen(joint1011.Position, sensor));
dc1.DrawLine(infer_pen, angle1.point_toScreen(joint1011.Position, sensor),
angle1.point_toScreen(joint1022.Position, sensor));
}
}
}
}
angle.cs类
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Kinect;
using System.Windows.Media;
using Microsoft.Xna.Framework;
using System.Windows;
namespace shoulder_joint
{
class angle
{
public void angle_between_left_shoulder(Skeleton sk1, DrawingContext draw,
JointType Shoulder_cntre,
JointType Shoulder_left, JointType Elbow_left, KinectSensor sen)
{
Joint sh_cntr = sk1.Joints[Shoulder_cntre];
Joint sh_left = sk1.Joints[Shoulder_left];
Joint elb_left = sk1.Joints[Elbow_left];
Vector3 v_shoulder = new Vector3(sh_cntr.Position.X, sh_cntr.Position.Y,
sh_cntr.Position.Z);
Vector3 v_should_l = new Vector3(sh_left.Position.X, sh_left.Position.Y,
sh_left.Position.Z);
Vector3 v_elbow_l = new Vector3(elb_left.Position.X, elb_left.Position.Y,
elb_left.Position.Z);
Vector3 va = v_shoulder - v_should_l;
Vector3 vb = v_elbow_l - v_should_l;
va = Vector3.Normalize(va);
vb = Vector3.Normalize(vb);
float len_prod = va.Length() * va.Length();
float dot_pro = Vector3.Dot(va, vb);
double angle = Math.Acos(dot_pro);
angle = angle * 180 / Math.PI;
angle = 180 - angle;
System.Windows.Point shoul_l = this.point_toScreen(sh_left.Position, sen);
draw.DrawText(new FormattedText(angle.ToString("0"), new
System.Globalization.CultureInfo("en-us"),
FlowDirection.LeftToRight,
new Typeface("Verdana"), 16, Brushes.WhiteSmoke),
new System.Windows.Point(shoul_l.X+10, shoul_l.Y +20));
}
public void angle_between_right_shoulder(Skeleton sk1, DrawingContext draw,
JointType head, JointType spine,
JointType Shoulder_cntre, JointType Shoulder_right, JointType
Elbow_right,KinectSensor sen)
{
Joint sh_cntr = sk1.Joints[Shoulder_cntre];
Joint sh_right = sk1.Joints[Shoulder_right];
Joint elb_right = sk1.Joints[Elbow_right];
Vector3 v_shoulder = new Vector3(sh_cntr.Position.X, sh_cntr.Position.Y,
sh_cntr.Position.Z);
Vector3 v_should_r = new Vector3(sh_right.Position.X, sh_right.Position.Y,
sh_right.Position.Z);
Vector3 v_elbow_r = new Vector3(elb_right.Position.X, elb_right.Position.Y,
elb_right.Position.Z);
Vector3 newv1 =v_shoulder - v_should_r ;
Vector3 newv2 = v_elbow_r - v_should_r;
newv1 = Vector3.Normalize(newv1);
newv2 = Vector3.Normalize(newv2);
float len_prod = newv1.Length() * newv2.Length();
float dot_pro = Vector3.Dot(newv1, newv2);
double angle = Math.Acos(dot_pro);
angle = angle * 180 / Math.PI;
angle = 180 - angle;
System.Windows.Point shoul_r = this.point_toScreen(sh_right.Position, sen);
draw.DrawText(new FormattedText(angle.ToString("0"), new
System.Globalization.CultureInfo("en-us"),
FlowDirection.LeftToRight,
new Typeface("Verdana"), 16, Brushes.WhiteSmoke),
new System.Windows.Point(shoul_r.X-15, shoul_r.Y+20));
}
public System.Windows.Point point_toScreen(SkeletonPoint point,KinectSensor sensor)
{
DepthImagePoint depth_point = sensor.MapSkeletonPointToDepth(point,
DepthImageFormat.Resolution640x480Fps30);
return new System.Windows.Point(depth_point.X, depth_point.Y);
}
public void angle_between_left_leg(Skeleton sk, DrawingContext draw_contex,
JointType hip_l, JointType knee_l,
JointType ankle_l,KinectSensor sen)
{
Joint Hl = sk.Joints[hip_l];
Joint kl = sk.Joints[knee_l];
Joint Al = sk.Joints[ankle_l];
Vector3 hip_left = new Vector3(Hl.Position.X,Hl.Position.Y,Hl.Position.Z);
Vector3 knee_left = new Vector3(kl.Position.X, kl.Position.Y, kl.Position.Z);
Vector3 ankle_left = new Vector3(Al.Position.X, Al.Position.Y, Al.Position.Z);
Vector3 va = hip_left - knee_left;
Vector3 vb = ankle_left - knee_left;
float len_prod = va.Length() * vb.Length();
float dot_pro = Vector3.Dot(va, vb);
double angle = Math.Acos(dot_pro/len_prod);
angle = angle * 180 / Math.PI;
angle = 180 - angle;
System.Windows.Point shoul_r = this.point_toScreen(kl.Position, sen);
draw_contex.DrawText(new FormattedText(angle.ToString("0"), new
System.Globalization.CultureInfo("en-us"),
FlowDirection.LeftToRight,
new Typeface("Verdana"), 16, Brushes.WhiteSmoke),
new System.Windows.Point(shoul_r.X - 15, shoul_r.Y + 20));
}
}
最佳答案
简单地使用 DispatchTimer 进行倒计时是否可以完成您想要做的事情?
伪代码如下:
private int isArmUpCounter = 5;
private bool isArmUp = false;
private void OnSkeletonReady() {
if (myArm.Angle > 70 && myArm.Angle < 80)
{
if (isArmUp == false)
{
isArmUp = true;
isArmUpCounter = 5;
armUpTimer.Start();
}
}
else
{
if (isArmUp == true && isArmUpCounter > 0)
{
Console.WriteLine("You dropped your arm too soon!");
}
isArmUp = false;
armUpTimer.Stop();
}
}
private void OnArmUpTimerTick() {
// one a 1 second tick
isArmUpCounter--;
}
当然需要对代码进行一些调整。但是这个概念是否实现了您正在寻找的东西?
关于c# - 使用kinect的 body 关节角度(检查时间间隔),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12608734/
对于游戏,我正在尝试计算我正在看的位置与场景中另一个对象的位置之间的角度。我通过使用以下代码获得了角度: Vec3 out_sub; Math.Subtract(pEnt->vOrigin, pLoc
我还是 Firebase 的新手。有什么方法可以使用 Firebase 性能监控从控制台自动逐屏监控我们的 Web 应用程序?我检查了文档,它说我们需要在代码中添加一些跟踪来跟踪(如果我弄错了,请纠正
我正在使用 angular-material2 的复选框。目前复选框的默认颜色为紫色。 看起来他们已将复选框的默认颜色从“主要”更改为重音。 有没有办法在不覆盖 css 的情况下获得“主要”(绿色)颜
Angular-Material 中是否有任何分页指令可与 md-list 一起使用? 这些确实有效,但不是基于 Material 设计的。 https://github.com/brantwills
所以我有一个configmap config.json { "apiUrl": "http://application.cloudapp.net/", "test": "1232" } 称为“连续部署
我可以成功对图像进行阈值处理并找到图像的边缘。我正在努力尝试的是准确地提取黑色边缘的 Angular 。 我目前正在使用黑色边缘的极端点,并使用atan2函数计算 Angular ,但是由于混叠,根据
我需要一些帮助来计算点的角度: 我需要计算从点 (0,0) 到从图像中提取的点的角度。 1 将是 0*,2 大约是 40-44* 等。 我的问题是 atan2 显示的值不正确。atan2 的当前输出是
好的,所以我有一个运动场 512x512环绕,-32变成 512对于x和 y . 现在我需要计算两个实体之间的角度,我有以下代码作为一种解决方法,它在大多数时间都有效,但有时仍然会失败: Shoote
我有一个组件,它有一个子组件。子组件有一个按钮,可以打开一个 Material 对话框。 在对话框中,我们有表单、用户名和密码以及提交按钮。当我提交时,我正在调用后端 REST api。 这在子组件中
我一直在试图找到2之间的差异,但是要减去这个就没有运气了 The primary diff erence between the two representations is that a quate
我在 Angular Material Expansion 面板中遇到了这个问题。部分分页下拉菜单被切断。如何使下拉菜单与扩展面板的末端重叠?我尝试了 z-index 但没有成功。 Material
我正在创建一个PapperSoccer项目,但是在寻找运动/线条的方向时遇到了问题。我正在使用HoughLinesP来检测行,并且效果尽可能好。 我使用ROI,在其中寻找一行,然后相应地移动它。 到目
我正在寻找修改构建函数输出的方法 ng build --prod 想添加一些引导CSS文件到index.html的head部分,更改名称index.html => index.php等 怎么做? 最佳
如何获得两个单位向量之间的 x、y 和 z 旋转值?我不能使用点积,因为它只给我一个值。我想使用旋转矩阵在每个轴上旋转,对于那些我需要每个轴上的角度差。我尝试了仅两个组件的点积,但我有点困惑。有没有一
我必须计算图像中每条可检测线的斜率(或角度)。如果可能的话,甚至可以检测直线斜率的变化。我已经执行了 2D 傅立叶并且我知道每个区域的邻域平均角度(64x64px 的集合)。我什至尝试了 Hough
我正在使用Tiled map 编辑器创建简单的平铺 map 。在我的 map 中,我有几个矩形,如果我创建一个宽度为 50、高度为 10 的矩形并将其精确旋转 90°,则保存 map 并将其加载到我的
我计算了一个三角形的角度,但我不明白为什么我得到一些锐角的负角。例如: var sin = Math.Sin(4.45); var radians = Math.Atan(sin); var
我正在开发一个机器学习项目,其中使用 TensorFlow(和 DNNRegressor)。我想预测范围在 -pi 和 pi 之间的模算术值(角度)。当我尝试“正常方式”执行此操作时,模型不是很好,因
我有一个包含 40 个旋转图像的图像。 图像索引实际上从 0. 0-39 开始。 这是将 0-39 转换为度数的代码 int image_direction = 0; //Can be 0-39 in
在 PostGIS/PostgreSQL 中,是否有一个函数可以给出给定点所在的线串的线段的角度? 最佳答案 在 PostGIS 版本 1.5.3 上 ST_Azimuth()需要两点作为输入——据我
我是一名优秀的程序员,十分优秀!