public void LocalizeServer() { ARCameraManager cameraManager = sdk.cameraManager; var cameraSubsystem = cameraManager.subsystem; XRCameraImage image; if (cameraSubsystem.TryGetLatestImage(out image)) { CoroutineJobLocalizeServer j = new CoroutineJobLocalizeServer(); j.server = this.server; j.token = this.token; Camera cam = Camera.main; j.rotation = cam.transform.rotation; j.position = cam.transform.position; j.intrinsics = ARHelper.GetIntrinsics(cameraManager); j.width = image.width; j.height = image.height; j.stats = this.stats; j.pcr = this.pcr; ARHelper.GetPlaneData(out j.pixels, image); jobs.Add(j); image.Dispose(); } }
public override void LocalizeServer() { bool rgb = false; ARCameraManager cameraManager = m_Sdk.cameraManager; var cameraSubsystem = cameraManager.subsystem; XRCameraImage image; if (cameraSubsystem.TryGetLatestImage(out image)) { CoroutineJobLocalizeServer j = new CoroutineJobLocalizeServer(); j.host = this; if (this.useGPS) { j.useGPS = true; j.latitude = m_Latitude; j.longitude = m_Longitude; j.radius = DefaultRadius; } Camera cam = this.mainCamera; j.rotation = cam.transform.rotation; j.position = cam.transform.position; j.intrinsics = ARHelper.GetIntrinsics(); j.width = image.width; j.height = image.height; if (rgb) { ARHelper.GetPlaneDataRGB(out j.pixels, image); j.channels = 3; } else { ARHelper.GetPlaneData(out j.pixels, image); j.channels = 1; } m_Jobs.Add(j); image.Dispose(); } }
public override void LocalizeServer() { bool rgb = false; ARCameraManager cameraManager = m_Sdk.cameraManager; var cameraSubsystem = cameraManager.subsystem; XRCpuImage image; if (cameraSubsystem.TryAcquireLatestCpuImage(out image)) { CoroutineJobLocalizeServer j = new CoroutineJobLocalizeServer(); if (gpsOn) { j.useGPS = true; j.latitude = m_Latitude; j.longitude = m_Longitude; j.radius = DefaultRadius; } else { int n = pcr.Count; j.mapIds = new SDKMapId[n]; int count = 0; foreach (int id in pcr.Keys) { j.mapIds[count] = new SDKMapId(); j.mapIds[count++].id = id; } } Camera cam = this.mainCamera; Vector3 camPos = cam.transform.position; Quaternion camRot = cam.transform.rotation; j.host = this; j.rotation = camRot; j.position = camPos; j.intrinsics = ARHelper.GetIntrinsics(); j.width = image.width; j.height = image.height; if (rgb) { ARHelper.GetPlaneDataRGB(out j.pixels, image); j.channels = 3; } else { ARHelper.GetPlaneData(out j.pixels, image); j.channels = 1; } j.OnResult += (SDKLocalizeResult result) => { /*if (result.error == "none") * {*/ if (result.success) { Matrix4x4 m = Matrix4x4.identity; Matrix4x4 cloudSpace = Matrix4x4.identity; cloudSpace.m00 = result.r00; cloudSpace.m01 = result.r01; cloudSpace.m02 = result.r02; cloudSpace.m03 = result.px; cloudSpace.m10 = result.r10; cloudSpace.m11 = result.r11; cloudSpace.m12 = result.r12; cloudSpace.m13 = result.py; cloudSpace.m20 = result.r20; cloudSpace.m21 = result.r21; cloudSpace.m22 = result.r22; cloudSpace.m23 = result.pz; Matrix4x4 trackerSpace = Matrix4x4.TRS(camPos, camRot, Vector3.one); this.stats.locSucc++; Debug.Log("*************************** On-Server Localization Succeeded ***************************"); Debug.Log("fc 4x4\n" + cloudSpace + "\n" + "ft 4x4\n" + trackerSpace); m = trackerSpace * (cloudSpace.inverse); foreach (KeyValuePair <int, PointCloudRenderer> p in this.pcr) { if (p.Key == result.map) { p.Value.go.transform.position = m.GetColumn(3); p.Value.go.transform.rotation = m.rotation; break; } } CoroutineJobEcef je = new CoroutineJobEcef(); je.host = this; je.id = result.map; je.OnSuccess += (SDKEcefResult result2) => { if (result2.error == "none") { Debug.Log(result2.ecef); LocalizerPose lastLocalizedPose; LocalizerBase.GetLocalizerPose(out lastLocalizedPose, result.map, cloudSpace.GetColumn(3), cloudSpace.rotation, m.inverse, result2.ecef); this.lastLocalizedPose = lastLocalizedPose; } else { Debug.LogError(result2.error); } }; m_Jobs.Add(je); } else { this.stats.locFail++; Debug.Log("*************************** On-Server Localization Failed ***************************"); } /*} * else * { * Debug.LogError(result.error); * }*/ }; m_Jobs.Add(j); image.Dispose(); } }