1

I'm trying to use an Allocation created with the USING_IO_INPUT flag to get images from the camera. I'm setting it up as follows

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);

I'm adding the Allocation surface to a Preview Session, and getting the callbacks to my very simple function

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

This setup works on a Nexus 5X, but fails on a Nexus 4 running 5.1.1. When I call allocation.ioReceive() in the callback, I get a few warnings printed from the driver, and copying from the Allocation to a byte array results in garbage being copied.

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

I am running the camera in a background thread, although onBufferAvailable gets called in the "RSMessageThread".

Is this problem related to the way I am setting the Allocations and the Camera Preview, or is it a bug in the driver?

user1906
  • 2,310
  • 2
  • 20
  • 37

2 Answers2

0

I see the same error message on a Samsung Galaxy S4 (Smart Phone), android version 5.0 (API 21), but do not with the identical application using camera2 and renderscript, on a Samsung Galaxy Tab 5 (Tablet), android version 5.1.1 (API 22). I'm assuming it is an early implementation problem on the device vendors part.

0

Have you tried the official HDR-viewfinder example? If this works on the Nexus 4, then you can study that example.

If not, you can try with my implementation YUV_420_888 to Bitmap that uses a different approach, not via YUV-allocations but via byte-allocation using the Information from the three image planes.

Community
  • 1
  • 1
Settembrini
  • 1,366
  • 3
  • 20
  • 32