Kinect user Detection
Also see Jurgeon D's answer on Kinect SDK player detection, as it deals with skeleton index. @Fixus is also right in that you could use a ID. But if you mean more than 2 people are detected, then only one is detected, that is not programming, that is in the Kinect's hardware and @FelixK. was right.
Skeletal Index
void nui_SkeletonFrameReady(object sender, SkeletonFrameReadyEventArgs e)
{
SkeletonFrame sf = e.SkeletonFrame;
//check which skeletons in array are active and
// use that array indexes for player index
SkeletonData player1 = sf.Skeletons[playerIndex1];
SkeletonData player2 = sf.Skeletons[playerIndex2];
}
Skeletal IDs
void nui_SkeletonFrameReady(object sender, SkeletonFrameReadyEventArgs e)
{
SkeletonFrame sf = e.SkeletonFrame;
if (sf.TrackingState == SkeletalTrackingState.Tracked)
{
int ID1 = sf.TrackingID;
}
Also the code for detecting humans
DepthImageFrame depthFrame;
short[] rawDepthData = new short[depthFrame.PixelDataLength];
depthFrame.CopyPixelDataTo(rawDepthData);
Byte[] pixels = new byte[depthFrame.Height * depthFrame.Width * 4];
int player = rawDepthData[depthIndex] & DepthImageFrame.PlayerIndexBitmask;
if (player > 0)
{
//do something
}
How to restrict the detection of users to be 1?
look at the example here
http://www.codeproject.com/Articles/743862/Kinect-for-Windows-version-Body-tracking
where the array _bodies gets filled with people data, then simply take the first array element if available.
How to dynamically detect user is standing or sitting mode in Kinect SDK 2.0
Have you tried checking the positions of bones relative to one another?
If the hips are above the knees by some threshold maybe the user is standing.
You might also just be able to check how far the hips (or some other bone) is above the ground plane.
Kinect SDK player detection
Every player has an index in the Skeleton array:
void nui_SkeletonFrameReady(object sender, SkeletonFrameReadyEventArgs e) {
SkeletonFrame sf = e.SkeletonFrame;
//check which skeletons in array are active and use that array indexes for player index
SkeletonData player1 = sf.Skeletons[playerIndex1];
SkeletonData player2 = sf.Skeletons[playerIndex2];
You can use that index to identify your players if one leave and comes back.
But if both players leave the sight of the Kinect it is not granted that the player index is correct when they enter the Kinect visibility again.
c# Kinect 2.0 How to detect how far a body away from the center of Kinect sensor
For me I use the CameraSpacePoint
class.
For this I use 1 Joint for example the center of the body, and i convert it in CameraSpacePoint
.
For example:
CameraSpacePoint myPoint = myJoint.Position;
Console.WriteLine(pointLeft.X);//for have your distance
The distance was in meter with 0 the center of Kinect Sensor
It works also with Y and Z.
You can found more information here: CameraSpacePoint Structure.
Unable to use the 'Gesture Detection using Kinect' from the Kinect SDK samples
Ok I still don't know where I was going wrong. What I did was work around this by creating methods to update flags in MainWindow
from within `GestureDetect' funtion and using those flags to call my 'Capture' method.
So that's a possible workaround. If somebody can tell me where I was going wroung though I would really appreciate it as I couldn't figure it out.
Thanks.
Related Topics
Linq: Passing Lambda Expression as Parameter to Be Executed and Returned by Method
Using Webclient or Webrequest to Login to a Website and Access Data
How to Add the Same Column to All Entities in Ef Core
System.Valuetype Understanding
Gracefully Handling Corrupted State Exceptions
Formatting Datetime in ASP.NET Core 3.0 Using System.Text.JSON
Why Does Guid.Tobytearray() Order the Bytes the Way It Does
Launching Process in C# Without Distracting Console Window
C# 4.0: How to Use a Timespan as an Optional Parameter with a Default Value
Wpf Binding - Default Value for Empty String
How to Check If Another Instance of the Application Is Running
Raise an Event of a Class from a Different Class in C#
String.Equals() Not Working as Intended
How to Get Text Between Nested Parentheses