Esempio n. 1
0
    private void OnEnable()
    {
        ipAddresses = ipSettings.ipAddresses;

        kinects = new GameObject[ipAddresses.Count];
        users   = new User[ipAddresses.Count];

        IPAddress address;

        //Test if the IP addresses are valid and promt to check the values if not.
        for (int i = 0; i < ipAddresses.Count; i++)
        {
            if (!IPAddress.TryParse(ipAddresses[i], out address))
            {
                popupCanvas.SetActive(true);
                this.gameObject.SetActive(false);
                return;
            }
        }

        kinectModel = AssetDatabase.LoadAssetAtPath <GameObject>("Assets/Models/Kinect.obj");

        //Create the Kinect GameObjects and Clients and provide the IP addresses.
        for (int i = 0; i < ipAddresses.Count; i++)
        {
            GameObject kinectGameObject = new GameObject("Kinect_" + ipAddresses[i]);
            kinectGameObject.transform.parent = transform;
            KinectClient kinect = kinectGameObject.AddComponent <KinectClient>();

            //3D model for the Kinect device.
            GameObject model = Instantiate(kinectModel);
            model.name                    = "Kinect3DModel";
            model.transform.parent        = kinectGameObject.transform;
            model.transform.localPosition = Vector3.zero;
            model.transform.localRotation = Quaternion.identity;

            //Create the game object for the skeleton
            GameObject skeleton = new GameObject("User");
            skeleton.transform.parent = kinectGameObject.transform;
            User user = skeleton.AddComponent <User>();
            user.skeletonProvider = kinect;// transform.GetComponentInChildren<KinectClient>(true);
            user.userID           = i;

            kinects[i] = kinectGameObject;
            users[i]   = user;
        }

        //Disable the ip settings canvas
        canvas.SetActive(false);
    }
Esempio n. 2
0
        protected override void LoadContent()
        {
            renderTarget = new RenderTarget2D(GraphicsDevice, graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight);
            spriteBatch  = new SpriteBatch(GraphicsDevice);
            hudFontSmall = Content.Load <SpriteFont>(@"Fonts\FontSmall");
            if (drawTestImage)
            {
                videoTexture = Content.Load <Texture2D>(@"test");
            }
            else
            {
                videoTexture = new Texture2D(GraphicsDevice, 640, 360, false, SurfaceFormat.Color);
            }

            colorData = new Microsoft.Xna.Framework.Color[640 * 360];
            videoPacketDecoderWorker = new VideoPacketDecoderWorker(PixelFormat.BGR24, true, OnVideoPacketDecoded);
            videoPacketDecoderWorker.Start();
            droneClient = new DroneClient();
            droneClient.VideoPacketAcquired  += OnVideoPacketAcquired;
            droneClient.ConfigurationUpdated += OnConfigurationUpdated;
            droneClient.Active = true;
            try
            {
                kinect = new KinectClient("it-IT");
                kinect.VoiceCommandRecognized   += OnVoiceCommandRecognized;
                kinect.VoiceCommandRejected     += OnVoiceCommandRejected;
                kinect.GestureCommandRecognized += OnGestureRecognized;
                kinectMessage = "Kinect trovato. Riconoscimento vocale e comandi attivi...";
            }
            catch (Exception e)
            {
                kinectMessage = e.Message;
            }
            oculusRiftDistortionShader = Content.Load <Effect>("Shaders/OculusRift");
            oculusClient = new OculusClient();
            UpdateResolutionAndRenderTargets();
            screenType = ScreenType.Splash; //The splash show commands
        }
Esempio n. 3
0
        public ClientSettings(KinectClient client, KinectStreamerConfig config)
        {
            KinectStreamerConfig = config;
            Client = client;
            InitializeComponent();
            DataContext = this;
            DepthCheckbox.IsChecked = config.StreamDepthData;
            ColorCheckbox.IsChecked = config.StreamColorData;
            PointCloudCheckbox.IsChecked = config.StreamPointCloudData;
            SkeletonCheckbox.IsChecked = config.StreamBodyData;
            CalibrationCheckbox.IsChecked = config.ProvideCalibrationData;
            SendAsOneCheckbox.IsChecked = config.SendAsOne;

            foreach (FrameworkElement item in CheckboxContainer.Children)
            {
                if (item is CheckBox)
                {
                    item.IsEnabled = client.Connected;
                }
            }

            initialized = true;
        }
 private void kinectServer_DepthDataReady(KinectDemoMessage message, KinectClient client)
 {
     DepthStreamMessage msg = (DepthStreamMessage)message;
     ActiveClient = client;
     RefreshBitmap(msg.DepthPixels);
 }
 public GestureCommandRecognizedEventArgs(KinectClient.GestureCommandType command)
 {
   GestureCommand = command;
 }
