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

ARView is a class that extends UIView with all DeepAR features which can be positioned in the UI hierarchy. More...

#import <ARView.h>

Inheritance diagram for ARView:

Instance Methods

(void) - setLicenseKey:
 Set the license key for your app. More...
 
(void) - initialize
 Starts the DeepAR engine initialization. More...
 
(void) - resume
 Resumes the rendering if it was previously paused, otherwise doesn't do anything. More...
 
(void) - pause
 Pauses the rendering. 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) - takeScreenshot
 Produces a snapshot of the current screen preview. More...
 
(void) - startVideoRecordingWithOutputWidth:outputHeight:
 Starts video recording of the ARView with given outputWidth and outputHeight resolution. More...
 
(void) - startVideoRecordingWithOutputWidth:outputHeight:subframe:
 Starts video recording of the ARView with given outputWidth and outputHeight resolution. More...
 
(void) - startVideoRecordingWithOutputWidth:outputHeight:subframe:videoCompressionProperties:
 Starts video recording of the ARView with given outputWidth and outputHeight resolution. More...
 
(void) - startVideoRecordingWithOutputWidth:outputHeight:subframe:videoCompressionProperties:recordAudio:
 Starts video recording of the ARView with given outputWidth and outputHeight resolution. More...
 
(void) - finishVideoRecording
 Finishes the video recording. More...
 
(void) - pauseVideoRecording
 Pauses video recording. More...
 
(void) - resumeVideoRecording
 Resumes video recording after it has been paused with pauseVideoRecording. More...
 
(void) - enableAudioProcessing:
 Enables or disables audio pitch processing for video recording. More...
 
(void) - setAudioProcessingSemitone:
 Sets the pitch change amount. More...
 
(void) - shutdown
 Shuts down the DeepAR engine. More...
 
(void) - startFrameOutputWithOutputWidth:outputHeight:subframe:
 Enables frameAvailable method callback. More...
 
(void) - stopFrameOutput
 Stops outputting frames to frameAvailable . More...
 
(void) - enqueueCameraFrame:mirror:
 Enqueues an image frame for processing to DeepAR. More...
 
(void) - enqueueAudioSample:
 Passes an audio sample to the DeepAR engine. 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) - fireTrigger:
 Fire named trigger of an fbx animation set on the currently loaded effect. More...
 
(void) - setFaceDetectionSensitivity:
 This method allows the user to change face detection sensitivity. More...
 
(void) - showStats:
 Display debugging stats on screen. More...
 
(void) - setParameterWithKey:value:
 Sets the internal SDK parameter. More...
 

Properties

DeepARdeepAR
 Instance of the DeepAR object.
 
BOOL initialized
 Indicates if ARView and the underlying DeepAR engine are successfully initialized. More...
 
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.
 
id< DeepARDelegatedelegate
 Set to the object which implements DeepARDelegate protocol to listen for async events coming from DeepAR.
 

Detailed Description

ARView is a class that extends UIView with all DeepAR features which can be positioned in the UI hierarchy.

DeepAR will render the result of the processed camera (or static image) frames within this view. ARView will be deprecated in the future releases because DeepAR has API to create custom view where the results are rendered. We keep it for backward compatibility.

Method Documentation

◆ 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.
Deprecated:
This API is deprecated. Please use DeepAR method changeParameter instead.

◆ 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.
Deprecated:
This API is deprecated. Please use DeepAR method changeParameter instead.

◆ 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.
Deprecated:
This API is deprecated. Please use DeepAR method changeParameter instead.

◆ 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.
Deprecated:
This API is deprecated. Please use DeepAR method changeParameter instead.

◆ 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.
Deprecated:
This API is deprecated. Please use DeepAR method changeParameter instead.

◆ enableAudioProcessing:

- (void) enableAudioProcessing: (BOOL)  enabled

Enables or disables audio pitch processing for video recording.

Parameters
BOOLenabled Enable audio processing.
Deprecated:
This API is deprecated. Please use DeepAR method enableAudioProcessing instead.

