gpt4 book ai didi

java - 在 ARCore 中访问图像数据字节

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:07:36 24 4
gpt4 key购买 nike

我创建了一个 ARCore Session并通过 Session#setCameraTextureName 附加一个 OpenGL 纹理 ID显示我的相机数据的方法。我想访问纹理上显示的相机图像数据字节。

ARKitTango提供对每个帧的图像字节的访问,但似乎没有任何东西可以在 ARCore API 中轻松提供。

在使用 ARCore 时,还有其他方法可以访问图像字节吗?

最佳答案

也许这可以帮助你我想以位图形式获取相机 View 。我已经在三星 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);

关于java - 在 ARCore 中访问图像数据字节,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45949769/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com