Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InputImage.fromMediaImage ignores cropRect #234

Closed
ivan200 opened this issue Feb 3, 2021 · 3 comments
Closed

InputImage.fromMediaImage ignores cropRect #234

ivan200 opened this issue Feb 3, 2021 · 3 comments

Comments

@ivan200
Copy link

ivan200 commented Feb 3, 2021

I'm trying to use simplest qr scanning image analyzer.
And I am trying to scan not the entire area of the screen, but only the center bounded by the frame.
In this example, I set the crop rect for MediaImage, which will be converted to the InputImage and then passed to the scanner.
but scanner still scan entire area

override fun analyze(imageProxy: ImageProxy) {
    val mediaImage = imageProxy.image
    if (mediaImage != null) {
        val cropSize = (min(mediaImage.width, mediaImage.height) * 0.6f).toInt()
        val cropRect = Rect(mediaImage.width / 2 - cropSize / 2, mediaImage.height / 2 - cropSize / 2,
            mediaImage.width / 2 + cropSize / 2, mediaImage.height / 2 + cropSize / 2)

        //here i set crop rect
        mediaImage.cropRect = cropRect
        val image = InputImage.fromMediaImage(mediaImage, imageProxy.imageInfo.rotationDegrees)

        //but here scanner wil process whole image instead of small area
        pendingTask = scanner.process(image)
            .addOnSuccessListener { barcodes ->
                //do something
            }
            .addOnCompleteListener {
                imageProxy.close()
            }
    }
}
@cs-googler
Copy link

Hi, this field is not supported by MLKit currently. We are working on supporting it in future releases.

@G00fY2
Copy link

G00fY2 commented Jul 7, 2021

Is there any progress or an alternative issue that we can subscribe to?

Currently UseCaseGroup is pretty much useless since the Analyzer does not use the cropRect of input images. Manually cropping images seems to be pretty messy.

Looking forwards for this feature!

@G00fY2
Copy link

G00fY2 commented Dec 14, 2021

@cs-googler is this feature still in your backlog? Will this available in the future releases?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants