Relative Content

Tag Archive for swiftarkitrealitykit

Calculate dimensions of RealityKit ModelEntity from 2D bounding box

I am running VNRecognizeTextRequests on the single captured frames of an ARSession.
As a result I get the recognized textblocks and their bounding boxes.
I want to display these bounding boxes in the ARView as a RealityKit-Mesh.
To do so I perform a raycast from the centerpoint of the bounding box and place an AnchorEntity with ModelEntity as child at the first intersection of the ray.
The MeshResource.generatePlane method requires width and height of the resulting rectangle in metres, how do I calculate these dimensions from the size of the bounding box in screen coordinates?