MrA*_*ean 8 java android arcore
我创建了一个ARCore Session并通过Session #setCameraTextureName方法附加了一个OpenGL纹理id 来显示我的相机数据.我想访问纹理上显示的摄像机图像数据字节.
ARKit和Tango提供对每个帧的图像字节的访问,但似乎在ARCore API中没有任何容易提供的东西.
在使用ARCore时,还有其他方法可以访问图像字节吗?
也许这可以帮助你我想以位图形式获取相机视图。我在三星s8上测试过。
int w=1080;
int h = 2220;
int b[]=new int[w*(0+h)];
int bt[]=new int[w*h];
IntBuffer ib = IntBuffer.wrap(b);
ib.position(0);
GLES20.glReadPixels(0, 0, w, h, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, ib);
for(int i=0, k=0; i<h; i++, k++)
{//remember, that OpenGL bitmap is incompatible with Android bitmap
//and so, some correction need.
for(int j=0; j<w; j++)
{
int pix=b[i*w+j];
int pb=(pix>>16)&0xff;
int pr=(pix<<16)&0x00ff0000;
int pix1=(pix&0xff00ff00) | pr | pb;
bt[(h-k-1)*w+j]=pix1;
}
}
sb=Bitmap.createBitmap(bt, w, h, Bitmap.Config.ARGB_8888);
Run Code Online (Sandbox Code Playgroud)
从 ARCore v1.1.0 开始,有一个 API 可以访问当前帧的图像字节:
https://developers.google.com/ar/reference/java/com/google/ar/core/Frame.html#acquireCameraImage()