Reputation: 8121
This has been stumping me for days...
In my app i am using AVCapture to take a photo, then i am using the ZBar SDK to scan a bar code. The problem is once I load ZBar after taking a picture, i lose the ability to auto focus when taking another picture. If i load ZBar first, then i can adjust the focus when taking a picture, but ZBar loses the ability to focus! I tried swapping out ZBar for the ShopSavvy code scanner SDK and im encountering the same problem...
Here is the code i am using to set the camera to turn on auto focus but no error is occurring, and i am unable to 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];
}
}
}
Upvotes: 4
Views: 1051
Reputation: 8121
Turns out you need to release each capture session before loading up a new one. In this case, i wasn't releasing my capture session before loading up ZBar, and i wasn't releasing ZBar before loading up my capture session.
Upvotes: 2