Skip to content

Hand Detection ​

Instance declaration ​

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

python
hand_detection = HandDetection(0)
# When there are multiple instances
hand_detection_1 = HandDetection(1)

Parameters ​

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

Select the camera device ​

Sets the camera to use for hand detection.

device

Parameters ​

NameKindDescriptionRange / TypeDefault
unitDropdown optionCamera device nameSystem camera label-

Python ​

python
hand_detection = HandDetection(0)

hand_detection.device('')

Load the model ​

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

load_model

Parameters ​

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

Python ​

python
hand_detection = HandDetection(0)

hand_detection.load_model(wait=True)

Set the maximum number of hands ​

Decides whether to detect based on one hand or on both hands.

max_hands

Parameters ​

NameKindDescriptionRange / TypeDefault
unitDropdown optionNumber of handsone hand (one), both hands (both)-

Python ​

python
hand_detection = HandDetection(0)

hand_detection.max_hands('one')
hand_detection.max_hands('both')

Detect once ​

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

detect_once

Parameters ​

(none)

Python ​

python
hand_detection = HandDetection(0)

hand_detection.detect_once()

Start / stop continuous detection ​

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

detect_continuous

Parameters ​

NameKindDescriptionRange / TypeDefault
unitDropdown optionActionstart, stop-

Python ​

python
hand_detection = HandDetection(0)

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

Show the detection result ​

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

display

Parameters ​

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

Python ​

python
hand_detection = HandDetection(0)

hand_detection.display(True)
hand_detection.display(False)

Coordinates of a hand part ​

Returns the palm/wrist position information of the specified hand.

hand_data

Parameters ​

NameKindDescriptionRange / TypeDefault
sideDropdown optionHand sideleft, right-
unitDropdown optionHand partpalm, wrist-
posDropdown optionKind of coordinate/sizex, y-

Python ​

python
hand_detection = HandDetection(0)

hand_detection.hand('left', 'palm', 'x')
hand_detection.hand('right', 'wrist', 'y')
hand_detection.hand('left', 'hand', 'min_x')
hand_detection.hand('right', 'palm', 'width')

Coordinates of a finger joint ​

Returns the joint coordinates of the specified finger.

joint_data

Parameters ​

NameKindDescriptionRange / TypeDefault
sideDropdown optionHand sideleft, right-
unitDropdown optionFingerthumb, index, middle, ring, pinky-
jointDropdown optionJoint positionfirst joint (first), second joint (second), third joint (third), last joint (last)-
posDropdown optionCoordinatex, y-

Python ​

python
hand_detection = HandDetection(0)

hand_detection.finger('left', 'index', 'first', 'x')
hand_detection.finger('right', 'thumb', 'last', 'y')

Hand rectangle information ​

Returns the position/size values of the rectangle around the specified hand region.

hand_square

Parameters ​

NameKindDescriptionRange / TypeDefault
sideDropdown optionHand sideleft, right-
unitDropdown optionHand parthand, palm-
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
hand_detection = HandDetection(0)

hand_detection.hand('left', 'hand', 'min_x')
hand_detection.hand('right', 'palm', 'width')

Distance between hand and hand ​

Returns the distance between two hand parts.

hand_to_hand_distance

Parameters ​

NameKindDescriptionRange / TypeDefault
unit1Input (string)First hand partHand: 'side_unit' (e.g. 'left_palm'). side=left/right, unit=palm/wrist/hand-
unit2Input (string)Second hand partHand: 'side_unit' (e.g. 'right_palm'). side=left/right, unit=palm/wrist/hand-
typeDropdown optionKind of distancedistance (omitted or None), horizontal distance (horizontal), vertical distance (vertical)None

Python ​

python
hand_detection = HandDetection(0)

# hand ↔ hand / distance
hand_detection.get_distance('left_palm', 'right_palm')

Distance between hand and finger ​

Returns the distance between a hand part and a finger joint.

hand_to_joint_distance

Parameters ​

NameKindDescriptionRange / TypeDefault
unit1Input (string)First partHand: 'side_unit' (e.g. 'left_palm'). side=left/right, unit=palm/wrist/hand-
unit2Input (string)Second partFinger: 'side_unit_joint' (e.g. 'right_index_first'). unit=thumb/index/middle/ring/pinky, joint=first/second/third/last-
typeDropdown optionKind of distancedistance (omitted or None), horizontal distance (horizontal), vertical distance (vertical)None

Python ​

python
hand_detection = HandDetection(0)

# hand ↔ finger joint / horizontal distance
hand_detection.get_distance('left_palm', 'right_index_first')

Distance between finger and finger ​

Returns the distance between two finger joints.

joint_to_joint_distance

Parameters ​

NameKindDescriptionRange / TypeDefault
unit1Input (string)First partFinger: 'side_unit_joint' (e.g. 'left_thumb_last'). unit=thumb/index/middle/ring/pinky, joint=first/second/third/last-
unit2Input (string)Second partFinger: 'side_unit_joint' (e.g. 'right_index_first'). unit=thumb/index/middle/ring/pinky, joint=first/second/third/last-
typeDropdown optionKind of distancedistance (omitted or None), horizontal distance (horizontal), vertical distance (vertical)None

Python ​

python
hand_detection = HandDetection(0)

# finger joint ↔ finger joint / vertical distance
hand_detection.get_distance('left_thumb_last', 'right_index_first', 'vertical')

Model state ​

Returns the loading state of the hand 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
hand_detection = HandDetection(0)

hand_detection.model_state()

Whether a hand was detected ​

Whether a hand was found

detected

Parameters ​

(none)

Python ​

python
hand_detection = HandDetection(0)

hand_detection.detected()