Anton
Anton

Reputation: 137

Remap Y-values of YUV NV21 byte array into bitmap

I have a NV21 byte array (that I get from the camera), and I need to convert it to a black and white bitmap (so I only need the Y-values from the byte array). I tried doing it in Java, but that was VERY slow. So I did some research and I found Renderscript, but I do not know how to use it since the input-Allocation is not the same dimension as the output-Allocation. Does someone have suggestions to do it in Renderscript or does someone have another idea? Thanks in advance.

Upvotes: 0

Views: 132

Answers (1)

FluidCode
FluidCode

Reputation: 301

I solved the problem of allocations of different sizes by binding only the output allocation and setting the input allocation from the Java code.

I found the solution in an answer on Stackoverflow, but I can't find the link now. But I posted a question few hours ago with a script with a similar structure.

Coding functions across multiple renderscripts to avoid duplications

The input allocation is defined as a property in the script

rs_allocation inputImg

It is set from java either by setting the surface to a buffer and calling:

inputAllocation.ioReceive()

Or by calling:

yourScript.setAllocationName(inputImage);

Upvotes: 1

Related Questions