ImageInfo


interface ImageInfo


Metadata for an image.

Summary

Public functions

Int

Returns the rotation needed to transform the image to the correct orientation.

Matrix

Returns the sensor to image buffer transform matrix.

Long

Returns the timestamp of the metadata.

Public functions

getRotationDegrees

Added in 1.0.0
fun getRotationDegrees(): Int

Returns the rotation needed to transform the image to the correct orientation.

This is a clockwise rotation in degrees that needs to be applied to the image buffer. Note that for images that are in JPEG this value will match the rotation defined in the EXIF.

The target rotation is set at the time the image capture was requested.

The correct orientation of the image is dependent upon the producer of the image. For example, if the ImageProxy that contains this instance of ImageInfo is produced by an ImageCapture, then the rotation will be determined by setTargetRotation or setTargetRotation.

Returns
Int

The rotation in degrees which will be a value in {0, 90, 180, 270}.

getSensorToBufferTransformMatrix

Added in 1.1.0
fun getSensorToBufferTransformMatrix(): Matrix

Returns the sensor to image buffer transform matrix.

The returned matrix is a mapping from sensor coordinates to buffer coordinates, which is, from the value of SENSOR_INFO_ACTIVE_ARRAY_SIZE to (0, 0, image.getWidth, image.getHeight). The matrix can be used to map the coordinates from one UseCase to another. For example, mapping coordinates of the face detected with ImageAnalysis to ImageCapture. If setOutputImageRotationEnabled is set to false, getRotationDegrees will return the rotation degree that needs to be applied to the image buffer to user. In this case, the transform matrix can be calculated using rotation degrees. If setOutputImageRotationEnabled is set to true, the ImageAnalysis pipeline will apply the rotation to the image buffer and getRotationDegrees will always return 0. In this case, the transform matrix cannot be calculated. This API provides the transform matrix which could handle both cases.

        // Calculate the matrix
        Matrix analysisToSensor = new Matrix();
        analysisToSensor.invert(
            imageAnalysisImageProxy.getImageInfo()
                                   .getSensorToBufferTransformMatrix());
        Matrix sensorToCapture = captureImageProxy.getImageInfo()
                                                  .getSensorToBufferTransformMatrix();
        Matrix analysisToCapture = new Matrix();
        analysisToCapture.setConcat(analysisToSensor, sensorToCapture);

        // Transforming the coordinates
        Rect faceBoundingBoxInAnalysis;
        Rect faceBoundingBoxInCapture;
        analysisToCapture.mapRect(faceBoundingBoxInAnalysis, faceBoundingBoxInCapture);

        // faceBoundingBoxInCapture is the desired value
    
Returns
Matrix

the transform matrix.

getTimestamp

Added in 1.0.0
fun getTimestamp(): Long

Returns the timestamp of the metadata. Details on the timestamp depend on the source providing the image, and the method providing the image contains more documentation.

Returns
Long

the timestamp of the image