Esempio n. 6
0
 private void kinectServer_ColorDataArrived(KinectDemoMessage message, KinectClient client)
 {
     ColorStreamMessage msg = (ColorStreamMessage)message;
     try
     {
         Dispatcher.Invoke(() =>
         {
             if (colorBitmap == null)
             {
                 colorBitmap = new WriteableBitmap(msg.ColorFrameSize.Width, msg.ColorFrameSize.Height, 96.0, 96.0, PixelFormats.Bgr32, null);
             }
             colorBitmap.WritePixels(
                 new Int32Rect(0, 0, colorBitmap.PixelWidth, colorBitmap.PixelHeight),
                 msg.ColorPixels,
                 colorBitmap.PixelWidth*4,
                 0);
         });
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message + "\n" + ex.StackTrace);
     }
 }
Esempio n. 7
0
        private void kinectServer_BodyDataArrived(KinectDemoMessage message, KinectClient kinectClient)
        {
            BodyStreamMessage msg = (BodyStreamMessage) message;

            //bones = kinectStreamer.Bones;

            //// populate body colors, one for each BodyIndex
            //bodyColors = new List<Pen>();

            //bodyColors.Add(new Pen(Brushes.Red, 6));
            //bodyColors.Add(new Pen(Brushes.Orange, 6));
            //bodyColors.Add(new Pen(Brushes.Green, 6));
            //bodyColors.Add(new Pen(Brushes.Blue, 6));
            //bodyColors.Add(new Pen(Brushes.Indigo, 6));
            //bodyColors.Add(new Pen(Brushes.Violet, 6));
        }
        private void BodyDataArrived(KinectDemoMessage message, KinectClient kinectClient)
        {
            BodyStreamMessage msg = (BodyStreamMessage)message;
            handPositions = new List<CameraSpacePoint>();
            foreach (SerializableBody body in msg.Bodies)
            {
                if (body != null)
                {
                    if (body.IsTracked)
                    {
                        IDictionary<JointType, Joint> joints = new Dictionary<JointType, Joint>();
                        body.Joints.CopyToDictionary(joints);
                        handPositions.Add(joints[JointType.HandLeft].Position);
                        handPositions.Add(joints[JointType.HandRight].Position);
                    }
                }

            }
            CheckActiveWorkspace(handPositions.ToArray());
        }
 private void SetCalibrationState(KinectClient client, CalibrationState state)
 {
     foreach (ObservableKeyValuePair<KinectClient, CalibrationState> observableKeyValuePair in clientCalibrationStates)
     {
         if (client.Equals(observableKeyValuePair.Key))
         {
             observableKeyValuePair.Value = state;
         }
     }
 }
Esempio n. 10
0
 private void CalibrationDataArrived(KinectDemoMessage message, KinectClient kinectClient)
 {
     SetCalibrationState(kinectClient, CalibrationState.Done);
     bool allDone = true;
     foreach (ObservableKeyValuePair<KinectClient, CalibrationState> keyValuePair in clientCalibrationStates)
     {
         if (!keyValuePair.Value.Equals(CalibrationState.Done))
         {
             allDone = false;
         }
     }
     if (allDone)
     {
         CalibrationFinished();
     }
 }
 public VoiceCommandRecognizedEventArgs(KinectClient.VoiceCommandType command)
 {
   VoiceCommand = command;
 }
Esempio n. 12
0
 private void ConfigurationDataArrived(KinectDemoMessage message, KinectClient kinectClient)
 {
     Dispatcher.Invoke(() =>
     {
         ClientConfigurationMessage msg = (ClientConfigurationMessage)message;
         //  TODO: bind
         KinectStreamerConfig config = msg.Configuration;
         DepthCheckbox.IsChecked = config.StreamDepthData;
         ColorCheckbox.IsChecked = config.StreamColorData;
         SkeletonCheckbox.IsChecked = config.StreamBodyData;
         SendAsOneCheckbox.IsChecked = config.SendAsOne;
         PointCloudCheckbox.IsChecked = config.StreamPointCloudData;
         ColoredPointCloudCheckbox.IsChecked = config.StreamColoredPointCloudData;
         CalibrationCheckbox.IsChecked = config.ProvideCalibrationData;
     });
 }