getPreviewImageBounds

fun getPreviewImageBounds(sourceImageWidth: Int, sourceImageHeight: Int, viewWidth: Int, viewHeight: Int, scaleType: PreviewView.ScaleType): PreviewImageBounds

Calculate the location of the preview image top-left corner (relative to the component top-left corner) and dimensions, to be used for displaying detected objects, for example with the DetectorViewBase.

When camera preview resolution differs from the dimensions of the PreviewView used to display camera input, image is scaled and cropped or padded according to the provided PreviewView.ScaleType. Because of this, in order to display detected objects on the PreviewView, their coordinates need to be converted. This method returns PreviewImageBounds object containing the necessary information to preform the conversion from the image coordinate system to the view coordinate system.

See also

Parameters

sourceImageWidth

width of the image from the camera

sourceImageHeight

height of the image from the camera

viewWidth

width of the target PreviewView

viewHeight

height of the target PreviewView

scaleType

scaling option used in the target PreviewView