void Start()
    {
        instance = this;
        _Sensor  = KinectSensor.GetDefault();
        if (_Sensor != null)
        {
            coordinateMapper = _Sensor.CoordinateMapper;
            _reader          = _Sensor.OpenMultiSourceFrameReader(FrameSourceTypes.Color | FrameSourceTypes.Depth | FrameSourceTypes.BodyIndex | FrameSourceTypes.Body);
            // we need a multi source
            if (_reader != null)
            {
                _reader.MultiSourceFrameArrived += MultiSourceFrameArrivedHandler;
                //we separate this because we still need a coordinateMapper to deal with the raw data, then send it to our real custom event.
                //(if we want to combine the whole process into the custom event, we can expose the coordinateMapper and pass it into the event as a params or just get the var)

                AddEvent(); //add event to the controllers
            }

            // init array and point
            FrameDescription colorFrameDesc = _Sensor.ColorFrameSource.CreateFrameDescription(ColorImageFormat.Rgba);
            colorData      = new byte[colorFrameDesc.BytesPerPixel * colorFrameDesc.LengthInPixels];
            _displayPixels = new byte[colorFrameDesc.BytesPerPixel * colorFrameDesc.LengthInPixels];

            FrameDescription depthFrameDesc = _Sensor.DepthFrameSource.FrameDescription;
            depthData        = new ushort[depthFrameDesc.LengthInPixels];
            depthSpacePoints = new DepthSpacePoint[colorFrameDesc.LengthInPixels];
            FrameDescription bodyIndexFrameDesc = _Sensor.BodyIndexFrameSource.FrameDescription;
            bodyIndexData = new byte[bodyIndexFrameDesc.BytesPerPixel * bodyIndexFrameDesc.LengthInPixels];
            // init array and point

            //the VGB database
            string path = System.IO.Path.Combine(Application.streamingAssetsPath, databasePath);
            Debug.Log("database path is " + path);
            _Database    = VisualGestureBuilderDatabase.Create(path);
            gesturesList = _Database.AvailableGestures;
            //the VGB database



            // init our ID managements
            HashIdtb   = new Hashtable();               // this manage the source and reader
            PlayerArgs = new Dictionary <ulong, int>(); // this pass to controllers
            // init our ID managements


            if (!_Sensor.IsOpen)
            {
                _Sensor.Open();
            }
        }
    }
Exemplo n.º 2
0
    private void ManageKinectBodyArgsManager()
    {
        if (KinectBodyArgsManagers == null || KinectBodyArgsManagers.Count == 0)
        {
            return;
        }
        multisourcebodyidmanager = MultiSourceBodyIDManager.Instance;
        Dictionary <ulong, int> PlayerArgs = multisourcebodyidmanager.GetPlayerArgs();
        ArrayList key = new ArrayList(KinectBodyArgsManagers.Keys);

        foreach (ulong trackedId in key)
        {
            if (!PlayerArgs.ContainsKey(trackedId))
            {
                Destroy(KinectBodyArgsManagers[trackedId]);
                KinectBodyArgsManagers.Remove(trackedId);
            }
        }
    }
 public void AddBodyDataEvent()  //bridge to source manager
 {
     multisourcebodyidmanager             = MultiSourceBodyIDManager.Instance;
     multisourcebodyidmanager.OnBodyData += DealwithRawData;
 }
Exemplo n.º 4
0
 public void AddGestureDataEvent() //the bridge to Gesturesource
 {
     multisourcebodyidmanager = MultiSourceBodyIDManager.Instance;
     multisourcebodyidmanager.OnGestureData += DealWithGestureData;
 }