HDR Implementaion

119 views
Skip to first unread message

Patrick Liao

unread,
Jul 14, 2020, 4:20:46 PM7/14/20
to Android CameraX Discussion Group
Hey guys,

I am thinking about implementing HDR photography on my CameraX-based app without using vendors' HDR extensions. Should I use ImageCapture or ImageAnalysis for achieving this? And How do I iterate through every pixel via ImageProxy?

I am new to Android developement, and the stuff from Stack Overflow keeps confusing me...

Xi Zhang

unread,
Jul 15, 2020, 1:23:55 PM7/15/20
to Android CameraX Discussion Group
It depends on your algorithm. 

Both ImageCapture and ImageAnalysis provide an image buffer which can be used with your HDR algorithm. ImageAnalysis provides a stream of frames, which is helpful if you are merging frames. But the buffer from ImageAnalysis is often lower resolution comparing to ImageCapture, which is not ideal to be used for photography. On the other hand, ImageCapture provides a single image buffer with the max resolution.

How to iterate thru the pixels depends on the output format. The output buffer format is the value of ImageProxy#getFormat. For ImageAnalysis the format is YUV_420_888. For best performance, It's better to design the algorithm input to be the format of the buffer. Otherwise for example if the algorithm input is RGB, you will need an extra step to convert the YUV buffer to RGB first. Code sample for YUV to RGB conversion: https://github.com/owahltinez/camerax-tflite/blob/master/app/src/main/java/com/android/example/camerax/tflite/YuvToRgbConverter.kt 

Patrick Liao

unread,
Jul 15, 2020, 9:42:37 PM7/15/20
to Android CameraX Discussion Group, Xi Zhang

Thank you. I tried to read stuff from ImageProxy today, but the output confuses me. Here is the snippet of my code that takes the picture:



And when I run the code on my phone (HUAWEI P10 Plus), this is what came out:



"256" indicates that it is a JPEG. Should I do anything prior to processing the plane? Both RowStride and PixelStride are 0, which is odd.
Reply all
Reply to author
Forward
0 new messages