public void Terminate()
 {
     if (this.IsStarted())
     {
         ScapeNative.citf_destroyClient(this.scapeClientPtr);
     }
 }
        public void StartClient(string apiKey, bool isDebugEnabled)
        {
            if (this.scapeClientPtr == IntPtr.Zero)
            {
                int isDebugInt = 0;
                if (isDebugEnabled)
                {
                    isDebugInt = 1;
                }

                this.scapeClientPtr = ScapeNative.citf_createClient(apiKey, isDebugInt);


                if (this.IsStarted())
                {
                    this.scapeSessionNative = new ScapeSessionNative(this.scapeClientPtr);

                    ScapeNative.citf_setClientStateCallbacks(this.scapeClientPtr,
                                                             onAquireMotionMeasurements,
                                                             onAquireLocationMeasurements);

                    if (isDebugEnabled)
                    {
                        this.debugSessionPtr = ScapeNative.citf_getDebugSession(this.scapeClientPtr);

                        debugSession = new DebugSessionNative(debugSessionPtr);
                    }

                    setDeviceInfo();

                    Input.location.Start();
                }
            }
        }
Esempio n. 3
0
        /// <summary>
        /// WsgToLocal, given a LatLng coordinate and a s2cell id, returns Vector3.
        /// typically used by a GeoAnchor component to find it's position in the Unity scene.
        /// </summary>
        /// <param name="latitude">
        /// latitude in degrees
        /// </param>
        /// <param name="longitude">
        /// longitude in degrees
        /// </param>
        /// <param name="altitude">
        /// altitude in meters
        /// </param>
        /// <param name="s2CellId">
        /// s2CellId long id
        /// </param>
        /// <returns>
        /// position for use in Unity scene
        /// </returns>
        public static Vector3 WgsToLocal(double latitude, double longitude, double altitude, long s2CellId)
        {
            var vec3 = new Vector3();

            double[] result = new double[3];
            ScapeNative._wgsToLocal(latitude, longitude, altitude, s2CellId, result);
            vec3.Set((float)result[0], (float)result[1], (float)result[2]);

            return(vec3);
        }
        internal ScapeSessionNative(IntPtr client)
        {
            this.scapeClient = client;

            ScapeNative.citf_setSessionCallbacks(this.scapeClient,
                                                 onScapeMeasurementsRequestedNative,
                                                 onScapeSessionErrorNative,
                                                 onScapeMeasurementsUpdatedNative
                                                 );
        }
 public static void LogError(string message = "", string tag = "SCKUnity")
 {
     if (ScapeClient.Instance.IsStarted())
     {
         ScapeNative.citf_log((int)LogLevel.LOG_ERROR, tag, message);
     }
     else
     {
         Debug.Log(tag + " [Error] : " + message);
     }
 }
        public void GetMeasurements(ScapeSession.ARImage image)
        {
            ScapeNative.citf_setYChannelPtr(this.scapeClient, image.YPixelBuffer, image.Width, image.Height);
            ScapeNative.citf_setCameraIntrinsics(this.scapeClient,
                                                 image.XFocalLength,
                                                 image.YFocalLength,
                                                 image.XPrincipalPoint,
                                                 image.YPrincipalPoint);

            ScapeNative.citf_getMeasurements(this.scapeClient);
        }
        private void setDeviceInfo()
        {
            ScapeNative.device_info di = new ScapeNative.device_info();

            di.id              = stringToFixedByteArray(SystemInfo.deviceUniqueIdentifier, 256);
            di.platform        = stringToFixedByteArray(Enum.GetName(typeof(RuntimePlatform), Application.platform), 256);
            di.model           = stringToFixedByteArray(SystemInfo.deviceModel, 256);
            di.os              = stringToFixedByteArray(SystemInfo.operatingSystem, 256);
            di.os_version      = stringToFixedByteArray(Enum.GetName(typeof(OperatingSystemFamily), SystemInfo.operatingSystemFamily), 256);
            di.write_directory = stringToFixedByteArray(Application.persistentDataPath, 256);
            di.sdk_version     = stringToFixedByteArray(ScapeKitVersionVars.version + "." + ScapeKitVersionVars.build, 256);
            ScapeNative.citf_setDeviceInfo(this.scapeClientPtr, ref di);
        }
