private void StopTracking()
 {
     //Debug.Log ("ServiceManager: Stop Tracking");
     RemoveAllTrackable();
     VisionUnityPlugin.StopAR();
     _enableTracking = false;
 }
        private void UpdateTracking()
        {
            VisionUnityPlugin.UpdateAR();

            //Set all the targets to be invisible
            foreach (var entry in _targets)
            {
                Target target   = entry.Value;
                int    targetId = entry.Key;

                Vector3    position    = Vector3.zero;
                Quaternion orientation = Quaternion.identity;
                bool       visible     = VisionUnityPlugin.GetPose(ref position, ref orientation, targetId);

                // Debug.Log ("visible " + targetId + "/" + visible + "/" + position);

                if (visible)
                {
                    //float scale = Math.Min (target.width, target.height);
                    target.isVisible   = true;
                    target.position    = position;
                    target.orientation = orientation;
                }
                else
                {
                    target.isVisible   = false;
                    target.position    = Vector3.zero;
                    target.orientation = Quaternion.identity;
                }
            }
        }
        private bool InitTracking()
        {
            //Debug.Log ("Springboard: InitTracking");

            if (_targetInfos.Count == 0)
            {
                return(false);
            }
            int numOfValidMarkers = _targetInfos.Count;

            int[]   markerIds     = new int[numOfValidMarkers];       //TODO : should be move ouside of this function
            float[] markerWidths  = new float[numOfValidMarkers];     //TODO : should be move ouside of this function
            float[] markerHeights = new float[numOfValidMarkers];     //TODO : should be move ouside of this function

            for (int index = 0; index < numOfValidMarkers; index++)
            {
                TrackedObject toObj = _targetInfos [index].trackableObject.GetComponent <TrackedObject>();
                markerWidths [index]  = toObj.WidthInMeters;
                markerHeights [index] = toObj.HeightInMeters;
            }
            VisionUnityPlugin.InitAR(_targetInfos.Select(x => x.path).ToArray(), numOfValidMarkers, markerWidths, markerHeights, markerIds);

            for (int index = 0; index < numOfValidMarkers; index++)
            {
                //Debug.Log ("Unity MarkerId[0]:" + markerIds [index] + " " + finalPaths [index]);//assumed to be in order
                Target target = new Target();
                target.id   = _markerIds [index];
                target.info = _targetInfos [index];
                Debug.Log(_targetInfos [index].path);
                target.isVisible   = false;
                target.isTrackable = true;
                if (!_targets.ContainsKey(target.id))
                {
                    _targets.Add(target.id, target);
                }
            }

            float[] projMatrixRawArray = new float[16];
            VisionUnityPlugin.GetProjectionMatrix(projMatrixRawArray);
            Matrix4x4 projMatrixRaw    = MatrixFromFloatArray(projMatrixRawArray);
            Matrix4x4 projectionMatrix = projMatrixRaw;

            _visionProjectionMatrix = projectionMatrix;

            _visionFieldOfView   = FieldOfViewFromProjection(_visionProjectionMatrix);
            _visionAspectRatio   = AspectRatioFromProjection(_visionProjectionMatrix);
            _hasVisionParameters = true;

            if (TargetIdsAvailable != null)
            {
                TargetIdsAvailable.Invoke();
            }
            if (VisionParametersAvailable != null)
            {
                VisionParametersAvailable.Invoke();
            }

            return(true);
        }
        void OnApplicationQuit()
        {
            StopCamera();
            StopThermal();
            StopIMU();
            StopPositionMonitor();

            /*//Debug.Log ("OnApplicationQuit");
             * if (_enableVideoTextureUpdates)
             * {
             *      if (videoBackgroundUsers.Count != 0) {
             *              StopCamera ();
             *      }
             * }
             *
             * if (_enableThermalUpdates)
             * {
             *      if (thermalBackgroundUsers.Count != 0) {
             *              StopThermal ();
             *      }
             * }
             *
             * if (_enableIMU)
             * {
             *      if (imuUsers.Count != 0) {
             *              StopIMU ();
             *      }
             * }
             *
             * if (_enablePose){
             *      if (vioUsers.Count != 0) {
             *              StopIMU ();
             *              StopPositionMonitor ();
             *      }
             * }*/
            if (_enableTracking)
            {
                VisionUnityPlugin.StopAR();
            }
        }