◆ 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 startVideoRecording method has been called with recordAudio parameter set to true.

Parameters
CMSampleBufferRefsampleBuffer The audio sample.
Deprecated:
This API is deprecated. Please use DeepAR method enqueueAudioSample instead.

◆ enqueueCameraFrame:mirror:

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

Enqueues an image frame for processing to DeepAR.

The processed frame will be rendered in ARView. Additionally if DeepARDelegate is set the same frame will be available in frameAvailable delegate method when ready (and startFrameOutputWithOutputWidth is called).

Parameters
CMSampleBufferRefsampleBuffer The camera frame.
BOOLmirror If mirror is set to true the image frame will be flipped vertically before processing (e.g. depending if you use back or front camera).
Deprecated:
This API is deprecated. Please use DeepAR method enqueueCameraFrame instead.

◆ 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.

Deprecated:
This API is deprecated. Please use DeepAR method finishVideoRecording instead.

◆ 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.
Deprecated:
This API is deprecated. Please use DeepAR method fireTrigger instead.

◆ initialize

- (void) initialize

Starts the DeepAR engine initialization.

ARView is initialized as one would any other iOS view. After instantiating the view, a user needs to call initialize. Other DeepAR methods can be safely called only when the initialization has properly finished. Successful initialization is notified via DeepARDelegate didInitialize method. Example of a proper ARView initialization:

- (void)viewDidLoad {
[super viewDidLoad];
// Instantiate ARView and add it to view hierarchy.
self.arview = [[ARView alloc] initWithFrame:[UIScreen mainScreen].bounds];
[self.view insertSubview:self.arview atIndex:0];
// Set delegate handler
self.arview.delegate = self;
[self.arview initialize];
}
...
- (void)didInitialize {
// Other ARView methods are safe to be invoked after this method has been called
}
ARView is a class that extends UIView with all DeepAR features which can be positioned in the UI hier...
Definition: ARView.h:16
void initialize()
Starts the DeepAR engine initialization.
Deprecated:
This API is deprecated. Please use DeepAR method initializeWithWidth instead.

◆ 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.

Deprecated:
This API is deprecated. Please use DeepAR method pause instead.

◆ pauseVideoRecording

- (void) pauseVideoRecording

Pauses video recording.

Deprecated:
This API is deprecated. Please use DeepAR method pauseVideoRecording instead.

◆ resume

- (void) resume

Resumes the rendering if it was previously paused, otherwise doesn't do anything.

Deprecated:
This API is deprecated. Please use DeepAR method resume instead.

◆ resumeVideoRecording

- (void) resumeVideoRecording

Resumes video recording after it has been paused with pauseVideoRecording.

Deprecated:
This API is deprecated. Please use DeepAR method resumeVideoRecording instead.

◆ 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.
Deprecated:
This API is deprecated. Please use DeepAR method setAudioProcessingSemitone instead.

◆ setFaceDetectionSensitivity:

- (void) setFaceDetectionSensitivity: (int)  sensitivity

This method allows the user to change face detection sensitivity.

Parameters
intsensitivity 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.
Deprecated:
This API is deprecated. Please use DeepAR method setFaceDetectionSensitivity instead.

◆ setLicenseKey:

- (void) setLicenseKey: (NSString *)  key

Set the license key for your app.

The license key is generated on DeepAR Developer portal. Here are steps how to generate 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.
    Deprecated:
    This API is deprecated. Please use DeepAR method setLicenseKey instead.

◆ setParameterWithKey:value:

- (void) setParameterWithKey: (NSString *)  key
value: (NSString *)  value 

Sets the internal SDK parameter.

Parameters
NSString*key The parameter key.
NSString*value The parameter value.
Deprecated:
This API is deprecated. Please use DeepAR method setParameterWithKey instead.

◆ showStats:

- (void) showStats: (bool)  enabled

Display debugging stats on screen.

Parameters
boolenabled Enable debugging stats.
Deprecated:
This API is deprecated. Please use DeepAR method showStats instead.

◆ shutdown

