DeepAR iOS  v5.2.0
DeepAR.h
Go to the documentation of this file.
1
7#import <Foundation/Foundation.h>
8#import <UIKit/UIKit.h>
9#import <AVFoundation/AVFoundation.h>
10
14typedef struct {
22 float translation[3];
26 float rotation[3];
30 float poseMatrix[16];
34 float landmarks[68 * 3];
39 float landmarks2d[68 * 3]; // TODO: *3 is definitely a typo; fix and test
43 float faceRect[4];
54 float emotions[5];
58 float actionUnits[63]; // TODO: discover more
62 int numberOfActionUnits; // TODO: discover more
63} FaceData;
64
68typedef struct {
72 FaceData faceData[4];
74
78typedef struct {
82 NSInteger outputWidth;
86 NSInteger outputHeight;
90 CGRect subframe;
100
104typedef struct {
108 float x;
112 float y;
116 float z;
120 float w;
121} Vector4;
122
126typedef struct {
130 float x;
134 float y;
138 float z;
139} Vector3;
140
144typedef enum
145{
153 RGBA, // 1
157 BGRA, // 2
161 ARGB, // 3
165 ABGR, // 4
169 COUNT
171
175typedef enum {
193
197typedef enum {
209 END
211
215typedef enum {
223 INT = 1,
231 STRING = 3
233
237typedef struct {
241 CGFloat x;
245 CGFloat y;
250} TouchInfo;
251
252typedef struct {
258
263 bool initializeFaceTrackingSynchronously;
265
270@protocol DeepARDelegate <NSObject>
271
272@optional
273
279- (void)didTakeScreenshot:(UIImage*)screenshot;
280
284- (void)didInitialize;
285
290- (void)faceVisiblityDidChange:(BOOL)faceVisible;
291
297- (void)frameAvailable:(CMSampleBufferRef)sampleBuffer;
298
303- (void)faceTracked:(MultiFaceData)faceData;
304
309- (void)numberOfFacesVisibleChanged:(NSInteger)facesVisible;
310
314- (void)didFinishShutdown;
315
321- (void)imageVisibilityChanged:(NSString*)gameObjectName imageVisible:(BOOL)imageVisible; // TODO: explore further
322
327- (void)didSwitchEffect:(NSString*)slot;
328
333- (void)animationTransitionedToState:(NSString*)state;
334
339
344
349- (void)didFinishVideoRecording:(NSString*)videoFilePath;
350
355- (void)recordingFailedWithError:(NSError*)error;
356
362- (void)onErrorWithCode:(ARErrorType)code error:(NSString*)error;
363
364@end
365
366#define ARViewDelegate DeepARDelegate
367
372@interface DeepAR : NSObject
373
377@property (nonatomic, weak) id<DeepARDelegate> delegate;
378
382@property (nonatomic, readonly) BOOL visionInitialized;
383
387@property (nonatomic, readonly) BOOL renderingInitialized;
388
392@property (nonatomic, readonly) BOOL faceVisible;
393
397@property (nonatomic, readonly) CGSize renderingResolution;
398
434@property (nonatomic, assign) BOOL videoRecordingWarmupEnabled;
435
439@property (nonatomic, strong) NSDictionary* audioCompressionSettings;
440
445+ (NSString*) sdkVersion;
446
457- (void)setLicenseKey:(NSString*)key;
458
466- (void)initializeWithWidth:(NSInteger)width height:(NSInteger)height window:(CAEAGLLayer*)window;
467
472- (void)initialize;
473
479- (void)initializeOffscreenWithWidth:(NSInteger)width height:(NSInteger)height;
480
487- (UIView*)createARViewWithFrame:(CGRect)frame;
488
493- (BOOL)isVisionOnly;
494
501- (void)setRenderingResolutionWithWidth:(NSInteger)width height:(NSInteger)height;
502
507- (void)shutdown;
508
515- (UIView*)switchToRenderingToViewWithFrame:(CGRect)frame;
516
523- (void)switchToRenderingOffscreenWithWidth:(NSInteger)width height:(NSInteger)height;
524
531- (void)changeLiveMode:(BOOL)liveMode;
532
536- (void)resume;
537
542- (void)pause;
543
550- (void)processFrame:(CVPixelBufferRef)imageBuffer mirror:(BOOL)mirror;
551
559- (void)processFrame:(CVPixelBufferRef)imageBuffer mirror:(BOOL)mirror timestamp:(CMTimeValue)timestamp;
560
568- (void)processFrameAndReturn:(CVPixelBufferRef)imageBuffer outputBuffer:(CVPixelBufferRef)outputBuffer mirror:(BOOL)mirror;
569
576- (void)enqueueCameraFrame:(CMSampleBufferRef)sampleBuffer mirror:(BOOL)mirror;
577
583- (void)enqueueAudioSample:(CMSampleBufferRef)sampleBuffer;
584
590- (void)setVideoRecordingOutputName:(NSString*)outputName;
591
600- (void)setVideoRecordingOutputPath:(NSString*)outputPath;
601
607- (void)startVideoRecordingWithOutputWidth:(int)outputWidth outputHeight:(int)outputHeight;
608
615- (void)startVideoRecordingWithOutputWidth:(int)outputWidth outputHeight:(int)outputHeight subframe:(CGRect)subframe;
616
624- (void)startVideoRecordingWithOutputWidth:(int)outputWidth outputHeight:(int)outputHeight subframe:(CGRect)subframe videoCompressionProperties:(NSDictionary*)videoCompressionProperties;
625
634- (void)startVideoRecordingWithOutputWidth:(int)outputWidth outputHeight:(int)outputHeight subframe:(CGRect)subframe videoCompressionProperties:(NSDictionary*)videoCompressionProperties recordAudio:(BOOL)recordAudio;
635
645- (void)switchEffectWithSlot:(NSString*)slot path:(NSString*)path;
646
663- (void)switchEffectWithSlot:(NSString*)slot path:(NSString*)path face:(NSInteger)face;
664
672- (void)switchEffectWithSlot:(NSString*)slot path:(NSString*)path face:(NSInteger)face targetGameObject:(NSString*)targetGameObject;
673
679- (void)switchEffectWithSlot:(NSString*)slot data:(NSData*)data;
680
687- (void)switchEffectWithSlot:(NSString*)slot data:(NSData*)data face:(NSInteger)face;
688
693- (void)takeScreenshot;
694
700
704- (void)pauseVideoRecording;
705
710
715- (void)enableAudioProcessing:(BOOL)enabled;
716
722- (void)setAudioProcessingSemitone:(float)sts;
723
731- (void)startCaptureWithOutputWidth:(NSInteger)outputWidth outputHeight:(NSInteger)outputHeight subframe:(CGRect)subframe;
732
741- (void)startCaptureWithOutputWidthAndFormat:(NSInteger)outputWidth outputHeight:(NSInteger)outputHeight subframe:(CGRect)subframe outputImageFormat:(OutputFormat)outputFormat;
742
746- (void)stopCapture;
747
753- (void)fireTrigger:(NSString*)trigger;
754
758- (void)touchOccurred:(TouchInfo)touchInfo;
759
764- (void)showStats:(BOOL) enabled;
765
770- (void)simulatePhysics:(BOOL) enabled;
771
776- (void)showColliders:(BOOL) enabled;
777
782- (void)setFaceDetectionSensitivity:(NSInteger)sensitivity;
783
792- (void)changeParameter:(NSString*)gameObject component:(NSString*)component parameter:(NSString*)parameter floatValue:(float)value;
793
802- (void)changeParameter:(NSString*)gameObject component:(NSString*)component parameter:(NSString*)parameter vectorValue:(Vector4)value;
803
812- (void)changeParameter:(NSString*)gameObject component:(NSString*)component parameter:(NSString*)parameter vector3Value:(Vector3)value;
813
822- (void)changeParameter:(NSString*)gameObject component:(NSString*)component parameter:(NSString*)parameter boolValue:(BOOL)value;
823
832- (void)changeParameter:(NSString*)gameObject component:(NSString*)component parameter:(NSString*)parameter image:(UIImage*)image;
833
842- (void)changeParameter:(NSString*)gameObject component:(NSString*)component parameter:(NSString*)parameter stringValue:(NSString*)value;
843
844
851- (void)moveGameObject:(NSString*)selectedGameObjectName targetGameObjectname:(NSString*)targetGameObjectName;
852
856- (void)startProfiling;
857
861- (void)stopProfiling;
862
867- (void)setFaceTrackingInitParameters:(FaceTrackingInitParameters)params;
868
876- (bool)hasVar:(NSString*)name slot:(NSString*) slot;
877
884- (bool)hasVar:(NSString*)name;
885
893- (VarType)getVarType:(NSString*)name slot:(NSString*) slot;
894
902- (VarType)getVarType:(NSString*)name;
903
911- (bool)getBoolVar:(NSString*)name slot:(NSString*) slot;
912
919- (bool)getBoolVar:(NSString*)name;
920
928- (int)getIntVar:(NSString*)name slot:(NSString*) slot;
929
936- (int)getIntVar:(NSString*)name;
937
945- (double)getDoubleVar:(NSString*)name slot:(NSString*) slot;
946
953- (double)getDoubleVar:(NSString*)name;
954
962- (NSString*)getStringVar:(NSString*)name slot:(NSString*) slot;
963
970- (NSString*)getStringVar:(NSString*)name;
971
980- (bool)setBoolVar:(NSString*)name value:(bool)value slot:(NSString*) slot;
981
989- (bool)setBoolVar:(NSString*)name value:(bool)value;
990
999- (bool)setIntVar:(NSString*)name value:(int)value slot:(NSString*) slot;
1000
1008- (bool)setIntVar:(NSString*)name value:(int)value;
1009
1018- (bool)setDoubleVar:(NSString*)name value:(double)value slot:(NSString*) slot;
1019
1027- (bool)setDoubleVar:(NSString*)name value:(double)value;
1028
1037- (bool)setStringVar:(NSString*)name value:(NSString*)value slot:(NSString*) slot;
1038
1046- (bool)setStringVar:(NSString*)name value:(NSString*)value;
1047
1055- (bool)deleteVar:(NSString*)name slot:(NSString*) slot;
1056
1063- (bool)deleteVar:(NSString*)name;
1064
1071- (bool)clearVars:(NSString*)slot;
1072
1078- (bool)clearVars;
1079
1080@end
1081
1082#import "ARView.h"
1083#import "CameraController.h"
Conatins the ARView DeepAR view class which extends UIView.
Contains the CameraController helper class that controls the camera device.
VarType
Possible variable types.
Definition: DeepAR.h:215
@ DOUBLE
Double variable type.
Definition: DeepAR.h:227
@ BOOLEAN
Bool variable type.
Definition: DeepAR.h:219
@ STRING
String variable type.
Definition: DeepAR.h:231
@ INT
Integer variable type.
Definition: DeepAR.h:223
ARErrorType
DeepAR error types.
Definition: DeepAR.h:175
@ DEEPAR_ERROR_TYPE_WARNING
DeepAR warning type.
Definition: DeepAR.h:187
@ DEEPAR_ERROR_TYPE_DEBUG
DeepAR debug type.
Definition: DeepAR.h:179
@ DEEPAR_ERROR_TYPE_ERROR
DeepAR error type.
Definition: DeepAR.h:191
@ DEEPAR_ERROR_TYPE_INFO
DeepAR info type.
Definition: DeepAR.h:183
TouchType
Possible types of an occurred touch.
Definition: DeepAR.h:197
@ START
Touch type that implies that a touch was started.
Definition: DeepAR.h:201
@ END
Touch type that implies that a previously started touch ended.
Definition: DeepAR.h:209
@ MOVE
Touch type that implies that a previously started touch changed.
Definition: DeepAR.h:205
OutputFormat
Output color format.
Definition: DeepAR.h:145
@ Undefined
Undefined format.
Definition: DeepAR.h:149
@ ARGB
Alpha, red, green and blue format.
Definition: DeepAR.h:161
@ COUNT
Number of formats.
Definition: DeepAR.h:169
@ ABGR
Alpha, blue, green and red format.
Definition: DeepAR.h:165
@ RGBA
Red, green, blue and alpha format.
Definition: DeepAR.h:153
@ BGRA
Blue, green, red and alpha format.
Definition: DeepAR.h:157
Main class for interacting with DeepAR engine.
Definition: DeepAR.h:373
id< DeepARDelegate > delegate
The object which implements DeepARDelegate protocol to listen for async events coming from DeepAR.
Definition: DeepAR.h:377
void pauseVideoRecording()
Pauses video recording if it has been started beforehand.
bool clearVars()
Clear all variables.
void finishVideoRecording()
Finishes the video recording.
BOOL visionInitialized
Indicates if computer vision components have been initialized during the initialization process.
Definition: DeepAR.h:382
void shutdown()
Shuts down the DeepAR engine.
BOOL isVisionOnly()
Indicates if DeepAR has been initialized in the vision-only mode or not.
BOOL videoRecordingWarmupEnabled
If set to true, changes how startVideoRecording and resumeVideoRecording methods work to allow the v...
Definition: DeepAR.h:434
void startProfiling()
Starts recording profiling stats by writing them to a CSV-formatted stream.
void resume()
Resumes the rendering if it was previously paused, otherwise doesn't do anything.
NSDictionary * audioCompressionSettings
The audio compression settings.
Definition: DeepAR.h:439
void pause()
Pauses the rendering.
BOOL faceVisible
Indicates if at least one face is detected in the current frame.
Definition: DeepAR.h:392
void stopCapture()
Stops outputting frames to frameAvailable .
NSString * sdkVersion()
The DeepAR SDK version number.
void stopProfiling()
Stops recording profiling stats and sends the recorded CSV to the stat export server.
BOOL renderingInitialized
Indicates if DeepAR rendering components have been initialized during the initialization process.
Definition: DeepAR.h:387
void resumeVideoRecording()
Resumes video recording after it has been paused with pauseVideoRecording.
void initialize()
Starts the engine initialization where the DeepAR will initialize in vision only mode.
void takeScreenshot()
Produces a snapshot of the current screen preview.
CGSize renderingResolution
Rendering resolution with which the DeepAR has been initialized.
Definition: DeepAR.h:397
A delegate that is used to notify events from DeepAR to the consumer of the DeepAR SDK.
Definition: DeepAR.h:270
void didInitialize()
Called when the DeepAR engine initialization is complete.
void didFinishPreparingForVideoRecording()
Called when the video recording preparation is finished.
void didStartVideoRecording()
Called when DeepAR has started video recording (after calling startVideoRecording method).
void didFinishShutdown()
DeepAR has successfully shut down after the method shutdown call.
Represents data structure containing all the information available about the detected face.
Definition: DeepAR.h:14
int numberOfActionUnits
The number of action units.
Definition: DeepAR.h:62
BOOL detected
Determines whether the face is detected or not.
Definition: DeepAR.h:18
Definition: DeepAR.h:252
bool initializeEngineWithFaceTracking
Definition: DeepAR.h:257
Structure containing face data for up to 4 detected faces.
Definition: DeepAR.h:68
The video (and audio) recording configuration.
Definition: DeepAR.h:78
BOOL recordAudio
Determine whether audio is recorded or not.
Definition: DeepAR.h:98
CGRect subframe
The sub rectangle of the ARView that you want to record in normalized coordinates (0....
Definition: DeepAR.h:90
NSInteger outputWidth
The output video width.
Definition: DeepAR.h:82
NSDictionary * videoCompressionProperties
An NSDictionary used as the value for the key AVVideoCompressionPropertiesKey. Read more about video ...
Definition: DeepAR.h:94
NSInteger outputHeight
The output video height.
Definition: DeepAR.h:86
Contains information about the current location and status of the started touch.
Definition: DeepAR.h:237
CGFloat y
Value of the y coordinate of the current touch location.
Definition: DeepAR.h:245
TouchType type
The status, i.e., touch type, of the touch.
Definition: DeepAR.h:249
CGFloat x
Value of the x coordinate of the current touch location.
Definition: DeepAR.h:241
A three-dimensional float vector.
Definition: DeepAR.h:126
float x
X value.
Definition: DeepAR.h:130
float y
Y value.
Definition: DeepAR.h:134
float z
Z value.
Definition: DeepAR.h:138
A four-dimensional float vector.
Definition: DeepAR.h:104
float x
X value.
Definition: DeepAR.h:108
float y
Y value.
Definition: DeepAR.h:112
float w
W value.
Definition: DeepAR.h:120
float z
Z value.
Definition: DeepAR.h:116