Ich analysiere Live-Bilder in einer Capture-Session vom Typ AVMediaTypeVideo. Wie kann ich ein qualitativ hochwertiges-Standbild (nicht der niedrigaufgelöste Probenpuffer), bei bestimmten Ereignissen =AVFoundation: Hochqualitatives Standbild in Video-Session nehmen
var videoCaptureDevice: AVCaptureDevice = AVCaptureDevice.defaultDevice(withMediaType: AVMediaTypeVideo)
var device = AVCaptureDevice.defaultDevice(withMediaType: AVMediaTypeVideo)
var previewLayer: AVCaptureVideoPreviewLayer?
var captureSession = AVCaptureSession()
let cameraOutput = AVCapturePhotoOutput()
//called in view did load
private func setupCamera() {
let input = try? AVCaptureDeviceInput(device: videoCaptureDevice)
captureSession.sessionPreset = AVCaptureSessionPreset640x480
if self.captureSession.canAddInput(input) {
self.captureSession.addInput(input)
}
self.previewLayer = AVCaptureVideoPreviewLayer(session: captureSession)
let videoDataOutput = AVCaptureVideoDataOutput()
if self.captureSession.canAddOutput(videoDataOutput){
self.captureSession.addOutput(videoDataOutput)
videoDataOutput.setSampleBufferDelegate(self, queue: DispatchQueue.main)
}
}
func captureOutput(_ captureOutput: AVCaptureOutput!, didOutputSampleBuffer sampleBuffer: CMSampleBuffer!, from connection: AVCaptureConnection!) {
// sampleBuffer is analysed
// if result is positive, I would like to take a high quality picture
}
danke für die Antwort! Ich habe Ihre Methode aufgerufen, wenn die Bedingungen erfüllt sind, und auch das AVCapture-Session-Preset auf Photo in Ihrer Methode setzen (weil ich das Foto in hoher Auflösung, aber die Vorschau in niedriger Auflösung brauche). Das Bild ist jedoch sehr dunkel. Weißt du, warum ich tun kann, damit es genug Licht bekommt? – Pascal