- (void) shutdown

Shuts down the DeepAR engine.

This method should be called when the ARView parent view controller has been disposed of. 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 controllers dealloc method, example:

-(void)dealloc {
[self.deepAR shutdown];
[self.arview removeFromSuperview];
}
void shutdown()
Shuts down the DeepAR engine.
Deprecated:
This API is deprecated. Please use DeepAR method shutdown instead.

◆ startFrameOutputWithOutputWidth:outputHeight:subframe:

- (void) startFrameOutputWithOutputWidth: (int)  outputWidth
outputHeight: (int)  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 ARView.

Parameters
intoutputWidth The width of the processed frames.
intoutputHeight 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 .
Deprecated:
This API is deprecated. Please use DeepAR method startCaptureWithOutputWidth instead.

◆ startVideoRecordingWithOutputWidth:outputHeight:

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

Starts video recording of the ARView with given outputWidth and outputHeight resolution.

Parameters
intoutputWidth Output video width.
intoutputHeight Output video height.
Deprecated:
This API is deprecated. Please use DeepAR method startVideoRecordingWithOutputWidth instead.

◆ startVideoRecordingWithOutputWidth:outputHeight:subframe:

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

Starts video recording of the ARView with given outputWidth and outputHeight resolution.

Parameters
intoutputWidth Output video width.
intoutputHeight Output video height.
CGRectsubframe The subframe parameter defines the sub rectangle of the ARView that you want to record in normalized coordinates (0.0 - 1.0).
Deprecated:
This API is deprecated. Please use DeepAR method startVideoRecordingWithOutputWidth instead.

◆ 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 outputWidth and outputHeight resolution.

Parameters
intoutputWidth Output video width.
intoutputHeight Output video 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.
Deprecated:
This API is deprecated. Please use DeepAR method startVideoRecordingWithOutputWidth instead.

◆ 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 outputWidth and outputHeight resolution.

Parameters
intoutputWidth Output video width.
intoutputHeight Output video 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 on ARView. 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.
Deprecated:
This API is deprecated. Please use DeepAR method startVideoRecordingWithOutputWidth instead.

◆ stopFrameOutput

- (void) stopFrameOutput

Stops outputting frames to frameAvailable .

Deprecated:
This API is deprecated. Please use DeepAR method stopCapture instead.

◆ 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.arview switchEffectWithSlot:@"mask" path:"flowers"];
[self.arview 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.
Deprecated:
This API is deprecated. Please use DeepAR method switchEffectWithSlot instead.

◆ switchEffectWithSlot:path:face:

- (void) switchEffectWithSlot: (NSString *)  slot
path: (NSString *)  path
face: (uint32_t)  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.
uint32_tface 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.arview switchEffectWithSlot:@"mask_f0" path:"flowers" face:0];
// apply beard effect to the second face
[self.arview switchEffectWithSlot:@"mask_f1" path:"beard" face:1];
// replace the effect on the first face with the lion
[self.arview switchEffectWithSlot:@"mask_f0" path:"lion" face:0];
// remove the beard effect from the second face
[self.arview switchEffectWithSlot:@"mask_f1" path:nil face:1];
Deprecated:
This API is deprecated. Please use DeepAR method switchEffectWithSlot instead.

◆ switchEffectWithSlot:path:face:targetGameObject:

- (void) switchEffectWithSlot: (NSString *)  slot
path: (NSString *)  path
face: (uint32_t)  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.
uint32_tface 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.
Deprecated:
This API is deprecated. Please use DeepAR method switchEffectWithSlot instead.

◆ takeScreenshot

- (void) takeScreenshot

Produces a snapshot of the current screen preview.

Resolution is equal to the dimension with which the ARView 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.

Deprecated:
This API is deprecated. Please use DeepAR method takeScreenshot instead.

Property Documentation

◆ initialized

- (BOOL) initialized
readnonatomicassign

Indicates if ARView and the underlying DeepAR engine are successfully initialized.

No method should be called on ARView until the initialization is fully finished.


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