In my app I've to capture a barcode with AVCaptureVideoPreviewLayer
and AVCaptureSession
, when I use the rear camera all works perfectly and very fast, but when I try to read the same code from the front camera it doesn't work. I tried to mirror the AVCaptureVideoPreviewLayer
with the following code videoPreviewLayer.affineTransform = CGAffineTransformMakeScale(-1, 1);
, it mirror the image but the device is still unable to detect barcode. There's a way to detect a barcode from the front camera?
Use the camera to read a QR code Open Camera, then position iPhone so that the code appears on the screen. Tap the notification that appears on the screen to go to the relevant website or app.
Several websites allow you to scan QR Codes through your webcam or front-facing camera. Hold up the QR Code in front of your device and the associated link will appear on the screen.
Tap the color lens icon in Google Assistant, or open the Google Lens app. Select the Search mode. Center the QR code that you want to scan on the screen and hold your phone steady for a couple of seconds. Tap the notification that pops up to open the link.
To scan QR codes in images, pictures, or screenshots on your iPhone, you need to use a third-party QR code scanner. There are countless apps like this on the App Store—many of which charge a hefty fee if you accidentally sign up for a premium subscription.
There's a way to detect a barcode from the front camera?
Yes, you can use a third party library to do that. For example ZXingObjC.
You will need to setup your ZXCapture
object like this:
ZXCapture *capture = [[ZXCapture alloc] init];
capture.camera = self.capture.front;
capture.focusMode = AVCaptureFocusModeLocked;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With