本文整理汇总了C#中AllFramesReadyEventArgs.OpenSkeletonFrame方法的典型用法代码示例。如果您正苦于以下问题:C# AllFramesReadyEventArgs.OpenSkeletonFrame方法的具体用法?C# AllFramesReadyEventArgs.OpenSkeletonFrame怎么用?C# AllFramesReadyEventArgs.OpenSkeletonFrame使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AllFramesReadyEventArgs
的用法示例。
在下文中一共展示了AllFramesReadyEventArgs.OpenSkeletonFrame方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: KinectAllFramesReady
public void KinectAllFramesReady(object sender,AllFramesReadyEventArgs e)
{
using (SkeletonFrame skeletonFrame = e.OpenSkeletonFrame())
{
if (skeletonFrame != null && screenManager != null)
{
// take skeleton data and update avatar state
skeletonFrame.CopySkeletonDataTo(skeletonData);
float headX = skeletonData[0].Joints[JointType.Head].Position.X; //floats between -1 and 1
float headY = skeletonData[0].Joints[JointType.Head].Position.Y;
midViewPort.X = screenManager.GraphicsDevice.Viewport.Width / 2;
midViewPort.Y = screenManager.GraphicsDevice.Viewport.Height / 2;
//set the posistion of the head's rectangle to be in the center of the screen and move by the joint amount
//TODO: figure out if skeleton data stream has lower left origin, because XNA has upper left origin and we adjust for that.
head.SetRectPos((int)((headX * 100) + midViewPort.X), (int)((headY * 100) + midViewPort.Y));
//head.SetRectPos((int)((headX * 100)), (int)((headY * 100) ));
//
Console.WriteLine( "head: " + head.Rectangle.X + ", " + head.Rectangle.Y );
Console.WriteLine("joint: " + headX + ", " + headY);
}
else
{
// skeletonFrame is null because the request did not arrive in time
}
}
}
示例2: sensor_AllFramesReady
void sensor_AllFramesReady(object sender, AllFramesReadyEventArgs e)
{
//throw new NotImplementedException();
using (SkeletonFrame skeletonFrame = e.OpenSkeletonFrame())
{
// check for frame drop.
if (skeletonFrame == null)
{
return;
}
// copy the frame data in to the collection
skeletonFrame.CopySkeletonDataTo(totalSkeleton);
// get the first Tracked skeleton
Skeleton firstSkeleton = (from trackskeleton in totalSkeleton
where trackskeleton.TrackingState == SkeletonTrackingState.Tracked
select trackskeleton).FirstOrDefault();
// if the first skeleton returns null
if (firstSkeleton == null)
{
return;
}
this.myCanvas.Children.Clear();
this.DrawSkeleton(firstSkeleton);
recognitionEngine.Skeleton = firstSkeleton;
recognitionEngine.StartRecognize();
}
}
示例3: GetTrackedSkeleton
private Skeleton GetTrackedSkeleton(AllFramesReadyEventArgs e)
{
using (SkeletonFrame skeletonFrameData = e.OpenSkeletonFrame())
{
SkeletonDetected = false;
if (skeletonFrameData == null)
{
return null;
}
// Kinect SDK always returns 6 skeleton
const int skeletonCount = 6;
Skeleton[] allSkeletons = new Skeleton[skeletonCount];
skeletonFrameData.CopySkeletonDataTo(allSkeletons);
//Get the first tracked skeleton out of the 6
Skeleton trackedSkeleton = null;
foreach (Skeleton skeleton in allSkeletons)
{
// if no skeleton is tracked, null will be returned.
if (skeleton.TrackingState == SkeletonTrackingState.Tracked)
{
trackedSkeleton = skeleton;
SkeletonDetected = true;
break;
}
}
return trackedSkeleton;
}
}
示例4: AllFramesReady
private void AllFramesReady(object sender,AllFramesReadyEventArgs e)
{
using(ColorImageFrame colorImage=e.OpenColorImageFrame())
using(SkeletonFrame skeletonFrame=e.OpenSkeletonFrame())
if(colorImage!=null&&skeletonFrame!=null){
colorImage.CopyPixelDataTo(bitmappixels);
skeletonFrame.CopySkeletonDataTo(skeletons);
bitmap.WritePixels(updateRect,bitmappixels,bitmap.PixelWidth*sizeof(int),0);
using(DrawingContext drawingContext=drawingGroup.Open()){
drawingContext.DrawImage(bitmap,drawingRect);
//drawingContext.DrawGeometry(button1.IsHitting?Brushes.White:null,new Pen(Brushes.Blue,2.0),button1.Geometry);
//drawingContext.DrawGeometry(button2.IsHitting?Brushes.White:null,new Pen(Brushes.Blue,2.0),button2.Geometry);
foreach(Skeleton skel in skeletons){
if(skel.TrackingState==SkeletonTrackingState.Tracked){
foreach(Joint joint in skel.Joints){
if(joint.TrackingState==JointTrackingState.Tracked){
var depthPoint=sensor.MapSkeletonPointToDepth(joint.Position,DepthImageFormat.Resolution640x480Fps30);
drawingContext.DrawEllipse(Brushes.Green,null,new Point(depthPoint.X,depthPoint.Y),15,15);
}
}
drawingContext.DrawRectangle(Brushes.Red,null,new Rect(0.0,0.0,distance1.Distance,50.0));
drawingContext.DrawLine(new Pen(Brushes.Blue,10),volume1.MiddlePoint,volume1.RightHandLocation);
var mat=Matrix.Identity;
mat.RotateAt(volume1.Angle,volume1.MiddlePoint.X,volume1.MiddlePoint.Y);
drawingContext.DrawLine(new Pen(Brushes.Blue,10),volume1.MiddlePoint,mat.Transform(volume1.RightHandLocation));
drawingContext.DrawText(new FormattedText(volume1.Angle.ToString(),CultureInfo.CurrentCulture,FlowDirection.LeftToRight,new Typeface("MS Gothic"),150,Brushes.Blue),new Point());
break;
}
}
}
}
return;
}
示例5: kinect_AllFramesReady
void kinect_AllFramesReady( object sender, AllFramesReadyEventArgs e )
{
using ( var colorFrame = e.OpenColorImageFrame() ) {
if ( colorFrame != null ) {
var pixel = new byte[colorFrame.PixelDataLength];
colorFrame.CopyPixelDataTo( pixel );
ImageRgb.Source = BitmapSource.Create( colorFrame.Width, colorFrame.Height, 96, 96,
PixelFormats.Bgr32, null, pixel, colorFrame.Width * 4 );
}
}
using ( var depthFrame = e.OpenDepthImageFrame() ) {
if ( depthFrame != null ) {
// Depth情報を入れる
// GetRawPixelData()はインタラクションライブラリ内で実装された拡張メソッド
stream.ProcessDepth( depthFrame.GetRawPixelData(), depthFrame.Timestamp );
}
}
using ( var skeletonFrame = e.OpenSkeletonFrame() ) {
if ( skeletonFrame != null ) {
var skeletons = new Skeleton[skeletonFrame.SkeletonArrayLength];
skeletonFrame.CopySkeletonDataTo( skeletons );
// スケルトン情報を入れる
stream.ProcessSkeleton( skeletons, kinect.AccelerometerGetCurrentReading(), skeletonFrame.Timestamp );
}
}
}
示例6: kinect_AllFramesReady
void kinect_AllFramesReady( object sender, AllFramesReadyEventArgs e )
{
image1.Source = e.OpenColorImageFrame().ToBitmapSource();
// スケルトンフレームを取得する
SkeletonFrame skeletonFrame = e.OpenSkeletonFrame();
if ( skeletonFrame != null ) {
// スケルトンデータを取得する
Skeleton[] skeletonData = new Skeleton[skeletonFrame.SkeletonArrayLength];
skeletonFrame.CopySkeletonDataTo( skeletonData );
// プレーヤーごとのスケルトンを描画する
foreach ( var skeleton in skeletonData ) {
var head = skeleton.Joints[JointType.Head];
if ( head.TrackingState == JointTrackingState.Tracked ) {
ColorImagePoint point = kinect.MapSkeletonPointToColor( head.Position, kinect.ColorStream.Format );
var x = image2.Width / 2;
var y = image2.Height / 2;
image2.Margin = new Thickness( point.X - x, point.Y - y, 0, 0 );
image2.Visibility = System.Windows.Visibility.Visible;
}
}
}
}
示例7: AllFramesReady
private void AllFramesReady(object sender,AllFramesReadyEventArgs e)
{
if(secondBuffer!=null){
using(ColorImageFrame colorImage=e.OpenColorImageFrame())
using(SkeletonFrame skeletonFrame=e.OpenSkeletonFrame())
if(colorImage!=null&&skeletonFrame!=null){
skeletonFrame.CopySkeletonDataTo(skeletons);
//colorImage.CopyPixelDataTo(bitmappixels);
//bitmap.WritePixels(updateRect,bitmappixels,bitmap.PixelWidth*sizeof(int),0);
using(DrawingContext drawingContext=drawingGroup.Open()){
//drawingContext.DrawImage(bitmap,drawingRect);
drawingContext.DrawRectangle(Brushes.Black,null,drawingRect);
var redPen=new Pen(Brushes.Red,5.0);
drawingContext.DrawGeometry(button.IsHitting?Brushes.White:null,redPen,button.Geometry);
drawingContext.DrawGeometry(muteButton.IsHitting?Brushes.White:null,redPen,muteButton.Geometry);
//drawingContext.DrawGeometry(boostButton.IsHitting?Brushes.White:null,redPen,boostButton.Geometry);
drawingContext.DrawGeometry(gateButton.IsHitting?Brushes.White:null,redPen,gateButton.Geometry);
drawingContext.DrawText(new FormattedText(secondBuffer.Status.Playing?"■":"▶",CultureInfo.CurrentCulture,FlowDirection.LeftToRight,new Typeface("メイリオ"),44,Brushes.Red),new Point(0,0));
foreach(Skeleton skel in skeletons){
if(skel.TrackingState==SkeletonTrackingState.Tracked){
foreach(Joint joint in skel.Joints){
if(joint.TrackingState==JointTrackingState.Tracked){
var depthPoint=sensor.CoordinateMapper.MapSkeletonPointToDepthPoint(joint.Position,DepthImageFormat.Resolution640x480Fps30);
drawingContext.DrawEllipse(Brushes.Green,null,new Point(depthPoint.X,depthPoint.Y),10,10);
}
}
if(mode==1){
drawingContext.DrawLine(new Pen(Brushes.DarkBlue,20),distance.Joint1Location,distance.Joint2Location);
var volume=-10000+(distance.Distance<=250?distance.Distance:250)*35;
if(timer.IsEnabled) prevvolume=volume;
else secondBuffer.Volume=volume;
}else if(mode==2){
var pen=new Pen(new SolidColorBrush(Color.FromArgb(0x7F,0,0,0x8B)),12.5);
drawingContext.DrawLine(pen,volume.MiddlePoint,volume.RightHandLocation);
var mat=Matrix.Identity;
mat.RotateAt(volume.Angle,volume.MiddlePoint.X,volume.MiddlePoint.Y);
drawingContext.DrawLine(pen,volume.MiddlePoint,mat.Transform(volume.RightHandLocation));
settings[0].Gain=15/180*(-volume.Angle);
settings[1].Gain=10/180*(-volume.Angle);
settings[2].Gain=15/180*(volume.Angle);
settings[3].Gain=15/180*(volume.Angle);
settings[4].Gain=15/180*(volume.Angle);
for(int i=0;i<settings.Length;i++){
var effectInst=(ParamEqEffect)secondBuffer.GetEffects(i);
effectInst.AllParameters=settings[i];
}
}
drawingContext.DrawText(new FormattedText("ControlMode:"+(mode==0?"None":mode==1?"Volume":"Filter"),CultureInfo.CurrentCulture,FlowDirection.LeftToRight,new Typeface("メイリオ"),40,Brushes.White),new Point(0,400));
if(muteButton.IsHitting){
secondBuffer.Volume=-10000;
}
break;
}
}
}
}
}
return;
}
示例8: Kinect_AllFramesReady
void Kinect_AllFramesReady(object sender, AllFramesReadyEventArgs e)
{
using (var Frame = e.OpenColorImageFrame())
{
if (Frame != null)
{
Frame.CopyPixelDataTo(Pixels);
Bitmap.WritePixels(
new Int32Rect(0, 0, Bitmap.PixelWidth, Bitmap.PixelHeight),
Pixels, Bitmap.PixelWidth * sizeof(int), 0);
}
}
using (var Frame = e.OpenSkeletonFrame())
{
if (Frame != null)
{
var skeletons = new Skeleton[Frame.SkeletonArrayLength];
Frame.CopySkeletonDataTo(skeletons);
var skel = (from s in skeletons where s.TrackingState == SkeletonTrackingState.Tracked select s).FirstOrDefault();
if (skel != null)
{
var left_hand = skel.Joints[JointType.HandLeft];
var rite_hand = skel.Joints[JointType.HandRight];
var shoulderRight = skel.Joints[JointType.ShoulderRight];
var fleft = skel.Joints[JointType.FootLeft];
var frite = skel.Joints[JointType.FootRight];
Joint head = skel.Joints[JointType.Head];
Point mousePos = new Point((rite_hand.Position.X * 1300 + 683), (rite_hand.Position.Y * -1300 + 768));
//двойное нажатие левой кнопкой мыши
if (distance(head.Position, left_hand.Position) < 0.06f) {
NatiteMethods.sendMouseDoubleClick(mousePos);
// правая кнопка мыши
} else if(distance(left_hand.Position, rite_hand.Position) < 0.03f) {
NatiteMethods.mouseLeftButtonDown(mousePos);
// перетаскивание
} else if(distance(shoulderRight.Position, left_hand.Position) < 0.03f) {
NatiteMethods.sendMouseRightclick(mousePos);
}
if (fleft.Position.Y <= fleft.Position.Y + 0.5f) {
// Get the virtual key code for the character we want to press
//int key = 87;
//uint vkKey = NatiteMethods.VkKeyScan((char) key);
//NatiteMethods.keybd_event(vkKey, 0, 0, 0);
//NatiteMethods.keybd_event(vkKey, 0, 2, 0);
}
NatiteMethods.SetCursorPos((int) mousePos.X, (int) mousePos.Y);
}
}
}
}
示例9: ManageAllFrame
/// <summary>
/// Manage frames of kinect sensor according to the services activated
/// </summary>
/// <param name="e"></param>
private void ManageAllFrame(AllFramesReadyEventArgs e)
{
if (!IsRunning)
{
return;
}
// SkeletonTracking Frame Manager
using (SkeletonFrame SFrame = e.OpenSkeletonFrame())
{
try
{
ManageSkeletonFrame(SFrame);
}
catch (Exception ex)
{
// Just log the error
Console.Error.WriteLine("Error with skeleton frame : " + ex.Message + " _ " + ex.StackTrace);
}
}
// Color Frame Manager
if (PropertiesPluginKinect.Instance.EnableColorFrameService)
{
using (ColorImageFrame CFrame = e.OpenColorImageFrame())
{
try
{
ManageColorFrame(CFrame);
}
catch (Exception ex)
{
// Just log the error
Console.Error.WriteLine("Error with color frame : " + ex.Message + " _ " + ex.StackTrace);
}
}
}
// Depth Frame Manager
if (PropertiesPluginKinect.Instance.EnableDepthFrameService ||
PropertiesPluginKinect.Instance.KinectPointingModeEnabled ||
PropertiesPluginKinect.Instance.EnableGestureGrip)
{
using (DepthImageFrame DFrame = e.OpenDepthImageFrame())
{
try
{
ManageDepthFrame(DFrame);
}
catch (Exception ex)
{
// Just log the error
Console.Error.WriteLine("Error with depth frame : " + ex.Message + " _ " + ex.StackTrace);
}
}
}
}
示例10: updateVis
private void updateVis(object sender, AllFramesReadyEventArgs e)
{
if (recorder.areRecording)
{
ellipse1.Fill = new SolidColorBrush(Colors.Red);
}
else if (recorder.handsMet)
{
ellipse1.Fill = new SolidColorBrush(Colors.Blue);
}
else
{
ellipse1.Fill = new SolidColorBrush(Colors.Green);
}
if (e.OpenSkeletonFrame() != null)
{
Skeleton[] skelData = new Skeleton[6];
e.OpenSkeletonFrame().CopySkeletonDataTo(skelData);
label1.Content = (skelData[0].Joints[JointType.HandLeft].Position.X - skelData[0].Joints[JointType.HandRight].Position.X).ToString();
}
}
示例11: FrameHandler
static void FrameHandler(object sender, AllFramesReadyEventArgs afrea)
{
using(var sf = afrea.OpenSkeletonFrame())
{
var data = new Skeleton[kinect.SkeletonStream.FrameSkeletonArrayLength];
sf.CopySkeletonDataTo(data);
foreach(Joint joint in data[0].Joints) {
if(joint.JointType == JointType.WristLeft)
Console.WriteLine("Left Wrist: ({0},{1},{2})", joint.Position.X, joint.Position.Y, joint.Position.Z);
}
}
}
示例12: GetFirstSkeleton
Skeleton GetFirstSkeleton(AllFramesReadyEventArgs e)
{
using (SkeletonFrame skeletonFrameData = e.OpenSkeletonFrame())
{
if (skeletonFrameData == null)
return null;
skeletonFrameData.CopySkeletonDataTo(allSkeletons);
Skeleton first = (from s in allSkeletons
where s.TrackingState == SkeletonTrackingState.Tracked
select s).FirstOrDefault();
return first;
}
}
示例13: FramesReady
//returns the latest picture!!!!!
void FramesReady(object sender, AllFramesReadyEventArgs e)
{
ColorImageFrame VFrame = e.OpenColorImageFrame();
if (VFrame == null) return;
byte[] pixelS = new byte[VFrame.PixelDataLength];
bmp = ImageToBitmap(VFrame);
SkeletonFrame SFrame = e.OpenSkeletonFrame();
if (SFrame == null) return;
Graphics g = Graphics.FromImage(bmp);
Skeleton[] Skeletons = new Skeleton[SFrame.SkeletonArrayLength];
SFrame.CopySkeletonDataTo(Skeletons);
foreach (Skeleton S in Skeletons)
{
if (S.TrackingState == SkeletonTrackingState.Tracked)
{
//body
DrawBone(JointType.Head, JointType.ShoulderCenter, S, g);
DrawBone(JointType.ShoulderCenter, JointType.Spine, S, g);
DrawBone(JointType.Spine, JointType.HipCenter, S, g);
//left leg
DrawBone(JointType.HipCenter, JointType.HipLeft, S, g);
DrawBone(JointType.HipLeft, JointType.KneeLeft, S, g);
DrawBone(JointType.KneeLeft, JointType.AnkleLeft, S, g);
DrawBone(JointType.AnkleLeft, JointType.FootLeft, S, g);
//Right Leg
DrawBone(JointType.HipCenter, JointType.HipRight, S, g);
DrawBone(JointType.HipRight, JointType.KneeRight, S, g);
DrawBone(JointType.KneeRight, JointType.AnkleRight, S, g);
DrawBone(JointType.AnkleRight, JointType.FootRight, S, g);
//Left Arm
DrawBone(JointType.ShoulderCenter, JointType.ShoulderLeft, S, g);
DrawBone(JointType.ShoulderLeft, JointType.ElbowLeft, S, g);
DrawBone(JointType.ElbowLeft, JointType.WristLeft, S, g);
DrawBone(JointType.WristLeft, JointType.HandLeft, S, g);
//Right Arm
DrawBone(JointType.ShoulderCenter, JointType.ShoulderRight, S, g);
DrawBone(JointType.ShoulderRight, JointType.ElbowRight, S, g);
DrawBone(JointType.ElbowRight, JointType.WristRight, S, g);
DrawBone(JointType.WristRight, JointType.HandRight, S, g);
}
}
}
示例14: Get
public static Skeleton Get(AllFramesReadyEventArgs e, Skeleton[] allSkeletons)
{
using (SkeletonFrame skeletonFrameData = e.OpenSkeletonFrame())
{
if (skeletonFrameData != null)
{
skeletonFrameData.CopySkeletonDataTo(allSkeletons);
//get the first tracked skeleton
Skeleton first = (from s in allSkeletons
where s.TrackingState == SkeletonTrackingState.Tracked
select s).FirstOrDefault();
return first;
}
}
return null;
}
示例15: kinect_AllFramesReady
private void kinect_AllFramesReady(object sender, AllFramesReadyEventArgs e)
{
byte[] imagem = ObterImagemSensorRGB(e.OpenColorImageFrame());
if( chkEscalaCinza.IsChecked.HasValue && chkEscalaCinza.IsChecked.Value)
ReconhecerDistancia(e.OpenDepthImageFrame(),imagem, 2000);
if (imagem != null)
canvasKinect.Background = new ImageBrush(BitmapSource.Create(kinect.ColorStream.FrameWidth, kinect.ColorStream.FrameHeight,
96, 96, PixelFormats.Bgr32, null, imagem,
kinect.ColorStream.FrameWidth * kinect.ColorStream.FrameBytesPerPixel));
canvasKinect.Children.Clear();
DesenharEsqueletoUsuario(e.OpenSkeletonFrame());
}
开发者ID:gilgaljunior,项目名称:CrieAplicacoesInterativascomoMicrosoftKinect,代码行数:16,代码来源:MainWindow.xaml.cs