Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ARCore how to release image acquired with acquireCameraImage

Tags:

android

arcore

I'm trying to capture image from the ARCore camera, but doing this continuously is returning me an exception (com.google.ar.core.exceptions.ResourceExhaustedException) and the same log is available at JNI level too

E: cpu_image_manager.cc:102 Failed to acquire new image, due to too many images acquired but not released.
E: status.cc:155 ArStatusErrorSpace::AR_ERROR_RESOURCE_EXHAUSTED: 

So I tried to find out how to release an image, and as pointed out by the ARCore ref it's pretty easy with C (Caller is responsible for later releasing the image with ArImage_release) but in Java there is no release method for a Frame object. Is it because GC is intended to free the resource itself?

like image 741
Dario Coletto Avatar asked Aug 06 '18 09:08

Dario Coletto


People also ask

What is point cloud ARCore?

public class PointCloud. Contains a set of observed 3D points and confidence values. This class implements Closeable and usually should be used in a Java try-with-resources or Kotlin use block, for example: Frame frame = session.

How does ARCore image recognition work?

ARCore detects with the camera so called feature points, which are visually distinct features found in the picture [6]. Through identification of feature points, together with the device's orientation and its accelerometer sensors, ARCore is able to track the motion of the the device.


1 Answers

After having acquired the Image object with

final Image image = frame.acquireCameraImage()

You can free the memory calling:

image.close();

Use the latest version ARCore SDK for Android 1.4, because prior to 1.3 image.close() had a bug with a reference received from frame.acquireCameraImage()

Ref: Image.close() reference

like image 64
MatPag Avatar answered Sep 27 '22 22:09

MatPag