Make an UIImage from a CMSampleBuffer

后端 未结 8 1198
温柔的废话
温柔的废话 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:42

    Swift 5.0

    if let cvImageBuffer = CMSampleBufferGetImageBuffer(sampleBuffer) {
       let ciimage = CIImage(cvImageBuffer: cvImageBuffer)
       let context = CIContext()
    
       if let cgImage = context.createCGImage(ciimage, from: ciimage.extent) {
          let uiImage = UIImage(cgImage: cgImage)
       }
    }
    

提交回复
热议问题