private void AnnotateButtonClick() { // TODO: check if tracking byte[] png; if (DebugImage != null) { png = DebugImage.EncodeToPNG(); } else { png = ArUtils.GetCameraImage(ARInterface.GetInterface()); if (png == null) { return; } } var imageModel = new ImageModel(png); imageModel.Save(); var annotationModel = new AnnotationModel( new Pose(Camera.main.transform.position, Camera.main.transform.rotation), Camera.main.aspect, imageModel); annotationModel.Save(); AddAnnotation(annotationModel); }
// Update is called once per frame void Update() { // Send pose update _deltaTimePose += Time.unscaledDeltaTime; if (_deltaTimePose >= 1.0 / 5) { if (ARInterface.GetInterface().TryGetPose(ref _pose)) { SendData("pose", _pose); _deltaTimePose = 0; } } // Send point cloud update _deltaTimePointCloud += Time.unscaledDeltaTime; if (_deltaTimePointCloud >= 1.0 / 5) { if (ARInterface.GetInterface().TryGetPointCloud(ref _pointCloud)) { var data = _pointCloud.points.ToArray(); SendData("pointcloud", data); _deltaTimePointCloud = 0; } } // Send image update _deltaTimeImage += Time.unscaledDeltaTime; if (_sendImage && _deltaTimeImage >= 1.0) { var png = ArUtils.GetCameraImage(ARInterface.GetInterface()); if (png != null) { SendData("image", png); _deltaTimeImage = 0; } } }
private void AnnotateButtonClick() { Debug.Log("attempting raycast"); var castPosition = FocusDot.transform.position; TrackableHit hit; // if (ARInterface.GetInterface().TryRaycast(castPosition.x, castPosition.y, ref anchorPoint)) if (Frame.Raycast(castPosition.x, castPosition.y, TrackableHitFlags.FeaturePoint, out hit)) { Debug.Log("raycast success"); // var obj = GameObject.CreatePrimitive(PrimitiveType.Sphere); // obj.transform.localScale = new Vector3(0.03f, 0.03f, 0.03f); // obj.transform.position = anchorPoint.position; // obj.transform.rotation = anchorPoint.rotation; // anchors.Add(anchorPoint.id, obj.transform); var png = ArUtils.GetCameraImage(ARInterface.GetInterface()); if (png != null) { if (ARInterface.GetInterface().TryGetPose(ref _pose)) { var anchor = hit.Trackable.CreateAnchor(hit.Pose); var annotation = new TrackedAnnotation(png, Camera.main.aspect, _pose, anchor); _annotations.Add(annotation); annotation.Show(); ObjToAnnotation.Add(annotation._obj, annotation); setCurrentAnnotation(annotation); // SocketConnection.Instance.SendData("annotate", annotation.ToJson()); } } } else { Debug.Log("raycast unsuccessful"); } }