/// <summary>
        /// Constructor for VisualKinectUnit
        /// </summary>
        /// <param name="sensor">LocatedSensor class kinect sensor</param>
        /// <param name="skeletonDrawingImage">Image that we'll draw the skeleton on</param>
        /// <param name="colorImage">Image we'll use to push the color camera video to</param>
        public VisualKinectUnit(LocatedSensor locatedSensor, System.Windows.Controls.Image skeletonDrawingImage = null, System.Windows.Controls.Image colorImage = null)
        {
            // Get in some parameters
            this.locatedSensor        = locatedSensor;
            this.skeletonDrawingImage = skeletonDrawingImage;
            this.colorImage           = colorImage;

            // Set up the basics for drawing a skeleton
            // 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);
            // Turn on the skeleton stream to receive skeleton frames
            locatedSensor.sensor.SkeletonStream.Enable();
            // Turn on the color stream to receive color frames
            locatedSensor.sensor.ColorStream.Enable(ColorImageFormat.RgbResolution640x480Fps30);

            // This is the bitmap we'll display on-screen
            colorBitmap = (new WriteableBitmap(locatedSensor.sensor.ColorStream.FrameWidth,
                                               locatedSensor.sensor.ColorStream.FrameHeight,
                                               96.0, 96.0, PixelFormats.Bgr32, null));

            // Add an event handler to be called whenever there is new color frame data
            if (colorImage != null)
            {
                locatedSensor.sensor.ColorFrameReady += this.refreshColorImage;
            }
            // Add an event handler to be called whenever there is new color frame data
            if (skeletonDrawingImage != null)
            {
                locatedSensor.sensor.SkeletonFrameReady += this.refreshSkeletonDrawing;
                this.skeletonDrawingImage.Source         = imageSource;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Constructor for VisualKinectUnit
        /// </summary>
        /// <param name="sensor">LocatedSensor class kinect sensor</param>
        /// <param name="skeletonDrawingImage">Image that we'll draw the skeleton on</param>
        /// <param name="colorImage">Image we'll use to push the color camera video to</param>
        public VisualKinectUnit(LocatedSensor locatedSensor, System.Windows.Controls.Image skeletonDrawingImage = null,
                                System.Windows.Controls.Image colorImage = null, KinectViewport viewport = null)
        {
            // Get in some parameters
            this.locatedSensor        = locatedSensor;
            this.skeletonDrawingImage = skeletonDrawingImage;
            this.colorImage           = colorImage;
            this.viewport             = viewport;

            // Set up the basics for drawing a skeleton
            this.showGlobalSkeletons = false;
            // 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);
            // Turn on the skeleton stream to receive skeleton frames
            locatedSensor.sensor.SkeletonStream.Enable();
            // Turn on the color stream to receive color frames
            locatedSensor.sensor.ColorStream.Enable(ColorImageFormat.RgbResolution640x480Fps30);

            // This is the bitmap we'll display on-screen
            colorBitmap = (new WriteableBitmap(locatedSensor.sensor.ColorStream.FrameWidth,
                                               locatedSensor.sensor.ColorStream.FrameHeight,
                                               96.0, 96.0, PixelFormats.Bgr32, null));

            // Add an event handler to be called whenever there is new color frame data
            if (colorImage != null)
            {
                locatedSensor.sensor.ColorFrameReady += this.refreshColorImage;
            }
            // Add an event handler to be called whenever there is new color frame data
            if (skeletonDrawingImage != null)
            {
                locatedSensor.sensor.SkeletonFrameReady += this.refreshSkeletonDrawing;
                this.skeletonDrawingImage.Source         = imageSource;
            }

            // If we've got a viewport, then let's attach the generic update value function to
            //  the text changed handlers
            if (viewport != null)
            {
                viewport.AttachVisualKinect(this);
                viewport.xOffset.TextChanged           += updateValues;
                viewport.yOffset.TextChanged           += updateValues;
                viewport.zOffset.TextChanged           += updateValues;
                viewport.pitchAngle.TextChanged        += updateValues;
                viewport.rollAngle.TextChanged         += updateValues;
                viewport.yawAngle.TextChanged          += updateValues;
                viewport.showGlobalSkeletons.Checked   += setGlobalSkeletons;
                viewport.showGlobalSkeletons.Unchecked += clearGlobalSkeletons;
            }
        }
Exemplo n.º 3
0
        /// <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();
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Constructor for VisualKinectUnit
        /// </summary>
        /// <param name="sensor">LocatedSensor class kinect sensor</param>
        /// <param name="skeletonDrawingImage">Image that we'll draw the skeleton on</param>
        /// <param name="colorImage">Image we'll use to push the color camera video to</param>
        public VisualKinectUnit(LocatedSensor locatedSensor, System.Windows.Controls.Image skeletonDrawingImage = null,
                                 System.Windows.Controls.Image colorImage = null, KinectViewport viewport = null)
        {
            // Get in some parameters
            this.locatedSensor = locatedSensor;
            this.skeletonDrawingImage = skeletonDrawingImage;
            this.colorImage = colorImage;
            this.viewport = viewport;

            // Set up the basics for drawing a skeleton
            this.showGlobalSkeletons = false;
            // 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);
            // Turn on the skeleton stream to receive skeleton frames
            locatedSensor.sensor.SkeletonStream.Enable();
            // Turn on the color stream to receive color frames
            locatedSensor.sensor.ColorStream.Enable(ColorImageFormat.RgbResolution640x480Fps30);

            // This is the bitmap we'll display on-screen
            colorBitmap = (new WriteableBitmap(locatedSensor.sensor.ColorStream.FrameWidth,
                                               locatedSensor.sensor.ColorStream.FrameHeight,
                                               96.0, 96.0, PixelFormats.Bgr32, null));

            // Add an event handler to be called whenever there is new color frame data
            if (colorImage != null) {
                locatedSensor.sensor.ColorFrameReady += this.refreshColorImage;
            }
            // Add an event handler to be called whenever there is new color frame data
            if (skeletonDrawingImage != null) {
                locatedSensor.sensor.SkeletonFrameReady += this.refreshSkeletonDrawing;
                this.skeletonDrawingImage.Source = imageSource;
            }

            // If we've got a viewport, then let's attach the generic update value function to
            //  the text changed handlers
            if (viewport != null)
            {
                viewport.AttachVisualKinect(this);
                viewport.xOffset.TextChanged += updateValues;
                viewport.yOffset.TextChanged += updateValues;
                viewport.zOffset.TextChanged += updateValues;
                viewport.pitchAngle.TextChanged += updateValues;
                viewport.rollAngle.TextChanged += updateValues;
                viewport.yawAngle.TextChanged += updateValues;
                viewport.showGlobalSkeletons.Checked += setGlobalSkeletons;
                viewport.showGlobalSkeletons.Unchecked += clearGlobalSkeletons;
            }
        }
Exemplo n.º 5
0
 public VisualKinectUnit(LocatedSensor sensor, KinectViewport viewport)
 {
     new VisualKinectUnit(sensor, viewport.skeletonDrawingImage, viewport.colorImage, viewport);
 }
Exemplo n.º 6
0
        /// <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...");
                    }
                }
            }
        }
