metsburg
metsburg

Reputation: 2021

GPUImage video capture with 'tap-to-focus' and exposure control

I am using this tutorial:https://github.com/BradLarson/GPUImage to create a video capture application in iOS.

The application is up and running. I have one query...

we use this code to start a live video capture session:

 GPUImageVideoCamera *videoCamera = [[GPUImageVideoCamera alloc]        
 initWithSessionPreset:AVCaptureSessionPreset640x480    
 cameraPosition:AVCaptureDevicePositionBack];
 videoCamera.outputImageOrientation = UIInterfaceOrientationPortrait;

 GPUImageFilter *customFilter = [[GPUImageFilter alloc]     
 initWithFragmentShaderFromFile:@"CustomShader"];
 GPUImageView *filteredVideoView = [[GPUImageView alloc] initWithFrame:CGRectMake(0.0,   
 0.0, viewWidth, viewHeight)];


 [videoCamera addTarget:customFilter];
 [customFilter addTarget:filteredVideoView];

 [videoCamera startCameraCapture];

But how to enable 'image picker' style 'focus-on-tap' and exposure correction on tap feature into this framework.

Is it possible? Could you please point me in the right direction.

Please help.

Thanks in advance.

Upvotes: 3

Views: 3163

Answers (1)

metsburg
metsburg

Reputation: 2021

Got it, partially:

 - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {

   UITouch *touch = [touches anyObject];
   CGPoint touchPoint = [touch locationInView:self.view];

    if([videoCamera.inputCamera isFocusPointOfInterestSupported]&&[videoCamera.inputCamera isFocusModeSupported:AVCaptureFocusModeAutoFocus])
   {

   if([videoCamera.inputCamera lockForConfiguration :nil])
   {
    [videoCamera.inputCamera setFocusPointOfInterest :touchPoint];
    [videoCamera.inputCamera setFocusMode :AVCaptureFocusModeLocked];

     if([videoCamera.inputCamera isExposurePointOfInterestSupported])
      {
        [videoCamera.inputCamera setExposurePointOfInterest:touchPoint];
        [videoCamera.inputCamera setExposureMode:AVCaptureExposureModeLocked];
    }
    [videoCamera.inputCamera unlockForConfiguration];
}
}

}

The exposure and focus is getting locked, but freezing after a time...

working on it.

Upvotes: 5

Related Questions