// Update is called once per frame void Update() { if (Frame.PointCloud.IsUpdatedThisFrame) { if (logger != null) { logger.text = "Have Points"; } if (AddVoxels) { CameraImageBytes cim = Frame.CameraImage.AcquireCameraImageBytes(); for (int i = 0; i < Frame.PointCloud.PointCount; i++) { Color colour = new Color(0, 0, 0); bool foundColour = false; PointCloudPoint p = Frame.PointCloud.GetPointAsStruct(i); Vector3 cameraCoordinates = arCamera.WorldToViewportPoint(p); if (cim.IsAvailable) { var uvQuad = Frame.CameraImage.DisplayUvCoords; int cx = (int)(cameraCoordinates.x * cim.Width); int cy = (int)((1.0f - cameraCoordinates.y) * cim.Height); colour = GetColourAt(cim, cx, cy, out foundColour); } if (foundColour) { tree.addPoint(p, colour); } } cim.Release(); } tree.renderOctTree(voxelParent); } else { if (logger != null) { logger.text = "No Points"; } } }
/** * Sends a snapshot of the current camera image and convert it into a JPG image * to be processed by a OCR service. * The response can arrive at any time. The default timeout time is 10 seconds * The average response time from Google Cloud Vision is 1 second */ private void InitiateOCRDetection() { image = Frame.CameraImage.AcquireCameraImageBytes(); // Detection needs to continue until enough cpu resources have been freed // If it fails, the user has to start the whole process again if (!image.IsAvailable) { _SystemStatePresenter.DisplayUserMessage("Couldn't access camera image! Please try again."); } /** * The camera image is split into its brightness(Y) channel and the meta data needed for calculations * This data is needed to create a Texture2D that can be converted into a JPG */ else { _TextDetection.DetectText(image.Width, image.Height, image.Y, image.YRowStride); } image.Release(); }