ARCore – 来自 arFragment 的图像与片段的显示不同

ARCore – Image from arFragment is different from the fragment's display

我在我的一个项目中使用 ARCore。我在视图中使用 arFragment。从那以后,我使用

arFragment.getArSceneView().getArFrame().acquireCameraImage()

其中 returns 一个 image。此图像和片段显示中的预览不同。我以为我通过 AR 片段看到的是通过 acquireCameraImage 捕获的内容,但看起来获取的图像比片段显示的部分更多,而且方向是横向(片段显示中的纵向视图).

我需要一个与片段显示中的预览相同的图像对象。
有什么办法可以得到吗?

如您所写 – public 方法 .acquireCameraImage() 从相机获取与当前帧对应的图像:

public Image acquireCameraImage()

为了获得与片段显示中预览相同的图像对象,只需使用:

public Frame update()

Google ARCore developers documentation:

update() method updates the state of the ARCore system. This includes: receiving a new camera frame, updating the location of the device, updating the location of tracking anchors, updating detected planes, etc. This call may cause off-screen OpenGL activity. Because of this, to avoid unnecessary frame buffer flushes and reloads, this call should not be made in the middle of rendering a frame or offscreen buffer. This call may update the pose of all created anchors and detected planes. The set of updated objects is accessible through getUpdatedTrackables(Class). This call in blocking mode (see Config.UpdateMode) will wait until a new camera image is available, or until the built-in timeout (currently 66ms) is reached. If the camera image does not arrive by the built-in timeout, then update() will return the most recent Frame object. For some applications it may be important to know if a new frame was actually obtained (for example, to avoid redrawing if the camera did not produce a new frame). To do that, compare the current frame's timestamp, obtained via getTimestamp(), with the previously recorded frame timestamp. If they are different, this is a new frame.