Skip to main content

Offscreen Rendering Guide

A cheat-sheet for offscreen rendering on iOS

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):

  • Create DeepAR object

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

  • set the delegate of the DeepAR object

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

  • call (void)initializeOffscreenWithWidth:(NSInteger)width height:(NSInteger)height

  • 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

  • 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?.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];