Ich versuche den Fokus mit der Frontkamera einzustellen.ios 9 AVCaptureDevice Einstellung Fokuspunkt
override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
let screenSize = cameraView.bounds.size
let frameSize:CGSize = view.frame.size
if let touchPoint = touches.first {
var location:CGPoint = touchPoint.locationInView(cameraView)
print("Tap Location : X: \(location.x), Y: \(location.y)")
if cameraManager.cameraDevice == .Front {
print("Front camera is used")
location.x = frameSize.width - location.x;
}
else {
print("Back camera is used")
}
let x = location.x/frameSize.width
let y = 1.0 - (location.x/frameSize.width)
let focusPoint = CGPoint(x: x, y: y)
print("POINT : X: \(x), Y: \(y)")
let captureDevice = (AVCaptureDevice.devicesWithMediaType(AVMediaTypeVideo) as! [AVCaptureDevice]).filter{$0.position == .Front}.first
if let device = captureDevice {
do {
try device.lockForConfiguration()
let support:Bool = device.focusPointOfInterestSupported
if support {
print("focusPointOfInterestSupported: \(support)")
device.focusPointOfInterest = focusPoint
// device.focusMode = .ContinuousAutoFocus
device.focusMode = .AutoFocus
// device.focusMode = .Locked
device.unlockForConfiguration()
print("Focus point was set successfully")
}
else{
print("focusPointOfInterestSupported is not supported: \(support)")
}
}
catch {
// just ignore
print("Focus point error")
}
}
}
}
Es funktioniert auf iphone6 für Rückkamera. Aber wenn ich die Frontkamera aktiviere, hat es gedroschen. focusPointOfInterestSupported gibt immer false zurück.
Wie kann ich dieses Problem lösen. Kann ich einen Fokuspunkt programmgesteuert festlegen?
Danke!
Danke für Ihre Antwort. Du hast recht. Die Frontkamera unterstützt nur die Einstellung der Belichtung. Weißt du, was ist mit Zoom? Ich kann den Zoomfaktor der vorderen Kamera nicht durch eine Fundstelle einstellen. Aber einige Anwendungen, die im Apple Store sind, können Zoom einstellen. – gkhanacer
Weder die vordere noch die hintere Kamera des iPhone unterstützen den optischen Zoom. Beim "Zoomen" dieser Apps wird das Bild einfach abgeschnitten, damit es vergrößert angezeigt wird. Wenn AVFoundation Sie daran hindert, den Zoom an der Frontkamera zu verwenden, kann dies daran liegen, dass die Auflösung geringer ist als die der hinteren Kamera. Die Kamera-App erlaubt auch nicht das Zoomen der Frontkamera, wie dies bei der Rückkamera der Fall ist. –