-
Notifications
You must be signed in to change notification settings - Fork 3k
Description
Hello,
I have been using ML Kit for iOS extensively, particularly the barcode detection functionality. I have run into an issue where barcode detection works for some devices in some orientations and does not work as expected in other cases. I did come across a couple of similar issues that were raised in the past and closed due to inactivity, but I wanted to raise a new issue and provide all of the details around my specific problem.
First off, I have recreated the issue in the quickstart-ios project but only by extending the CameraViewController to include live barcode detection. The still image barcode detection with the UIImagePickerController works for me in all scenarios as it seems to be able to properly rotate the image no matter what orientation it was taken in.
I am using the AVCaptureSession in the CameraViewController to detect barcodes using the live feed. For my specific use case, however, I am using the AVCaptureSession "photo" preset. Everything works as expected for the iPhone 7 Plus and iPhone 8 Plus (and I believe probably any other iPhone that has two cameras). When holding the phone in portrait mode these devices are able to detect barcodes very well. However, if using an iPhone SE, iPhone 7, iPhone 8 (and potentially and other single camera iPhone?) barcodes are only detected in the landscape orientation.
It gets even more interesting though because if I change the AVCaptureSession preset to "medium" or "high" the barcode detection starts working the same (and as expected) for all devices I've tested on. Only when using the "photo" preset do I see an inconsistency in functionality. It seems like the image orientation metadata has absolutely no affect when using the "photo" preset because I tried every possible value for the orientation metadata and the functionality did not change; still worked as expected for iPhone Plus devices, and not as expected for single camera devices.
If helpful I can provide my CameraViewController.swift where I recreate the issue for live feed barcode detection.
Any help or guidance on this issue would be greatly appreciated!
Thank you.