/// <summary> /// This method open depth stream and/or skeleton streams properly /// User can only select one in the four : depth, skeleton, depth And skeleton, user depth and skeleton /// </summary> private ImiWrapper.ErrorCode openDepthAndSkeletonStream() { ImiWrapper.ImiFrameType streamType; if (imiManager.processUserDepthAndSkeleton) { streamType = ImiWrapper.ImiFrameType.IMI_USER_INDEX_SKELETON_FRAME; imiManager.processDepth = false; imiManager.processSkeleton = false; imiManager.processDepthSkeleton = false; } else if (imiManager.processDepthSkeleton) { streamType = ImiWrapper.ImiFrameType.IMI_DEPTH_SKELETON_FRAME; imiManager.processDepth = false; imiManager.processSkeleton = false; } else if (imiManager.processDepth) { streamType = ImiWrapper.ImiFrameType.IMI_DEPTH_FRAME; imiManager.processSkeleton = false; } else if (imiManager.processSkeleton) { streamType = ImiWrapper.ImiFrameType.IMI_SKELETON_FRAME; } else { //Don't open any kind of depth stream or skeleton stream return(ImiWrapper.ErrorCode.OK); } return(ImiWrapper.OpenStream(streamType, ImiWrapper.ImiImageResolution.IMI_IMAGE_RESOLUTION_640x480, ImiWrapper.ImiPixelFormat.IMI_PIXEL_FORMAT_DEP_16BIT)); }
//void OnApplicationQuit() //{ // Debug.Log("On ApplicationQuit"); // isPrcStop = true; // isClosed = true; // Close(); //} /// <summary> /// Open Device and Open Streams according to the user choice /// </summary> private void IminectInitialize() { //Returns if Device is unavailable //Returns if Already Initialized if (!imiManager.IsDeviceAvailable() || iminectInitialized) { return; } ImiWrapper.ErrorCode error; if ((error = imiManager.OpenDevice()) != ImiWrapper.ErrorCode.OK) { Debug.LogError(error); return; } //Open Depth/Skeleton Stream error = openDepthAndSkeletonStream(); if (error != ImiWrapper.ErrorCode.OK) { Debug.LogError(error); return; } //Open Color Stream if (imiManager.processColorData) { if ((error = ImiWrapper.OpenStream(ImiWrapper.ImiFrameType.IMI_COLOR_FRAME, ImiWrapper.ImiImageResolution.IMI_IMAGE_RESOLUTION_640x480, ImiWrapper.ImiPixelFormat.IMI_PIXEL_FORMAT_IMAGE_RGB24)) != ImiWrapper.ErrorCode.OK) { Debug.LogError(error); return; } } Debug.Log("Initialize success!"); iminectInitialized = true; }