I had starter project that used AVFoundation to set up the Camera and it worked perfectly. Now I needed to convert the Camera mechanism into GPUImage. I'm using the same focus and exposure method in both projects (which worked prefect at the AVFoundation project) but at the GPUImage project it doesn't focus properly and the always wrong.
Don't mind the applies filter it's the same over all of them
Sample : At the top right of the screen you can see the lamb. This is how it get focused + exposure.
Set up GPU :
stillCamera = GPUImageStillCamera(sessionPreset: AVCaptureSessionPreset640x480, cameraPosition: .Front)
CorrectPosition = AVCaptureDevicePosition.Front
stillCamera!.outputImageOrientation = .Portrait;
stillCamera?.horizontallyMirrorFrontFacingCamera = true
filter = GPUImageFilter()
stillCamera?.addTarget(filter)
filter?.addTarget(self.view as! GPUImageView)
(self.view as! GPUImageView).fillMode = GPUImageFillModeType.init(2)
TouchBegan method:
override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
var tap : CGPoint!
if let touch = touches.first as UITouch! {
tap = touch.locationInView(self.view)
}
let device: AVCaptureDevice! = self.stillCamera?.inputCamera!
var error: NSError? = nil
do {
try device.lockForConfiguration()
if device.focusPointOfInterestSupported && device.isFocusModeSupported(AVCaptureFocusMode.AutoFocus){
device.focusMode = AVCaptureFocusMode.AutoFocus
device.focusPointOfInterest = tap
}
if device.exposurePointOfInterestSupported && device.isExposureModeSupported(AVCaptureExposureMode.AutoExpose){
device.exposurePointOfInterest = tap
device.exposureMode = AVCaptureExposureMode.AutoExpose
}
device.subjectAreaChangeMonitoringEnabled = monitorSubjectAreaChange
device.unlockForConfiguration()
} catch let error1 as NSError {
error = error1
print(error)
} catch {
fatalError()
}
}
Any ideas?

The issue you are probably encountering is the
device.focusPointOfInterest'sxandyneed to be in[0;1]range, where the point(0,0)is the left-bottom corner of camera and the(1,1)is top-right, while you are passing the coordinates of tap in view's frame coordinate system.The only thing you need to do is to convert tap's coordinates into your camera points. Note, however, that camera can have different fill modes.
Here is how I am doing conversion (sorry for Objective-C code, but there is mostly simple math):
and the methods' implementation: