Open iosnatarajan opened 7 years ago
Hi there! Thank you for trying out the API. Let's see can I help you solve the issue.
First, I want to confirm how to reproduce the issue you're having:
If the above steps reproduced the issue you're seeing, then this is due to the incorrect GMVDetectorImageOrientation value is passing to the featuresInImage:options: method on GMVDetector.
Here's some more detail about what's going on.
When the device orientation is UIDeviceOrientationFaceUp or UIDeviceOrientationFaceDown, the application doesn't understand it's rotated. This is also why the screenshot you took has portrait mode UI instead of landscape mode UI.
If you try to scan a barcode in UIDeviceOrientationLandscapeLeft or UIDeviceOrientationLandscapeRight position, then the overlay should show up correctly.
The barcode API is doing the right thing. This is more of an issue in the sample app. Below is the code snippet from the sample app where the barcode API is called.
UIDeviceOrientation deviceOrientation = [[UIDevice currentDevice] orientation];
GMVImageOrientation orientation = [GMVUtility
imageOrientationFromOrientation:deviceOrientation
withCaptureDevicePosition:devicePosition
defaultDeviceOrientation:self.lastKnownDeviceOrientation];
NSDictionary *options = @{
GMVDetectorImageOrientation : @(orientation)
};
NSArray<GMVBarcodeFeature *> *barcodes = [self.barcodeDetector featuresInImage:image
options:options];
The sample code uses lastKnownDeviceOrientation as the orientation to use when the device orientation is either UIDeviceOrientationFaceUp or UIDeviceOrientationFaceDown. You can read more details on the GMVUtility imageOrientationFromOrientation:withCaptureDevicePosition:defaultDeviceOrientation: method in the API reference.
To fix the issue, instead of using the lastKnownDeviceOrientation, it should be replaced with a UIDeviceOrientation derived from UIInterfaceOrientation.
Please feel free to submit a patch to the issue. Otherwise we can update the sample code in the next update.
any update on this issue?
When I try to scan a linear and 2D barcodes, the scanned area(purple shape) shows in wrong location on preview layer. Herewith I have attached the screenshots which reflects this issue.
Note: This issue only occurs when I hold the device horizontally at the top of barcode.
Thanks!