相关疑难解决方法(0)

从Android相机的NV21格式中提取黑白图像

我做了一些google-ing,但找不到有关此格式的足够信息.它是相机预览的默认格式.任何人都可以建议有关它的良好信息来源以及如何从该格式的照片/预览图像中提取数据?更具体地说,我需要提取黑白图像.

编辑:似乎这种格式也称为YCbCr 420 Semi Planar

rgb android format-conversion android-camera

31
推荐指数
3
解决办法
3万
查看次数

如何在ARCore中从session.update()获取Bitmap [A​​ndroid Studio]

我正在尝试使用 ARCore 从 ARSession 的当前帧获取位图。但它始终等于 null。我已经在网上搜索了一段时间,但无法弄清楚我做错了什么。

try {
    capturedImage = mFrame.acquireCameraImage();

    ByteBuffer buffer = capturedImage.getPlanes()[0].getBuffer();

    byte[] bytes = new byte[buffer.capacity()];

    Bitmap bitmap = BitmapFactory.decodeByteArray(bytes, 0, bytes.length,null);

    if (bitmap == null) 
        Log.e(TAG,"Bitmap was NOT initialized!");

} catch(Exception e){

}
Run Code Online (Sandbox Code Playgroud)

我正在mFrameonDrawFrameGLSurfaceView用来显示相机图像的地方获取信息。一切工作正常,除了我的位图等于空。

我使用的是按钮,因此只使用了一个框架,如下所示:

scanButton = (Button) findViewById(R.id.scanButton);
scanButton.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View view) {
        checkbox = false;
        if (capturedImage!=null) capturedImage.close();
            BitmapMethod();
    }
});
Run Code Online (Sandbox Code Playgroud)

capturedImagebuffer并且bytes全部不等于 null。

可能有什么问题吗mFrame.acquireCameraImage()

多谢

java android bitmap bitmapfactory arcore

3
推荐指数
1
解决办法
2439
查看次数