Description: I am working on a project that receive a ImageProxy from camera library in RGBA format and send the image buffer to other calling library that accepts RGBA. The image by other library is rendered correctly.
As I want to integrate DeepAR, I changed cameraX format to YUV and pass image to DeepAR and render it on surfaceView. It works awesome :slight_smile
The next step is to send image from DeepAR to calling library. Thus I changed
// deepAR.setRenderSurface(surface, 1280, 720,)
-> to
deepAR.setOffscreenRendering(1280, 720, DeepARPixelFormat.RGBA_8888)
override fun frameAvailable(image: Image?)
Issue:
As the frameAvailable receive frame in RGBA the expectation is it should work fine when passed to calling library.
However, it appears with green lines.
Diagnostics: As if I use surfaceView, the image is rendered correctly on View and sending RGBA directly from cameraX works fine, it seems somehow the calling library is not good with RGBA received from frameAvailable.
In addition, I converted RGBA from frameAvailable to bitmap and saved to images on device, it is also distorted.
I have very limited knowledge of image rendering + conversion. Any feedback will help me.
HI @aulakh.inderpal, that you for reporting. You seem to have set the output format correctly, we will test this out to diagnose the issue and get back to you
Sorry you had that issue, the width being greater than the height shouldn’t cause this to happen, could you compare your frameAvailable code to one of our example apps to check if everything is correct? From the look of the issue, it might be related to the stride.
@Override
public void frameAvailable(Image frame) {
if (frame != null) {
final Image.Plane[] planes = frame.getPlanes();
final Buffer buffer = planes[0].getBuffer().rewind();
int pixelStride = planes[0].getPixelStride();
int rowStride = planes[0].getRowStride();
int rowPadding = rowStride - pixelStride * width;
Bitmap bitmap = Bitmap.createBitmap(width + rowPadding / pixelStride, height, Bitmap.Config.ARGB_8888);
bitmap.copyPixelsFromBuffer(buffer);
offscreenView.setImageBitmap(bitmap);
}
}