A value of type "AVCapturePhotoSettings" does not have user typesPreviewPhotoPixelFormatTypes

@objc func launchCoreML() {
    let settings = AVCapturePhotoSettings()
    let previewPixelType = settings.availablePreviewPhotoPixelFormatTypes.first
    let previewFormat = [
        kCVPixelBufferPixelFormatTypeKey as String: previewPixelType, 
        kCVPixelBufferWidthKey as String: 160, 
        kCVPixelBufferHeightKey as String: 160
    ] as [String : Any]

    settings.previewPhotoFormat = previewFormat
    cameraOutput.capturePhoto(with: settings, delegate: self)
}

I have a mistake:

A value of type 'AVCapturePhotoSettings' does not have a member of 'AvailablePreviewPhotoPixelFormat'.

I am using Xcode 9 beta.

+4
source share
2 answers

In beta 4, this is renamed to __availablePreviewPhotoPixelFormat. I have not watched beta 5 yet.

+6
source
        var photoSettings: AVCapturePhotoSettings
        if #available(iOS 11.0, *) {
            photoSettings = AVCapturePhotoSettings.init(format: [AVVideoCodecKey: AVVideoCodecType.jpeg])
        } else {
            // Fallback on earlier versions
            photoSettings = AVCapturePhotoSettings()
            if photoSettings.__availablePreviewPhotoPixelFormatTypes.count > 0 {
                photoSettings.previewPhotoFormat = [kCVPixelBufferPixelFormatTypeKey as String : photoSettings.__availablePreviewPhotoPixelFormatTypes.first!]
            }
        }
0
source

Source: https://habr.com/ru/post/1683213/


All Articles