iPhone 4s camera issues (maybe 5.1 beta issue?)

I have been working on a small app and recently got an iPhone4s.

The app runs really great, but it uses the camera and for some reason the camera doesn’t continually focus when it is in my app.

It sort of picks a focus range right when the app opens (ie it will focus close on my keyboard but not on anything far away…and vice versa).

The same problem isn’t apparent on an iPod touch with a camera…everything seems to re-focus (but the camera draws much slower even though the fps is shown to be ~30)

Tried this with my app and the videoGrabber example. The iPod touch is running 5.0.1 and the iphone 4s is running 5.1 beta 2 so that could be the issue, but I think I remember seeing this problem when I was in 5.0

Looks like it may be linked to something in Lion…in the AvFoundationVideoGrabber.mm this is where the focus is declared in initGrabber:

-(void) startCapture{  
	if( !bInitCalled ){  
		[self initCapture:60 capWidth:480 capHeight:320];  
	[self.captureSession startRunning];  
	[captureInput.device lockForConfiguration:nil];  
	//if( [captureInput.device isExposureModeSupported:AVCaptureExposureModeAutoExpose] ) [captureInput.device setExposureMode:AVCaptureExposureModeAutoExpose ];  
	if( [captureInput.device isFocusModeSupported:AVCaptureFocusModeAutoFocus] )	{  
        [captureInput.device setFocusMode:AVCaptureFocusModeAutoFocus ];  
       // captureInput.device AVCaptureTorchModeOn:  

But this line:

if( [captureInput.device isFocusModeSupported:AVCaptureFocusModeAutoFocus] )	{  
        [captureInput.device setFocusMode:AVCaptureFocusModeAutoFocus ];  

should be:

if( [captureInput.device isFocusModeSupported:AVCaptureFocusModeAutoFocus] )	{  
        [captureInput.device setFocusMode:AVCaptureFocusModeContinuousAutoFocus ];  

According to the apple class ref plain autofocus will only focus once and then lock-off…only available in 10.7…strange functionality, although it makes sense in any ‘tap to focus’ method

class ref:

Constants to specify the focus mode of a capture device.  
enum {  
    AVCaptureFocusModeLocked                = 0,  
    AVCaptureFocusModeAutoFocus             = 1,  
    AVCaptureFocusModeContinuousAutoFocus   = 2,  
typedef NSInteger AVCaptureFocusMode;  
    The focus should be locked at the lens’s current position.  
    Available in Mac OS X v10.7 and later.  
    Declared in AVCaptureDevice.h.  
    The device should autofocus once and then change the focus mode to AVCaptureFocusModeLocked.  
    Available in Mac OS X v10.7 and later.  
    Declared in AVCaptureDevice.h.  
    The device should automatically focus when needed.  
    Available in Mac OS X v10.7 and later.  
    Declared in AVCaptureDevice.h.  

Well, there really should be no problem with an iPod touch because it has no autofocus built in it to begin with. So whatever it sees is what you can see through it unlike the iPhone 4s where it will look for spots to focus on. It is also not something that you can bunk on for an extended shot as it tends to bog down for those types of scenes. Have some work around it though that will disable it apparently.