قالب وردپرس درنا توس
Home / IOS Development / IOS – Smooth focus ramp on AVCaptureDevice

IOS – Smooth focus ramp on AVCaptureDevice



I use AVCaptureDevice setFocusModeLocked to implement a focus ramp from point A to point B. The way I do is I define delta to be something like 0.03 and then repeatedly call the API to set lensPosition.

     device.setFocusModeLocked (lensPosition: pointA, completionHandler: {[weak self] (time) in
DispatchQueue.main.asyncAfter (deadline: DispatchTime.now (), run: {[weak self] in

if pointA == pointB {
device.unlockForConfiguration ()
return
}

var beginPoint = fmax (currentLensPosition + delta), Float (0))
let endPoint = fmin (pointB, Float (1.0))


self? .focusRampRecursive (StartPoint,
pointB: end point,
participate: participate,
unit: unit)
})
})

The problem is that the ramp is not slippery. It is jump visible when the ramp happens. How can I make it smooth?


Source link