Make an UIImage from a CMSampleBuffer

后端 未结 8 1108
温柔的废话
温柔的废话 2020-12-13 15:01

This is not the same as the countless questions about converting a CMSampleBuffer to a UIImage. I\'m simply wondering why I can\'t convert it like

8条回答
  •  醉梦人生
    2020-12-13 15:58

    For JPEG images:

    Swift 4:

    let buff: CMSampleBuffer ...            // Have you have CMSampleBuffer 
    if let imageData = AVCapturePhotoOutput.jpegPhotoDataRepresentation(forJPEGSampleBuffer: buff, previewPhotoSampleBuffer: nil) {
        let image = UIImage(data: imageData) //  Here you have UIImage
    }
    

提交回复
热议问题