/// <summary>
        /// Render camera background image with tracked frame
        /// </summary>
        /// <param name="state">TrackingState</param>
        public void UpdateCameraBackgroundImage(TrackingState state)
        {
            if (!keepRendering)
            {
                return;
            }

            TrackedImage image = state.GetImage(rg16TextureSupported);

            if (prevImageIndex == image.GetIndex())
            {
                return;
            }

            prevImageIndex = image.GetIndex();

            if (image.GetWidth() == 0 && image.GetHeight() == 0)
            {
                return;
            }

            if (!textureCreateDone)
            {
                CreateCameraTexture(image.GetWidth(), image.GetHeight(), image.GetFormat());
                textureCreateDone = true;
            }

            UpdateCameraTexture(image);
            TransformBackgroundPlane();
        }
Esempio n. 2
0
        /// <summary>
        /// Render camera background image with tracked frame
        /// </summary>
        /// <param name="state">TrackingState</param>
        public void UpdateCameraBackgroundImage(TrackingState state)
        {
            if (!keepRendering)
            {
                return;
            }

            TrackedImage image = state.GetImage(!rg16SupportGpuAndUnityVersionCheck);

            if (prevImageIndex == image.GetIndex())
            {
                return;
            }

            prevImageIndex = image.GetIndex();

            if (image.GetWidth() == 0 && image.GetHeight() == 0)
            {
                return;
            }

            if (!textureCreateDone)
            {
                CreateCameraTexture(image.GetWidth(), image.GetHeight(), image.GetFormat());
                textureCreateDone = true;
            }

            UpdateInternal(image);
        }
Esempio n. 3
0
        public void FindImageOfCloudRecognition()
        {
            if (autoState)
            {
                return;
            }

            new Thread(() => {
                TrackingState trackingState   = TrackerManager.GetInstance().GetTrackingState();
                TrackingResult trackingResult = trackingState.GetTrackingResult();
                TrackedImage trackedImage     = trackingState.GetImage();

                int trackingCount = trackingResult.GetCount();
                if (trackingCount == 0)
                {
                    if (cloudState == CloudState.CLOUDSTATE_TRACKING || cloudState == CloudState.CLOUDSTATE_STOP)
                    {
                        cloudState = CloudState.CLOUDSTATE_FEATURE_COLLECT_READY;
                    }
                }
                else
                {
                    cloudState = CloudState.CLOUDSTATE_TRACKING;
                }

                if (cloudState != CloudState.CLOUDSTATE_FEATURE_COLLECT_READY)
                {
                    return;
                }


                GetCloudRecognition(trackedImage, (bool cloudResult, string featureBase64) =>
                {
                    if (cloudResult)
                    {
                        this.featureBase64 = featureBase64;
                        this.cloudState    = CloudState.CLOUDSTATE_CONNECT;
                    }
                    else
                    {
                        this.cloudState = CloudState.CLOUDSTATE_FEATURE_COLLECT_READY;
                    }

                    if (this.restart)
                    {
                        this.loopState = true;
                        this.restart   = false;
                    }
                });
            }).Start();
        }
Esempio n. 4
0
        internal void StartCloud()
        {
            loopState       = true;
            this.cloudState = CloudState.CLOUDSTATE_FEATURE_COLLECT_READY;
            while (this.loopState)
            {
                Thread.Sleep(100);

                TrackingState  trackingState  = TrackerManager.GetInstance().UpdateTrackingState();
                TrackingResult trackingResult = trackingState.GetTrackingResult();
                TrackedImage   trackedImage   = trackingState.GetImage();

                int trackingCount = trackingResult.GetCount();
                if (trackingCount == 0)
                {
                    if (cloudState == CloudState.CLOUDSTATE_TRACKING)
                    {
                        cloudState = CloudState.CLOUDSTATE_FEATURE_COLLECT_READY;
                    }
                }
                else
                {
                    cloudState = CloudState.CLOUDSTATE_TRACKING;
                }

                if (trackingCount == 0 && (cloudState == CloudState.CLOUDSTATE_TRACKING || cloudState == CloudState.CLOUDSTATE_FEATURE_COLLECT_READY))
                {
                    if (!TrackerManager.GetInstance().IsTrackerDataLoadCompleted() || cloudState == CloudState.CLOUDSTATE_STOP)
                    {
                        continue;
                    }

                    isGetFeatureState = true;
                    bool isCameraMove = CameraDevice.GetInstance().CheckCameraMove(trackedImage);
                    isGetFeatureState = false;
                    if (isCameraMove)
                    {
                        GetCloudRecognition(trackedImage, (bool cloudResult, string featureBase64) =>
                        {
                            if (cloudResult)
                            {
                                this.featureBase64 = featureBase64;
                                this.cloudState    = CloudState.CLOUDSTATE_CONNECT;
                            }
                            else
                            {
                                this.cloudState = CloudState.CLOUDSTATE_FEATURE_COLLECT_READY;
                            }

                            if (this.restart)
                            {
                                this.loopState = true;
                                this.restart   = false;
                            }
                            cloudSemaphore.Release();
                        });
                        cloudSemaphore.WaitOne();
                    }
                }

                if (this.cloudState == CloudState.CLOUDSTATE_STOP)
                {
                    this.loopState = false;
                }
            }
        }