DeepARSDK / quickstart-ios-swift

DeepAR SDK for iOS example project
https://developer.deepar.ai
MIT License
23 stars 9 forks source link

Invalid image format! DeepAR.processFrame method #13

Closed olegkhomenko closed 3 years ago

olegkhomenko commented 3 years ago

Hi! Thank you for the amazing product 🙌 . I have my own implementation of CameraManager and CameraController. I tried to use processFrameAndReturn method of DeepAR class instance. However, the following error always occurs:

2020-12-22 20:45:24.167526+0300 APPNAME [18884:12654410] Invalid image format!
extension CameraController: CameraManagerDelegate {
  func cameraManager(_ cameraManager: CameraManager, didOutputSamplePixelBuffer samplePixelBuffer: CVPixelBuffer?, withPresentationTime presentationTime: CMTime) {
      guard let samplePixelBuffer = samplePixelBuffer else { return }
      guard let deepAR = deepAR else { return }
      if !deepAR.renderingInitialized {
          print("Rendering is not initialized")
          return
      }
      // ERROR:
      self.deepAR.processFrame(samplePixelBuffer, mirror: false)
  }
}

samplePixelBuffer has the following PixelFormatType (which is a kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange) :

var type: OSType = CVPixelBufferGetPixelFormatType(samplePixelBuffer)
print(type)
>>> 875704438

and resolution

var width = 720
var height = 1280

The same error is also for:

self.deepAR.processFrameAndReturn(samplePixelBuffer, outputBuffer: deepARPixelbuffer, mirror: false)
olegkhomenko commented 3 years ago

Solution: Use kCVPixelFormatType_32BGRA for CVPixelBufferRef

Question: Is there any way how to use CVPixelBuffer with alternative PixelFormatType ?

olegkhomenko commented 3 years ago

It looks like there is no answer. I'm closing this one.