public void TestMultipleCenter() { KinectBody[] bodies = new KinectBody[] { FakeBodies.FakeSpineBody(10, true, new CameraSpacePoint() { X = 0.2f }), FakeBodies.FakeSpineBody(20, true, new CameraSpacePoint() { X = -0.02f //Center is an absolute value, so 1 and 2 should be same distance }), FakeBodies.FakeSpineBody(30, true, new CameraSpacePoint() { X = 0.02f }), FakeBodies.FakeSpineBody(40, true, new CameraSpacePoint() { X = 0.7f }) }; var closest = bodies.CenterBodies().ToArray(); Assert.AreEqual(closest.Length, 2); Assert.AreEqual(closest.Contains(bodies[1]), true); Assert.AreEqual(closest.Contains(bodies[2]), true); }
public void TestMultipleClosest() { KinectBody[] bodies = new KinectBody[] { FakeBodies.FakeSpineBody(10, true, new CameraSpacePoint() { Z = 0.2f }), FakeBodies.FakeSpineBody(20, true, new CameraSpacePoint() { Z = 0.02f }), FakeBodies.FakeSpineBody(30, true, new CameraSpacePoint() { Z = 0.02f }), FakeBodies.FakeSpineBody(40, true, new CameraSpacePoint() { Z = 0.7f }) }; var closest = bodies.ClosestBodies().ToArray(); Assert.AreEqual(closest.Length, 2); Assert.AreEqual(closest.Contains(bodies[1]), true); Assert.AreEqual(closest.Contains(bodies[2]), true); }
public void TestSingleCenter() { KinectBody[] bodies = new KinectBody[] { FakeBodies.FakeSpineBody(10, true, new CameraSpacePoint() { X = 0.2f, }), FakeBodies.FakeSpineBody(20, true, new CameraSpacePoint() { X = 0.1f, }), FakeBodies.FakeSpineBody(30, true, new CameraSpacePoint() { X = 0.01f, }), FakeBodies.FakeSpineBody(40, true, new CameraSpacePoint() { X = 0.7f }) }; var closest = bodies.CenterBodies().ToArray(); Assert.AreEqual(closest.Length, 1); Assert.AreEqual(closest[0], bodies[2]); }
public void TestSerialize() { KinectBody[] bodies = new KinectBody[] { FakeBodies.FakeSpineBody(10, true, new CameraSpacePoint() { X = 0.2f }), FakeBodies.FakeSpineBody(20, true, new CameraSpacePoint() { X = -0.02f //Center is an absolute value, so 1 and 2 should be same distance }), FakeBodies.FakeSpineBody(30, true, new CameraSpacePoint() { X = 0.02f }), FakeBodies.FakeSpineBody(40, true, new CameraSpacePoint() { X = 0.7f }) }; string json = JsonSerializer.ToJson(bodies); var deserialize = JsonSerializer.FromJson(json); Assert.AreEqual(deserialize.Count(), 4); }