My app's custom camera does not focus properly. Close distance images are sharp, but far distance objects show in low resolution. I contacted apple developer support for this and provided them with my source code. they pointed out what to look at. I attached two relevant files, and see below for response:
"Thanks for sending the two source files.
I took a look at these, and you appear to be using the same techniques for focus that are being used in the AVCam & AVCamManual projects I referenced previously. More specifically, I'm referring to the following 'focusWithMode' method which you have also implemented in your code:
- (void)focusWithMode:(AVCaptureFocusMode)focusMode exposeWithMode:(AVCaptureExposureMode)exposureMode atDevicePoint:(CGPoint)point monitorSubjectAreaChange:(BOOL)monitorSubjectAreaChange
However, I'm not able to verify the value for the 'point' parameter you are passing into this function. This is something you'll want to check on -- for example, the AVCam sample simply uses a value of CGPointMake( 0.5, 0.5 ) here.
Also, when the AVCam sample code receives AVCaptureDeviceSubjectAreaDidChangeNotification notifications, it calls the same focusWithMode: method but specifies different values for the 'focusMode' (=Continuous) and 'monitorSubjectAreaChange' (=NO) parameters as shown here:
- (void)subjectAreaDidChange:(NSNotification *)notification
CGPoint devicePoint = CGPointMake( 0.5, 0.5 );
[self focusWithMode:AVCaptureFocusModeContinuousAutoFocus exposeWithMode:AVCaptureExposureModeContinuousAutoExposure atDevicePoint:devicePoint monitorSubjectAreaChange:NO];
You may also want to specify focusMode = Continuous and monitorSubjectAreaChange=NO in this case, otherwise with autofocus the device will autofocus once and then go to mode=locked (locked at current position), and with area change monitoring enabled you will receive subsequent AVCaptureDeviceSubjectAreaDidChangeNotification whenever it detects a change to the subject area (thus your function focusWithMode: will get called again). This may not be the desired behavior. Do you still have the problem if you use the above settings?
If you are indeed passing a valid 'point' value to the focusWithMode: function, and you are still able to reproduce the problem, then it may be a bug. In this case, you can certainly file a bug report using the Apple Bug Reporter ([url removed, login to view]) for our engineers to investigate.
And as discussed, let us know if you are able to reproduce the problem using the AVCam & AVCamManual projects. These projects demonstrate best practices for working with the AVFoundation Capture APIs. If you can't reproduce the problem using these projects, then you should compare your code against these to make sure you are using the same recommended techniques for the Capture APIs.
Apple Developer Technical Support"