RAW format with RenderScript

flyboy Source

I am trying to preview RAW frames and histogram the values in an efficient way. In YUV format, this can be done by setting a RenderScript Allocation as a target surface in the Camera2 API:

Allocation ain = Allocation.createTyped(mRS, new Type.Builder(mRS, Element.YUV(mRS))
            .setX(mPreviewSize.getWidth())
            .setY(mPreviewSize.getHeight())
            .setYuvFormat(ImageFormat.YUV_420_888)
            .create(), Allocation.USAGE_IO_INPUT | Allocation.USAGE_SCRIPT);

Surface surface = ain.getSurface()
mPreviewRequestBuilder.addTarget(surface);
mCameraDevice.createCaptureSession(Arrays.asList(surface), mStateCallback, null);

and then using ScriptIntrinsicHistogram. Is it possible to stream RAW images directly to an Allocation as well?

I know that ScriptIntrinsicHistogram only works for type uchar and RAW typically has 10 bits. However, I am more interested in the 0-255 range anyway, so I would be satisfied with truncating the leading bits first in a RenderScript kernel.

I also know that the RAW buffers can be acquired with an ImageReader, copied to an array, and then re-copied into an Allocation, but for 16 MP images I would hope that a more efficient solution would be possible.

Thanks

androidrenderscript

Answers

comments powered by Disqus