# JSDoc: Class: FaceDetector

# Class: FaceDetector

## visual.FaceDetector(options, @param, @param)

#### new FaceDetector(options, @param, @param)

This manager handles the detecting of faces in video streams. FaceDetector relies on the Face-API library developed by Vincent Muehler

##### Parameters:

Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---

`options`

Object

###### Properties

Name | Type | Description
--- | --- | ---
`name` | String | the name used when logging messages from the detector

`@param` | module:core.Window |  |  | options.win - the associated Window
`@param` | string | HTMLVideoElement | module:visual.Camera |  |  | input - the name of a movie resource or of a HTMLVideoElement or of a Camera component
`options.faceApiUrl` | string | <optional> | 'face-api.js' | the Url of the face-api library
`options.modelDir` | string | <optional> | 'models' | the directory where to find the face detection models
`options.units` | string | <optional> | "norm" | the units of the stimulus (e.g. for size, position, vertices)
`options.pos` | Array.<number> | <optional> | [0, 0] | the position of the center of the stimulus
`options.units` | string | <optional> | 'norm' | the units of the stimulus vertices, size and position
`options.ori` | number | <optional> | 0.0 | the orientation (in degrees)
`options.size` | number | <optional> |  | the size of the rendered image (the size of the image will be used if size is not specified)
`options.opacity` | number | <optional> | 1.0 | the opacity
`options.autoDraw` | boolean | <optional> | false | whether or not the stimulus should be automatically drawn on every frame flip
`options.autoLog` | boolean | <optional> | false | whether or not to log

Source:
  - visual/FaceDetector.js, line 19

### Methods

#### (protected) _estimateBoundingBox()

Estimate the bounding box.

Source:
  - visual/FaceDetector.js, line 309

#### (protected) _initFaceApi()

Init the Face-API library.

Source:
  - visual/FaceDetector.js, line 215

#### (protected) _updateIfNeeded()

Update the visual representation of the detected faces, if necessary.

Source:
  - visual/FaceDetector.js, line 245

#### isReady() → {boolean}

Query whether or not the face detector is ready to detect.

Source:
  - visual/FaceDetector.js, line 68

##### Returns:

whether or not the face detector is ready to detect

Type
  boolean

#### setCamera(input, logopt)

Setter for the video attribute.

##### Parameters:

Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`input` | string | HTMLVideoElement | module:visual.Camera |  |  | the name of a movie resource or a HTMLVideoElement or a Camera component
`log` | boolean | <optional> | false | whether of not to log

Source:
  - visual/FaceDetector.js, line 82

#### start(period, detectionCallback, logopt)

Start detecting faces.

##### Parameters:

Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`period` | number |  |  | the detection period, in ms (e.g. 100 ms for 10Hz)
`detectionCallback` |  |  |  | the callback triggered when detection results are available
`log` | boolean | <optional> | false | whether of not to log

Source:
  - visual/FaceDetector.js, line 156

#### stop(logopt)

Stop detecting faces.

##### Parameters:

Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`log` | boolean | <optional> | false | whether of not to log

Source:
  - visual/FaceDetector.js, line 195