DeepAR iOS  v5.2.0
Instance Methods | Class Methods | Properties | List of all members
DeepAR Class Reference

Main class for interacting with DeepAR engine. More...

#import <DeepAR.h>

Inheritance diagram for DeepAR:

Instance Methods

(void) - setLicenseKey:
 Set the license key for your app. More...
 
(void) - initializeWithWidth:height:window:
 Starts the engine initialization where the DeepAR will initialize in rendering mode. More...
 
(void) - initialize
 Starts the engine initialization where the DeepAR will initialize in vision only mode. More...
 
(void) - initializeOffscreenWithWidth:height:
 Starts the engine initialization for rendering in off-screen mode. More...
 
(UIView *) - createARViewWithFrame:
 Starts the engine initialization where the DeepAR will initialize in rendering mode. More...
 
(BOOL) - isVisionOnly
 Indicates if DeepAR has been initialized in the vision-only mode or not. More...
 
(void) - setRenderingResolutionWithWidth:height:
 Changes the output resolution of the processed frames. More...
 
(void) - shutdown
 Shuts down the DeepAR engine. More...
 
(UIView *) - switchToRenderingToViewWithFrame:
 Returns new UIView in which DeepAR will render with a given frame size. More...
 
(void) - switchToRenderingOffscreenWithWidth:height:
 Starts rendering in the off-screen buffer. More...
 
(void) - changeLiveMode:
 An optimization method and it allows the user to indicate the DeepAR in which mode it should operate. More...
 
(void) - resume
 Resumes the rendering if it was previously paused, otherwise doesn't do anything.
 
(void) - pause
 Pauses the rendering. More...
 
(void) - processFrame:mirror:
 Feed frame to DeepAR for processing. More...
 
(void) - processFrame:mirror:timestamp:
 Feed frame to DeepAR for processing. More...
 
(void) - processFrameAndReturn:outputBuffer:mirror:
 Feed frame to DeepAR for processing. More...
 
(void) - enqueueCameraFrame:mirror:
 Same functionality as processFrame with CMSampleBufferRef as an input type for frame data which is more suitable if using camera frames via AVFoundation. More...
 
(void) - enqueueAudioSample:
 Passes an audio sample to the DeepAR engine. More...
 
(void) - setVideoRecordingOutputName:
 Sets the video recording file output name. More...
 
(void) - setVideoRecordingOutputPath:
 Changes the output path for all video recordings during runtime after it is called. More...
 
(void) - startVideoRecordingWithOutputWidth:outputHeight:
 Starts video recording of the ARView with given resolution. More...
 
(void) - startVideoRecordingWithOutputWidth:outputHeight:subframe:
 Starts video recording of the ARView with given resolution. More...
 
(void) - startVideoRecordingWithOutputWidth:outputHeight:subframe:videoCompressionProperties:
 Starts video recording of the ARView with given resolution. More...
 
(void) - startVideoRecordingWithOutputWidth:outputHeight:subframe:videoCompressionProperties:recordAudio:
 Starts video recording of the ARView with given resolution. More...
 
(void) - switchEffectWithSlot:path:
 Load a DeepAR Studio file as an effect/filter in the scene. More...
 
(void) - switchEffectWithSlot:path:face:
 Load a DeepAR Studio file as an effect/filter in the scene. More...
 
(void) - switchEffectWithSlot:path:face:targetGameObject:
 Load a DeepAR Studio file as an effect/filter in the scene. More...
 
(void) - switchEffectWithSlot:data:
 Load contents of a DeepAR Studio file as an effect/filter in the scene. More...
 
(void) - switchEffectWithSlot:data:face:
 Load contents of a DeepAR Studio file as an effect/filter in the scene. More...
 
(void) - takeScreenshot
 Produces a snapshot of the current screen preview. More...
 
(void) - finishVideoRecording
 Finishes the video recording. More...
 
(void) - pauseVideoRecording
 Pauses video recording if it has been started beforehand.
 
(void) - resumeVideoRecording
 Resumes video recording after it has been paused with pauseVideoRecording.
 
(void) - enableAudioProcessing:
 Enables or disables audio pitch processing for video recording. More...
 
(void) - setAudioProcessingSemitone:
 Sets the pitch change amount. More...
 
(void) - startCaptureWithOutputWidth:outputHeight:subframe:
 Enables frameAvailable method callback. More...
 
(void) - startCaptureWithOutputWidthAndFormat:outputHeight:subframe:outputImageFormat:
 Enables frameAvailable method callback. More...
 
(void) - stopCapture
 Stops outputting frames to frameAvailable .
 
(void) - fireTrigger:
 Fire named trigger of an fbx animation set on the currently loaded effect. More...
 
(void) - touchOccurred:
 Informs DeepAR that a touch with was detected.
 
(void) - showStats:
 Display debugging stats on screen. More...
 
(void) - simulatePhysics:
 Enable or disable global physics simulation. More...
 
(void) - showColliders:
 Display physics colliders preview on screen. More...
 
(void) - setFaceDetectionSensitivity:
 This method allows the user to change face detection sensitivity. More...
 
(void) - changeParameter:component:parameter:floatValue:
 Changes a node or component float parameter. More...
 
(void) - changeParameter:component:parameter:vectorValue:
 Changes a node or component 4D vector parameter. More...
 