Exemplo n.º 7
0
        /// <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>
            /// Constructor for VisualKinectUnit
            /// </summary>
            /// <param name="sensor">LocatedSensor class kinect sensor</param>
            /// <param name="skeletonDrawingImage">Image that we'll draw the skeleton on</param>
            /// <param name="colorImage">Image we'll use to push the color camera video to</param>
            public VisualKinectUnit(LocatedSensor locatedSensor, System.Windows.Controls.Image skeletonDrawingImage = null, System.Windows.Controls.Image colorImage = null)
            {
                // Get in some parameters
                this.locatedSensor = locatedSensor;
                this.skeletonDrawingImage = skeletonDrawingImage;
                this.colorImage = colorImage;

                // Set up the basics for drawing a skeleton
                // 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);
                // Turn on the skeleton stream to receive skeleton frames
                locatedSensor.sensor.SkeletonStream.Enable();
                // Turn on the color stream to receive color frames
                locatedSensor.sensor.ColorStream.Enable(ColorImageFormat.RgbResolution640x480Fps30);

                // This is the bitmap we'll display on-screen
                colorBitmap = (new WriteableBitmap(locatedSensor.sensor.ColorStream.FrameWidth,
                                                   locatedSensor.sensor.ColorStream.FrameHeight,
                                                   96.0, 96.0, PixelFormats.Bgr32, null));

                // Add an event handler to be called whenever there is new color frame data
                if (colorImage != null) {
                    locatedSensor.sensor.ColorFrameReady += this.refreshColorImage;
                }
                // Add an event handler to be called whenever there is new color frame data
                if (skeletonDrawingImage != null) {
                    locatedSensor.sensor.SkeletonFrameReady += this.refreshSkeletonDrawing;
                    this.skeletonDrawingImage.Source = imageSource;
                }
            }
        /// <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...");
                    }
                }
            }
        }
Exemplo n.º 10
0
 public VisualKinectUnit(LocatedSensor sensor, KinectViewport viewport)
 {
     new VisualKinectUnit(sensor, viewport.skeletonDrawingImage, viewport.colorImage, viewport);
 }