![]() |
DeepAR iOS
v5.2.0
|
ARView is a class that extends UIView with all DeepAR features which can be positioned in the UI hierarchy. More...
#import <ARView.h>
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 | |
DeepAR * | deepAR |
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< DeepARDelegate > | delegate |
Set to the object which implements DeepARDelegate protocol to listen for async events coming from DeepAR. | |
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.
- (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.
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. |
bool | value New parameter value. |
- (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.
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. |
float | value New parameter value. |
- (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.
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. |
- (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.
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. |
Vector3 | value New parameter value. |
- (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.
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. |
Vector4 | value New parameter value. |
- (void) enableAudioProcessing: | (BOOL) | enabled |
Enables or disables audio pitch processing for video recording.
BOOL | enabled Enable audio processing. |
- (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.
CMSampleBufferRef | sampleBuffer The audio sample. |
- (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).
CMSampleBufferRef | sampleBuffer The camera frame. |
BOOL | mirror 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). |
- (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.
- (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.
NSString* | trigger The trigger name. |
- (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) 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.
- (void) pauseVideoRecording |
Pauses video recording.
- (void) resume |
Resumes the rendering if it was previously paused, otherwise doesn't do anything.
- (void) resumeVideoRecording |
Resumes video recording after it has been paused with pauseVideoRecording.
- (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.
float | sts The pitch change amount. |
- (void) setFaceDetectionSensitivity: | (int) | sensitivity |
This method allows the user to change face detection sensitivity.
int | sensitivity 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. |
- (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:
Copy the newly generated license key as a parameter in this method
You must call this method before you call the initialize.
NSString* | key The license key. |
- (void) setParameterWithKey: | (NSString *) | key | |
value: | (NSString *) | value | |
Sets the internal SDK parameter.
NSString* | key The parameter key. |
NSString* | value The parameter value. |
- (void) showStats: | (bool) | enabled |
Display debugging stats on screen.
bool | enabled Enable debugging stats. |
- (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) 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.
int | outputWidth The width of the processed frames. |
int | outputHeight The height of the processed frames. |
CGRect | subframe 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 . |
- (void) startVideoRecordingWithOutputWidth: | (int) | outputWidth | |
outputHeight: | (int) | outputHeight | |
Starts video recording of the ARView with given outputWidth and outputHeight resolution.
int | outputWidth Output video width. |
int | outputHeight Output video height. |
- (void) startVideoRecordingWithOutputWidth: | (int) | outputWidth | |
outputHeight: | (int) | outputHeight | |
subframe: | (CGRect) | subframe | |
Starts video recording of the ARView with given outputWidth and outputHeight resolution.
int | outputWidth Output video width. |
int | outputHeight Output video height. |
CGRect | subframe The subframe parameter defines the sub rectangle of the ARView that you want to record in normalized coordinates (0.0 - 1.0). |
- (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.
int | outputWidth Output video width. |
int | outputHeight Output video height. |
CGRect | subframe 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. |
- (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.
int | outputWidth Output video width. |
int | outputHeight Output video height. |
CGRect | subframe 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. |
BOOL | recordAudio 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. |
- (void) stopFrameOutput |
Stops outputting frames to frameAvailable .
- (void) switchEffectWithSlot: | (NSString *) | slot | |
path: | (NSString *) | path | |
Load a DeepAR Studio file as an effect/filter in the scene.
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. |
- (void) switchEffectWithSlot: | (NSString *) | slot | |
path: | (NSString *) | path | |
face: | (uint32_t) | face | |
Load a DeepAR Studio file as an effect/filter in the scene.
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_t | face 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];
|
- (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.
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_t | face 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. |
- (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.
|
readnonatomicassign |