Closed CoreyCole closed 3 years ago
We fixed the issue by changing the ResolutionPreset
on the CameraController
to high:
final newCameraController = CameraController(
cameras.first,
ResolutionPreset.high,
enableAudio: false,
);
We are only using the camera preview for scanning a QR code, so high resolution is overkill for our use case. On lower-end devices it causes dropped frames to set the camera controller to high. Would love to be able to use this plugin on lower resolution presets.
Same issue, high resolution is overkill, medium crash
I'm seeing the same thing with a Nexus 5x, on medium it doesn't find anything.
For anyone else looking only to scan QR codes, we decided to use qrcode
. It uses native packages AVCaptureSession in iOS and zxing in Android.
https://pub.dev/packages/qrcode
Running the firebase_ml_vision for QR codes was overkill, even more so with the resolution pinned at high.
I met the issue when I run app on pixel 3a with camera streaming and ml_vision. If ResolutionPresent is setting lower than high, ml_vision will detect nothing.
But this problem not appear when I debug on Samsung s8 and iPhone 6s. They can only work when I set ResolutionPresent to medium. CameraPreview will lag when ResolutionPresent set high.
Any solution ?
Same issue, the example app doesn't even work on Android.
Similar thing also happened here, I am writing a real time face detection app using face detector, and I was setting ResolutionPreset to medium, which results no faces detected at all, it took me days to find out the reason. My device is Samsung S9 running Android X(api 29), face detection working fine if preset is not set to medium.
I can relate to this. Text OCR works on ResolutionPreset.HIGH, but on slower devices it might stutter a bit. On Samsung S8 it stutters hell a lot and is completely unusable. Switching to ResolutionPreset.MEDIUM fixes the Samsung S8 issue, but completely disables other devices as they no longer recognize a single character from the image.
Same Problem here. The medium resolution was not working at all.
I looked closer at what happened, and I found that my phone (redmi 4X) added a padding to each row of the planes when the medium resolution was selected (but not with high or low resolution).
In my case the image format is a YUV 4:2:0, meaning the image is decomposed in 3 planes (Y, U, V), with 8 bits per pixel for Y, and 4 for U and V.
Each plane is a matrix of ~pixel stored in a 1D-array. They come with a bytesPerRow
value that represents the length of a row. This may be or not the same size than the image width depending if some padding is added at the end of each row or not. On my case, bytesPerRow
was 768
and my image width 720
(so a padding of 48 bytes has been added to each row).
As bytesPerRow
is given to the FirebaseVisionImagePlaneMetadata
object I suppose that the row stride should be handled correctly by the library. But it looks that something is not handled right?
1 - I can't help and dig more into this than I actually did.
2 - I wrote 2 workarounds (A and B) that keep the data consistency:
A: Remove manually the padding in the plane (for each row) and set the bytesPerRow
to the image width. Drawback: It's a bit painful and I suppose it may slow down a bit the process.
B: Change the image width to include the padding. Drawback: your image has a "black border" on the right of the image of the size of the padding. It may not be a problem in some cases.
// For each plane
FirebaseVisionImagePlaneMetadata(
bytesPerRow: plane.bytesPerRow,
width: plane.bytesPerRow,
height: image.height,
)
...
int newWidth = planes[0].bytesPerRow;
// Build image metadata
var metadata = FirebaseVisionImageMetadata(
rawFormat: image.format.raw,
size: Size(newWidth.toDouble(), image.height.toDouble()),
rotation: ImageRotation.rotation90,
planeData: planesMetadata,
);
...
Both are working for my own but they still are workaround. I hope this will help some of you.
Bar Code scanner won't run iPhone 8 device while set it max resolution. if i set resolution to medium at the time it work's fine but can't able to scan the lower quality bar code in printed copies. while set to max resolution iPhone 6, 6s, 7, 7 plus, 8, 8 plus memory consumption is more than gb and it leads to crash. Attached Memory usage screen shot. please advice
I have the same problem on my Pixel 3a. Only works with max resolution, and in max resolution the memory builds until the app crashes.
We fixed the issue by changing the
ResolutionPreset
on theCameraController
to high:final newCameraController = CameraController( cameras.first, ResolutionPreset.high, enableAudio: false, );
We are only using the camera preview for scanning a QR code, so high resolution is overkill for our use case. On lower-end devices it causes dropped frames to set the camera controller to high. Would love to be able to use this plugin on lower resolution presets.
ResolutionPreset.high or even ultra didn't help me on OnePlus 6t :(
whats new?
I'm having the same problem on a Google Pixel (1) and Pixel 4 XL. Only with ResolutionPreset.high
are barcodes detected reliably.
whats new?
nothing, by the looks of it. This issue has been opened for over a year now, so I'm assuming that nobody's looking at this. If I were you I would be looking at using another library
Describe the bug I'm building an android app using flutter that has a QR code scanning feature. I've broken out the QR code logic into a minimum reproduction case here.
Oddly enough, the QR scanning only works on my Samsung devices. My Google Pixel XL and Oneplus 6 both do not detect anything when scanning a QR code using google/firebase ml vision barcode scanning model.
To Reproduce Steps to reproduce the behavior
Key code locations in the repository are:
android/app/build.gradle
where I include the barcode model api:lib/src/bloc/services/qr_service.dart
where I run the barcode detection on the image:I'm hoping I'm doing something wrong. But it is very weird that this minimum repro works flawlessly on my Samsung S8, Samsung J7, and Samsung S10+ while it does not work on my Oneplus 6 (android 10) and it does not work on my Google Pixel XL (android 9).
Additional context Dependency Versions
Device List
Working on these devices
Not working on these devices
flutter doctor -v
Posted on Stack Overflow as well in case I'm doing something wrong and this isn't actually a bug with firebase ML vision