ULSMultiTrackeriOSSDK.h
10.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
//
// ULSMultiTrackeriOSSDK.h
// ULSMultiTrackeriOSSDK
//
// Created by ulsee on 2/3/17.
// Copyright © 2017 ulsee. All rights reserved.
//
// Version : v1.3.8
#import <UIKit/UIKit.h>
#import "ULSPixelBufferWrapper.h"
//! Project version number for ULSMultiTrackeriOSSDK.
FOUNDATION_EXPORT double ULSMultiTrackeriOSSDKVersionNumber;
//! Project version string for ULSMultiTrackeriOSSDK.
FOUNDATION_EXPORT const unsigned char ULSMultiTrackeriOSSDKVersionString[];
@interface ULSMultiTrackeriOSSDK : NSObject
/*!
@method initFromFolder:withActivationKey:withActivationKey:
@abstract
Initialization of ULSMultiTrackeriOSSDK class object.
@param path
The path of the tracker resource. (The default resource name is ULSFaceTrackerAssets.bundle)
@param key
The valid key is essential to active the initialization of tracker object. The valid key is provided by ulsee.com.
@param maxFaces
Max number of face that want to be tracked.
@result
Return an object of ULSMultiTrackeriOSSDK class or nil value.
*/
- (id)initFromFolder:(NSString*)path withActivationKey:(NSString*)key withMaxFaces:(int)maxFaces;
- (id)initFromFolder:(NSString*)path withActivationKey:(NSString*)key withMaxFaces:(int)maxFaces withContext:(EAGLContext*)context;
/*!
@method process:withFaceCount:withFaceRects:withRollAngle:
@abstract
This function gets facial tracking result from an input image captured by camera. This function should be called in each new frame generating.
The face rectangle is expected to be in absolute coordinates.
@param src
The CVPixelBuferRef-format frame captured from the camera. This frame is used to do the facial tracking process. Format supported: kCVPixelFormatType_32BGRA, kCVPixelFormatType_420YpCbCr8BiPlanarFullRange, kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange.
@param count
An integer value which indicates the number of faces are detected.
@param faceRect
The CGRect array of face rectangle value which returned from the method of AVCaptureMetadataOutputObjectsDelegate.
@param radians
The float array of roll angle value of the tracking face. This value would be got from the method of A VCaptureMetadataOutputObjectsDelegate.
@result
Return an integer that indicates the number of active faces.
*/
- (int) process:(CVPixelBufferRef)src
withFaceCount:(int)count
withFaceRects:(CGRect*)faceRect
withRollAngle:(float*)radians;
/*!
@method process:withBufferWidth:withBufferHeight:withFaceCount:withFaceRects:withRollAngle:
@abstract
This function gets facial tracking result from an CVOpenGLESTextureRef. This function should be called in each new frame generating, and is designed for those who wanted to pre-process the Pixelbuffer and use the textureref afterwards.
The face rectangle is expected to be in absolute coordinates.
@param srcTexture
The CVOpenGLESTextureRef generated from related CVOpenGLES API(s). Currently only support BGRA format.
@param bufferWidth
Width of the texture image in pixel.
@param bufferHeight
Height of the texture image in pixel.
@param count
An integer value which indicates the number of faces are detected.
@param faceRect
The CGRect array of face rectangle value which returned from the method of AVCaptureMetadataOutputObjectsDelegate.
@param radians
The float array of roll angle value of the tracking face. This value would be got from the method of A VCaptureMetadataOutputObjectsDelegate.
@result
Return an integer that indicates the number of active faces.
*/
- (int) process:(CVOpenGLESTextureRef)srcTexture withBufferWidth:(int)bufferWidth withBufferHeight:(int)bufferHeight withFaceCount:(int)count withFaceRects:(CGRect *)faceRect withRollAngle:(float *)radians;
- (int) process:(CVPixelBufferRef)src;
- (int) processWithPixelBufferWrapper:(ULSPixelBufferWrapper *)src;
/*!
@method numberOfPoints
@abstract
Get the number of points in the shape.
@result
Returns an integer that indicates number of points in the shape.
*/
- (unsigned int)numberOfPoints;
/*!
@method getShape66p:
@abstract
Get the original facial landmarkers in 2D (x, y) from face index i.
@param index
The face index value.
@result
Return an array of floats [x0,y0,x1,y1,x2,y2......x65,y65] for index(th) tracked face, or NULL.
*/
- (const float*)getShape66p:(int)index;
/*!
@method getShape:
@abstract
Get the facial landmarkers in 2D (x, y) from face index i.
@param index
The face index value.
@result
Return an array of floats [x0,y0,x1,y1,x2,y2......] for index(th) tracked face, or NULL.
*/
- (const float*)getShape:(int)index;
/*!
@method getShape3D:
@abstract
Get the facial landmarkers in 3D (x, y, z) from face index i.
@param index
The face index value.
@result
Return an array of floats [x0,y0,x1,y1,x2,y2......] for index(th) tracked face, or NULL, in camera coordinate system.
*/
- (const float*)getShape3D:(int)index;
/*!
@method getScaleInImage:
@abstract
Get face scale value of index(th) tracked face which relates to the initial 3D model.
Weak-perspective camera model's scale parameter.
@param index
The face index value.
@result
Return a float value means scale of index(th) face.
*/
- (float) getScaleInImage:(int)index;
/*!
@method getTranslationInImage:x:y:
@abstract
Get the X-axis and Y-axis translation in the image of a tracked face of the specified index.
Data will be in order [x, y], to help find the centre-point of the face in the image, for accurate positioning.
@param index
The face index value.
@param x
Returned x value of centre-point of the face in the image.
@param y
Returned y value of centre-point of the face in the image.
@result
Return TRUE if the pose value was estimated. Return FALSE otherwise.
*/
- (BOOL) getTranslationInImage:(int)index x:(float*) x y:(float*)y;
/*!
@method getRotationPitch:pitch:yaw:roll:
@abstract
This function is used to get the real time head pose pitch, yaw, roll value of the index(th) tracked face.
@param index
The face index value.
@param pitch
Returned picth value of the index(th) tracked face.
@param yaw
Returned yaw value of the index(th) tracked face.
@param roll
Returned roll value of the index(th) tracked face.
@result
Return TRUE if the pose is tracked for index(th) face. Return FALSE otherwise.
*/
- (BOOL) getRotationPitch:(const int)index pitch:(float*)pitch yaw:(float*)yaw roll:(float*)roll;
/*!
@method getNewStablePoseIndex:pixelBuffer:
@abstract
This function is used to calculate the new pose values, for every tracked face of the specified index.
This new algorithm is making POSE more stable when head is still with big open mouth or big open eyes.
It's especially useful for avatar applications.
You may skip the getNewStablePoseIndex function if you don't mind the POSE minor changes when open big mouth and eyes.
@param index
The face index value.
@param pb
The CVPixelBuferRef-format frame captured from the camera. This frame is same as the used one to do the facial tracking process.
@result
Return an array of new pose [pitch, roll, yaw, scale].
*/
- (float *)getNewStablePoseIndex:(int)index pixelBuffer:(CVPixelBufferRef)pb;
/*!
@method getShapeQuality:
@abstract
Get the shape quality from face index i.
@param index
The face index value.
@result
Return an array of shape quality [q0, q1, q2, q3...] indicates the quality of each landmark of the shape.
*/
- (const float*)getShapeQuality:(int)index;
/*!
@method getPoseQuality
@abstract
Get pose quality from face index i.
@param index
The face index value.
@result
Return 0.7f while the pose value is not NULL. Return 0.0f otherwise.
*/
- (const float)getPoseQuality:(int)index;
/*!
@method getPupilsLocation
@abstract
Get the pupil location of the index(th) face.
@param index
The face index value.
@result
Return an array of 4 floats (x,y)(x,y), or NULL.
*/
- (const float*)getPupilsLocation:(int)index;
/*!
@method getGaze
@abstract
Get the gaze direction in left gaze (x, y, z) and right gaze (x, y, z) from face index i.
@param index
The face index value.
@result
Return an array of 6 floats (x,y,z)(x,y,z) with the direction of the gaze, or NULL.
*/
- (const float*)getGaze:(int)index;
/*!
@method getTranslationIndex:x:y:z:focalLength:imageCentreX:imageCentreY:
@abstract
Get head center in 3D.
@param index
The face index value.
@param x
Returned x value of head center in 3D.
@param y
Returned y value of head center in 3D.
@param z
Returned z value of head center in 3D.
@param focalLength
The focal length value of camera. (Use 1000 as default.)
@param imageCentreX
The x-center value of the input pixel buffer of image.
@param imageCentreY
The y-center value of the input pixel buffer of image.
*/
- (void)getTranslationIndex:(int)index
x:(float *)x
y:(float *)y
z:(float *)z
focalLength:(const float)focalLength
imageCentreX:(const float)imageCentreX
imageCentreY:(const float)imageCentreY;
/*!
@method isTracking:
@abstract
Check if the index(th) face is tracked or not.
@param index
The face index value.
@result
Return TRUE while the index(th) face is tracked. Return FALSE otherwise.
*/
- (BOOL)isTracking:(int)index;
/*!
@method setTrackerThreshold:
@abstract
Set the threshold value of tracker health value.
@param threshold
tracker health threshold. (default: 0.3f)
*/
- (void)setTrackerThreshold:(const float)threshold;
/*!
@method resetTracker
@abstract
Reset the tracker(s).
*/
- (void)resetTracker;
/*!
@method startFaceTracking:
@abstract
Start or stop face tracking process.
@param isStart
Set TRUE to start face tracking process. Set FALSE otherwise.
*/
- (void)startFaceTracking:(BOOL)isStart;
/*!
@method ulsFaceDetectWithPixelBuffer:
@abstract
Return NSArray that contains with CGRect values of face detection rectangles.
@param pixelBuffer
The PORTRAIT mode pixel buffer.
@result
An NSArray of CGrect face rectangle
*/
- (NSArray*)ulsFaceDetectWithPixelBuffer:(CVPixelBufferRef)pixelBuffer;
- (NSArray*)ulsFaceDetectWithImage:(UIImage *)image;
/*!
@method getPortraitPixelBufferFromImage:
@abstract
Return CVPixeBufferRef with portrait mode orientation.
@param uiImage
The input UIImage with any orientation.
@result
A CVPixelBufferRef value with portrait mode orientation.
*/
- (CVPixelBufferRef)getPortraitPixelBufferFromImage:(UIImage *)uiImage;
/*!
@method pixelBufferRotateLeftFlipHorizontal:
@abstract
Return CVPixeBufferRef with rotate left and flip horizontal.
@param pixelBuffer
The input pixel buffer.
@result
A CVPixelBufferRef value with rotate left and flip horizontal.
*/
- (CVPixelBufferRef)pixelBufferRotateLeftFlipHorizontal:(CVPixelBufferRef)pixelBuffer;
@end