Exemple #1
0
        /// <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));
        }
Exemple #2
0
        public void Close()
        {
            iminectInitialized = false;
            ImiWrapper.ErrorCode error;

            if (imiManager.processDepth)
            {
                error = ImiWrapper.CloseStream(ImiWrapper.ImiFrameType.IMI_DEPTH_FRAME);
                if (error != ImiWrapper.ErrorCode.OK)
                {
                    Debug.LogError(error);
                }
            }

            if (imiManager.processSkeleton)
            {
                error = ImiWrapper.CloseStream(ImiWrapper.ImiFrameType.IMI_SKELETON_FRAME);
                if (error != ImiWrapper.ErrorCode.OK)
                {
                    Debug.LogError(error);
                }
            }

            if (imiManager.processDepthSkeleton)
            {
                error = ImiWrapper.CloseStream(ImiWrapper.ImiFrameType.IMI_DEPTH_SKELETON_FRAME);
                if (error != ImiWrapper.ErrorCode.OK)
                {
                    Debug.LogError(error);
                }
            }

            if (imiManager.processUserDepthAndSkeleton)
            {
                error = ImiWrapper.CloseStream(ImiWrapper.ImiFrameType.IMI_USER_INDEX_SKELETON_FRAME);
                if (error != ImiWrapper.ErrorCode.OK)
                {
                    Debug.LogError(error);
                }
            }

            if (imiManager.processColorData)
            {
                error = ImiWrapper.CloseStream(ImiWrapper.ImiFrameType.IMI_COLOR_FRAME);
                if (error != ImiWrapper.ErrorCode.OK)
                {
                    Debug.LogError(error);
                }
            }
            error = ImiWrapper.CloseDevice();
            if (error != ImiWrapper.ErrorCode.OK)
            {
                Debug.LogError(error);
            }
        }
Exemple #3
0
        /**
         * TODO support for hot swap
         */
        private void CheckDeviceState()
        {
            if (ImiWrapper.GetDeviceState() == ImiWrapper.ImiDeviceState.IMI_DEVICE_STATE_DISCONNECT)
            {
                Debug.LogError("IMI_DEVICE_STATE_DISCONNECT");
            }

            if (ImiWrapper.GetDeviceState() == ImiWrapper.ImiDeviceState.IMI_DEVICE_STATE_CONNECT)
            {
                Debug.Log("IMI_DEVICE_STATE_CONNECT");
            }
        }
Exemple #4
0
        private void PrcSkeletonData()
        {
            while (!isPrcStop)
            {
                if (iminectInitialized)
                {
                    retDepth = ImiWrapper.GetSkeletonFrame(ref skeletonFrame, 30);

                    if (retDepth == ImiWrapper.ErrorCode.OK)
                    {
                        ProcessSkeleton();
                    }
                }
                Thread.Sleep(THREAD_INTERVAL);
            }
        }
Exemple #5
0
 private void PrcColorData()
 {
     while (!isPrcStop)
     {
         if (iminectInitialized)
         {
             skipFrame++;
             if (skipFrame % 1 == 0)
             {
                 retColor = ImiWrapper.GetColorData(colorData, 30);
                 if (retColor == ImiWrapper.ErrorCode.OK)
                 {
                     imiManager.Enqueue(UpdateColorTex());
                 }
             }
         }
         Thread.Sleep(THREAD_INTERVAL);
     }
 }
Exemple #6
0
        //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;
        }
Exemple #7
0
        private void PrcDepthData()
        {
            while (!isPrcStop)
            {
                if (iminectInitialized)
                {
                    retDepth = ImiWrapper.GetDepthData(depthData, 30);

                    if (retDepth == ImiWrapper.ErrorCode.OK)
                    {
                        if (!prcDepthDrawLock)
                        {
                            UpdateDepthDrawData();
                            prcDepthDrawLock = true;
                        }
                        imiManager.Enqueue(UpdateDepthTex());
                    }
                }
                Thread.Sleep(THREAD_INTERVAL);
            }
        }
Exemple #8
0
        //体感数据处理.
        private void PrcImiDepthAndSkeletonData()
        {
            while (!isPrcStop)
            {
                if (iminectInitialized)
                {
                    retDepth = ImiWrapper.GetDepthPlayerDataAndSkeletonFrame(depthPlayerData, ref skeletonFrame, 30);

                    if (retDepth == ImiWrapper.ErrorCode.OK)
                    {
                        ProcessSkeleton();

                        if (!prcDepthDrawLock)
                        {
                            UpdateUserDepthDrawData();
                            prcDepthDrawLock = true;
                        }
                        imiManager.Enqueue(UpdateDepthTex());
                    }
                }
                Thread.Sleep(THREAD_INTERVAL);
            }
        }
Exemple #9
0
        public ImiWrapper.ErrorCode OpenDevice()
        {
            ImiWrapper.ErrorCode error;
#if UNITY_ANDROID
            //return if the device has not been opened
            if (fd == -1)
            {
                return(ImiWrapper.ErrorCode.OPEN_DEVICE_FAILED);
            }

            if (fd == 0)
            {
                //open device on rooted system
                if ((error = ImiWrapper.OpenDevice()) != ImiWrapper.ErrorCode.OK)
                {
                    Debug.LogError(error);
                    return(ImiWrapper.ErrorCode.OPEN_DEVICE_FAILED);
                }
            }
            else
            {
                if ((error = ImiWrapper.OpenDevice2(fd, usbPath)) != ImiWrapper.ErrorCode.OK)
                {
                    Debug.LogError(error);
                    return(ImiWrapper.ErrorCode.OPEN_DEVICE_FAILED);
                }
            }
#else
            //open device on rooted system
            if ((error = ImiWrapper.OpenDevice()) != ImiWrapper.ErrorCode.OK)
            {
                Debug.LogError(error);
                return(ImiWrapper.ErrorCode.OPEN_DEVICE_FAILED);
            }
#endif
            return(ImiWrapper.ErrorCode.OK);
        }