Skip to content

Détection de la main ​

Déclarer l'instance ​

Si tu ajoutes un bloc de Détection de la main (HandDetection) à la zone de travail, la déclaration d'instance suivante est insérée automatiquement dans le code Python :

python
hand_detection = HandDetection(0)
# s'il y a plusieurs instances
hand_detection_1 = HandDetection(1)

Paramètres ​

NomTypeDescriptionPlage / TypeValeur par défaut
indexOption de listeNuméro de l'instance (commence à 0)entier supérieur ou égal à 00

Choisir la caméra ​

Règle la caméra pour la détection de visage.

device

Paramètres ​

NomTypeDescriptionPlage / TypeValeur par défaut
unitOption de listeNom de la caméraétiquettes des caméras du système-

Python ​

python
hand_detection = HandDetection(0)

hand_detection.device('')

Charger le modèle ​

Charge le modèle de main entraîné. Cette opération est indispensable pour pouvoir utiliser les fonctions du module « Détection de la main ».

load_model

Paramètres ​

NomTypeDescriptionPlage / TypeValeur par défaut
waitCase à cocherS'il faut attendre la fin du chargementTRUE / FALSETRUE

Python ​

python
hand_detection = HandDetection(0)

hand_detection.load_model(wait=True)

Régler le nombre maximal de mains ​

Décide si, en cherchant les mains, la référence est une seule main ou les deux mains.

max_hands

Paramètres ​

NomTypeDescriptionPlage / TypeValeur par défaut
unitOption de listeNombre de mainsune main(one), deux mains(both)-

Python ​

python
hand_detection = HandDetection(0)

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

Détecter une fois ​

Cherche la main présente dans l'image actuelle et l'affiche une seule fois.

detect_once

Paramètres ​

(aucun)

Python ​

python
hand_detection = HandDetection(0)

hand_detection.detect_once()

Démarrer / arrêter la détection continue ​

Suit en continu la main présente dans l'image actuelle et l'affiche à l'écran.

detect_continuous

Paramètres ​

NomTypeDescriptionPlage / TypeValeur par défaut
unitOption de listeActiondémarrer(start), arrêter(stop)-

Python ​

python
hand_detection = HandDetection(0)

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

Afficher le résultat de la détection ​

Décide s'il faut afficher ou non le résultat de la détection de la main sur l'image de la caméra.

display

Paramètres ​

NomTypeDescriptionPlage / TypeValeur par défaut
onOption de listeAffichage ON / OFFafficher(on=True), masquer(off=False)TRUE

Python ​

python
hand_detection = HandDetection(0)

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

Coordonnées d'une partie de la main ​

Renvoie les informations sur la position de la paume ou du poignet de la main indiquée.

hand_data

Paramètres ​

NomTypeDescriptionPlage / TypeValeur par défaut
sideOption de listeCôté de la maingauche(left), droite(right)-
unitOption de listePartie de la mainpaume(palm), poignet(wrist)-
posOption de listeType de coordonnée / taillex, 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')

Coordonnées de l'articulation d'un doigt ​

Renvoie les coordonnées de l'articulation du doigt indiqué.

joint_data

Paramètres ​

NomTypeDescriptionPlage / TypeValeur par défaut
sideOption de listeCôté de la maingauche(left), droite(right)-
unitOption de listeDoigtpouce(thumb), index(index), majeur(middle), annulaire(ring), auriculaire(pinky)-
jointOption de listePosition de l'articulationpremière articulation(first), deuxième articulation(second), troisième articulation(third), bout(last)-
posOption de listeCoordonnéex, y-

Python ​

python
hand_detection = HandDetection(0)

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

Informations sur le rectangle de la main ​

Renvoie la position et la taille du rectangle de la zone de la main indiquée.

hand_square

Paramètres ​

NomTypeDescriptionPlage / TypeValeur par défaut
sideOption de listeCôté de la maingauche(left), droite(right)-
unitOption de listePartie de la mainmain(hand), paume(palm)-
posOption de listeInformation sur le rectangleposition x min(min_x), position x max(max_x), position y min(min_y), position y max(max_y), largeur(width), hauteur(height), aire(area)-

Python ​

python
hand_detection = HandDetection(0)

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

Distance entre main et main ​

Renvoie la distance entre deux parties de la main.

hand_to_hand_distance

Paramètres ​

NomTypeDescriptionPlage / TypeValeur par défaut
unit1Entrée (texte)Première partie de la mainmain : 'side_unit' (p. ex. 'left_palm'). side=left/right, unit=palm/wrist/hand-
unit2Entrée (texte)Deuxième partie de la mainmain : 'side_unit' (p. ex. 'right_palm'). side=left/right, unit=palm/wrist/hand-
typeOption de listeType de distancedistance(omis ou None), distance horizontale(horizontal), distance verticale(vertical)None

Python ​

python
hand_detection = HandDetection(0)

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

Distance entre main et doigt ​

Renvoie la distance entre une partie de la main et l'articulation d'un doigt.

hand_to_joint_distance

Paramètres ​

NomTypeDescriptionPlage / TypeValeur par défaut
unit1Entrée (texte)Première partiemain : 'side_unit' (p. ex. 'left_palm').side=left/right, unit=palm/wrist/hand-
unit2Entrée (texte)Deuxième partiedoigt : 'side_unit_joint' (p. ex. 'right_index_first'). unit=thumb/index/middle/ring/pinky, joint=first/second/third/last-
typeOption de listeType de distancedistance(omis ou None), distance horizontale(horizontal), distance verticale(vertical)None

Python ​

python
hand_detection = HandDetection(0)

# main ↔ articulation du doigt / distance horizontale
hand_detection.get_distance('left_palm', 'right_index_first')

Distance entre doigt et doigt ​

Renvoie la distance entre les articulations de deux doigts.

joint_to_joint_distance

Paramètres ​

NomTypeDescriptionPlage / TypeValeur par défaut
unit1Entrée (texte)Première partiedoigt : 'side_unit_joint' (p. ex. 'left_thumb_last'). unit=thumb/index/middle/ring/pinky, joint=first/second/third/last-
unit2Entrée (texte)Deuxième partiedoigt : 'side_unit_joint' (p. ex. 'right_index_first'). unit=thumb/index/middle/ring/pinky, joint=first/second/third/last-
typeOption de listeType de distancedistance(omis ou None), distance horizontale(horizontal), distance verticale(vertical)None

Python ​

python
hand_detection = HandDetection(0)

# articulation du doigt ↔ articulation du doigt / distance verticale
hand_detection.get_distance('left_thumb_last', 'right_index_first', 'vertical')

État du modèle ​

Renvoie l'état de chargement du modèle de main.
Renvoie 0 s'il n'est pas encore chargé, 1 si le chargement est en cours et 2 si le chargement est terminé.

model_state

Paramètres ​

(aucun)

Python ​

python
hand_detection = HandDetection(0)

hand_detection.model_state()

Si la main est détectée ​

Si la main a été trouvée

detected

Paramètres ​

(aucun)

Python ​

python
hand_detection = HandDetection(0)

hand_detection.detected()