public void EqualityTest() { try { IavaSkeleton[] skeletons = new IavaSkeleton[] { new IavaSkeleton(), new IavaSkeleton(), new IavaSkeleton(), new IavaSkeleton(), new IavaSkeleton(), new IavaSkeleton() }; IavaSkeletonFrame_Accessor accessor1 = new IavaSkeletonFrame_Accessor() { FloorClipPlane = Tuple.Create(1.0f, 2.0f, 3.0f, 4.0f), FrameNumber = 14, Skeletons = skeletons, Timestamp = 123456789 }; IavaSkeletonFrame_Accessor accessor2 = new IavaSkeletonFrame_Accessor() { FloorClipPlane = Tuple.Create(1.0f, 2.0f, 3.0f, 4.0f), FrameNumber = 14, Skeletons = skeletons, Timestamp = 123456789 }; IavaSkeletonFrame_Accessor accessor3 = new IavaSkeletonFrame_Accessor() { FloorClipPlane = Tuple.Create(4.0f, 3.0f, 2.0f, 1.0f), FrameNumber = 18, Skeletons = skeletons, Timestamp = 123456789 }; IavaSkeletonFrameReadyEventArgs eventArgs1 = new IavaSkeletonFrameReadyEventArgs((IavaSkeletonFrame)accessor1.Target); IavaSkeletonFrameReadyEventArgs eventArgs2 = new IavaSkeletonFrameReadyEventArgs((IavaSkeletonFrame)accessor2.Target); IavaSkeletonFrameReadyEventArgs eventArgs3 = new IavaSkeletonFrameReadyEventArgs((IavaSkeletonFrame)accessor3.Target); IavaSkeletonFrameReadyEventArgs eventArgs4 = new IavaSkeletonFrameReadyEventArgs((IavaSkeletonFrame)null); IavaSkeletonFrameReadyEventArgs eventArgs5 = new IavaSkeletonFrameReadyEventArgs((IavaSkeletonFrame)null); // Make sure eventArgs1 does not equal null Assert.IsFalse(eventArgs1 == null); // Make sure null does not equal eventArgs1 Assert.IsFalse(null == eventArgs1); // Make sure eventArgs1 and eventArgs3 are not equal Assert.IsFalse(eventArgs1 == eventArgs3); // Make sure eventArgs1 and eventArgs2 are equal Assert.IsTrue(eventArgs1 == eventArgs2); // Make sure eventArgs4 and eventArgs5 are equal Assert.IsTrue(eventArgs4 == eventArgs5); // Make sure eventArgs1 equals itself Assert.IsTrue(eventArgs1 == eventArgs1); } catch (Exception ex) { Assert.Fail(ex.Message); } }
public void ConstructorTest() { try { IavaSkeletonFrame skeletonFrame = CreateSkeletonFrame(); IavaSkeletonFrameReadyEventArgs iavaEventArgs = new IavaSkeletonFrameReadyEventArgs(skeletonFrame); // Make sure the property set correctly Assert.AreEqual(skeletonFrame, iavaEventArgs.SkeletonFrame); } catch (Exception ex) { Assert.Fail(ex.Message); } }
/// <summary> /// Displays the full skeleton image from the Kinect sensor /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OnCameraSkeletonFrameReady(object sender, IavaSkeletonFrameReadyEventArgs e) { // If we don't have a canvas to draw on, there's nothing for us to do... if (_activeSkeletonCanvas == null) { lblActiveSkeleton.Content = "No Skeleton"; return; } _activeSkeletonCanvas.Skeleton = e.SkeletonFrame.ActiveSkeleton; // For debugging purposes if (e.SkeletonFrame.ActiveSkeleton == null) { lblActiveSkeleton.Content = "No Skeleton"; } else { lblActiveSkeleton.Content = ""; } }
/// <summary> /// Displays the full skeleton image from the Kinect sensor /// </summary> private void OnCameraSkeletonFrameReady(object sender, IavaSkeletonFrameReadyEventArgs e) { Iava.Input.Camera.IavaSkeletonFrame skeletonFrame = e.SkeletonFrame; int iSkeleton = 0; Brush[] brushes = new Brush[6]; brushes[0] = new SolidColorBrush(Color.FromRgb(255, 0, 0)); brushes[1] = new SolidColorBrush(Color.FromRgb(0, 255, 0)); brushes[2] = new SolidColorBrush(Color.FromRgb(64, 255, 255)); brushes[3] = new SolidColorBrush(Color.FromRgb(255, 255, 64)); brushes[4] = new SolidColorBrush(Color.FromRgb(255, 64, 255)); brushes[5] = new SolidColorBrush(Color.FromRgb(128, 128, 255)); kinectSkeletonFeed.Children.Clear(); foreach (IavaSkeleton data in skeletonFrame.Skeletons) { if (IavaSkeletonTrackingState.Tracked == data.TrackingState) { // Draw bones Brush brush = brushes[iSkeleton % brushes.Length]; kinectSkeletonFeed.Children.Add(GetBodySegment(data.Joints, brush, IavaJointType.HipCenter, IavaJointType.Spine, IavaJointType.ShoulderCenter, IavaJointType.Head)); kinectSkeletonFeed.Children.Add(GetBodySegment(data.Joints, brush, IavaJointType.ShoulderCenter, IavaJointType.ShoulderLeft, IavaJointType.ElbowLeft, IavaJointType.WristLeft, IavaJointType.HandLeft)); kinectSkeletonFeed.Children.Add(GetBodySegment(data.Joints, brush, IavaJointType.ShoulderCenter, IavaJointType.ShoulderRight, IavaJointType.ElbowRight, IavaJointType.WristRight, IavaJointType.HandRight)); kinectSkeletonFeed.Children.Add(GetBodySegment(data.Joints, brush, IavaJointType.HipCenter, IavaJointType.HipLeft, IavaJointType.KneeLeft, IavaJointType.AnkleLeft, IavaJointType.FootLeft)); kinectSkeletonFeed.Children.Add(GetBodySegment(data.Joints, brush, IavaJointType.HipCenter, IavaJointType.HipRight, IavaJointType.KneeRight, IavaJointType.AnkleRight, IavaJointType.FootRight)); // Draw joints foreach (IavaJoint joint in data.Joints) { Point jointPos = new Point(joint.Position.X, joint.Position.Y); Line jointLine = new Line(); jointLine.X1 = jointPos.X - 3; jointLine.X2 = jointLine.X1 + 6; jointLine.Y1 = jointLine.Y2 = jointPos.Y; //jointLine.Stroke = jointColors[point.JointType]; jointLine.StrokeThickness = 6; kinectSkeletonFeed.Children.Add(jointLine); } } iSkeleton++; } // for each skeleton }
/// <summary> /// Displays the full skeleton image from the Kinect sensor /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OnCameraSkeletonFrameReady(object sender, IavaSkeletonFrameReadyEventArgs e) { kinectSkeletonFeed.Skeleton = e.SkeletonFrame.ActiveSkeleton; }
/// <summary> /// Handles the SkeletonFrameReady event of the IRuntime control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="IavaSkeletonFrameReadyEventArgs"/> instance containing the event data.</param> private static void OnSkeletonFrameReady(object sender, IavaSkeletonFrameReadyEventArgs e) { if (SkeletonFrameReady != null) { SkeletonFrameReady(null, e); } }
public void ExplicitTest() { // Create the Kinect object SkeletonFrameReadyEventArgs kinectEventArgs = CreateSkeletonFrameReadyEventArgs(); // Create the Iava Equivalent IavaSkeletonFrameReadyEventArgs iavaEventArgs = new IavaSkeletonFrameReadyEventArgs((IavaSkeletonFrame)kinectEventArgs.OpenSkeletonFrame()); // Test the object as a whole Assert.AreEqual(iavaEventArgs, (IavaSkeletonFrameReadyEventArgs)kinectEventArgs); // Set the Kinect Object to null kinectEventArgs = null; // Make sure we don't attempt to cast nulls Assert.IsNull((IavaSkeletonFrameReadyEventArgs)kinectEventArgs); }