Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

minor cleanup

  • Loading branch information...
commit 319a6a534cdfc633b43732cd2fd28963eefd5237 1 parent d97388f
joreg joreg authored
Showing with 68 additions and 102 deletions.
  1. +68 −102 vvvv45/addonpack/src/nodes/plugins/Devices/OpenNI/Skeleton.cs
170 vvvv45/addonpack/src/nodes/plugins/Devices/OpenNI/Skeleton.cs
View
@@ -156,8 +156,7 @@ public void Evaluate(int SpreadMax)
if (FSmoothingIn.IsChanged)
FSkeletonCapability.SetSmoothing(FSmoothingIn[0]);
-
- if (FInit == false && FEnableIn[0] == true)
+ if (!FInit && FEnableIn[0])
{
//get all Users and sort them
int[] tUsers = FUsersIn[0].GetUsers();
@@ -173,115 +172,96 @@ public void Evaluate(int SpreadMax)
FJointOrientationZOut.SliceCount = Users.Length;
FStatusOut.SliceCount = Users.Length;
FConfidenceOut.SliceCount = Users.Length;
+
+ if (Users.Length == 0)
+ {
+ FStatusOut.SliceCount = 1;
+ FStatusOut[0] = "No User found";
+ }
-
- if (Users.Length > 0)
+ for (int i = 0; i < Users.Length; i++)
{
- for (int i = 0; i < Users.Length; i++)
+ //Reset the User
+ if (FResetIn[i])
{
- //Rest the User
- if (FResetIn.IsChanged)
- {
- if (FResetIn[0] == true)
- {
- FSkeletonCapability.Reset(Users[i]);
- FWorkerList.Clear();
- }
- }
+ FSkeletonCapability.Reset(Users[i]);
+ FWorkerList.Clear();
+ }
- //write the User ID
- FUserIdOut[i] = Users[i];
+ //write the User ID
+ FUserIdOut[i] = Users[i];
- //Check the state of the skeleton
- if (FSkeletonCapability.IsTracking(Users[i]))
- {
- FStatusOut[i] = "Tracking";
- //when the user is tracked stop pose detection
- FPoseDecetionCapability.StopPoseDetection(Users[i]);
+ //Check the state of the skeleton
+ if (FSkeletonCapability.IsTracking(Users[i]))
+ {
+ FStatusOut[i] = "Tracking";
+ //when the user is tracked stop pose detection
+ FPoseDecetionCapability.StopPoseDetection(Users[i]);
- //write all requested joint to the ouput
- WriteJointValuesToOutput(i, Users);
+ //write all requested joint to the ouput
+ WriteJointValuesToOutput(i, Users);
- //save the user to file and to an memory slot
- if (FSaveIn.IsChanged)
- {
- if (FSaveIn[0] == true)
- {
- FSkeletonCapability.SaveCalibrationDataToFile(Users[i], FFilePathIn[i]);
- FSkeletonCapability.SaveCalibrationData(Users[i], i);
- }
- }
- }
- else if (FSkeletonCapability.IsCalibrated(Users[i]))
+ //save the user to file and to an memory slot
+ if (FSaveIn[i])
{
- FStatusOut[i] = "Clibrated";
- //if a skeleton is loaded to a user start tracking and stop pose detection
- FSkeletonCapability.StartTracking(Users[i]);
- FPoseDecetionCapability.StopPoseDetection(Users[i]);
+ FSkeletonCapability.SaveCalibrationDataToFile(Users[i], FFilePathIn[i]);
+ FSkeletonCapability.SaveCalibrationData(Users[i], i);
}
- else if (FSkeletonCapability.IsCalibrating(Users[i]))
- {
- FStatusOut[i] = "Calibrating";
- }
- else
- {
- //if there is a users but he is not tracked delete the position data
- FJointOut[i].SliceCount = FJointsPositionOut[i].SliceCount = 0;
- FJointOrientationXOut[i].SliceCount = FJointOrientationYOut[i].SliceCount = FJointOrientationZOut[i].SliceCount = 0;
- FConfidenceOut[i].SliceCount = 0;
+ }
+ else if (FSkeletonCapability.IsCalibrated(Users[i]))
+ {
+ FStatusOut[i] = "Calibrated";
+ //if a skeleton is loaded to a user start tracking and stop pose detection
+ FSkeletonCapability.StartTracking(Users[i]);
+ FPoseDecetionCapability.StopPoseDetection(Users[i]);
+ }
+ else if (FSkeletonCapability.IsCalibrating(Users[i]))
+ {
+ FStatusOut[i] = "Calibrating";
+ }
+ else
+ {
+ //if there is a users but he is not tracked delete the position data
+ FJointOut[i].SliceCount = FJointsPositionOut[i].SliceCount = 0;
+ FJointOrientationXOut[i].SliceCount = FJointOrientationYOut[i].SliceCount = FJointOrientationZOut[i].SliceCount = 0;
+ FConfidenceOut[i].SliceCount = 0;
- //check if a user should calibrate or load an skeleton to the users
+ //check if a user should calibrate or load a skeleton to the users
- if (FLoadIn[0] == true)
+ if (FLoadIn[i])
+ {
+ //check if the user is loading the skelton
+ if (!FWorkerList.ContainsKey(Users[i]))
{
- //check if the user is loading the skelton
- if (!FWorkerList.ContainsKey(Users[i]))
- {
- FStatusOut[i] = "Load Skeleton";
-
- //load the skelton in a backgroundthread s that it does not interrup vvvv
- BackgroundWorker Worker = new BackgroundWorker();
- Worker.DoWork += new DoWorkEventHandler(Worker_DoWork);
- Worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(Worker_RunWorkerCompleted);
+ FStatusOut[i] = "Load Skeleton";
- FWorkerList.Add(Users[i], Worker);
+ //load the skelton in a backgroundthread so that it does not interrup vvvv
+ BackgroundWorker Worker = new BackgroundWorker();
+ Worker.DoWork += new DoWorkEventHandler(Worker_DoWork);
+ Worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(Worker_RunWorkerCompleted);
- LoadingValues Values = new LoadingValues();
- Values.Slice = 1;
- Values.UserID = Users[i];
+ FWorkerList.Add(Users[i], Worker);
- Worker.RunWorkerAsync(Values);
+ LoadingValues Values = new LoadingValues();
+ Values.Slice = 1;
+ Values.UserID = Users[i];
- }
- else
- {
- FLogger.Log(LogType.Message, "Load Skeleton");
- }
+ Worker.RunWorkerAsync(Values);
}
else
{
- //start the pose detection if a user should calibrate
- FStatusOut[i] = "Pose Detection";
- FPoseDecetionCapability.StartPoseDetection("Psi", Users[i]);
+ FLogger.Log(LogType.Message, "Load Skeleton");
}
}
+ else
+ {
+ //start the pose detection if a user should calibrate
+ FStatusOut[i] = "Pose Detection";
+ FPoseDecetionCapability.StartPoseDetection("Psi", Users[i]);
+ }
}
}
- else
- {
- //reset the outputpins
- FJointOut.SliceCount = 0;
- FUserIdOut.SliceCount = 0;
- FJointsPositionOut.SliceCount = 0;
- FJointOrientationXOut.SliceCount = 0;
- FJointOrientationYOut.SliceCount = 0;
- FJointOrientationZOut.SliceCount = 0;
- FConfidenceOut.SliceCount = 0;
-
-
- FStatusOut.SliceCount = 1;
- FStatusOut[0] = "No User found";
- }
+
if (FErrorMessages.Count > 0)
{
@@ -379,11 +359,6 @@ void Worker_DoWork(object sender, DoWorkEventArgs e)
}
}
- /// <summary>
- /// Reads the Joint Position and writes it to the Output Pins
- /// </summary>
- /// <param name="Index">Index of Users</param>
- /// <param name="Users">Array of all Users</param>
private void WriteJointValuesToOutput(int Index, int[] Users)
{
int BinSize = FJointIn[Index].SliceCount;
@@ -392,14 +367,12 @@ private void WriteJointValuesToOutput(int Index, int[] Users)
FJointOrientationXOut[Index].SliceCount = FJointOrientationYOut[Index].SliceCount = FJointOrientationZOut[Index].SliceCount = BinSize;
FConfidenceOut[Index].SliceCount = BinSize;
-
for (int i = 0; i < BinSize; i++)
{
FJointOut[Index][i] = FJointIn[Index][i].ToString();
Point3D Point = GetJointPoint(Users[Index], FJointIn[Index][i]);
-
float Confidence = 0;
if (FConfidenceIn[Index] == true)
Confidence = FSkeletonCapability.GetSkeletonJointPosition(Users[Index], FJointIn[Index][i]).Confidence;
@@ -425,7 +398,6 @@ private void WriteJointValuesToOutput(int Index, int[] Users)
// Debug.WriteLine("Out of Confidence");
}
}
-
}
private Point3D GetJointPoint(int User, SkeletonJoint Joint)
@@ -442,12 +414,6 @@ private Point3D GetJointPoint(int User, SkeletonJoint Joint)
return Point;
}
- /// <summary>
- /// get and orientation of an specific joint
- /// </summary>
- /// <param name="User"></param>
- /// <param name="Joint"></param>
- /// <returns></returns>
private SkeletonJointOrientation GetJointOrientation(int User, SkeletonJoint Joint)
{
SkeletonJointOrientation Orientation = new SkeletonJointOrientation();
Please sign in to comment.
Something went wrong with that request. Please try again.