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?
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.
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.
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 fromframe.acquireCameraImage()
Ref: Image.close() reference
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With