【问题标题】:Camera2 and Renderscript AllocationsCamera2 和 Renderscript 分配
【发布时间】:2016-03-12 06:40:17
【问题描述】:

我正在尝试使用使用 USING_IO_INPUT 标志创建的分配来从相机获取图像。我是这样设置的

Type.Builder yuvType = new Type.Builder(mRS, Element.YUV(mRS));
                yuvType.setYuvFormat(imageReaderFormat);
                yuvType.setX(mCameraWidth).setY(mCameraHeight);
mAllocation = Allocation.createTyped(mRS, yuvType.create(), Allocation
                        .MipmapControl.MIPMAP_NONE,
                        Allocation.USAGE_IO_INPUT | Allocation.USAGE_SCRIPT);
mAllocation.setOnBufferAvailableListener(mOnBufferAllocationAvailable);

我正在将分配表面添加到预览会话中,并获取对我非常简单的函数的回调

public void onBufferAvailable(Allocation allocation) {
     allocation.ioReceive();
     //mPixels is properly initialised
     allocation.copyTo(mPixels);
}

此设置适用于 Nexus 5X,但在运行 5.1.1 的 Nexus 4 上失败。当我在回调中调用allocation.ioReceive() 时,我从驱动程序中打印出一些警告,并且从分配复制到字节数组会导致垃圾被复制。

W/Adreno-RS: <rsdVendorAllocationUnMapQCOM:394>: NOT Found allocation map for alloc 0xa1761000
W/Adreno-GSL: <gsl_ldd_control:427>: ioctl fd 25 code 0xc01c0915 (IOCTL_KGSL_MAP_USER_MEM) failed: errno 22 Invalid argument
W/Adreno-RS: <rsdVendorAllocationMapQCOM:288>: gsl_memory_map_fd failed -5 hostptr: 0xa0112000 sz: 0 offset: 0 flags: 0x10c0b00 alloc: 0xa1761000

我在后台线程中运行相机,尽管onBufferAvailable 在“RSMessageThread”中被调用。

此问题与我设置分配和相机预览的方式有关,还是驱动程序中的错误?

【问题讨论】:

    标签: android renderscript android-camera2


    【解决方案1】:

    我在三星 Galaxy S4(智能手机)、android 版本 5.0 (API 21) 上看到相同的错误消息,但在三星 Galaxy Tab 5(平板电脑)、android 上使用 camera2 和 renderscript 的相同应用程序没有看到版本 5.1.1 (API 22)。我假设这是设备供应商部分的早期实施问题。

    【讨论】:

    • 众所周知,API 21 还不适合 Camera2。开始为 API>= 22 使用它。
    【解决方案2】:

    你试过官方HDR-viewfinder example吗?如果这适用于 Nexus 4,那么您可以研究该示例。

    如果没有,您可以尝试使用我的实现 YUV_420_888 to Bitmap,它使用不同的方法,不是通过 YUV 分配,而是通过使用来自三个图像平面的信息的字节分配。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多