KinectV2Core.KinectCoreV2.KinectCoreV2 C# (CSharp) Method

KinectCoreV2() public method

public KinectCoreV2 ( KinectBase &settings, bool isGUILaunched, int kinectNumber ) : System
settings KinectBase
isGUILaunched bool
kinectNumber int
return System
        public KinectCoreV2(ref KinectBase.MasterSettings settings, bool isGUILaunched, int kinectNumber)
        {
            masterSettings = settings;
            dynamic temp = masterSettings.kinectOptionsList[kinectNumber];
            masterKinectSettings = (KinectV2Settings)temp;

            //TODO: Update this to open a specific Kinect v2, if the SDK is ever updated to support multiple on one machine
            kinect = KinectSensor.GetDefault();
            kinectID = kinectNumber;

            uint tempC = kinect.ColorFrameSource.FrameDescription.LengthInPixels;
            uint tempD = kinect.DepthFrameSource.FrameDescription.LengthInPixels;
            uint tempI = kinect.InfraredFrameSource.FrameDescription.LengthInPixels;
            colorImagePool = new KinectBase.ObjectPool<byte[]>(() => new byte[tempC * 4]);
            depthImagePool = new KinectBase.ObjectPool<byte[]>(() => new byte[tempD * 4]);
            irImagePool = new KinectBase.ObjectPool<byte[]>(() => new byte[tempI * sizeof(UInt16)]);

            if (isGUILaunched)
            {
                isGUI = true;
                LaunchKinect();
            }
            else
            {
                launchKinectDelegate kinectDelegate = LaunchKinect;
                IAsyncResult result = kinectDelegate.BeginInvoke(null, null);
                kinectDelegate.EndInvoke(result);  //Even though this is blocking, the events should be on a different thread now.
            }
        }