To successfully initialize DeepAR in offscreen rendering mode, the initialization steps need to be done in the correct order.

Off-screen rendering iOS

Steps to take to do off-screen rendering (see iOS API documentation):

  1. Create DeepAR object

  2. call (void)setLicenseKey:(NSString)* key to activate licence key

  3. set the delegate of the DeepAR object

  4. call (void)changeLiveMode:(BOOL)liveMode; with false.

  5. call (void)initializeOffscreenWithWidth:(NSInteger)width height:(NSInteger)height

  6. feed the frames through (void)processFrame:(CVPixelBufferRef)imageBuffer mirror:(BOOL)mirror or (void)enqueueCameraFrame:(CMSampleBufferRef)sampleBuffer mirror:(BOOL)mirror if you are using camera frames via AVFoundation

  7. rendered frames will be delivered through void (void)frameAvailable:(CMSampleBufferRef)sampleBuffer via the DeepARDelegate.

Sample Swift initialisation code:

deepAr = DeepAR() 
deepAr?.setLicenseKey("Your license key here!")
deepAr?.delegate = self
deepAr?.changeLiveMode(false)
deepAr?.initializeOffscreen(withWidth: 1080, height: 1920)

Sample ObjectiveC initialisation code:

self.deepAR = [[DeepAR alloc] init]; 
[self.deepAR setLicenseKey:@"Your license key here!"]; self.deepAR.delegate = self;
[self.deepAR changeLiveMode:NO];
[self.deepAR initializeOffscreenWithWidth:1080 height:1920];
Did this answer your question?