amélioration reco video

This commit is contained in:
telereview
2023-03-27 12:33:28 +02:00
parent fb736639e3
commit 4c6dccfcf5
2 changed files with 20 additions and 9 deletions

View File

@@ -18,7 +18,7 @@ class HandDetector():
min_detection_confidence=0.5,
min_tracking_confidence=0.5)
#Paramètres
self.BUFFER_LENGTH = 30
self.BUFFER_LENGTH = 60
self.DETECTION_THRESHOLD = 3/4
self.resultBuffer = []
@@ -31,10 +31,13 @@ class HandDetector():
i=0
j=0
for cpt in range (0,4):
V1=[handLandmarks[(4*cpt)+5][0]-handLandmarks[(4*cpt)+0][0],handLandmarks[(4*cpt)+5][1]-handLandmarks[(4*cpt)+0][1]]
V2=[handLandmarks[(4*cpt)+8][0]-handLandmarks[(4*cpt)+5][0],handLandmarks[(4*cpt)+8][1]-handLandmarks[(4*cpt)+5][1]]
j1=np.dot(V1,V2)
V1=[handLandmarks[(4*cpt)+6][0]-handLandmarks[(4*cpt)+5][0],handLandmarks[(4*cpt)+6][1]-handLandmarks[(4*cpt)+5][1]]
V2=[handLandmarks[(4*cpt)+8][0]-handLandmarks[(4*cpt)+6][0],handLandmarks[(4*cpt)+8][1]-handLandmarks[(4*cpt)+6][1]]
j=np.dot(V1,V2)
if (j>0.005):
j2=np.dot(V1,V2)
if (j1>0 and j2>0):
return etatDuPouce[0]
V1=[handLandmarks[4][0]-handLandmarks[1][0],handLandmarks[4][1]-handLandmarks[1][1]]
V2=[handLandmarks[2][0]-handLandmarks[1][0],handLandmarks[2][1]-handLandmarks[1][1]]
@@ -67,20 +70,24 @@ class HandDetector():
for landmarks in hand_landmarks.landmark:
handLandmarks.append([landmarks.x, landmarks.y])
#On ajoute la position de chaque mains a une liste
handsPositions.append(self.reconnaissancePouce(handLandmarks))
handsPositions.append([self.reconnaissancePouce(handLandmarks), handLandmarks])
#On calcule le résultat suivant la position des deux mains
if(len(handsPositions) == 2):
if(handsPositions[0] == handsPositions[1]):
if(handsPositions[0][0] == handsPositions[1][0]):
thumbState = handsPositions[0]
elif(handsPositions[0] == "neutre"):
handLandmarks = handsPositions[0][1]
elif(handsPositions[0][0] == "neutre"):
thumbState = handsPositions[1]
elif(handsPositions[1] == "neutre"):
thumbState = handsPositions[0]
handLandmarks = handsPositions[1][1]
elif(handsPositions[1][0] == "neutre"):
thumbState = handsPositions[0][0]
handLandmarks = handsPositions[0][1]
else:
thumbState = "neutre"
else:
thumbState = handsPositions[0]
thumbState = handsPositions[0][0]
handsLandmarks = handsPositions[0][1]
self.resultBuffer.append(thumbState)
if(len(self.resultBuffer) > self.BUFFER_LENGTH):
@@ -101,3 +108,7 @@ class HandDetector():
return False
if __name__ == "__main__":
h = HandDetector()
while(1):
print(h.detect())