aframe-components

head-tracking components

Overview

An experimental set of components that use Google Mediapipe Face Detection.

Intended for use in desktop and mobile, not in VR.

face-detector

Simple A-Frame wrapper around Google Mediapipe’s faceDetector

head-tracker

Component that analyzes data generated by face-detector and maintains a position vector indicating the position of the user’s head (specifically the mid-point between their eyes), relative to a WebCam.

Only works with a single face.

window-camera

Highly experimental component that tries to use data head-tracker to adjust the camera feed, so that the screen of a laptop or desktop computer appears to be a window into a 3D world.

Schemas

face-detector

No schema - currently no configuration parameters

head-tracker

Property Description Default
cameraFov The horizontal field of view of the webCam, in degrees. Should be set to the correct value for accurate estimation of head position 60
ipd The user’s inter-pupil distance (in meters). This is used to determine the distance of the head from the camera, by comparing the observed with to this value 0.07
stabilizationFactor To stabilize the reported position, head-tracker uses an Exponential Moving Average for the estimated head position. This is the proportion of the weight, each frame, that comes from the preceding values rather than the latest value.
High values will give stable positions, at the cost of some lag.
Low values will be more responsive, but also jerkier.
0.9
debug Set to true to display a box at the estimate head position, with text indicating the computed x, y & z co-ordinates false
defaultPosition Default position of head, relative to web camera 0 0 0.75

window-camera

This component is highly experiemental, and this schema is likely to change in future.

Property Description Default
screenHeight The physical height of the screen display. Should be set to the correct value for an accurate window effect. 0.2
webCamPosition The position of the webCam relative to the screen center. The webCam is assumed to face directly out from the screen {x: 0, y: 0.1, z: 0}
screenOffset This is the offset of the screen in world space, relative to the initial camera position. This is assumed to be an offset along the z axis only (i.e. the scene camera must be a fixed camera pointing along the z-axis when the scene is initialized). With an FOV of 50, and screen height of 0.2m, this will be this will be (0.2 / tan(25)) = 0.43m. 0.43
debug Set to true to display a panel of data updating in realtime about the camera set-up. false

Examples

See a basic demo of head-tracker here

Examples of window-camera as follows:

Code

head-tracking