Skip to content

Body Detection ​

Instance declaration ​

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

python
body_detection = BodyDetection(0)
# When there are multiple instances
body_detection_1 = BodyDetection(1)

Parameters ​

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

Select the camera device ​

Sets the camera to use for body detection.

device

Parameters ​

NameKindDescriptionRange / TypeDefault
unitDropdown optionCamera device nameSystem camera label-

Python ​

python
body_detection = BodyDetection(0)

body_detection.device('')

Load the model ​

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

load_model

Parameters ​

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

Python ​

python
body_detection = BodyDetection(0)

body_detection.load_model(wait=True)

Detect once ​

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

detect_once

Parameters ​

(none)

Python ​

python
body_detection = BodyDetection(0)

body_detection.detect_once()

Start / stop continuous detection ​

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

detect_continuous

Parameters ​

NameKindDescriptionRange / TypeDefault
unitDropdown optionActionstart, stop-

Python ​

python
body_detection = BodyDetection(0)

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

Show the detection result ​

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

display

Parameters ​

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

Python ​

python
body_detection = BodyDetection(0)

body_detection.display(True)
body_detection.display(False)

Coordinates of a body part ​

Returns the coordinates of each body part.

body_data

Parameters ​

NameKindDescriptionRange / TypeDefault
unitDropdown optionBody partnose, mouth, left eye, right eye, left ear, right ear, left shoulder, right shoulder, left elbow, right elbow, left wrist, right wrist, left hand, right hand, left hip, right hip, left knee, right knee, left ankle, right ankle, left foot, right foot-
posDropdown optionCoordinatex, y-

Python ​

python
body_detection = BodyDetection(0)

body_detection.nose('x')
body_detection.mouth('y')
body_detection.left_eye('x')
body_detection.right_shoulder('y')
body_detection.left_hand('x')

Distance between two parts ​

Returns the distance between two body parts.

body_distance

Parameters ​

NameKindDescriptionRange / TypeDefault
unit1Dropdown optionFirst body part(see the body part table above)-
unit2Dropdown optionSecond body part(see the body part table above)-
typeDropdown optionKind of distancedistance (omitted or None), horizontal distance (horizontal), vertical distance (vertical)None

Python ​

python
body_detection = BodyDetection(0)

body_detection.get_distance('left_shoulder', 'right_shoulder')  # distance
body_detection.get_distance('left_wrist', 'right_wrist', 'horizontal')  # horizontal distance
body_detection.get_distance('left_hip', 'left_knee', 'vertical')  # vertical distance

Model state ​

Returns the loading state of the body 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
body_detection = BodyDetection(0)

body_detection.model_state()

Whether a body was detected ​

Whether a body was found

detected

Parameters ​

(none)

Python ​

python
body_detection = BodyDetection(0)

body_detection.detected()