AVCapture loses the ability to set focus when using the ZBar SDK

It made me whole days ...

In my application, I use AVCapture to take a photo, then I use the ZBar SDK to scan the barcode. The problem is that when I load the ZBar after shooting, I lose the ability to autofocus when shooting another image. If I load the ZBar first, then I can adjust the focus when shooting, but the ZBar loses the ability to focus! I tried replacing the ZBar with the ShopSavvy scanner SDK, and I ran into the same problem ...

Here is the code that I use to turn the camera on to auto focus, but the error does not occur, and I cannot focus!

AVCaptureDevice *device = [[self videoInput] device]; if ([device isFocusPointOfInterestSupported] && [device isFocusModeSupported:AVCaptureFocusModeContinuousAutoFocus]) { NSError *error; if ([device lockForConfiguration:&error]) { [device setFocusPointOfInterest:point]; [device setFocusMode:AVCaptureFocusModeContinuousAutoFocus]; [device unlockForConfiguration]; } else { if ([[self delegate] respondsToSelector:@selector(captureManager:didFailWithError:)]) { [[self delegate] captureManager:self didFailWithError:error]; } } } 
+4
source share
1 answer

Turns out you need to free every capture session before loading a new one. In this case, I did not remove the capture session before loading the ZBar, and I did not release the ZBar before loading the capture session.

+2
source

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


All Articles