private Image image; // The image where the object will be shown

        #endregion Fields

        #region Constructors

        /// <summary>
        /// Constructor of the class
        /// </summary>
        /// <param name="img">Image in the .xaml</param>
        /// <param name="picture">Path to the image</param>
        /// <param name="freq"></param>
        public InteractiveObject(ref Image img, string picture, int freq, int delay = 60, int first_frame = -1)
        {
            image = img;
            image.Source = new BitmapImage(new Uri(System.IO.Path.GetFullPath("../../images/" + picture)));
            frequency = freq;
            calculator = new Calculator();
            first_active_frame = first_frame;
            this.delay = delay;
        }
Exemple #2
0
 /// <summary>
 /// Constructor of the shoot object
 /// </summary>
 /// <param name="sensor"></param>
 /// <param name="skel"></param>
 /// <param name="forearm"></param>
 public Shoot(KinectSensor sensor, Skeleton skel, float forearm)
 {
     SkeletonPoint hand = skel.Joints[JointType.HandRight].Position;
     SkeletonPoint elbow = skel.Joints[JointType.ElbowRight].Position;
     calculator = new Calculator();
     gestures = new Gesture[2];
     gestures[0] = new Gesture(hand, JointType.HandRight, sensor, 1, 0.08f);
     gestures[1] = new Gesture(calculator.sum(elbow, 0.05 * Math.Sign(hand.X - elbow.X), 0.9 * forearm, 0.9 * forearm), JointType.HandRight, sensor, 0.1f, 0.3f);
     this.sensor = sensor;
     this.forearm = forearm;
 }
Exemple #3
0
        /// <summary>
        /// Create a new instance of Gesture
        /// </summary>
        /// <param name="location">3Dpoint</param>
        /// <param name="joint">Joint must be in the location</param>
        /// <param name="sensor">Sensor to Maps a Skeleton to the screen</param>
        /// <param name="seconds">Seconds to maintain the position</param>
        /// <param name="tolerance">Tolerance of the error</param>
        public Gesture(SkeletonPoint location, JointType joint, KinectSensor sensor, float seconds, float tolerance = (float)0.15)
        {
            this.locations = new SkeletonPoint[1];
            this.locations[0] = location;

            this.joints = new JointType[1];
            this.joints[0] = joint;

            this.pens = new Pen[1];
            this.pens[0] = new Pen(Brushes.Blue, 6);

            this.sensor = sensor;
            this.calculator = new Calculator();
            this.screen_locations = new Point[1];
            this.screen_locations[0] = calculator.SkeletonPointToScreen(sensor, locations[0]);

            this.seconds = seconds;
            this.tolerance = tolerance;

            initializeColors();
            calculator = new Calculator();
        }
Exemple #4
0
        /// <summary>
        /// Create a new instance of Gesture
        /// </summary>
        /// <param name="location">3Dpoint collection</param>
        /// <param name="joint">Joint collection must be in the location</param>
        /// <param name="sensor">Sensor to Maps a Skeleton to the screen</param>
        /// <param name="seconds">Seconds to maintain the position</param>
        /// <param name="tolerance">Tolerance of the error</param>
        public Gesture(SkeletonPoint[] locations, JointType[] joints, KinectSensor sensor, float seconds, float tolerance = (float)0.15)
        {
            this.locations = new SkeletonPoint[locations.Length];
            this.locations = locations;

            this.joints = new JointType[joints.Length];
            this.joints = joints;

            this.pens = new Pen[locations.Length];
            this.calculator = new Calculator();

            this.sensor = sensor;
            this.screen_locations = new Point[locations.Length];
            for (int i = 0; i < locations.Length; i++) {
                this.screen_locations[i] =  calculator.SkeletonPointToScreen(sensor,locations[i]);
            }

            this.seconds = seconds;
            this.tolerance = tolerance;

            initializeColors();
            calculator = new Calculator();
        }
        /// <summary>
        /// Execute startup tasks
        /// </summary>
        /// <param name="sender">object sending the event</param>
        /// <param name="e">event arguments</param>
        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
            draw_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 (See components in Toolkit Browser).
            foreach (var potentialSensor in KinectSensor.KinectSensors) {
                if (potentialSensor.Status == KinectStatus.Connected) {
                    this.my_KinectSensor = potentialSensor;
                    break;
                }
            }

            if (null != this.my_KinectSensor) {
                // Turn on the skeleton stream to receive skeleton frames
                this.my_KinectSensor.SkeletonStream.Enable();

                // Add an event handler to be called whenever there is new color frame data
                this.my_KinectSensor.SkeletonFrameReady += this.SensorSkeletonFrameReady;

                this.my_KinectSensor.ColorStream.Enable();

                // Add an event handler to be called whenever there is new color frame data
                this.my_KinectSensor.ColorFrameReady += Sensor_ColorFrameReady;

                // Start the sensor!
                try {
                    this.my_KinectSensor.Start();
                }
                catch (IOException) {
                    this.my_KinectSensor = null;
                }
            }

            calculator = new Calculator();
        }