Skip to content

Face Detection ​

Instance declaration ​

When you add a Face Detection block to the workspace, the following instance declaration is automatically inserted into the Python code:

python
face_detection = FaceDetection(0)
# When there are multiple instances
face_detection_1 = FaceDetection(1)

Parameters ​

NameKindDescriptionRange / TypeDefault
indexDropdown optionInstance number (starting from 0)Integer 0 or greater0

Select the camera device ​

Sets the camera to use for face detection.

device

Parameters ​

NameKindDescriptionRange / TypeDefault
unitDropdown optionCamera device nameSystem camera label-

Python ​

python
face_detection = FaceDetection(0)

face_detection.device('')

Load the model ​

Loads the trained face model. This step is required in order to use the features of the 'Face Detection' module.

load_model

Parameters ​

NameKindDescriptionRange / TypeDefault
waitCheckboxWhether to wait for loading to completeTRUE / FALSETRUE

Python ​

python
face_detection = FaceDetection(0)

face_detection.load_model(wait=True)

Detect once ​

Finds the faces currently on screen and marks them just once.

detect_once

Parameters ​

(none)

Python ​

python
face_detection = FaceDetection(0)

face_detection.detect_once()

Start / stop continuous detection ​

Keeps following the faces currently on screen and marks them on the screen.

detect_continuous

Parameters ​

NameKindDescriptionRange / TypeDefault
unitDropdown optionActionstart, stop-

Python ​

python
face_detection = FaceDetection(0)

# unit = "start"
face_detection.detect_continuous()
# unit = "stop"
face_detection.stop()

Show the detection result ​

Decides whether or not to show the face detection result on the camera screen.

display

Parameters ​

NameKindDescriptionRange / TypeDefault
onDropdown optionDisplay ON / OFFshow (on=True), hide (off=False)TRUE

Python ​

python
face_detection = FaceDetection(0)

face_detection.display(True)
face_detection.display(False)

Position of a face part ​

Returns the position coordinate of the face or of a face part.

face_data

Parameters ​

NameKindDescriptionRange / TypeDefault
unitDropdown optionFace partface, left eye, right eye, left ear, right ear, nose, mouth-
posDropdown optionKind of coordinatex, y-

Python ​

python
face_detection = FaceDetection(0)

face_detection.face('x')
face_detection.left_eye('y')
face_detection.right_eye('x')
face_detection.left_ear('x')
face_detection.right_ear('y')
face_detection.nose('x')
face_detection.mouth('y')

Face rectangle information ​

Returns the position/size values of the rectangle around the face region.

face_square

Parameters ​

NameKindDescriptionRange / TypeDefault
posDropdown optionRectangle informationmin x position (min_x), max x position (max_x), min y position (min_y), max y position (max_y), width, height, area-

Python ​

python
face_detection = FaceDetection(0)

face_detection.face('min_x')
face_detection.face('width')
face_detection.face('area')

Distance between two parts ​

Returns the distance between two parts of the face.

distance

Parameters ​

NameKindDescriptionRange / TypeDefault
unit1Dropdown optionFirst partface, left_eye, right_eye, left_ear, right_ear, nose, mouth-
unit2Dropdown optionSecond partface, left_eye, right_eye, left_ear, right_ear, nose, mouth-
typeDropdown optionKind of distancedistance (omitted or None), horizontal distance (horizontal), vertical distance (vertical)None

Python ​

python
face_detection = FaceDetection(0)

face_detection.get_distance('left_eye', 'right_eye')  # distance
face_detection.get_distance('left_eye', 'right_eye', 'horizontal')  # horizontal distance
face_detection.get_distance('nose', 'mouth', 'vertical')  # vertical distance

Model state ​

Returns the loading state of the face model.
It returns 0 if it has not been loaded yet, 1 while it is loading, and 2 once loading is complete.

model_state

Parameters ​

(none)

Python ​

python
face_detection = FaceDetection(0)

face_detection.model_state()

Whether a face was detected ​

Whether a face was found

detected

Parameters ​

(none)

Python ​

python
face_detection = FaceDetection(0)

face_detection.detected()