Exemplo n.º 1
0
    private void InitializeSensor()
    {
        //if (bodyTracking)
        //{
        //    depth = true;
        //}

        switch (trackingSDK)
        {
        case Voxar.TrackingSDK.Astra:
            var controller = gameObject.AddComponent <AstraController>();

            controller._shouldEnableColor = rgb;
            controller._shouldEnableDepth = depth;
            controller._shouldEnableBody  = bodyTracking;

            controller.depthResolution = depthResolution;
            controller.rgbResolution   = rgbResolution;

            source = new AstraSource(rgbResolution, depthResolution, numberOfBodies);
            controller.NewBodyFrameEvent.AddListener(source.OnNewBodyFrame);
            controller.NewColorFrameEvent.AddListener(source.OnNewRGBFrame);
            controller.NewDepthFrameEvent.AddListener(source.OnNewDepthFrame);
            break;


        case Voxar.TrackingSDK.Kinect:
            KinectController kinectController = gameObject.AddComponent <KinectController>();

            source = new KinectSource(rgbResolution, depthResolution, numberOfBodies);

            kinectController.OnNewBodyFrame.AddListener(source.OnNewBodyFrame);
            kinectController.OnNewColorFrame.AddListener(source.OnNewRGBFrame);
            kinectController.OnNewDepthFrame.AddListener(source.OnNewDepthFrame);

            break;

        default:
            Debug.Log("SDK NOT SUPPORTED");
            break;
        }

        if (bodyTracking)
        {
            foreach (var receiver in bodyReceivers)
            {
                source.AddBodyReceiver(receiver.GetComponent <IReceiver <BodyJoints[]> >());
            }
        }
        if (rgb)
        {
            foreach (var receiver in rgbReceivers)
            {
                source.AddRGBReceiver(receiver.GetComponent <IImageReceiver <Texture2D> >());
            }
        }
        if (depth)
        {
            foreach (var receiver in depthReceivers)
            {
                source.AddDepthReceiver(receiver.GetComponent <IImageReceiver <Texture2D> >());
            }
        }
    }