Esempio n. 8
0
        /// <summary>
        /// localToWsg, given a Unity position vector3 and s2 cell id, returns a LatLng coordinate.
        /// The Unity scene uses an S2 Cell's center to define it's origin.
        /// In this way by taking the world position of an object in the Unity scene
        /// and combining it with the Cell id defined in the GeoAnchorManager, the world coordinate of that
        /// position can be deduced.
        /// </summary>
        /// <param name="localVec3">
        /// local position in unity scene
        /// </param>
        /// <param name="s2CellId">
        /// s2CellId long id
        /// </param>
        /// <returns>
        /// GPS world coordinates
        /// </returns>
        public static LatLng LocalToWgs(Vector3 localVec3, long s2CellId)
        {
            LatLng coords = new LatLng();

            double[] result = new double[3];
            ScapeNative._localToWgs(localVec3.x, localVec3.y, localVec3.z, s2CellId, result);
            coords = new LatLng()
            {
                Latitude  = result[0],
                Longitude = result[1]
            };

            return(coords);
        }
        private void ProcessImage(AsyncCameraImageConversionStatus status,
                                  XRCameraImageConversionParams conversionParams,
                                  NativeArray <byte> imageBuffer)
        {
            if (status != AsyncCameraImageConversionStatus.Ready)
            {
                // attempt to call getMeasurements with empty image will compel SDK core to report error
                // triggering session to request another
                ScapeNative.citf_setYChannelPtr(this.scapeClient, IntPtr.Zero, 0, 0);
                ScapeNative.citf_getMeasurements(this.scapeClient);
                return;
            }

            CopyImageBuffer(imageBuffer);

            ScapeNative.citf_setYChannelPtr(this.scapeClient, imagePtr, ScapeImgWidth, ScapeImgHeight);
            ScapeNative.citf_getMeasurements(this.scapeClient);

            ScapeLogging.LogDebug("citf_getMeasurements() " + (Time.time - requestTime));
        }
        private void TryGetIntrinsics(float scaleX, float scaleY)
        {
            XRCameraIntrinsics intrinsics = new XRCameraIntrinsics();

            if (cameraManager.TryGetIntrinsics(out intrinsics))
            {
                ScapeNative.citf_setCameraIntrinsics(this.scapeClient,
                                                     intrinsics.focalLength.x * scaleX,
                                                     intrinsics.focalLength.y * scaleY,
                                                     intrinsics.principalPoint.x * scaleX,
                                                     intrinsics.principalPoint.y * scaleY);

                ScapeLogging.LogDebug("setCameraIntrinsics " + "\n" +
                                      "focalLength.x = " + (intrinsics.focalLength.x * scaleX) + "\n" +
                                      "focalLength.y = " + (intrinsics.focalLength.y * scaleY) + "\n" +
                                      "principalPoint.x = " + (intrinsics.principalPoint.x * scaleX) + "\n" +
                                      "principalPoint.y = " + (intrinsics.principalPoint.y * scaleY) + "\n");

                gotIntrinsics = true;
            }
        }
 public override void SaveImages(bool save)
 {
     ScapeNative.citf_saveImages(nativePtr, save);
 }
 public override void MockGPSCoordinates(double latitude, double longitude)
 {
     ScapeNative.citf_mockGPSCoordinates(nativePtr, latitude, longitude);
 }
 public override void SetLogConfig(LogLevel level, LogOutput output)
 {
     ScapeNative.citf_setLogConfig(nativePtr, (int)level, (int)output);
 }
Esempio n. 14
0
 /// <summary>
 /// angleBetweenCoordinates, the angular distance between 2 gps coords
 /// </summary>
 /// <param name="latitude1">
 /// latitude1 the first latitude parameter in degrees
 /// </param>
 /// <param name="longitude1">
 /// longitude1 the first longitude parameter in degrees
 /// </param>
 /// <param name="latitude2">
 /// latitude2 the second latitude parameter in degrees
 /// </param>
 /// <param name="longitude2">
 /// longitude2 the second longitude parameter in degrees
 /// </param>
 /// <returns>
 /// value in degrees
 /// </returns>
 public static double AngleBetweenCoordinates(double latitude1, double longitude1, double latitude2, double longitude2)
 {
     return(ScapeNative._angleBetweenCoordinates(latitude1, longitude1, latitude2, longitude2));
 }
Esempio n. 15
0
 /// <summary>
 /// metersBetweenCoordinates given to coordinates returns distance between them in meters
 /// </summary>
 /// <param name="latitude1">
 /// latitude1 the first latitude parameter in degrees
 /// </param>
 /// <param name="longitude1">
 /// longitude1 the first longitude parameter in degrees
 /// </param>
 /// <param name="latitude2">
 /// latitude2 the second latitude parameter in degrees
 /// </param>
 /// <param name="longitude2">
 /// longitude2 the second longitude parameter in degrees
 /// </param>
 /// <returns>
 /// value in meters
 /// </returns>
 public static double MetersBetweenCoordinates(double latitude1, double longitude1, double latitude2, double longitude2)
 {
     return(ScapeNative._metersBetweenCoordinates(latitude1, longitude1, latitude2, longitude2));
 }
Esempio n. 16
0
 /// <summary>
 /// cellIdForGps S2 cell id for GPS.
 /// S2 Cells are areas's on the Earth's surface.
 /// In a Scape integrated Unity scene the center of one such cell is always used as the
 /// scene's origin.
 /// This function is used by the GeoAnchorManager to ascertain the S2 Cell for the current scene.
 /// </summary>
 /// <param name="latitude">
 /// latitude in degrees
 /// </param>
 /// <param name="longitude">
 /// longitude in degrees
 /// </param>
 /// <param name="s2CellLevel">
 /// An S2 Cell Level
 /// </param>
 /// <returns>
 /// ID of s2 cell containing GPS coordinate.
 /// </returns>
 public static long CellIdForWgs(double latitude, double longitude, int s2CellLevel)
 {
     return(ScapeNative._cellIdForWgs(latitude, longitude, s2CellLevel));
 }