googlesamples / mlkit

A collection of sample apps to demonstrate how to use Google's ML Kit APIs on Android and iOS
Apache License 2.0
3.55k stars 2.93k forks source link

Translate Showcase app: "region of interest" for text recognition is not what is shown in the reticle #29

Open sheepmaster opened 4 years ago

sheepmaster commented 4 years ago

The reticle overlay over the preview image is set to a certain percentage (by default 74% x 8%) of the preview view. The image from the camera is cropped to the same percentage, but the image might not actually have the same aspect ratio as the preview view, which can result in text that is outside the overlay being recognized (or possibly text inside the overlay not being recognized).

sheepmaster commented 4 years ago

@owahltinez How is the fit of the camera image into the preview view determined? Fit the image (centered) into the view and crop anything sticking out (i.e. https://developer.android.com/reference/android/graphics/Matrix.ScaleToFit#CENTER)?

owahltinez commented 4 years ago

It is center-cropped (like you described). Currently you have to translate the coordinates yourself after accounting for the cropping, but this is something the team is actively working on and soon it will be much easier for developers to achieve WYSIWYG behavior. We might also see the ability to do letter-boxing (black bars instead of center-cropping) coming to PreviewView but I don't think that's very high priority right now.