IPhone: barcode scanning - auto focus every second

I am currently using ZBar for scanning, and although it works very well, I would like to implement something similar to the shopsavvy , which is located in the barcode scanner, causing the camera to focus every second, which leads to an almost instant scan of the bar code.

Can someone point me in the right direction? "I know that shopavvy has its own SDK, but the barcode type that interests me is not supported on their SDK.

+4
source share
1 answer

To force autofocus, use the following:

NSArray *devices = [AVCaptureDevice devices]; NSError *error; for (AVCaptureDevice *device in devices) { if ([device position] == AVCaptureDevicePositionBack) { [device lockForConfiguration:&error]; if ([device isFocusModeSupported:AVCaptureFocusModeAutoFocus]) { device.focusMode = AVCaptureFocusModeAutoFocus; } [device unlockForConfiguration]; } } 

You can drag this into a method and schedule it using NSTimer .

Based on Focus Square IPhone iOS 4.3 - perhaps with the ability to delete?

+6
source

Source: https://habr.com/ru/post/1392103/


All Articles