When calling AcquireCameraImageBytes
to retrieve an CameraImageBytes
instance and the underlying Y
IntPtr buffer, I need to pass that IntPtr to my own AAR library which takes a ByteBuffer
as argument. I could not find a way of converting the IntPtr
to an AndroidJavaObject
reference which would allow me to pass it to my method.
using (GoogleARCore.CameraImageBytes image = GoogleARCore.Frame.CameraImage.AcquireCameraImageBytes())
{
if (!image.IsAvailable)
{
return;
}
int width = image.Width;
int height = image.Height;
IntPtr yPixelBuffer = image.Y;
using (AndroidJavaClass utilsClass = new AndroidJavaClass("com.mypackage.MyClassUtils"))
{
utilsClass.CallStatic("setCurrentBuffer", yPixelBuffer, width, height); // <-- Need to pass a AndroidJavaObject here but no way to just pass the ByteBuffer
}
}
the Java method implementation:
public class MyClassUtils {
public static final void setCurrentBuffer(
ByteBuffer buffer,
int width,
int height) {
}
Is there any way to convert the IntPtr
to its underlying ByteBuffer
reference ?