-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathindex.html
935 lines (757 loc) · 32.9 KB
/
index.html
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
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" href="css/docs.css">
<title>Beyond Reality Face - BRFv4 - API reference</title>
</head>
<body>
<div id="wrapper">
<div class="description">
<div id="logo">
<img id="img_logo" src="https://d1bh1gwjshk0ig.cloudfront.net/assets/brf_landingpage/brfv4_logo.png" alt="BRFv4 logo" />
</div>
<div class="menu">
<a href="what_can_i_do_with_it.html">What can I do with it?</a> |
<a href="index.html">API Reference</a> |
<a href="https://github.com/Tastenkunst">BRFv4 on Github</a> |
<a href="https://tastenkunst.github.io/brfv4_javascript_examples/">JS Demo</a>
</div>
</div>
<div class="spacer"></div>
<h1>BRFv4 - API Reference</h1>
<h2>Overview</h2>
<div class="description">
<p>
The BRFv4 API is the same on all platforms. Everything described on this page can be applied to Javascript, Actionscript 3 or C++.<br><br>
Before you read this API, please take a look at what you can do with BRFv4, especially what results to expect from
face detection and face tracking (<a href="what_can_i_do_with_it.html">link: What can I do with it?</a>).<br><br>
There are two main classes: BRFManager and BRFFace.<br><br>
Going forward "roi" means "region of interest", the rectangular area of an image an algorithm works in.
</p>
</div>
<div class="spacer"></div>
<h2 id="hl_BRFManager">BRFManager</h2>
<h4>(control flow)</h4>
<div class="description functionlist">
<p><a href="#init">init( Rectangle imageDataSize, Rectangle imageRoi, String appId ) : void</a></p>
<p><a href="#update">update( Bitmap imageData ) : void</a></p>
<p><a href="#reset">reset() : void</a></p>
<p><a href="#getMode">getMode() : String</a></p>
<p><a href="#setMode">setMode( String mode ) : void</a></p>
</div>
<h4>(face detection)</h4>
<div class="description functionlist">
<p><a href="#setFaceDetectionParams">setFaceDetectionParams( int minWidth, int maxWidth, int stepSize, int minMergeNeighbors ) : void</a></p>
<p><a href="#setFaceDetectionRoi">setFaceDetectionRoi( Rectangle roi ) : void</a></p>
<p><a href="#getAllDetectedFaces">getAllDetectedFaces() : Vector<Rectangle></a></p>
<p><a href="#getMergedDetectedFaces">getMergedDetectedFaces() : Vector<Rectangle></a></p>
</div>
<h4>(face tracking)</h4>
<div class="description functionlist">
<p><a href="#setNumFacesToTrack">setNumFacesToTrack( int numFaces ) : void</a></p>
<p><a href="#setFaceTrackingStartParams">setFaceTrackingStartParams( double minWidth, double maxWidth, double rx, double ry, double rz ) : void</a></p>
<p><a href="#setFaceTrackingResetParams">setFaceTrackingResetParams( double minWidth, double maxWidth, double rx, double ry, double rz ) : void</a></p>
<p><a href="#getFaces">getFaces() : Vector<BRFFace></a></p>
</div>
<h4>(point tracking - optical flow)</h4>
<div class="description functionlist">
<p><a href="#setOpticalFlowParams">setOpticalFlowParams( int patchSize, int numLevels, int numIterations, double error ) : void</a></p>
<p><a href="#addOpticalFlowPoints">addOpticalFlowPoints( Vector<Point> pointArray ) : void</a></p>
<p><a href="#getOpticalFlowCheckPointsValidBeforeTracking">getOpticalFlowCheckPointsValidBeforeTracking() : Boolean</a></p>
<p><a href="#setOpticalFlowCheckPointsValidBeforeTracking">setOpticalFlowCheckPointsValidBeforeTracking( Boolean value ) : void</a></p>
<p><a href="#getOpticalFlowPoints">getOpticalFlowPoints() : Vector<Point></a></p>
<p><a href="#getOpticalFlowPointStates">getOpticalFlowPointStates() : Vector<Boolean></a></p>
</div>
<div class="spacer"></div>
<h2 id="hl_BRFFace">BRFFace</h2>
<div class="spacer"></div>
<div class="description functionlist">
<p><a href="#lastState">lastState : String</a></p>
<p><a href="#state">state : String</a></p>
<p><a href="#nextState">nextState : String</a></p>
<p><a href="#vertices">vertices : float[]</a></p>
<p><a href="#triangles">triangles : int[]</a></p>
<p><a href="#points">points : Vector<Point></a></p>
<p><a href="#bounds">bounds : Rectangle</a></p>
<p><a href="#refRect">refRect : Rectangle</a></p>
<p><a href="#candideVertices">candideVertices : float[]</a></p>
<p><a href="#candideTriangles">candideTriangles : int[]</a></p>
<p><a href="#scale">scale : float</a></p>
<p><a href="#translationX">translationX : float</a></p>
<p><a href="#translationY">translationY : float</a></p>
<p><a href="#rotationX">rotationX : float</a></p>
<p><a href="#rotationY">rotationY : float</a></p>
<p><a href="#rotationZ">rotationZ : float</a></p>
</div>
<div class="spacer"></div>
<h2 id="hl_BRFMode">BRFMode</h2>
<div class="spacer"></div>
<div class="description functionlist">
<p><a href="#mode_FACE_DETECTION">FACE_DETECTION</a></p>
<p><a href="#mode_FACE_TRACKING">FACE_TRACKING</a></p>
<p><a href="#mode_POINT_TRACKING">POINT_TRACKING</a></p>
</div>
<div class="spacer"></div>
<h2 id="hl_BRFState">BRFState</h2>
<div class="spacer"></div>
<div class="description functionlist">
<p><a href="#state_FACE_DETECTION">FACE_DETECTION</a></p>
<p><a href="#state_FACE_TRACKING_START">FACE_TRACKING_START</a></p>
<p><a href="#state_FACE_TRACKING">FACE_TRACKING</a></p>
<p><a href="#state_RESET">RESET</a></p>
</div>
<div class="spacer"></div>
<div class="description">
<a class="link_top" href="#wrapper">↑ top</a>
<br>
<br>
</div>
<div class="spacer white"></div>
<div class="spacer"></div>
<h2>BRFManager</h2>
<div class="spacer"></div>
<div class="description">
<p>
BRFManager controls everything. First you need to call:
<br><br>
<b>init( ... )</b>
<br><br>
Based on the image size the SDK sets reasonable default parameters to start tracking a single face,
but you can change any parameter once BRFv4 is ready. Keep in mind that most parameters are pixel values
and you need to adjust parameters based on the image data size that you put in, eg.
<br><br>
<b>setFaceDetectionParams( int minWidth, int maxWidth, int stepSize, int minMergeNeighbors ) : void</b>
<br><br>
If you use a 640x480 camera resolution the trackable face size is 480 pixel at maximum.<br>A reasonable minimum would be 25% of
that max size, which is 120 pixel.
<br><br>
For a 1920x1080 resolution the trackable face size is 1080 pixel and 25% of that is 270 pixel.
<br><br>
That's why the examples use percentages for all areas and sizes. This makes sure that the camera resolution can easily be changed.
<br><br>
Once everything is set up you need to update the image data before calling:
<br><br>
<b>update( ... )</b>
<br><br>
BRFv4 tries to detect a face. If a face was detected BRFv4 immediately starts the face tracking based on it.
<br><br>
Face Detection operates globally. That's why BRFManager and not BRFFace got the result functions:
<br><br>
<b>getAllDetectedFaces() : Vector<Rectangle></b><br>
<b>getMergedDetectedFaces() : Vector<Rectangle></b>
<br><br>
The detailed face tracking data can be retrieved by calling:
<br><br>
<b>getFaces() : Vector<BRFFace></b><br><br>
which gives you a list of BRFFaces with a length based on your setting of:
<br><br>
<b>setNumFacesToTrack( int numFaces )</b>
<br><br>
And that's all about it. Init, set parameters, and continuously update.
For more information about the implementation details for your specific platform, see the sample packages.
</p>
</div>
<h4>(control flow)</h4>
<div class="description">
<p class="function_name" id="init"><b>init( Rectangle imageDataSize, Rectangle imageRoi, String appId ) : void</b></p>
<p class="function_description">
This function is the starting point.
<br><br>
It tells BRFv4 what image data size it should expect, on which area to operate and what your appId is.
<br><br>
If you want to switch the image data and thus need to change the image data size, just call <b>init()</b> again
to reinit BRFv4.<br><b>Don't create a new BRFManager! Reuse a single instance.</b><br><br>
When you first call <b>init()</b> a license check is performed. It's a single server call. If it fails in the trial version
BRFv4 will stop working after about 1 to 2 minutes. The commercial version is fail safe,
which means that even if no connection to the license server can be established, BRFv4 will still work.
Apart from that BRFv4 works fully on the client side.
</p>
<dl>
<dt class="parameter">imageDataSize (Rectangle)</dt>
<dd>The size of the image data you put in.<br><br>For a 640x480 camera resolution you need an imageDataSize of
Rectangle(0, 0, 640, 480) or for a mobile portrait camera resolutions you will need eg. Rectangle(0, 0, 480, 640).</dd>
<dt class="parameter">imageRoi (Rectangle)</dt>
<dd>The area within imageDataSize that you want to analyse. Usually you want to analyse the whole image, but
sometimes you only need a part of it and restrict the area.<br><br>For a 640x480 camera resolution you will
want to set the roi at the same size as the imageDataSize: Rectangle(0, 0, 640, 480). But maybe you want to
restrict it to the center, eg. Rectangle(80, 0, 480, 480), this would restrict the analysed area from
xStart = 80 to xEnd = 80 + 480 = 560.</dd>
<dt class="parameter">appId (String)</dt>
<dd>Choose your own appId (minimum length is 8 characters). In our examples we usually put something in like
"com.tastenkunst.brfv4.as3.examples". Create your own appId using your reversed company domain.</dd>
</dl>
<a class="link_top" href="#hl_BRFManager">↑ top</a>
<br>
<br>
</div>
<div class="description">
<p class="function_name" id="update"><b>update( Bitmap imageData ) : void</b></p>
<p class="function_description">
This function does the tracking job. It operates in either of the three BRFModes.
<br><br>
In C++ implementations, eg. OpenCV (camera handling) or iOS, you need to update the imageData on your own before calling update.
<br><br>
All other platforms have their known image containers and BRFv4 is already set up to deal with those.
<br><br>
The results can be retrieved after calling <b>update()</b> as arrays of Rectangle or BRFFace:
<br><br>
<b>getAllDetectedFaces() : Vector<Rectangle></b><br>
<b>getMergedDetectedFaces() : Vector<Rectangle></b><br>
<b>getFaces() : Vector<BRFFace></b><br><br>
</p>
<dl>
<dt class="parameter">imageData (a platform dependent image data)</dt>
<dd>This is platform dependent. In C++ implementations, eg. OpenCV (camera handling) or iOS, you need to update
the imageData on your own before calling update. All other platforms have their known image containers and
BRFv4 is already set up to deal with those, eg. Android(Java): Bitmap, AS3: BitmapData etc.</dd>
</dl>
<a class="link_top" href="#hl_BRFManager">↑ top</a>
<br>
<br>
</div>
<div class="description">
<p class="function_name" id="reset">reset() : void</p>
<p class="function_description">
All face trackers reset and start over by performing face detection. Also all point tracking points are removed.
</p>
<a class="link_top" href="#hl_BRFManager">↑ top</a>
<br>
<br>
</div>
<div class="description">
<p class="function_name" id="getMode">getMode() : String</p>
<p class="function_description">
Returns the BRFMode that is currently set.
</p>
<a class="link_top" href="#hl_BRFManager">↑ top</a>
<br>
<br>
</div>
<div class="description">
<p class="function_name" id="setMode">setMode(String mode) : void</p>
<p class="function_description">
Sets one of the three modes from BRFMode:
</p>
<dl>
<dt class="parameter">BRFMode.FACE_DETECTION</dt>
<dd>This mode will only perform the face detection part and skip the detailed analysis.</dd>
<dt class="parameter">BRFMode.FACE_TRACKING</dt>
<dd>This is the usual mode for face tracking. It performs face detection to find a face and then tracks
the facial features in detail.</dd>
<dt class="parameter">BRFMode.POINT_TRACKING</dt>
<dd>This mode will skip on face detection and tracking and only perform point tracking. You can perform
face tracking and point tracking simultaneously by choosing FACE_TRACKING as mode.</dd>
</dl>
<br>
<dl>
<dt class="parameter">mode (String)</dt>
<dd>either BRFMode.FACE_DETECTION, BRFMode.FACE_TRACKING or BRFMode.POINT_TRACKING
</dl>
<a class="link_top" href="#hl_BRFManager">↑ top</a>
<br>
<br>
</div>
<h4>(face detection)</h4>
<div class="description">
<p class="function_name" id="setFaceDetectionParams">setFaceDetectionParams( int minWidth, int maxWidth, int stepSize, int minMergeNeighbors ) : void</p>
<p class="function_description">
Internally BRFv4 uses a DYNx480 (landscape) or 480xDYN (portrait) image for it's analysis. So 480px is the
base size that every other input size compares to (eg. 1280x720 -> 854x480).
<br><br>
The minimum detectable face size for the following resolutions are:
</p>
<ul style="margin: 10px;">
<li style="margin-left: 15px;"> 640 x 480: 24px ( 480 / 480 = 1.00 * 24 = 24) (base)</li>
<li style="margin-left: 15px;">1280 x 720: 36px ( 720 / 480 = 1.50 * 24 = 36)</li>
<li style="margin-left: 15px;">1920 x 1080: 54px (1080 / 480 = 2.25 * 24 = 54)</li>
</ul>
<p class="function_description">
Also: faces (blue) are only detected at step sizes multiple of 12.<br>
So the actual face detection layers (sizes) are:
</p>
<ul style="margin: 10px;">
<li style="margin-left: 15px;"> 640 x 480: 24, 36, 48, 60, 72, ..., 456, 468, 480</li>
<li style="margin-left: 15px;">1280 x 720: 36, 54, 72, 90, 108, ..., 684, 702, 720</li>
<li style="margin-left: 15px;">1920 x 1080: 54, 81, 108, 135, 162, ..., 1026, 1053, 1080</li>
</ul>
<p class="function_description">
Detected faces (blue) get merged (yellow) if they are<br>
+ roughly placed in the same location,<br>
+ roughly the same size and<br>
+ have at least minMergeNeighbors of other rectangle in the same spot.
</p>
<dl>
<dt class="parameter">minWidth (int)</dt>
<dd>The starting/minimum face size (in pixel) that the algorithm is looking for.</dd>
<dt class="parameter">maxWidth (int)</dt>
<dd>The end/maximum face size (in pixel) that the algorithm is looking for.</dd>
<dt class="parameter">stepSize (int)</dt>
<dd>Minimum step size is 12, must be a multiple of 12 (12, 24, 36 etc.). By increasing the stepSize you skip detection layers and make the face detection less accurate, but perform faster.</dd>
<dt class="parameter">minMergeNeighbors (int)</dt>
<dd>Number of candidates (blue) necessary in one spot to merge all of them into a "detected face" (yellow).</dd>
</dl>
<a class="link_top" href="#hl_BRFManager">↑ top</a>
<br>
<br>
</div>
<div class="description">
<p class="function_name" id="setFaceDetectionRoi">setFaceDetectionRoi( Rectangle roi ) : void</p>
<p class="function_description">
Sets the region of interest, the area within the image data where the face detection shall do its work.
</p>
<dl>
<dt class="parameter">roi (Rectangle)</dt>
<dd>A rectangular area within the image.</dd>
</dl>
<a class="link_top" href="#hl_BRFManager">↑ top</a>
<br>
<br>
</div>
<div class="description">
<p class="function_name" id="getAllDetectedFaces">getAllDetectedFaces( ) : Vector<Rectangle></p>
<p class="function_description">
Returns all face candidates (blue) that were detected during the last update.
</p>
<a class="link_top" href="#hl_BRFManager">↑ top</a>
<br>
<br>
</div>
<div class="description">
<p class="function_name" id="getMergedDetectedFaces">getMergedDetectedFaces( ) : Vector<Rectangle></p>
<p class="function_description">
Returns all actual merged/detected faces (yellow) of the last update call.
</p>
<a class="link_top" href="#hl_BRFManager">↑ top</a>
<br>
<br>
</div>
<h4>(face tracking)</h4>
<div class="description">
<p class="function_name" id="setNumFacesToTrack">setNumFacesToTrack( int numFaces ) : void</p>
<p class="function_description">
By default BRFv4 sets the number of faces to track to 1 (single face tracking). To track more than one face
increase this value. Be aware that increasing the number of faces to track will hurt the performance with
every face you add.
</p>
<dl>
<dt class="parameter">numFaces (int)</dt>
<dd>The number of faces you want to track, usually 1.</dd>
</dl>
<a class="link_top" href="#hl_BRFManager">↑ top</a>
<br>
<br>
</div>
<div class="description">
<p class="function_name" id="setFaceTrackingStartParams">setFaceTrackingStartParams( double minWidth, double maxWidth, double rx, double ry, double rz ) : void</p>
<p class="function_description">
By setting these parameters you can control the conditions for picking up a face. Restrict the distance/range to
the camera by setting minWidth and maxWidth. Smaller values mean more distance to the camera. Restricting
the starting angles may help to create a consistent user experience.<br><br>
Keep the minWidth and maxWidth values about the same as for the params set in <b>setFaceDetectionParams()</b>;
</p>
<dl>
<dt class="parameter">minWidth (double)</dt>
<dd>A pixel based value. The minimum size a face must have to be picked up.</dd>
<dt class="parameter">maxWidth (double)</dt>
<dd>A pixel based value. The maximum size a face can have to be picked up.</dd>
<dt class="parameter">rx (double)</dt>
<dd>A degree angle. Rotation around the X axis (pitch, turning head up/down)</dd>
<dt class="parameter">ry (double)</dt>
<dd>A degree angle. Rotation around the Y axis (yaw, turning head to the left/right)</dd>
<dt class="parameter">rz (double)</dt>
<dd>A degree angle. Rotation around the Z axis (roll, tilt head to the left/right)</dd>
</dl>
<a class="link_top" href="#hl_BRFManager">↑ top</a>
<br>
<br>
</div>
<div class="description">
<p class="function_name" id="setFaceTrackingResetParams">setFaceTrackingResetParams( double minWidth, double maxWidth, double rx, double ry, double rz ) : void</p>
<p class="function_description">
By setting these parameters you can control the conditions for resetting the tracking of a face. If a face gets
smaller than minWidth or larger than maxWidth or if the head turns more than rx, ry, or rz, the tracking will reset.
</p>
<dl>
<dt class="parameter">minWidth (double)</dt>
<dd>A pixel based value. Faces smaller than this value will trigger a reset of the tracking.</dd>
<dt class="parameter">maxWidth (double)</dt>
<dd>A pixel based value. Faces larger than this value will trigger a reset of the tracking.</dd>
<dt class="parameter">rx (double)</dt>
<dd>A degree angle. Rotation around the X axis (pitch, turning head up/down).</dd>
<dt class="parameter">ry (double)</dt>
<dd>A degree angle. Rotation around the Y axis (yaw, turning head to the left/right)</dd>
<dt class="parameter">rz (double)</dt>
<dd>A degree angle. Rotation around the Z axis (roll, tilt head to the left/right)</dd>
</dl>
<a class="link_top" href="#hl_BRFManager">↑ top</a>
<br>
<br>
</div>
<div class="description">
<p class="function_name" id="getFaces">getFaces( ) : Vector<BRFFace></p>
<p class="function_description">
Returns the list of currently tracked faces. Please see <a href="#hl_BRFFace">BRFFace</a> for details.
</p>
<a class="link_top" href="#hl_BRFManager">↑ top</a>
<br>
<br>
</div>
<h4>(point tracking)</h4>
<div class="description">
<p class="function_name" id="setOpticalFlowParams">setOpticalFlowParams( int patchSize, int numLevels, int numIterations, double error ) : void</p>
<p class="function_description">
Optical Flow is a point tracking algorithm. It is used in BRFv4 to stabilize fast movements. You can perform
this point tracking either standalone by setting BRFMode.POINT_TRACKING or in parallel by setting either one of
the other two modes.
</p>
<dl>
<dt class="parameter">patchSize (int)</dt>
<dd>
This is the area around a point that is used to compare to the new image. Has to be an odd number.
Larger values will decrease performance. Lower values will decrease accuracy. 21 (10 pixels on in each direction)
is a good default value.
</dd>
<dt class="parameter">numLevels (int)</dt>
<dd>The number of pyramid levels to use. Either 1, 2, 3 or 4 (default). Lower values will decrease accuracy.</dd>
<dt class="parameter">numIterations (int)</dt>
<dd>The maximum number of iterations to perform the search.</dd>
<dt class="parameter">error (double)</dt>
<dd>Usually smaller than 0.0001. Higher values will decrease accuracy.</dd>
</dl>
<a class="link_top" href="#hl_BRFManager">↑ top</a>
<br>
<br>
</div>
<div class="description">
<p class="function_name" id="addOpticalFlowPoints">addOpticalFlowPoints( Vector<Point> pointArray ) : void</p>
<p class="function_description">
Adds new points to track. This should be done synchronously right before calling <b>update()</b>. If you call this method in the middle
of an update call, eg. by doing so in a click/touch handler, the tracking might get confused.
</p>
<dl>
<dt class="parameter">pointArray (Vector<Point>)</dt>
<dd>
A list of points to add to the optical flow tracking.
</dd>
</dl>
<a class="link_top" href="#hl_BRFManager">↑ top</a>
<br>
<br>
</div>
<div class="description">
<p class="function_name" id="getOpticalFlowCheckPointsValidBeforeTracking">getOpticalFlowCheckPointsValidBeforeTracking() : Boolean</p>
<p class="function_description">
Returns whether BRF will check the validity of points.
</p>
<a class="link_top" href="#hl_BRFManager">↑ top</a>
<br>
<br>
</div>
<div class="description">
<p class="function_name" id="setOpticalFlowCheckPointsValidBeforeTracking">setOpticalFlowCheckPointsValidBeforeTracking( Boolean value ) : void</p>
<p class="function_description">
Sets whether BRF will check the validity of points. In continuous point tracking there will be
points that fail to be tracked. Their state will be false after an update call. As a developer you can react
on failed points by checking the state. If you wish that BRF removes failed points right before the next
tracking, set this value to true. If you wish to handle the removal or resetting of points yourself, set
this value to false.
</p>
<dl>
<dt class="parameter">value (Boolean)</dt>
<dd>
true or false
</dd>
</dl>
<a class="link_top" href="#hl_BRFManager">↑ top</a>
<br>
<br>
</div>
<div class="description">
<p class="function_name" id="getOpticalFlowPoints">getOpticalFlowPoints() : Vector<Point></p>
<p class="function_description">
Returns all currently tracked points.
</p>
<a class="link_top" href="#hl_BRFManager">↑ top</a>
<br>
<br>
</div>
<div class="description">
<p class="function_name" id="getOpticalFlowPointStates">getOpticalFlowPointStates() : Vector<Boolean></p>
<p class="function_description">
Returns the states of all currently tracked points.
</p>
<a class="link_top" href="#hl_BRFManager">↑ top</a>
<br>
<br>
</div>
<div class="spacer"></div>
<h2>BRFFace</h2>
<div class="spacer"></div>
<div class="description">
<p>
BRFFace holds all information about a tracked face. BRFv4 is now able to track more than one face, so every
BRFFace has it's individual state. These states are being set automatically by BRFv4 depending on what it
currently does.
<br><br>
Compared to BRFv3 there was a change on how the vertices are laid out.<br><br>
<img src="assets/brfv4_landmarks.jpg" alt="BRFv4 landmarks." style="width: 480px; max-width: 100%;"/><br><br>
The origin for the 3D transformation (scale, translationX, translationY, rotationX, rotationY, rotationZ)
is right behind vertex index 27 (top of the nose). So if you want to put a 3D object or PNG file on top of a
tracked face you know exactly where to position it.
</p>
</div>
<div class="description">
<p class="function_name" id="lastState"><b>lastState (String)</b></p>
<p class="function_description">
The last state this face was in before calling update. See BRFState.
</p>
<a class="link_top" href="#hl_BRFFace">↑ top</a>
<br>
<br>
</div>
<div class="description">
<p class="function_name" id="state"><b>state (String)</b></p>
<p class="function_description">
The state this face is currently in. Either one of the following BRFStates:
</p>
<dl>
<dt class="parameter">BRFState.RESET</dt>
<dd>This face was reset because of a call to reset or because it exceeded the reset parameters.</dd>
<dt class="parameter">BRFState.FACE_DETECTION</dt>
<dd>BRFv4 is looking for a face, still nothing found.</dd>
<dt class="parameter">BRFState.FACE_TRACKING_START</dt>
<dd>
BRFv4 found a face and tries to align the face tracking to the identified face. In this state the candide3
model and 3D position might not be correct yet.
</dd>
<dt class="parameter">BRFState.FACE_TRACKING</dt>
<dd>BRFv4 aligned the face and is now tracking it.</dd>
</dl>
<a class="link_top" href="#hl_BRFFace">↑ top</a>
<br>
<br>
</div>
<div class="description">
<p class="function_name" id="nextState"><b>nextState (String)</b></p>
<p class="function_description">
The next thing BRF does with this faces. See BRFState.
</p>
<a class="link_top" href="#hl_BRFFace">↑ top</a>
<br>
<br>
</div>
<div class="description">
<p class="function_name" id="vertices"><b>vertices (float[])</b></p>
<p class="function_description">
A list of vertex positions in the form of [x, y, x, y, ..., x, y], length is therefore: 68 * 2<br><br>
<img src="assets/brfv4_landmarks.jpg" alt="BRFv4 landmarks." width="480" height="360"/><br><br>
Getting the position of a certain vertex would be like:
<br><br>
<b>var vx = vertices[index * 2];</b> // where index is eg. 27 for the top of the nose.<br>
<b>var vy = vertices[index * 2 + 1];</b><br>
</p>
<a class="link_top" href="#hl_BRFFace">↑ top</a>
<br>
<br>
</div>
<div class="description">
<p class="function_name" id="triangles"><b>triangles (int[])</b></p>
<p class="function_description">
The vertices can be connected and triangles can be formed.<br><br>This is the vertex index list for the triangles
int the following form: [i0, i1, i2, i0, i1, i2, ... , i0, i1, i2] where 3 indices span a triangle.
</p>
<a class="link_top" href="#hl_BRFFace">↑ top</a>
<br>
<br>
</div>
<div class="description">
<p class="function_name" id="points"><b>points (Vector<Point>)</b></p>
<p class="function_description">
Same as vertices, but a list of points in the form of [{x, y}, {x, y}, ..., {x, y}], length is therefore: 68
<br><br>
Getting the position of a certain point would be like:
<br><br>
<b>var px = points[index].x;</b> // where index is eg. 27 for the top of the nose.<br>
<b>var py = points[index].y;</b><br>
</p>
<a class="link_top" href="#hl_BRFFace">↑ top</a>
<br>
<br>
</div>
<div class="description">
<p class="function_name" id="bounds"><b>bounds (Rectangle)</b></p>
<p class="function_description">
This is the outline rectangle of all vertices.
</p>
<a class="link_top" href="#hl_BRFFace">↑ top</a>
<br>
<br>
</div>
<div class="description">
<p class="function_name" id="refRect"><b>refRect (Rectangle)</b></p>
<p class="function_description">
This is the reference rectangle that the face tracking algorithm uses to perform the tracking.
</p>
<a class="link_top" href="#hl_BRFFace">↑ top</a>
<br>
<br>
</div>
<div class="description">
<p class="function_name" id="candideVertices"><b>candideVertices (float[])</b></p>
<p class="function_description">
The candide 3 model vertices. Can be used to visualize the 3D position, scaling and rotation.
</p>
<a class="link_top" href="#hl_BRFFace">↑ top</a>
<br>
<br>
</div>
<div class="description">
<p class="function_name" id="candideTriangles"><b>candideTriangles (int[])</b></p>
<p class="function_description">
Triangle list to be able to draw the candide 3 model.
</p>
<a class="link_top" href="#hl_BRFFace">↑ top</a>
<br>
<br>
</div>
<div class="description">
<p class="function_name" id="scale"><b>scale (float)</b></p>
<p class="function_description">
The scale of the whole face.
</p>
<a class="link_top" href="#hl_BRFFace">↑ top</a>
<br>
<br>
</div>
<div class="description">
<p class="function_name" id="translationX"><b>translationX (float)</b></p>
<p class="function_description">
The x position of the origin of face on the image. The origin is right behind vertex index 27 (top of the nose).
</p>
<a class="link_top" href="#hl_BRFFace">↑ top</a>
<br>
<br>
</div>
<div class="description">
<p class="function_name" id="translationY"><b>translationY (float)</b></p>
<p class="function_description">
The y position of the origin of face on the image. The origin is right behind vertex index 27 (top of the nose).
</p>
<a class="link_top" href="#hl_BRFFace">↑ top</a>
<br>
<br>
</div>
<div class="description">
<p class="function_name" id="rotationX"><b>rotationX (float)</b></p>
<p class="function_description">
A radian angle. Rotation around the X axis (pitch, turning head up/down)
</p>
<a class="link_top" href="#hl_BRFFace">↑ top</a>
<br>
<br>
</div>
<div class="description">
<p class="function_name" id="rotationY"><b>rotationY (float)</b></p>
<p class="function_description">
A radian angle. Rotation around the Y axis (yaw, turning head to the left/right)
</p>
<a class="link_top" href="#hl_BRFFace">↑ top</a>
<br>
<br>
</div>
<div class="description">
<p class="function_name" id="rotationZ"><b>rotationZ (float)</b></p>
<p class="function_description">
A radian angle. Rotation around the Z axis (roll, tilt head to the left/right)
</p>
<a class="link_top" href="#hl_BRFFace">↑ top</a>
<br>
<br>
</div>
<div class="spacer"></div>
<h2>BRFMode</h2>
<div class="spacer"></div>
<div class="description">
<p>
BRFv4 can operate in either of the following modes.
</p>
</div>
<div class="description">
<p class="function_name" id="mode_FACE_DETECTION"><b>FACE_DETECTION (String)</b></p>
<p class="function_description">
Set this mode if you want to skip the face tracking part and only detect face rectangles. Point tracking can
also be done synchronously.
</p>
<a class="link_top" href="#hl_BRFMode">↑ top</a>
<br>
<br>
</div>
<div class="description">
<p class="function_name" id="mode_FACE_TRACKING"><b>FACE_TRACKING (String)</b></p>
<p class="function_description">
Set this mode if you want the full face detection and face tracking. Point tracking can
also be done synchronously.
</p>
<a class="link_top" href="#hl_BRFMode">↑ top</a>
<br>
<br>
</div>
<div class="description">
<p class="function_name" id="mode_POINT_TRACKING"><b>POINT_TRACKING (String)</b></p>
<p class="function_description">
Set this mode if you want to skip face detection and face tracking and only track points.
</p>
<a class="link_top" href="#hl_BRFMode">↑ top</a>
<br>
<br>
</div>
<div class="spacer"></div>
<h2>BRFState</h2>
<div class="spacer"></div>
<div class="description">
<p>
A BRFFace can be in one of the following states.
</p>
</div>
<div class="description">
<p class="function_name" id="state_FACE_DETECTION"><b>FACE_DETECTION (String)</b></p>
<p class="function_description">
The BRFFace tried to initially detect a face in the image data.
</p>
<a class="link_top" href="#hl_BRFState">↑ top</a>
<br>
<br>
</div>
<div class="description">
<p class="function_name" id="state_FACE_TRACKING_START"><b>FACE_TRACKING_START (String)</b></p>
<p class="function_description">
The BRFFace found a face in the image data and tries to align the face tracking.
</p>
<a class="link_top" href="#hl_BRFState">↑ top</a>
<br>
<br>
</div>
<div class="description">
<p class="function_name" id="state_FACE_TRACKING"><b>FACE_TRACKING (String)</b></p>
<p class="function_description">
The BRFFace is tracking the face in the image data.
</p>
<a class="link_top" href="#hl_BRFState">↑ top</a>
<br>
<br>
</div>
<div class="description">
<p class="function_name" id="state_RESET"><b>RESET (String)</b></p>
<p class="function_description">
The BRFFace triggered a reset, either because of a call to <b>BRFManager.reset()</b> or because
it exceeds the reset parameters set in <b>BRFManager.setFaceTrackingResetParams()</b>;
</p>
<a class="link_top" href="#hl_BRFState">↑ top</a>
<br>
<br>
</div>
<div class="spacer"></div>
</div>
</body>
</html>