private void Window_Loaded(object sender, RoutedEventArgs e) { Room room = new Room(); Tracker tracker = new Tracker("kinect", new Point(10, 10), 225, 15); room.AddTracker(tracker); //double angle = 180.0; //double fov = 190; //room.AddDevice(new Device("one", new Point(5, 0), angle, fov)); //room.AddDevice(new Device("two", new Point(10, 0), angle, fov)); //room.AddDevice(new Device("three", new Point(15, 0), angle, fov)); //room.AddDevice(new Device("four", new Point(10, 5), angle, fov)); //room.AddDevice(new Device("five", new Point(10, -5), angle, fov)); //Debug.WriteLine(room.GetDevicesInViewOf(room.GetDevice("one")).Count); //Debug.WriteLine(room.GetDevicesInViewOf(room.GetDevice("two")).Count); //Debug.WriteLine(room.GetDevicesInViewOf(room.GetDevice("three")).Count); //Debug.WriteLine(room.GetDevicesInViewOf(room.GetDevice("four")).Count); //Debug.WriteLine(room.GetDevicesInViewOf(room.GetDevice("five")).Count); Device dev = new Device("dev"); room.AddDevice(dev); tracker.UpdatePositionForDevice(dev, new Vector(-20,0)); Debug.Write(dev.Location.X + " " + dev.Location.Y); }
/// <summary> /// Initializes a new instance of the MainWindow class. /// </summary> public MainWindow() { InitializeComponent(); nearX = 1000; nearY = 1000; nearZ = 1000; farX = 0; farY = 0; farZ = 0; myRoom = new Room(); myTracker = new Tracker("myKinect", new Point(0, 2.5), 0.0, 15); myRoom.AddTracker(myTracker); myDevice = new Device("me"); myRoom.AddDevice(myDevice); }
private void Window_Loaded(object sender, RoutedEventArgs e) { // Create the drawing group we'll use for drawing this.drawingGroup = new DrawingGroup(); // Create an image source that we can use in our image control this.imageSource = new DrawingImage(this.drawingGroup); // Display the drawing using our image control Image.Source = this.imageSource; // Look through all sensors and start the first connected one. // This requires that a Kinect is connected at the time of app startup. // To make your app robust against plug/unplug, // it is recommended to use KinectSensorChooser provided in Microsoft.Kinect.Toolkit foreach (var potentialSensor in KinectSensor.KinectSensors) { if (potentialSensor.Status == KinectStatus.Connected) { this.sensor = potentialSensor; break; } } if (null != this.sensor) { // Turn on the skeleton stream to receive skeleton frames this.sensor.SkeletonStream.Enable(); // Add an event handler to be called whenever there is new color frame data this.sensor.SkeletonFrameReady += this.SensorSkeletonFrameReady; // Start the sensor! try { this.sensor.Start(); } catch (IOException) { this.sensor = null; } } if (null == this.sensor) { MessageBox.Show("No Kinect"); //this.statusBarText.Text = Properties.Resources.NoKinectReady; } room = new Room(); tracker = new Tracker("kinect", new Point(2.25, yRange), 270.0); room.AddTracker(tracker); devices = new Device[6]; for (int i = 0; i < 6; i++) { devices[i] = new Device(i.ToString()); if (i % 2 == 1) devices[i].Orientation = 0; else devices[i].Orientation = 180.0; room.AddDevice(devices[i]); } }
public void FieldOfViewWithVaryingOrientationTest() { Room r = new Room(); List<Device> devices = new List<Device>(); devices.Add((new Device("zero", new Point(5, 0), 0.0, 15.0))); devices.Add((new Device("one", new Point(10, 0), 0.0, 15.0))); devices.Add((new Device("two", new Point(15, 0), 0.0, 15.0))); devices.Add((new Device("three", new Point(10, 5), 0.0, 15.0))); devices.Add((new Device("four", new Point(10, -5), 0.0, 15.0))); foreach (Device d in devices) r.AddDevice(d); List<Device> results = r.GetDevicesInViewOf(r.GetDevice("zero")); Assert.AreEqual(results[0], devices[1]); Assert.AreEqual(results[1], devices[2]); Assert.AreEqual(results.Count, 2); results = r.GetDevicesInViewOf(r.GetDevice("one")); Assert.AreEqual(results[0], devices[2]); Assert.AreEqual(results.Count, 1); results = r.GetDevicesInViewOf(r.GetDevice("two")); Assert.AreEqual(results.Count, 0); results = r.GetDevicesInViewOf(r.GetDevice("three")); Assert.AreEqual(results.Count, 0); results = r.GetDevicesInViewOf(r.GetDevice("four")); Assert.AreEqual(results.Count, 0); foreach (Device d in devices) { d.Orientation = 90.0; } results = r.GetDevicesInViewOf(r.GetDevice("one")); Assert.AreEqual(results[0], devices[3]); Assert.AreEqual(results.Count, 1); results = r.GetDevicesInViewOf(r.GetDevice("four")); Assert.AreEqual(results[0], devices[1]); Assert.AreEqual(results[1], devices[3]); Assert.AreEqual(results.Count, 2); results = r.GetDevicesInViewOf(r.GetDevice("zero")); Assert.AreEqual(results.Count, 0); results = r.GetDevicesInViewOf(r.GetDevice("two")); Assert.AreEqual(results.Count, 0); results = r.GetDevicesInViewOf(r.GetDevice("three")); Assert.AreEqual(results.Count, 0); foreach (Device d in devices) { d.Orientation = 115.0; } foreach (Device d in devices) { results = r.GetDevicesInViewOf(d); Assert.AreEqual(results.Count, 0); } }
public void CoordinateTranslationTest() { Room r = new Room(); Tracker t = new Tracker("myKinect", new Point(5, 5), 270); r.AddTracker(t); Device one = new Device("one"); Device two = new Device("two"); Device three = new Device("three"); r.AddDevice(one); r.AddDevice(two); r.AddDevice(three); t.UpdatePositionForDevice(one, new Vector(1, 1)); t.UpdatePositionForDevice(two, new Vector(5, 0)); t.UpdatePositionForDevice(three, new Vector(3, -3)); Assert.AreEqual(one.Location.X, 6, 0.001); Assert.AreEqual(one.Location.Y, 4, 0.001); Assert.AreEqual(two.Location.X, 5, 0.001); Assert.AreEqual(two.Location.Y, 0, 0.001); Assert.AreEqual(three.Location.X, 2, 0.001); Assert.AreEqual(three.Location.Y, 2, 0.001); // test of translation alone Tracker t2 = new Tracker("kinect2", new Point(0, -10), 0.0); r.AddTracker(t2); t2.UpdatePositionForDevice(one, new Vector(6, 14)); t2.UpdatePositionForDevice(two, new Vector(5, 10)); t2.UpdatePositionForDevice(three, new Vector(2, 12)); Assert.AreEqual(one.Location.X, 6, 0.001); Assert.AreEqual(one.Location.Y, 4, 0.001); Assert.AreEqual(two.Location.X, 5, 0.001); Assert.AreEqual(two.Location.Y, 0, 0.001); Assert.AreEqual(three.Location.X, 2, 0.001); Assert.AreEqual(three.Location.Y, 2, 0.001); //test of rotation alone Tracker t3 = new Tracker("kinect3", new Point(0, 0), 135); t3.UpdatePositionForDevice(one, new Vector(-1.425, -7.0678)); t3.UpdatePositionForDevice(two, new Vector(-3.535, -3.535)); t3.UpdatePositionForDevice(three, new Vector(0, -Math.Sqrt(8))); Assert.AreEqual(one.Location.X, 6, 0.01); // to deal with horrible horrible rounding error introduced by hardcoded positions just above Assert.AreEqual(one.Location.Y, 4, 0.01); Assert.AreEqual(two.Location.X, 5, 0.001); Assert.AreEqual(two.Location.Y, 0, 0.001); Assert.AreEqual(three.Location.X, 2, 0.001); Assert.AreEqual(three.Location.Y, 2, 0.001); }
public void VaryingFieldOfViewTest() { Room r = new Room(); List<Device> devices = new List<Device>(); devices.Add((new Device("zero", new Point(5, 0), 0.0, 190.0))); devices.Add((new Device("one", new Point(10, 0), 0.0, 190.0))); devices.Add((new Device("two", new Point(15, 0), 0.0, 190.0))); devices.Add((new Device("three", new Point(10, 5), 0.0, 190.0))); devices.Add((new Device("four", new Point(10, -5), 0.0, 190.0))); foreach (Device d in devices) r.AddDevice(d); List<Device> results = r.GetDevicesInViewOf(r.GetDevice("zero")); Assert.AreEqual(results.Count, 4); results = r.GetDevicesInViewOf(r.GetDevice("one")); Assert.AreEqual(results.Count, 3); results = r.GetDevicesInViewOf(r.GetDevice("two")); Assert.AreEqual(results.Count, 0); results = r.GetDevicesInViewOf(r.GetDevice("three")); Assert.AreEqual(results.Count, 3); results = r.GetDevicesInViewOf(r.GetDevice("four")); Assert.AreEqual(results.Count, 3); }