How to correlate the pixel from preview to image processing

726 views
Skip to first unread message

Mark Z

unread,
Aug 12, 2021, 4:46:43 AM8/12/21
to Android CameraX Discussion Group

Hi,

assumed I'm working on the "getting started with camerax" example. It calculates the average luminosity of the image with the LuminosityAnalyzer.

But how could I exacly calculate the average luminosity of top left and the right bottom point shown in the preview?

On my device the preview has a size of 936*1318 px and the image in the 
LuminosityAnalyzer has 480px*640px.

So, what point in the preprocessing image is top left of my preview image?
And what point in the preprocessing image is bottom right of my preview image?


Thanks, Mark


Xi Zhang (张熹)

unread,
Aug 12, 2021, 9:42:24 AM8/12/21
to Mark Z, Android CameraX Discussion Group
Hi Mark:

The outputs are aligned with the crop rect. The crop rect of different use cases should be mapped to the same area on the camera sensor. If you are using PreviewView, a simple way to calculate the transform from ImageAnalysis to Preview is using CoordinatesTransform:

 // imageProxy the output of an ImageAnalysis.
 OutputTransform source = ImageProxyTransformFactory().getOutputTransform(imageProxy);
 OutputTransform target = previewView.getOutputTransform();
 
 // Build the transform from ImageAnalysis to PreviewView
 CoordinateTransform coordinateTransform = new CoordinateTransform(source, target);
 
 
// Detect face in ImageProxy and transform the coordinates to PreviewView.
 // The value of faceBox can be used to highlight the face in PreviewView.
 RectF faceBox = detectFaceInImageProxy(imageProxy);
 coordinateTransform.mapRect(faceBox);

Thank you,
Xi

--
You received this message because you are subscribed to the Google Groups "Android CameraX Discussion Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to camerax-develop...@android.com.
To view this discussion on the web visit https://groups.google.com/a/android.com/d/msgid/camerax-developers/8090243f-2290-4bde-a060-de7b862e319an%40android.com.
Reply all
Reply to author
Forward
0 new messages