juliansteenbakker / mobile_scanner

A universal scanner for Flutter based on MLKit. Uses CameraX on Android and AVFoundation on iOS.
BSD 3-Clause "New" or "Revised" License
756 stars 446 forks source link

fix: increase-camera-quality #760

Closed EArminjon closed 7 months ago

EArminjon commented 8 months ago

ML Kit need to have image in good quality else it will not be able to process images with precision. Bad precision can lead to bad code recognition and produce wrong detection.

This PR can maybe replace this PR and fix the aspect ratio issue mentioned : https://github.com/juliansteenbakker/mobile_scanner/pull/612 This PR can fix theses issues : https://github.com/juliansteenbakker/mobile_scanner/issues/674, https://github.com/juliansteenbakker/mobile_scanner/issues/752, https://github.com/juliansteenbakker/mobile_scanner/pull/749

I'm not a native expert. I tested and it works well, if you see something weird, please comment.

mocmeow commented 8 months ago

I've tested your fix and it do improve the scan distance and speed, difference is noticeably specially on not a really good cam like 5 or 8mpx cam and 16 digits barcode. No problem has been found so far, I'm waiting for a merge soon. Great job, thank you!

EArminjon commented 7 months ago

Hello @juliansteenbakker

What do you think of this PR ?

EArminjon commented 7 months ago

Hello @navaronbracke, modifications pushed :)

Usage example :

MobileScannerController(
    androidResolution: const Size(1920, 2560),
)
navaronbracke commented 7 months ago

Will have a look, thanks!

navaronbracke commented 7 months ago

@EArminjon did you manage to use the newer API, which replaces the deprecated setTargetResolution on newer Android versions? That is going to be a requirement for this as well.

EArminjon commented 7 months ago

@EArminjon did you manage to use the newer API, which replaces the deprecated setTargetResolution on newer Android versions? That is going to be a requirement for this as well. That also mean current camera2 package to camera2 version 1.3.

I'm not native expert, could take responsability on this :/

navaronbracke commented 7 months ago

I can take a look for that for you.

navaronbracke commented 7 months ago

@EArminjon I found a solution for the display listener (and the deprecated window display getter)

EArminjon commented 7 months ago

@navaronbracke PR updated :

navaronbracke commented 7 months ago

@EArminjon Apparently we did things side-by-side :)

I fixed the display listener issue in a slightly different way in https://github.com/juliansteenbakker/mobile_scanner/pull/785 so that we don't need to keep track of the window manager as well.

I also fixed a small warning about a private method in the Android code and fixed a deprecated API usage.

Your original commits are included in that PR as well (except for the things we did in parallel)

EArminjon commented 7 months ago

@EArminjon Apparently we did things side-by-side :)

I fixed the display listener issue in a slightly different way in #785 so that we don't need to keep track of the window manager as well.

I also fixed a small warning about a private method in the Android code and fixed a deprecated API usage.

Your original commits are included in that PR as well (except for the things we did in parallel)

I'm happy to see that my fix was closest to yours, i'm pretty junior in Android Native. Ty for making this better ressource cleanup <3 !

I close this PR right ?

navaronbracke commented 7 months ago

Yes that is correct. While looking at your latest commit I also found an error I made, we can indeed use DisplayManager.DisplayListener with an anonymous object (instead of using a separate class)

I added that to the other PR as well. Thank you!