/// <summary> /// Parse a static sample response for the sake of faster testing /// </summary> /// <returns></returns> IEnumerator ParseSampleResponse() { WWW www = new WWW(AppManager.Instance.serverAddress + "/sample_resp"); yield return(www); if (www.error != null) { print(www.error); yield break; } Matrix4x4 lastCameraToWorldMatrix = Matrix4x4.identity; Matrix4x4 lastProjectionMatrix = Matrix4x4.identity; ResponseStruct resp = JsonUtility.FromJson <ResponseStruct>(www.text); print("Response Length: " + resp.recognizedObjects.Length); RecognisedObject obj = resp.recognizedObjects[0]; Vector3? hitPoint = ObjectLocator.Instance.PixelToWorldPoint(new Vector2(obj.details[0] + (obj.details[2] - obj.details[0]) / 2, obj.details[1] + (obj.details[3] - obj.details[1]) / 2), lastCameraToWorldMatrix, lastProjectionMatrix); if (hitPoint.HasValue) { ObjectLocator.Instance.AttemptToDropMarker(new Vector3(0, 0.5f, 5), resp.recognizedObjects[0]); } else { DebugManager.Instance.PrintToRunningLog("No boundary found"); } }
/// <summary> /// Attempts to Drops the label and the marker at the given position if no overlaps found /// </summary> /// <param name="pos">Position</param> /// <param name="obj">RecognisedObject</param> /// <returns>The Object Marker object</returns> public ObjectMarker AttemptToDropMarker(Vector3 pos, RecognisedObject obj) { if (IsOverlappingSimilarMarker(pos, obj.type)) { DebugManager.Instance.PrintToRunningLog("Similar marker: " + obj.type); return(null); } else { ObjectMarker marker = CreateMarker(); marker.SetProperties(pos, obj.type, obj.score); markers.Add(marker); return(marker); } }
/// <summary> /// Gets all anchors. /// </summary> void GetAllAnchors() { string[] ids = this.store.GetAllIds(); DebugManager.Instance.PrintToInfoLog("persistence : " + store.anchorCount + " " + ids.Length); for (int index = 0; index < ids.Length; index++) { ///[0]: Marker type ///[1]: Marker confidence score ///[2]: Marker additional info(random number for now) string[] chunks = ids[index].Split(':'); RecognisedObject obj = new RecognisedObject { type = chunks[0], score = float.Parse(chunks[1]) }; ObjectMarker om = ObjectLocator.Instance.AttemptToDropMarker(Vector3.zero, obj); om.markerName = ids[index]; store.Load(ids[index], om.gameObject); DebugManager.Instance.PrintToInfoLog(ids[index] + "@" + om.transform.position); } }