(void) - changeParameter:component:parameter:vector3Value:
 Changes a node or component 3D vector parameter. More...
 
(void) - changeParameter:component:parameter:boolValue:
 Changes a node or component boolean parameter. More...
 
(void) - changeParameter:component:parameter:image:
 Changes a node or component image parameter. More...
 
(void) - changeParameter:component:parameter:stringValue:
 Changes a node or component string parameter. More...
 
(void) - moveGameObject:targetGameObjectname:
 Moves the selected game object from its current position in a tree and sets it as a direct child of a target game object. More...
 
(void) - startProfiling
 Starts recording profiling stats by writing them to a CSV-formatted stream.
 
(void) - stopProfiling
 Stops recording profiling stats and sends the recorded CSV to the stat export server.
 
(void) - setFaceTrackingInitParameters:
 Set parameters that will determine how the face tracking is initialized. More...
 
(bool) - hasVar:slot:
 Check if variable with the given name is already created in the specified effect. More...
 
(bool) - hasVar:
 Check if variable with the given name is already created in at least one effect. More...
 
(VarType- getVarType:slot:
 Get the type of the variable with the given name in the specified effect. More...
 
(VarType- getVarType:
 Get the type of the variable with the given name. The variable is searched in all effects. More...
 
(bool) - getBoolVar:slot:
 Get boolean variable with the given name. More...
 
(bool) - getBoolVar:
 
(int) - getIntVar:slot:
 Get integer variable with the given name. More...
 
(int) - getIntVar:
 Get integer variable with the given name. The variable is searched in all effects. More...
 
(double) - getDoubleVar:slot:
 Get double variable with the given name. More...
 
(double) - getDoubleVar:
 Get double variable with the given name. The variable is searched in all effects. More...
 
(NSString *) - getStringVar:slot:
 Get string variable with the given name. More...
 
(NSString *) - getStringVar:
 Get string variable with the given name. The variable is searched in all effects. More...
 
(bool) - setBoolVar:value:slot:
 Set the boolean variable wih the given name. More...
 
(bool) - setBoolVar:value:
 Set the boolean variable with the given name. The variable is set globally, for all effects. More...
 
(bool) - setIntVar:value:slot:
 Set the int variable wih the given name. More...
 
(bool) - setIntVar:value:
 Set the int variable with the given name. The variable is set globally, for all effects. More...
 
(bool) - setDoubleVar:value:slot:
 Set the double variable wih the given name. More...
 
(bool) - setDoubleVar:value:
 Set the double variable with the given name. The variable is set globally, for all effects. More...
 
(bool) - setStringVar:value:slot:
 Set the string variable wih the given name. More...
 
(bool) - setStringVar:value:
 Set the string variable with the given name. The variable is set globally, for all effects. More...
 
(bool) - deleteVar:slot:
 Delete the variable with the given name. More...
 
(bool) - deleteVar:
 Delete the variable with the given name. The variable is searched in all effects. More...
 
(bool) - clearVars:
 Clear all variables or variables from the specified effect. More...
 
(bool) - clearVars
 Clear all variables. More...
 

Class Methods

(NSString *) + sdkVersion
 The DeepAR SDK version number. More...
 

Properties

id< DeepARDelegatedelegate
 The object which implements DeepARDelegate protocol to listen for async events coming from DeepAR.
 
BOOL visionInitialized
 Indicates if computer vision components have been initialized during the initialization process.
 
BOOL renderingInitialized
 Indicates if DeepAR rendering components have been initialized during the initialization process.
 
BOOL faceVisible
 Indicates if at least one face is detected in the current frame.
 
CGSize renderingResolution
 Rendering resolution with which the DeepAR has been initialized.
 
BOOL videoRecordingWarmupEnabled
 If set to true, changes how startVideoRecording and resumeVideoRecording methods work to allow the video recording to be started immediately during runtime. More...
 
NSDictionary * audioCompressionSettings
 The audio compression settings.
 

Detailed Description

Main class for interacting with DeepAR engine.

You need to create an instance of this class to interact with DeepAR. DeepAR can work in vision only or rendering mode. Vision only means only computer vision functionalities (like FaceData of detected faces etc.) are available and no rendering. Rendering mode means that result of DeepAR processing will be rendered live in the UI. Different initialization methods are used for each mode.

Method Documentation

◆ changeLiveMode:

- (void) changeLiveMode: (BOOL)  liveMode

An optimization method and it allows the user to indicate the DeepAR in which mode it should operate.

If called with true value, DeepAR will expect a continuous flow of new frames and it will optimize its inner processes for such workload. An example of this is the typical use case of processing the frames from the camera stream.

If called with false it will optimize for preserving resources and memory by pausing the rendering after each processed frame. A typical use case for this is when the user needs to process just one image. In that case, the user will feed the image to DeepAR by calling processFrame or similar method, and DeepAR would process it and stop rendering until a new frame is received. If we did so when the DeepAR is in live mode, it would process the same frame over and over again without ever stopping the rendering process, thus wasting processing time.

Parameters
BOOLliveMode Enable or disable live mode.

◆ changeParameter:component:parameter:boolValue:

- (void) changeParameter: (NSString *)  gameObject
component: (NSString *)  component
parameter: (NSString *)  parameter
boolValue: (BOOL)  value 

Changes a node or component boolean parameter.

For more details about changeParameter API read our article here.

Parameters
NSString*gameObject The name of the node. If multiple nodes share the same name, only the first one will be affected.
NSString*component The name of the component. If the name of the component is null or an empty string, the node itself will be affected.
NSString*parameter The name of the parameter.
BOOLvalue New parameter value.

◆ changeParameter:component:parameter:floatValue:

- (void) changeParameter: (NSString *)  gameObject
component: (NSString *)  component
parameter: (NSString *)  parameter
floatValue: (float)  value 

Changes a node or component float parameter.

For more details about changeParameter API read our article here.

Parameters
NSString*gameObject The name of the node. If multiple nodes share the same name, only the first one will be affected.
NSString*component The name of the component. If the name of the component is null or an empty string, the node itself will be affected.
NSString*parameter The name of the parameter.
floatvalue New parameter value.

◆ changeParameter:component:parameter:image:

- (void) changeParameter: (NSString *)  gameObject
component: (NSString *)  component
parameter: (NSString *)  parameter
image: (UIImage *)  image 

Changes a node or component image parameter.

For more details about changeParameter API read our article here.

Parameters
NSString*gameObject The name of the node. If multiple nodes share the same name, only the first one will be affected.
NSString*component The name of the component. If the name of the component is null or an empty string, the node itself will be affected.
NSString*parameter The name of the parameter.
UIImage*image New image parameter.

◆ changeParameter:component:parameter:stringValue:

- (void) changeParameter: (NSString *)  gameObject
component: (NSString *)  component
parameter: (NSString *)  parameter
stringValue: (NSString *)  value 

Changes a node or component string parameter.

For more details about changeParameter API read our article here.

Parameters
NSString*gameObject The name of the node. If multiple nodes share the same name, only the first one will be affected.
NSString*component The name of the component. If the name of the component is null or an empty string, the node itself will be affected.
NSString*parameter The name of the parameter.
NSString*value New parameter value.

◆ changeParameter:component:parameter:vector3Value:

- (void) changeParameter: (NSString *)  gameObject
component: (NSString *)  component
parameter: (NSString *)  parameter
vector3Value: (Vector3 value 

Changes a node or component 3D vector parameter.

For more details about changeParameter API read our article here.

Parameters
NSString*gameObject The name of the node. If multiple nodes share the same name, only the first one will be affected.
NSString*component The name of the component. If the name of the component is null or an empty string, the node itself will be affected.
NSString*parameter The name of the parameter.
Vector3value New parameter value.

◆ changeParameter:component:parameter:vectorValue:

- (void) changeParameter: (NSString *)  gameObject
component: (NSString *)  component
parameter: (NSString *)  parameter
vectorValue: (Vector4 value 

Changes a node or component 4D vector parameter.

For more details about changeParameter API read our article here.

Parameters
NSString*gameObject The name of the node. If multiple nodes share the same name, only the first one will be affected.
NSString*component The name of the component. If the name of the component is null or an empty string, the node itself will be affected.
NSString*parameter The name of the parameter.
Vector4value New parameter value.

◆ clearVars

- (bool) clearVars

Clear all variables.

Returns
YES One of more variables are deleted.
NO No variables are deleted

◆ clearVars:

- (bool) clearVars: (NSString *)  slot

Clear all variables or variables from the specified effect.

Parameters
NSString*slot The ID of the effect in which to search the variable.
Returns
YES One of more variables are deleted.
NO No variables are deleted

◆ createARViewWithFrame:

- (UIView *) createARViewWithFrame: (CGRect)  frame

Starts the engine initialization where the DeepAR will initialize in rendering mode.

This means users can use the rendering functionality of DeepAR, in addition to computer vision features, to load effects in the scene, render the frames in the UI, etc. This method returns an UIView on which surface the frames will be rendered. Internally this method uses initializeWithWidth , which means the rendering resolution and the size of the view will be the size of the provided frame.

Parameters
CGRectframe The view dimensions.
Returns
UIView* The surface where the DeepAR frames will be rendered.

◆ deleteVar:

- (bool) deleteVar: (NSString *)  name

Delete the variable with the given name. The variable is searched in all effects.

Parameters
NSString*name The variable name.
Returns
YES The variable is deleted.
NO The variable is not deleted.

◆ deleteVar:slot:

- (bool) deleteVar: (NSString *)  name
slot: (NSString *)  slot 

Delete the variable with the given name.

Parameters
NSString*name The variable name.
NSString*slot The slot of the effect in which to search the variable.
Returns
YES The variable is deleted.
NO The variable is not deleted.

◆ enableAudioProcessing:

- (void) enableAudioProcessing: (BOOL)  enabled

Enables or disables audio pitch processing for video recording.

Parameters
BOOLenabled Enable or disable audio processing.

◆ enqueueAudioSample:

- (void) enqueueAudioSample: (CMSampleBufferRef)  sampleBuffer

Passes an audio sample to the DeepAR engine.

Used in video recording when user wants to record audio too. Audio samples will be processed only if the startVideoRecordingWithOutputWidth method has been called with recordAudio parameter set to true.

Parameters
CMSampleBufferRefsampleBuffer The sample buffer.

◆ enqueueCameraFrame:mirror:

- (void) enqueueCameraFrame: (CMSampleBufferRef)  sampleBuffer
mirror: (BOOL)  mirror 

Same functionality as processFrame with CMSampleBufferRef as an input type for frame data which is more suitable if using camera frames via AVFoundation.

It is advised to use this method instead of processFrame when using camera frames as input because it will use native textures to fetch frames from the iPhone camera more efficiently.

Parameters
CMSampleBufferRefsampleBuffer The sample buffer.
BOOLmirror Indicates whether the image should be flipped vertically before processing (front/back camera).

◆ finishVideoRecording

- (void) finishVideoRecording

Finishes the video recording.

Delegate method didFinishVideoRecording will be called when the recording is done with the temporary path of the recorded video.

◆ fireTrigger:

- (void) fireTrigger: (NSString *)  trigger

Fire named trigger of an fbx animation set on the currently loaded effect.

To learn more about fbx and image sequence animations on DeepAR please read our article here.

Parameters
NSString*trigger The trigger name.

◆ getBoolVar:

- (bool) getBoolVar: (NSString *)  name

@brieg Get boolean variable with the given name. The variable is searched in all effects.

Parameters
NSString*name The variable name.
Exceptions
NSExceptionVariable with the specified name does not exist or is not a boolean.
Returns
Value of the variable with the specified name.

◆ getBoolVar:slot:

- (bool) getBoolVar: (NSString *)  name
slot: (NSString *)  slot 

Get boolean variable with the given name.

Parameters
NSString*name The variable name.
NSString*slot The slot of the effect in which to search the variable.
Exceptions
NSExceptionVariable with the specified name does not exist or is not a boolean.
Returns
Value of the variable with the specified name.

◆ getDoubleVar:

- (double) getDoubleVar: (NSString *)  name

Get double variable with the given name. The variable is searched in all effects.

Parameters
NSString*name The variable name.
Exceptions
NSExceptionVariable with the specified name does not exist or is not a double.
Returns
Value of the variable with the specified name.

◆ getDoubleVar:slot:

- (double) getDoubleVar: (NSString *)  name
slot: (NSString *)  slot 

Get double variable with the given name.

Parameters
NSString*name The variable name.
NSString*slot The slot of the effect in which to search the variable.
Exceptions
NSExceptionVariable with the specified name does not exist or is not a double.
Returns
Value of the variable with the specified name.

◆ getIntVar:

- (int) getIntVar: (NSString *)  name

Get integer variable with the given name. The variable is searched in all effects.

Parameters
NSString*name The variable name.
Exceptions
NSExceptionVariable with the specified name does not exist or is not an int.
Returns
Value of the variable with the specified name.

◆ getIntVar:slot:

- (int) getIntVar: (NSString *)  name
slot: (NSString *)  slot 

Get integer variable with the given name.

Parameters
NSString*name The variable name.
NSString*slot The slot of the effect in which to search the variable.
Exceptions
NSExceptionVariable with the specified name does not exist or is not an int.
Returns
Value of the variable with the specified name.

◆ getStringVar:

- (NSString *) getStringVar: (NSString *)  name

Get string variable with the given name. The variable is searched in all effects.

Parameters
NSString*name The variable name.
Exceptions
NSExceptionVariable with the specified name does not exist or is not a string.
Returns
Value of the variable with the specified name.

◆ getStringVar:slot:

- (NSString *) getStringVar: (NSString *)  name
slot: (NSString *)  slot 

Get string variable with the given name.

Parameters
NSString*name The variable name.
NSString*slot The slot of the effect in which to search the variable.
Exceptions
NSExceptionVariable with the specified name does not exist or is not a string.
Returns
Value of the variable with the specified name.

◆ getVarType:

- (VarType) getVarType: (NSString *)  name

Get the type of the variable with the given name. The variable is searched in all effects.

Parameters
NSString*name The variable name.
Exceptions
NSExceptionVariable with the specified name does not exist.
Returns
The variable type. Supported types are: boolean, int, double and string.

◆ getVarType:slot:

- (VarType) getVarType: (NSString *)  name
slot: (NSString *)  slot 

Get the type of the variable with the given name in the specified effect.

Parameters
NSString*name The variable name.
NSString*slot The slot of the effect in which to search the variable.
Exceptions
NSExceptionVariable with the specified name does not exist.
Returns
The variable type. Supported types are: boolean, int, double and string.

◆ hasVar:

- (bool) hasVar: (NSString *)  name

Check if variable with the given name is already created in at least one effect.

Parameters
NSString*name The variable name.
Returns
true The variable is already created.
false The variable is not created.

◆ hasVar:slot:

- (bool) hasVar: (NSString *)  name
slot: (NSString *)  slot 

Check if variable with the given name is already created in the specified effect.

Parameters
NSString*name The variable name.
NSString*slot The slot of the effect in which to search the variable.
Returns
true The variable is already created.
false The variable is not created.

◆ initialize

- (void) initialize

Starts the engine initialization where the DeepAR will initialize in vision only mode.

Vision only means that it will process frames in terms of detecting faces and their properties that are available in FaceData object. No rendering will be available in this mode.

◆ initializeOffscreenWithWidth:height:

- (void) initializeOffscreenWithWidth: (NSInteger)  width
height: (NSInteger)  height 

Starts the engine initialization for rendering in off-screen mode.

Parameters
NSIntegerwidth The rendering width.
NSIntegerheight The rendering height.

◆ initializeWithWidth:height:window:

- (void) initializeWithWidth: (NSInteger)  width
height: (NSInteger)  height
window: (CAEAGLLayer *)  window 

Starts the engine initialization where the DeepAR will initialize in rendering mode.

This means users can use the rendering functionality of DeepAR, in addition to computer vision features, to load effects in the scene, render the frames in the UI, etc.

Parameters
NSIntegerwidth The rendering width.
NSIntegerheight The rendering height.
CAEAGLLayer*window Destination layer where the DeepAR engine will render the frames.

◆ isVisionOnly

- (BOOL) isVisionOnly

Indicates if DeepAR has been initialized in the vision-only mode or not.

Returns
BOOL Indication if the vision-only mode is active.

◆ moveGameObject:targetGameObjectname:

- (void) moveGameObject: (NSString *)  selectedGameObjectName
targetGameObjectname: (NSString *)  targetGameObjectName 

Moves the selected game object from its current position in a tree and sets it as a direct child of a target game object.

This is equivalent to moving around a node in the node hierarchy in the DeepAR Studio.

Parameters
NSString*selectedGameObjectName Node to move.
NSString*targetGameObjectName New node parent.

◆ pause

- (void) pause

Pauses the rendering.

This method will not release any resources and should be used only for temporary pause (e.g. user goes to the next screen). Use the shutdown method to stop the engine and to release the resources.

◆ processFrame:mirror:

- (void) processFrame: (CVPixelBufferRef)  imageBuffer
mirror: (BOOL)  mirror 

Feed frame to DeepAR for processing.

The result can be received in the frameAvailable delegate method.

Parameters
CVPixelBufferRefimageBuffer The input image data that needs processing.
BOOLmirror Indicates whether the image should be flipped vertically before processing (front/back camera).

◆ processFrame:mirror:timestamp:

- (void) processFrame: (CVPixelBufferRef)  imageBuffer
mirror: (BOOL)  mirror
timestamp: (CMTimeValue)  timestamp 

Feed frame to DeepAR for processing.

The result can be received in the frameAvailable delegate method.

Parameters
CVPixelBufferRefimageBuffer The input image data that needs processing.
BOOLmirror Indicates whether the image should be flipped vertically before processing (front/back camera).
CMTimeValuetimestamp The frame timestamp.

◆ processFrameAndReturn:outputBuffer:mirror:

- (void) processFrameAndReturn: (CVPixelBufferRef)  imageBuffer
outputBuffer: (CVPixelBufferRef)  outputBuffer
mirror: (BOOL)  mirror 

Feed frame to DeepAR for processing.

Outputs the result in the outputBuffer parameter. Requires frame capturing to be started (user must call startCaptureWithOutputWidth or startCaptureWithOutputWidthAndFormat beforehand).

Parameters
CVPixelBufferRefimageBuffer The input image data that needs processing.
CVPixelBufferRefoutputBuffer The output image buffer.
BOOLmirror Indicates whether the image should be flipped vertically before processing (front/back camera).

◆ sdkVersion

+ (NSString *) sdkVersion

The DeepAR SDK version number.

Returns
DeepAR SDK version number string.

◆ setAudioProcessingSemitone:

- (void) setAudioProcessingSemitone: (float)  sts

Sets the pitch change amount.

Negative values will make the recorded audio lower in pitch and positive values will make it higher in pitch. Must call enableAudioProcessing to enable the pitch processing beforehand.

Parameters
floatsts The pitch change amount.

◆ setBoolVar:value:

- (bool) setBoolVar: (NSString *)  name
value: (bool)  value 

Set the boolean variable with the given name. The variable is set globally, for all effects.

Parameters
NSString*name The variable name.
boolvalue Value to be set.
Returns
YES The variable is created.
NO The variable with the given name already exists and the new value is set.

◆ setBoolVar:value:slot:

- (bool) setBoolVar: (NSString *)  name
value: (bool)  value
slot: (NSString *)  slot 

Set the boolean variable wih the given name.

Parameters
NSString*name The variable name.
NSString*slot The slot of the effect in which to search the variable.
boolvalue Value to be set.
Returns
YES The variable is created.
NO The variable with the given name already exists and the new value is set.

◆ setDoubleVar:value:

- (bool) setDoubleVar: (NSString *)  name
value: (double)  value 

Set the double variable with the given name. The variable is set globally, for all effects.

Parameters
NSString*name The variable name.
doublevalue Value to be set.
Returns
YES The variable is created.
NO The variable with the given name already exists and the new value is set.

◆ setDoubleVar:value:slot:

- (bool) setDoubleVar: (NSString *)  name
value: (double)  value
slot: (NSString *)  slot 

Set the double variable wih the given name.

Parameters
NSString*name The variable name.
NSString*slot The slot of the effect in which to search the variable.
doublevalue Value to be set.
Returns
YES The variable is created.
NO The variable with the given name already exists and the new value is set.

◆ setFaceDetectionSensitivity:

- (void) setFaceDetectionSensitivity: (NSInteger)  sensitivity

This method allows the user to change face detection sensitivity.

Parameters
NSIntegersensitivity The sensitivity parameter can range from 0 to 3, where 0 is the fastest but might not recognize smaller (further away) faces, and 3 is the slowest but will find smaller faces. By default, this parameter is set to 1.

◆ setFaceTrackingInitParameters:

- (void) setFaceTrackingInitParameters: (FaceTrackingInitParameters params

Set parameters that will determine how the face tracking is initialized.

Parameters
paramsFaceTrackingInitParameters

◆ setIntVar:value:

- (bool) setIntVar: (NSString *)  name
value: (int)  value 

Set the int variable with the given name. The variable is set globally, for all effects.

Parameters
NSString*name The variable name.
intvalue Value to be set.
Returns
YES The variable is created.
NO The variable with the given name already exists and the new value is set.

◆ setIntVar:value:slot:

- (bool) setIntVar: (NSString *)  name
value: (int)  value
slot: (NSString *)  slot 

Set the int variable wih the given name.

Parameters
NSString*name The variable name.
NSString*slot The slot of the effect in which to search the variable.
intvalue Value to be set.
Returns
YES The variable is created.
NO The variable with the given name already exists and the new value is set.

◆ setLicenseKey:

- (void) setLicenseKey: (NSString *)  key

Set the license key for your app.

The license key is generated on the DeepAR Developer portal. Here are steps on how to generate a license key:

  • Log in/Sign up to developer.deepar.ai
  • Create a new project and in that project create an iOS app
  • In the create app dialog enter your app name and bundle id that your app is using. Bundle id must match the one you are using in your app, otherwise, the license check will fail. Read more about iOS bundle id here.
  • Copy the newly generated license key as a parameter in this method

    You must call this method before you call the initialize.

    Parameters
    NSString*key The license key.

◆ setRenderingResolutionWithWidth:height:

- (void) setRenderingResolutionWithWidth: (NSInteger)  width
height: (NSInteger)  height 

Changes the output resolution of the processed frames.

Can be called any time.

Parameters
NSIntegerwidth The output resolution width.
NSIntegerheight The output resolution height.

◆ setStringVar:value:

- (bool) setStringVar: (NSString *)  name
value: (NSString *)  value 

Set the string variable with the given name. The variable is set globally, for all effects.

Parameters
NSString*name The variable name.
NSString*value Value to be set.
Returns
YES The variable is created.
NO The variable with the given name already exists and the new value is set.

◆ setStringVar:value:slot:

- (bool) setStringVar: (NSString *)  name
value: (NSString *)  value
slot: (NSString *)  slot 

Set the string variable wih the given name.

Parameters
NSString*name The variable name.
NSString*slot The slot of the effect in which to search the variable.
NSString*value Value to be set.
Returns
YES The variable is created.
NO The variable with the given name already exists and the new value is set.

◆ setVideoRecordingOutputName:

- (void) setVideoRecordingOutputName: (NSString *)  outputName

Sets the video recording file output name.

The argument is file name only, no extension. The file extension .mov will be appended automatically. Defalut value is "export".

Parameters
NSString*outputName Output file name without the extension.

◆ setVideoRecordingOutputPath:

- (void) setVideoRecordingOutputPath: (NSString *)  outputPath

Changes the output path for all video recordings during runtime after it is called.

The argument is path only, no name. The defalut value is the AppData Documents folder. Example:

[self.deepAR setVideoRecordingOutputPath:[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject]];
Parameters
NSString*outputPath Output video file path.

◆ showColliders:

- (void) showColliders: (BOOL)  enabled

Display physics colliders preview on screen.

Parameters
BOOLenabled Enable physics colliders preview.

◆ showStats:

- (void) showStats: (BOOL)  enabled

Display debugging stats on screen.

Parameters
BOOLenabled Enable debugging stats.

◆ shutdown

- (void) shutdown

Shuts down the DeepAR engine.

Reinitialization of a new DeepAR instance which has not been properly shut down can cause crashes and memory leaks. Usually, it is done in view controller dealloc method.

◆ simulatePhysics:

- (void) simulatePhysics: (BOOL)  enabled

Enable or disable global physics simulation.

Parameters
BOOLenabled Enable global physics simulation.

◆ startCaptureWithOutputWidth:outputHeight:subframe:

- (void) startCaptureWithOutputWidth: (NSInteger)  outputWidth
outputHeight: (NSInteger)  outputHeight
subframe: (CGRect)  subframe 

Enables frameAvailable method callback.

By default DeepARDelegate will not call frameAvailable method on each new processed frame to save on processing time and resources. If we want the processed frames to be available in frameAvailable method of DeepARDelegate we need to call this method first on DeepAR.

Parameters
NSIntegeroutputWidth The width of the processed frames.
NSIntegeroutputHeight The height of the processed frames.
CGRectsubframe The subrectangle of ARView which will be outputted. This means that the output frame in frameAvailable does not need to be the same size and/or position as the one rendered to the ARView.

◆ startCaptureWithOutputWidthAndFormat:outputHeight:subframe:outputImageFormat:

- (void) startCaptureWithOutputWidthAndFormat: (NSInteger)  outputWidth
outputHeight: (NSInteger)  outputHeight
subframe: (CGRect)  subframe
outputImageFormat: (OutputFormat outputFormat 

Enables frameAvailable method callback.

By default DeepARDelegate will not call frameAvailable method on each new processed frame to save on processing time and resources. If we want the processed frames to be available in frameAvailable method of DeepARDelegate we need to call this method first on DeepAR.

Parameters
NSIntegeroutputWidth The width of the processed frames.
NSIntegeroutputHeight The height of the processed frames.
CGRectsubframe The subrectangle of ARView which will be outputted. This means that the output frame in frameAvailable does not need to be the same size and/or position as the one rendered to the ARView.
OutputFormatoutputFormat Parameter for user to control the pixel output format of frameAvailable method

◆ startVideoRecordingWithOutputWidth:outputHeight:

- (void) startVideoRecordingWithOutputWidth: (int)  outputWidth
outputHeight: (int)  outputHeight 

Starts video recording of the ARView with given resolution.

Parameters
intoutputWidth The output width.
intoutputHeight The output height.

◆ startVideoRecordingWithOutputWidth:outputHeight:subframe:

- (void) startVideoRecordingWithOutputWidth: (int)  outputWidth
outputHeight: (int)  outputHeight
subframe: (CGRect)  subframe 

Starts video recording of the ARView with given resolution.

Parameters
intoutputWidth The output width.
intoutputHeight The output height.
CGRectsubframe The subframe parameter defines the sub rectangle of the ARView that you want to record in normalized coordinates (0.0 - 1.0).

◆ startVideoRecordingWithOutputWidth:outputHeight:subframe:videoCompressionProperties:

- (void) startVideoRecordingWithOutputWidth: (int)  outputWidth
outputHeight: (int)  outputHeight
subframe: (CGRect)  subframe
videoCompressionProperties: (NSDictionary *)  videoCompressionProperties 

Starts video recording of the ARView with given resolution.

Parameters
intoutputWidth The output width.
intoutputHeight The output height.
CGRectsubframe The subframe parameter defines the sub rectangle of the ARView that you want to record in normalized coordinates (0.0 - 1.0).
NSDictionary*videoCompressionProperties The videoCompressionProperties is an NSDictionary used as the value for the key AVVideoCompressionPropertiesKey. Read more about video compression options in the official docs here.

◆ startVideoRecordingWithOutputWidth:outputHeight:subframe:videoCompressionProperties:recordAudio:

- (void) startVideoRecordingWithOutputWidth: (int)  outputWidth
outputHeight: (int)  outputHeight
subframe: (CGRect)  subframe
videoCompressionProperties: (NSDictionary *)  videoCompressionProperties
recordAudio: (BOOL)  recordAudio 

Starts video recording of the ARView with given resolution.

Parameters
intoutputWidth The output width.
intoutputHeight The output height.
CGRectsubframe The subframe parameter defines the sub rectangle of the ARView that you want to record in normalized coordinates (0.0 - 1.0).
NSDictionary*videoCompressionProperties The videoCompressionProperties is an NSDictionary used as the value for the key AVVideoCompressionPropertiesKey. Read more about video compression options in the official docs here.
BOOLrecordAudio If recordAudio parameter is set to true the recording will wait until you call enqueueAudioSample . When DeepAR is ready to receive audio samples it will publish NSNotification with key deepar_start_audio. You can subscribe to this notification and start feeding audio samples once you receive it. If you use provided CameraController this is handled for you by default.

◆ switchEffectWithSlot:data:

- (void) switchEffectWithSlot: (NSString *)  slot
data: (NSData *)  data 

Load contents of a DeepAR Studio file as an effect/filter in the scene.

Parameters
NSString*slot The slot specifies a namespace for the effect in the scene. In each slot, there can be only one effect. If you load another effect in the same slot the previous one will be removed and replaced with a new effect.
NSData*data The contents of the file.

◆ switchEffectWithSlot:data:face:

- (void) switchEffectWithSlot: (NSString *)  slot
data: (NSData *)  data
face: (NSInteger)  face 

Load contents of a DeepAR Studio file as an effect/filter in the scene.

Parameters
NSString*slot The slot specifies a namespace for the effect in the scene. In each slot, there can be only one effect. If you load another effect in the same slot the previous one will be removed and replaced with a new effect.
NSData*data The contents of the file.
NSIntegerface The face parameter indicates on which face to apply the effect. DeepAR offers tracking up to 4 faces, so valid values for this parameter are 0, 1, 2, and 3. For example, if you call this method with face value 2, the effect will be only applied to the third detected face in the scene. If you want to set an effect on a different face make sure to also use a different value for the slot parameter to avoid removing the previously added effect.

◆ switchEffectWithSlot:path:

- (void) switchEffectWithSlot: (NSString *)  slot
path: (NSString *)  path 

Load a DeepAR Studio file as an effect/filter in the scene.

Parameters
NSString*slot The slot specifies a namespace for the effect in the scene. In each slot, there can be only one effect. If you load another effect in the same slot the previous one will be removed and replaced with a new effect. Example of loading 2 effects in the same scene:
[self.deepAR switchEffectWithSlot:@"mask" path:"flowers"];
[self.deepAR switchEffectWithSlot:@"filter" path:"tv80"];
NSString*path The path is a string path to a file located in the app bundle or anywhere in the filesystem where the app has access to. For example, one can download the filters from online locations and save them in the Documents directory. Value nil for the path param will remove the effect from the scene.

◆ switchEffectWithSlot:path:face:

- (void) switchEffectWithSlot: (NSString *)  slot
path: (NSString *)  path
face: (NSInteger)  face 

Load a DeepAR Studio file as an effect/filter in the scene.

Parameters
NSString*slot The slot specifies a namespace for the effect in the scene. In each slot, there can be only one effect. If you load another effect in the same slot the previous one will be removed and replaced with a new effect.
NSString*path The path is a string path to a file located in the app bundle or anywhere in the filesystem where the app has access to. For example, one can download the filters from online locations and save them in the Documents directory. Value nil for the path param will remove the effect from the scene.
NSIntegerface The face parameter indicates on which face to apply the effect. DeepAR offers tracking up to 4 faces, so valid values for this parameter are 0, 1, 2, and 3. For example, if you call this method with face value 2, the effect will be only applied to the third detected face in the scene. If you want to set an effect on a different face make sure to also use a different value for the slot parameter to avoid removing the previously added effect. Example:
// apply flowers effect to the first face
[self.deepAR switchEffectWithSlot:@"mask_f0" path:"flowers" face:0];
// apply beard effect to the second face
[self.deepAR switchEffectWithSlot:@"mask_f1" path:"beard" face:1];
// replace the effect on the first face with the lion
[self.deepAR switchEffectWithSlot:@"mask_f0" path:"lion" face:0];
// remove the beard effect from the second face
[self.deepAR switchEffectWithSlot:@"mask_f1" path:nil face:1];

◆ switchEffectWithSlot:path:face:targetGameObject:

- (void) switchEffectWithSlot: (NSString *)  slot
path: (NSString *)  path
face: (NSInteger)  face
targetGameObject: (NSString *)  targetGameObject 

Load a DeepAR Studio file as an effect/filter in the scene.

Parameters
NSString*slot The slot specifies a namespace for the effect in the scene. In each slot, there can be only one effect. If you load another effect in the same slot the previous one will be removed and replaced with a new effect.
NSString*path The path is a string path to a file located in the app bundle or anywhere in the filesystem where the app has access to. For example, one can download the filters from online locations and save them in the Documents directory. Value nil for the path param will remove the effect from the scene.
NSIntegerface The face parameter indicates on which face to apply the effect. DeepAR offers tracking up to 4 faces, so valid values for this parameter are 0, 1, 2, and 3. For example, if you call this method with face value 2, the effect will be only applied to the third detected face in the scene. If you want to set an effect on a different face make sure to also use a different value for the slot parameter to avoid removing the previously added effect.
NSString*targetGameObject The targetGameObject parameter indicates a node in the currently loaded scene/effect into which the new effect will be loaded. By default, effects are loaded in the root node object.

◆ switchToRenderingOffscreenWithWidth:height:

- (void) switchToRenderingOffscreenWithWidth: (NSInteger)  width
height: (NSInteger)  height 

Starts rendering in the off-screen buffer.

Does nothing if already rendering in off-screen mode. Internally calls startCaptureWithOutputWidth method meaning the frames will be available in the frameAvailable method as soon as they are ready.

Parameters
NSIntegerwidth The buffer width.
NSIntegerheight The buffer height.

◆ switchToRenderingToViewWithFrame:

- (UIView *) switchToRenderingToViewWithFrame: (CGRect)  frame

Returns new UIView in which DeepAR will render with a given frame size.

User can position the returned UIView in the hierarchy to display the results in the app UI.

Parameters
CGRectframe The frame size.
Returns
UIView* The new UIView in which DeepAR will render with a given frame size.

◆ takeScreenshot

- (void) takeScreenshot

Produces a snapshot of the current screen preview.

Resolution is equal to the dimension with which the DeepAR has been initialized. The DeepARDelegate method didTakeScreenshot will be called upon successful screenshot capture is finished with a path where the image has been temporarily stored.

Property Documentation

◆ videoRecordingWarmupEnabled

- (BOOL) videoRecordingWarmupEnabled
readwritenonatomicassign

If set to true, changes how startVideoRecording and resumeVideoRecording methods work to allow the video recording to be started immediately during runtime.

To use video recodring warmup follow these steps

  • Set videoRecordingWarmupEnabled = true after calling deepar.initialize
    - (void)viewDidLoad {
    self.deepAR = [[DeepAR alloc] init];
    self.deepAR.videoRecordingWarmupEnabled = YES;
    ...
    }
    Main class for interacting with DeepAR engine.
    Definition: DeepAR.h:373
  • After initialization is finished (didInitialize callback) call startVideoRecording with desired parameters. Only needs to be called once.
    - (void)didInitialize {
    [self.deepAR startVideoRecordingWithOutputWidth:outputWidth outputHeight:outputHeight subframe:screenRect];
    }
  • Wait for didFinishPreparingForVideoRecording callback (now working as expected) to enable recording
  • Call resumeVideoRecording to start prepared recording
    - (IBAction)startVideoRecordingPressed:(id)sender {
    // Start prepared recording
    [self.deepAR resumeVideoRecording];
    }
    void resumeVideoRecording()
    Resumes video recording after it has been paused with pauseVideoRecording.
  • Call finishVideoRecording to finish recording. This will automatically start preparing for the next recording session with the parameters set in startVideoRecording .
    - (IBAction)stopVideoRecordingPressed:(id)sender {
    //Finish recording. This will automatically start preparing for the next recording session with the same parameters
    [self.deepAR finishVideoRecording];
    }
    void finishVideoRecording()
    Finishes the video recording.
  • Wait for didFinishPreparingForVideoRecording callback and repeat the resumeVideoRecording step as needed

The documentation for this class was generated from the following file: