├── .gitignore ├── assets ├── brfv4_landmarks.jpg └── wcidwi │ ├── color_libs.jpg │ ├── face_texture.jpg │ ├── glasses_3d.jpg │ ├── mask_overlay.jpg │ ├── extended_shape.jpg │ ├── point_tracking.jpg │ ├── yawn_detection.jpg │ ├── blink_detection.jpg │ ├── candide_overlay.jpg │ ├── face_detection_1.jpg │ ├── face_detection_2.jpg │ ├── face_detection_3.jpg │ ├── face_detection_4.jpg │ ├── face_tracking_0.jpg │ ├── face_tracking_1.jpg │ ├── glasses_overlay.jpg │ ├── smile_detection.jpg │ └── point_face_tracking.jpg ├── README.md ├── css └── docs.css ├── what_can_i_do_with_it.html └── index.html /.gitignore: -------------------------------------------------------------------------------- 1 | /.idea/ 2 | -------------------------------------------------------------------------------- /assets/brfv4_landmarks.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tastenkunst/brfv4_docs/HEAD/assets/brfv4_landmarks.jpg -------------------------------------------------------------------------------- /assets/wcidwi/color_libs.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tastenkunst/brfv4_docs/HEAD/assets/wcidwi/color_libs.jpg -------------------------------------------------------------------------------- /assets/wcidwi/face_texture.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tastenkunst/brfv4_docs/HEAD/assets/wcidwi/face_texture.jpg -------------------------------------------------------------------------------- /assets/wcidwi/glasses_3d.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tastenkunst/brfv4_docs/HEAD/assets/wcidwi/glasses_3d.jpg -------------------------------------------------------------------------------- /assets/wcidwi/mask_overlay.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tastenkunst/brfv4_docs/HEAD/assets/wcidwi/mask_overlay.jpg -------------------------------------------------------------------------------- /assets/wcidwi/extended_shape.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tastenkunst/brfv4_docs/HEAD/assets/wcidwi/extended_shape.jpg -------------------------------------------------------------------------------- /assets/wcidwi/point_tracking.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tastenkunst/brfv4_docs/HEAD/assets/wcidwi/point_tracking.jpg -------------------------------------------------------------------------------- /assets/wcidwi/yawn_detection.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tastenkunst/brfv4_docs/HEAD/assets/wcidwi/yawn_detection.jpg -------------------------------------------------------------------------------- /assets/wcidwi/blink_detection.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tastenkunst/brfv4_docs/HEAD/assets/wcidwi/blink_detection.jpg -------------------------------------------------------------------------------- /assets/wcidwi/candide_overlay.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tastenkunst/brfv4_docs/HEAD/assets/wcidwi/candide_overlay.jpg -------------------------------------------------------------------------------- /assets/wcidwi/face_detection_1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tastenkunst/brfv4_docs/HEAD/assets/wcidwi/face_detection_1.jpg -------------------------------------------------------------------------------- /assets/wcidwi/face_detection_2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tastenkunst/brfv4_docs/HEAD/assets/wcidwi/face_detection_2.jpg -------------------------------------------------------------------------------- /assets/wcidwi/face_detection_3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tastenkunst/brfv4_docs/HEAD/assets/wcidwi/face_detection_3.jpg -------------------------------------------------------------------------------- /assets/wcidwi/face_detection_4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tastenkunst/brfv4_docs/HEAD/assets/wcidwi/face_detection_4.jpg -------------------------------------------------------------------------------- /assets/wcidwi/face_tracking_0.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tastenkunst/brfv4_docs/HEAD/assets/wcidwi/face_tracking_0.jpg -------------------------------------------------------------------------------- /assets/wcidwi/face_tracking_1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tastenkunst/brfv4_docs/HEAD/assets/wcidwi/face_tracking_1.jpg -------------------------------------------------------------------------------- /assets/wcidwi/glasses_overlay.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tastenkunst/brfv4_docs/HEAD/assets/wcidwi/glasses_overlay.jpg -------------------------------------------------------------------------------- /assets/wcidwi/smile_detection.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tastenkunst/brfv4_docs/HEAD/assets/wcidwi/smile_detection.jpg -------------------------------------------------------------------------------- /assets/wcidwi/point_face_tracking.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tastenkunst/brfv4_docs/HEAD/assets/wcidwi/point_face_tracking.jpg -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Beyond Reality Face SDK - v4.0.0 (BRFv4) - Docs 2 | 3 | + [Docs / API](https://tastenkunst.github.io/brfv4_docs/) 4 | 5 | ##### Other links: 6 | 7 | + [Github](https://github.com/Tastenkunst) 8 | + [Demo](https://tastenkunst.github.io/brfv4_javascript_examples/) 9 | + [What can I do with it?](https://tastenkunst.github.io/brfv4_docs/what_can_i_do_with_it.html) 10 | + [Website](https://www.beyond-reality-face.com) 11 | + [Facebook](https://www.facebook.com/BeyondRealityFace) 12 | + [Twitter](https://twitter.com/tastenkunst) 13 | -------------------------------------------------------------------------------- /css/docs.css: -------------------------------------------------------------------------------- 1 | 2 | /* widths and heights */ 3 | 4 | html, body { width: 100%; height: calc(100% - 10px); } 5 | div { width: calc(100% - 10px); max-width: 980px; display: block; } 6 | h1, h2, h3, h4 { max-width: 980px; } 7 | figure { width: calc(50% - 10px); max-width: 640px; } 8 | figure > img { width: 100%; } 9 | figcaption { width: 100%; } 10 | .spacer { width: calc(100% - 10px); min-height: 28px; } 11 | .description { width: calc(100% - 10px); min-height: 28px; position: relative; } 12 | 13 | @media screen and (max-width: 640px) { 14 | figure { width: calc(100% - 10px); } 15 | } 16 | 17 | #wrapper { max-width: 1000px;} 18 | 19 | /* margin and padding */ 20 | 21 | * { margin: 0; padding: 0; } 22 | 23 | #wrapper { margin-top: 0; margin-bottom: 0; margin-left: auto; margin-right: auto; } 24 | div { margin: 5px; } 25 | h1, h2, h3, h4 { margin: 5px; padding-top: 5px; padding-bottom: 5px; } 26 | p { padding: 10px; } 27 | dt { margin-top: 15px; margin-left: 15px; } 28 | dd { margin-top: 5px; margin-left: 30px; margin-right: 10px; } 29 | figure { margin: 5px; float: left; } 30 | .menu { padding-top: 4px; padding-bottom: 4px; } 31 | 32 | .clear_float { clear: both; } 33 | 34 | /* background colors */ 35 | 36 | html, body { background-color: #ffffff; } 37 | h1, h2, h3, h4 { background-color: #fafafa; } 38 | .images { background-color: #fafafa; } 39 | .spacer { background-color: #fafafa; } 40 | .white { background-color: #ffffff; } 41 | .description { background-color: #e7e7e7; } 42 | .description p:nth-child(odd) { background-color: #e7e7e7; } 43 | .description p:nth-child(even) { background-color: #fafafa; } 44 | .function_name { background-color: #f1f1f1; } 45 | 46 | /* fonts stuff */ 47 | 48 | 49 | 50 | html, body { font-family: Arial, sans-serif; text-align: justify; font-size: 16px; color: #000000; } 51 | 52 | a { text-decoration: none; color: #005f9c; } 53 | .description > a { position: relative; top: 8px; left: calc(50% - 17px); } 54 | 55 | h1, h2, h3, h4 { text-align: center; color: #005f9c; } 56 | figcaption { text-align: center; } 57 | p { text-align: justify; } 58 | 59 | .function_name { font-style: italic; font-weight: bold; } 60 | .parameter { font-style: italic; } 61 | .functionlist a { font-style: italic; } 62 | h4 { font-style: italic; } 63 | 64 | .menu { text-align: center; font-weight: bold; width: 100%; height: 60px; padding-top: 42px;} 65 | 66 | #logo { position: absolute; top: 0; left: 0; width: 160px; } 67 | #img_logo { width: 160px; } -------------------------------------------------------------------------------- /what_can_i_do_with_it.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 |
23 | 32 | Beyond Reality Face is a multi face tracker. It detects faces and tracks them continuously. It is a two step 33 | process using face detection and face tracking. This page shows what you can do with BRFv4 and what results 34 | to expect from each step. 35 |
36 |44 | It scans the image systematically to detect faces. A found candidate is marked by a (blue) rectangle. This 45 | produces lots of candidates and if enough (blue) rectangles are located in the same spot, this spot is marked 46 | as an actual found face by merging the blue rectangles into a yellow one. 47 |
48 |
53 |
57 |
61 |
65 | 72 | A merged (yellow) rectangle is used as a starting point for the actual face tracking. 73 |
74 |82 | A detected face is being analysed in detail and provides facial data: 68 facial landmarks, eg. the location of 83 | eyes, eyebrows, nose and mouth, also the 3D position, scale and rotation. 84 |
85 |
90 |
94 |
98 |
102 | 110 | These 68 facial landmarks may be utilized in many different ways, eg. ... 111 |
112 |
117 |
121 |
125 |
129 | 137 | ... or for a bit more advanced stuff, like ... 138 |
139 |
144 |
148 |
152 |
156 | 167 | Apart from tracking the face you can also track points. 168 |
169 |
174 |
178 |
16 |
32 | The BRFv4 API is the same on all platforms. Everything described on this page can be applied to Javascript, Actionscript 3 or C++.
33 | Before you read this API, please take a look at what you can do with BRFv4, especially what results to expect from
34 | face detection and face tracking (link: What can I do with it?).
35 | There are two main classes: BRFManager and BRFFace.
36 | Going forward "roi" means "region of interest", the rectangular area of an image an algorithm works in.
37 |
init( Rectangle imageDataSize, Rectangle imageRoi, String appId ) : void
49 | 50 | 51 | 52 | 53 |setFaceDetectionParams( int minWidth, int maxWidth, int stepSize, int minMergeNeighbors ) : void
60 |setFaceDetectionRoi( Rectangle roi ) : void
61 | 62 | 63 |setOpticalFlowParams( int patchSize, int numLevels, int numIterations, double error ) : void
80 |addOpticalFlowPoints( Vector<Point> pointArray ) : void
81 |getOpticalFlowCheckPointsValidBeforeTracking() : Boolean
82 |setOpticalFlowCheckPointsValidBeforeTracking( Boolean value ) : void
83 | 84 | 85 |
154 | BRFManager controls everything. First you need to call:
155 |
156 |
157 | init( ... )
158 |
159 |
160 | Based on the image size the SDK sets reasonable default parameters to start tracking a single face,
161 | but you can change any parameter once BRFv4 is ready. Keep in mind that most parameters are pixel values
162 | and you need to adjust parameters based on the image data size that you put in, eg.
163 |
164 |
165 | setFaceDetectionParams( int minWidth, int maxWidth, int stepSize, int minMergeNeighbors ) : void
166 |
167 |
168 | If you use a 640x480 camera resolution the trackable face size is 480 pixel at maximum.
A reasonable minimum would be 25% of
169 | that max size, which is 120 pixel.
170 |
171 |
172 | For a 1920x1080 resolution the trackable face size is 1080 pixel and 25% of that is 270 pixel.
173 |
174 |
175 | That's why the examples use percentages for all areas and sizes. This makes sure that the camera resolution can easily be changed.
176 |
177 |
178 | Once everything is set up you need to update the image data before calling:
179 |
180 |
181 | update( ... )
182 |
183 |
184 | BRFv4 tries to detect a face. If a face was detected BRFv4 immediately starts the face tracking based on it.
185 |
186 |
187 | Face Detection operates globally. That's why BRFManager and not BRFFace got the result functions:
188 |
189 |
190 | getAllDetectedFaces() : Vector<Rectangle>
191 | getMergedDetectedFaces() : Vector<Rectangle>
192 |
193 |
194 | The detailed face tracking data can be retrieved by calling:
195 |
196 |
197 | getFaces() : Vector<BRFFace>
198 |
199 | which gives you a list of BRFFaces with a length based on your setting of:
200 |
201 |
202 | setNumFacesToTrack( int numFaces )
203 |
204 |
205 | And that's all about it. Init, set parameters, and continuously update.
206 | For more information about the implementation details for your specific platform, see the sample packages.
207 |
init( Rectangle imageDataSize, Rectangle imageRoi, String appId ) : void
215 |
216 | This function is the starting point.
217 |
218 |
219 | It tells BRFv4 what image data size it should expect, on which area to operate and what your appId is.
220 |
221 | If you want to switch the image data and thus need to change the image data size, just call init() again
222 | to reinit BRFv4.
Don't create a new BRFManager! Reuse a single instance.
223 |
224 | When you first call init() a license check is performed. It's a single server call. If it fails in the trial version
225 | BRFv4 will stop working after about 1 to 2 minutes. The commercial version is fail safe,
226 | which means that even if no connection to the license server can be established, BRFv4 will still work.
227 | Apart from that BRFv4 works fully on the client side.
228 |
update( Bitmap imageData ) : void
254 |
255 | This function does the tracking job. It operates in either of the three BRFModes.
256 |
257 |
258 | In C++ implementations, eg. OpenCV (camera handling) or iOS, you need to update the imageData on your own before calling update.
259 |
260 |
261 | All other platforms have their known image containers and BRFv4 is already set up to deal with those.
262 |
263 |
264 | The results can be retrieved after calling update() as arrays of Rectangle or BRFFace:
265 |
266 |
267 | getAllDetectedFaces() : Vector<Rectangle>
268 | getMergedDetectedFaces() : Vector<Rectangle>
269 | getFaces() : Vector<BRFFace>
270 |
reset() : void
285 |286 | All face trackers reset and start over by performing face detection. Also all point tracking points are removed. 287 |
288 | ↑ top 289 |getMode() : String
296 |297 | Returns the BRFMode that is currently set. 298 |
299 | ↑ top 300 |setMode(String mode) : void
307 |308 | Sets one of the three modes from BRFMode: 309 |
310 | 311 |setFaceDetectionParams( int minWidth, int maxWidth, int stepSize, int minMergeNeighbors ) : void
338 |
339 | Internally BRFv4 uses a DYNx480 (landscape) or 480xDYN (portrait) image for it's analysis. So 480px is the
340 | base size that every other input size compares to (eg. 1280x720 -> 854x480).
341 |
342 |
343 | The minimum detectable face size for the following resolutions are:
344 |
351 | Also: faces (blue) are only detected at step sizes multiple of 12.
352 | So the actual face detection layers (sizes) are:
353 |
361 | Detected faces (blue) get merged (yellow) if they are
362 | + roughly placed in the same location,
363 | + roughly the same size and
364 | + have at least minMergeNeighbors of other rectangle in the same spot.
365 |
setFaceDetectionRoi( Rectangle roi ) : void
387 |388 | Sets the region of interest, the area within the image data where the face detection shall do its work. 389 |
390 |getAllDetectedFaces( ) : Vector<Rectangle>
402 |403 | Returns all face candidates (blue) that were detected during the last update. 404 |
405 | ↑ top 406 |getMergedDetectedFaces( ) : Vector<Rectangle>
413 |414 | Returns all actual merged/detected faces (yellow) of the last update call. 415 |
416 | ↑ top 417 |setNumFacesToTrack( int numFaces ) : void
426 |427 | By default BRFv4 sets the number of faces to track to 1 (single face tracking). To track more than one face 428 | increase this value. Be aware that increasing the number of faces to track will hurt the performance with 429 | every face you add. 430 |
431 |setFaceTrackingStartParams( double minWidth, double maxWidth, double rx, double ry, double rz ) : void
443 |
444 | By setting these parameters you can control the conditions for picking up a face. Restrict the distance/range to
445 | the camera by setting minWidth and maxWidth. Smaller values mean more distance to the camera. Restricting
446 | the starting angles may help to create a consistent user experience.
447 | Keep the minWidth and maxWidth values about the same as for the params set in setFaceDetectionParams();
448 |
setFaceTrackingResetParams( double minWidth, double maxWidth, double rx, double ry, double rz ) : void
469 |470 | By setting these parameters you can control the conditions for resetting the tracking of a face. If a face gets 471 | smaller than minWidth or larger than maxWidth or if the head turns more than rx, ry, or rz, the tracking will reset. 472 |
473 |getFaces( ) : Vector<BRFFace>
493 |494 | Returns the list of currently tracked faces. Please see BRFFace for details. 495 |
496 | ↑ top 497 |setOpticalFlowParams( int patchSize, int numLevels, int numIterations, double error ) : void
506 |507 | Optical Flow is a point tracking algorithm. It is used in BRFv4 to stabilize fast movements. You can perform 508 | this point tracking either standalone by setting BRFMode.POINT_TRACKING or in parallel by setting either one of 509 | the other two modes. 510 |
511 |addOpticalFlowPoints( Vector<Point> pointArray ) : void
533 |534 | Adds new points to track. This should be done synchronously right before calling update(). If you call this method in the middle 535 | of an update call, eg. by doing so in a click/touch handler, the tracking might get confused. 536 |
537 |getOpticalFlowCheckPointsValidBeforeTracking() : Boolean
551 |552 | Returns whether BRF will check the validity of points. 553 |
554 | ↑ top 555 |setOpticalFlowCheckPointsValidBeforeTracking( Boolean value ) : void
562 |563 | Sets whether BRF will check the validity of points. In continuous point tracking there will be 564 | points that fail to be tracked. Their state will be false after an update call. As a developer you can react 565 | on failed points by checking the state. If you wish that BRF removes failed points right before the next 566 | tracking, set this value to true. If you wish to handle the removal or resetting of points yourself, set 567 | this value to false. 568 |
569 |getOpticalFlowPoints() : Vector<Point>
583 |584 | Returns all currently tracked points. 585 |
586 | ↑ top 587 |getOpticalFlowPointStates() : Vector<Boolean>
594 |595 | Returns the states of all currently tracked points. 596 |
597 | ↑ top 598 |
612 | BRFFace holds all information about a tracked face. BRFv4 is now able to track more than one face, so every
613 | BRFFace has it's individual state. These states are being set automatically by BRFv4 depending on what it
614 | currently does.
615 |
616 | Compared to BRFv3 there was a change on how the vertices are laid out.
617 | 
618 | The origin for the 3D transformation (scale, translationX, translationY, rotationX, rotationY, rotationZ)
619 | 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
620 | tracked face you know exactly where to position it.
621 |
lastState (String)
627 |628 | The last state this face was in before calling update. See BRFState. 629 |
630 | ↑ top 631 |state (String)
638 |639 | The state this face is currently in. Either one of the following BRFStates: 640 |
641 |nextState (String)
665 |666 | The next thing BRF does with this faces. See BRFState. 667 |
668 | ↑ top 669 |vertices (float[])
676 |
677 | A list of vertex positions in the form of [x, y, x, y, ..., x, y], length is therefore: 68 * 2
678 | 
679 | Getting the position of a certain vertex would be like:
680 |
681 | var vx = vertices[index * 2]; // where index is eg. 27 for the top of the nose.
682 | var vy = vertices[index * 2 + 1];
683 |
triangles (int[])
692 |
693 | The vertices can be connected and triangles can be formed.
This is the vertex index list for the triangles
694 | int the following form: [i0, i1, i2, i0, i1, i2, ... , i0, i1, i2] where 3 indices span a triangle.
695 |
points (Vector<Point>)
704 |
705 | Same as vertices, but a list of points in the form of [{x, y}, {x, y}, ..., {x, y}], length is therefore: 68
706 |
707 | Getting the position of a certain point would be like:
708 |
709 | var px = points[index].x; // where index is eg. 27 for the top of the nose.
710 | var py = points[index].y;
711 |
bounds (Rectangle)
720 |721 | This is the outline rectangle of all vertices. 722 |
723 | ↑ top 724 |refRect (Rectangle)
731 |732 | This is the reference rectangle that the face tracking algorithm uses to perform the tracking. 733 |
734 | ↑ top 735 |candideVertices (float[])
742 |743 | The candide 3 model vertices. Can be used to visualize the 3D position, scaling and rotation. 744 |
745 | ↑ top 746 |candideTriangles (int[])
753 |754 | Triangle list to be able to draw the candide 3 model. 755 |
756 | ↑ top 757 |scale (float)
764 |765 | The scale of the whole face. 766 |
767 | ↑ top 768 |translationX (float)
775 |776 | The x position of the origin of face on the image. The origin is right behind vertex index 27 (top of the nose). 777 |
778 | ↑ top 779 |translationY (float)
786 |787 | The y position of the origin of face on the image. The origin is right behind vertex index 27 (top of the nose). 788 |
789 | ↑ top 790 |rotationX (float)
797 |798 | A radian angle. Rotation around the X axis (pitch, turning head up/down) 799 |
800 | ↑ top 801 |rotationY (float)
808 |809 | A radian angle. Rotation around the Y axis (yaw, turning head to the left/right) 810 |
811 | ↑ top 812 |rotationZ (float)
819 |820 | A radian angle. Rotation around the Z axis (roll, tilt head to the left/right) 821 |
822 | ↑ top 823 |835 | BRFv4 can operate in either of the following modes. 836 |
837 |FACE_DETECTION (String)
842 |843 | Set this mode if you want to skip the face tracking part and only detect face rectangles. Point tracking can 844 | also be done synchronously. 845 |
846 | ↑ top 847 |FACE_TRACKING (String)
854 |855 | Set this mode if you want the full face detection and face tracking. Point tracking can 856 | also be done synchronously. 857 |
858 | ↑ top 859 |POINT_TRACKING (String)
866 |867 | Set this mode if you want to skip face detection and face tracking and only track points. 868 |
869 | ↑ top 870 |882 | A BRFFace can be in one of the following states. 883 |
884 |FACE_DETECTION (String)
889 |890 | The BRFFace tried to initially detect a face in the image data. 891 |
892 | ↑ top 893 |FACE_TRACKING_START (String)
900 |901 | The BRFFace found a face in the image data and tries to align the face tracking. 902 |
903 | ↑ top 904 |FACE_TRACKING (String)
911 |912 | The BRFFace is tracking the face in the image data. 913 |
914 | ↑ top 915 |RESET (String)
922 |923 | The BRFFace triggered a reset, either because of a call to BRFManager.reset() or because 924 | it exceeds the reset parameters set in BRFManager.setFaceTrackingResetParams(); 925 |
926 | ↑ top 927 |