/// <summary> /// Execute startup tasks /// </summary> /// <param name="sender">object sending the event</param> /// <param name="e">event arguments</param> private void WindowLoaded(object sender, RoutedEventArgs e) { // Setup osc sender oscArgs[0] = "127.0.0.1"; oscArgs[1] = OscPort.Text; oscWriter = new UdpWriter(oscArgs[0], Convert.ToInt32(oscArgs[1])); deltaToscWriter = new UdpWriter(oscArgs[0], 7114); // Initialize Data viewer oscViewer.Text = "\nData will be shown here\nwhen there is a skeleton\nbeing tracked."; kinectGroup = new VisualKinectGroup(); viewports = new List <KinectViewport>(); viewports.Add(this.TestViewport); viewports.Add(this.TestViewport2); // 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 int numberOfKinects = 0; foreach (var potentialSensor in KinectSensor.KinectSensors) { if (potentialSensor.Status == KinectStatus.Connected) { // Start the sensor! try { potentialSensor.Start(); // Good to go, so count this one as connected! // So let's set up some environment for this... // LocatedSensor sensor = new LocatedSensor(potentialSensor, kinectXPositions[numberOfKinects], // kinectYPositions[numberOfKinects], // kinectZPositions[numberOfKinects], // kinectAngles[numberOfKinects]); LocatedSensor sensor = new LocatedSensor(potentialSensor, 0, 0, 0, 0, 0, 0); VisualKinectUnit newSensor = new VisualKinectUnit(sensor, viewports[numberOfKinects].skeletonDrawingImage, viewports[numberOfKinects].colorImage, viewports[numberOfKinects]); kinectGroup.AddVisualKinectUnit(newSensor); // This function sends out skeleton data as OSC //newSensor.locatedSensor.sensor.SkeletonFrameReady += sendOSCAsAnimataData; newSensor.locatedSensor.sensor.SkeletonFrameReady += sendOSCSkeletonPositions; numberOfKinects++; Console.WriteLine("Number of Kinects : " + numberOfKinects); } catch (IOException) { Console.WriteLine("Couldn't start one of the Kinect sensors..."); } } } // Now that we have all of our sensors loaded, let's see if we have any data // Try and load in data from a file.. string configSerialization = ""; try { configSerialization = File.ReadAllText(KinectCalibrationFilename); } catch (Exception exception) { Console.WriteLine("The file could not be read:"); Console.WriteLine(exception.Message); Console.WriteLine("Using default parameters..."); } // If we got data, parse it! if (configSerialization != "") { List <KinectCoordinates> coordinates = JsonConvert.DeserializeObject <List <KinectCoordinates> >(File.ReadAllText(KinectCalibrationFilename)); for (int i = 0; i < viewports.Count && i < coordinates.Count; i++) { viewports[i].xOffset.Text = coordinates[i].xOffset; viewports[i].yOffset.Text = coordinates[i].yOffset; viewports[i].zOffset.Text = coordinates[i].zOffset; viewports[i].pitchAngle.Text = coordinates[i].pitch; viewports[i].rollAngle.Text = coordinates[i].roll; viewports[i].yawAngle.Text = coordinates[i].yaw; } // Update the info from the kinect windows // TODO: Maybe this happens automagically, but maybe not... Test this. //Console.WriteLine("VisualKinectUnit 0's x offset is:"); // Console.WriteLine(kinectGroup.visualKinectUnits[0].locatedSensor.xOffset); } // Now get the overall calibration stuff, like OSC port and such configSerialization = ""; try { configSerialization = File.ReadAllText(MetaCalibrationFilename); } catch (Exception exception) { Console.WriteLine("The file could not be read:"); Console.WriteLine(exception.Message); Console.WriteLine("Using default parameters..."); } // If we got data, parse it! if (configSerialization != "") { MetaConfiguration config = JsonConvert.DeserializeObject <MetaConfiguration>(configSerialization); XOffsetTextBox.Text = config.XOffset; YOffsetTextBox.Text = config.YOffset; XScaleTextBox.Text = config.XScaling; YScaleTextBox.Text = config.YScaling; OscAddress.Text = config.OSCAddress; OscPort.Text = config.port; // Update the actual OSC port stuff // We don't change the scaling and offset stuff since that's // directly read from the text boxen oscArgs[1] = OscPort.Text; oscWriter = new UdpWriter(oscArgs[0], Convert.ToInt32(oscArgs[1])); UpdateOscAddress(); } }
/// <summary> /// Execute startup tasks /// </summary> /// <param name="sender">object sending the event</param> /// <param name="e">event arguments</param> private void WindowLoaded(object sender, RoutedEventArgs e) { // Setup osc sender oscArgs[0] = "127.0.0.1"; oscArgs[1] = OscPort.Text; oscWriter = new UdpWriter(oscArgs[0], Convert.ToInt32(oscArgs[1])); deltaToscWriter = new UdpWriter(oscArgs[0], 7114); // Initialize Data viewer oscViewer.Text = "\nData will be shown here\nwhen there is a skeleton\nbeing tracked."; kinectGroup = new VisualKinectGroup(); viewports = new List<KinectViewport>(); viewports.Add(this.TestViewport); viewports.Add(this.TestViewport2); // 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 int numberOfKinects = 0; foreach (var potentialSensor in KinectSensor.KinectSensors) { if (potentialSensor.Status == KinectStatus.Connected) { // Start the sensor! try { potentialSensor.Start(); // Good to go, so count this one as connected! // So let's set up some environment for this... // LocatedSensor sensor = new LocatedSensor(potentialSensor, kinectXPositions[numberOfKinects], // kinectYPositions[numberOfKinects], // kinectZPositions[numberOfKinects], // kinectAngles[numberOfKinects]); LocatedSensor sensor = new LocatedSensor(potentialSensor, 0, 0,0,0, 0 , 0); VisualKinectUnit newSensor = new VisualKinectUnit(sensor, viewports[numberOfKinects].skeletonDrawingImage, viewports[numberOfKinects].colorImage, viewports[numberOfKinects]); kinectGroup.AddVisualKinectUnit(newSensor); // This function sends out skeleton data as OSC //newSensor.locatedSensor.sensor.SkeletonFrameReady += sendOSCAsAnimataData; newSensor.locatedSensor.sensor.SkeletonFrameReady += sendOSCSkeletonPositions; numberOfKinects++; Console.WriteLine("Number of Kinects : " + numberOfKinects); } catch (IOException) { Console.WriteLine("Couldn't start one of the Kinect sensors..."); } } } // Now that we have all of our sensors loaded, let's see if we have any data // Try and load in data from a file.. string configSerialization = ""; try { configSerialization = File.ReadAllText(KinectCalibrationFilename); } catch (Exception exception) { Console.WriteLine("The file could not be read:"); Console.WriteLine(exception.Message); Console.WriteLine("Using default parameters..."); } // If we got data, parse it! if (configSerialization != ""){ List<KinectCoordinates> coordinates = JsonConvert.DeserializeObject<List<KinectCoordinates>>(File.ReadAllText(KinectCalibrationFilename)); for (int i = 0; i < viewports.Count && i < coordinates.Count; i++) { viewports[i].xOffset.Text = coordinates[i].xOffset; viewports[i].yOffset.Text = coordinates[i].yOffset; viewports[i].zOffset.Text = coordinates[i].zOffset; viewports[i].pitchAngle.Text = coordinates[i].pitch; viewports[i].rollAngle.Text = coordinates[i].roll; viewports[i].yawAngle.Text = coordinates[i].yaw; } // Update the info from the kinect windows // TODO: Maybe this happens automagically, but maybe not... Test this. //Console.WriteLine("VisualKinectUnit 0's x offset is:"); // Console.WriteLine(kinectGroup.visualKinectUnits[0].locatedSensor.xOffset); } // Now get the overall calibration stuff, like OSC port and such configSerialization = ""; try { configSerialization = File.ReadAllText(MetaCalibrationFilename); } catch (Exception exception) { Console.WriteLine("The file could not be read:"); Console.WriteLine(exception.Message); Console.WriteLine("Using default parameters..."); } // If we got data, parse it! if (configSerialization != "") { MetaConfiguration config = JsonConvert.DeserializeObject<MetaConfiguration>(configSerialization); XOffsetTextBox.Text = config.XOffset; YOffsetTextBox.Text = config.YOffset; XScaleTextBox.Text = config.XScaling; YScaleTextBox.Text = config.YScaling; OscAddress.Text = config.OSCAddress; OscPort.Text = config.port; // Update the actual OSC port stuff // We don't change the scaling and offset stuff since that's // directly read from the text boxen oscArgs[1] = OscPort.Text; oscWriter = new UdpWriter(oscArgs[0], Convert.ToInt32(oscArgs[1])); UpdateOscAddress(); } }
/// <summary> /// Execute startup tasks /// </summary> /// <param name="sender">object sending the event</param> /// <param name="e">event arguments</param> private void WindowLoaded(object sender, RoutedEventArgs e) { // Setup osc sender oscArgs[0] = "127.0.0.1"; oscArgs[1] = OscPort.Text; oscWriter = new UdpWriter(oscArgs[0], Convert.ToInt32(oscArgs[1])); oscWriter2 = new UdpWriter(RemoteAddress, 7110); deltaToscWriter = new UdpWriter(oscArgs[0], 7114); // Initialize Data viewer oscViewer.Text = "\nData will be shown here\nwhen there is a skeleton\nbeing tracked."; // Set up our lists visualKinectUnitList = new List <VisualKinectUnit>(); skeletonImageList = new List <System.Windows.Controls.Image>(); skeletonImageList.Add(Image0); skeletonImageList.Add(Image1); skeletonImageList.Add(Image2); skeletonImageList.Add(Image3); colorImageList = new List <System.Windows.Controls.Image>(); colorImageList.Add(ColorImage0); colorImageList.Add(ColorImage1); colorImageList.Add(ColorImage2); colorImageList.Add(ColorImage3); masterSkeletonList = new List <Skeleton>(); leadSkeletonIDs = new List <int>(); prunedSkeletonList = new List <Skeleton>(); // 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 int numberOfKinects = 0; foreach (var potentialSensor in KinectSensor.KinectSensors) { if (potentialSensor.Status == KinectStatus.Connected) { // Start the sensor! try { potentialSensor.Start(); // Good to go, so count this one as connected! // So let's set up some environment for this... LocatedSensor sensor = new LocatedSensor(potentialSensor, kinectXPositions[numberOfKinects], kinectYPositions[numberOfKinects], kinectZPositions[numberOfKinects], kinectAngles[numberOfKinects]); if ((numberOfKinects < colorImageList.Count) && (numberOfKinects < skeletonImageList.Count)) { System.Windows.Controls.Image colorImage = colorImageList[numberOfKinects]; System.Windows.Controls.Image skeletonImage = skeletonImageList[numberOfKinects]; VisualKinectUnit newSensor = new VisualKinectUnit(sensor, skeletonImage, colorImage); // Add a callback to our updateSkeletons function, so every frameReady event, // we update our global list of skeletons newSensor.locatedSensor.sensor.SkeletonFrameReady += updateSkeletons; //newSensor.locatedSensor.sensor.SkeletonFrameReady += sendOSCHeadOnly; //newSensor.locatedSensor.sensor.SkeletonFrameReady += sendOSCHands; //newSensor.locatedSensor.sensor.SkeletonFrameReady += sendOSCForearms; newSensor.locatedSensor.sensor.SkeletonFrameReady += sendOSCAsAnimataData; visualKinectUnitList.Add(newSensor); } else { visualKinectUnitList.Add(new VisualKinectUnit(sensor)); } numberOfKinects++; Console.WriteLine("Number of Kinects : " + numberOfKinects); } catch (IOException) { Console.WriteLine("Couldn't start one of the Kinect sensors..."); } } } }
public void AddVisualKinectUnit(VisualKinectUnit unit) { unit.locatedSensor.sensor.SkeletonFrameReady += updateSkeletons; visualKinectUnits.Add(unit); }
/// <summary> /// Execute startup tasks /// </summary> /// <param name="sender">object sending the event</param> /// <param name="e">event arguments</param> private void WindowLoaded(object sender, RoutedEventArgs e) { // Setup osc sender oscArgs[0] = "127.0.0.1"; oscArgs[1] = OscPort.Text; oscWriter = new UdpWriter(oscArgs[0], Convert.ToInt32(oscArgs[1])); // Initialize Data viewer oscViewer.Text = "\nData will be shown here\nwhen there is a skeleton\nbeing tracked."; // Set up our lists visualKinectUnitList = new List<VisualKinectUnit>(); skeletonImageList = new List<System.Windows.Controls.Image>(); skeletonImageList.Add(Image0); skeletonImageList.Add(Image1); skeletonImageList.Add(Image2); skeletonImageList.Add(Image3); colorImageList = new List<System.Windows.Controls.Image>(); colorImageList.Add(ColorImage0); colorImageList.Add(ColorImage1); colorImageList.Add(ColorImage2); colorImageList.Add(ColorImage3); masterSkeletonList = new List<Skeleton>(); leadSkeletonIDs = new List<int>(); // 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 int numberOfKinects = 0; foreach (var potentialSensor in KinectSensor.KinectSensors) { if (potentialSensor.Status == KinectStatus.Connected) { // Start the sensor! try { potentialSensor.Start(); // Good to go, so count this one as connected! // So let's set up some environment for this... LocatedSensor sensor = new LocatedSensor(potentialSensor, kinectXPositions[numberOfKinects], kinectYPositions[numberOfKinects], kinectZPositions[numberOfKinects], kinectAngles[numberOfKinects]); if ((numberOfKinects < colorImageList.Count) && (numberOfKinects < skeletonImageList.Count)) { System.Windows.Controls.Image colorImage = colorImageList[numberOfKinects]; System.Windows.Controls.Image skeletonImage = skeletonImageList[numberOfKinects]; VisualKinectUnit newSensor = new VisualKinectUnit(sensor, skeletonImage, colorImage); // Add a callback to our updateSkeletons function, so every frameReady event, // we update our global list of skeletons newSensor.locatedSensor.sensor.SkeletonFrameReady += updateSkeletons; newSensor.locatedSensor.sensor.SkeletonFrameReady += sendOSCHeadOnly; visualKinectUnitList.Add(newSensor); } else { visualKinectUnitList.Add(new VisualKinectUnit(sensor)); } numberOfKinects++; Console.WriteLine("Number of Kinects : " + numberOfKinects); } catch (IOException) { Console.WriteLine("Couldn't start one of the Kinect sensors..."); } } } }
public void DetachVisualKinectUnit() { attachedKinectUnit = null; }
public void AttachVisualKinect(VisualKinectUnit unit) { attachedKinectUnit = unit; }