diff --git a/BasicPythonScripts/Fingers Counter using Hand Tracking/README.md b/BasicPythonScripts/Fingers Counter using Hand Tracking/README.md new file mode 100644 index 000000000..ee2b29ea1 --- /dev/null +++ b/BasicPythonScripts/Fingers Counter using Hand Tracking/README.md @@ -0,0 +1,14 @@ +# Finger-Counter-using-Hand-Tracking-And-Open-cv +finger counting based on open-cv and hand tracking in real time + +the important library : +- opencv-python +- mediapipe + +the project detects the counting fingers for the right hand and count from (0-7) + +# Screenshot +![](fingerCounting.png) + +to run the project execute the fingerCountingProject.py script + diff --git a/BasicPythonScripts/Fingers Counter using Hand Tracking/fingerCounting.png b/BasicPythonScripts/Fingers Counter using Hand Tracking/fingerCounting.png new file mode 100644 index 000000000..a460a514f Binary files /dev/null and b/BasicPythonScripts/Fingers Counter using Hand Tracking/fingerCounting.png differ diff --git a/BasicPythonScripts/Fingers Counter using Hand Tracking/fingerCountingProject.py b/BasicPythonScripts/Fingers Counter using Hand Tracking/fingerCountingProject.py new file mode 100644 index 000000000..35ed01610 --- /dev/null +++ b/BasicPythonScripts/Fingers Counter using Hand Tracking/fingerCountingProject.py @@ -0,0 +1,76 @@ +# -*- coding: utf-8 -*- +""" +Created on Sat Apr 3 23:09:19 2021 + +@author: amine gasa +""" +import cv2 +import os +import time +import handTrackingModule as htm +def getNumber(ar): + s="" + for i in ar: + s+=str(ar[i]); + + if(s=="00000"): + return (0) + elif(s=="01000"): + return(1) + elif(s=="01100"): + return(2) + elif(s=="01110"): + return(3) + elif(s=="01111"): + return(4) + elif(s=="11111"): + return(5) + elif(s=="01001"): + return(6) + elif(s=="01011"): + return(7) + +wcam,hcam=640,480 +cap=cv2.VideoCapture(0) +cap.set(3,wcam) +cap.set(4,hcam) +pTime=0 +detector = htm.handDetector(detectionCon=0.75) +while True: + success,img=cap.read() + img = detector.findHands(img, draw=True ) + lmList=detector.findPosition(img,draw=False) + #print(lmList) + tipId=[4,8,12,16,20] + if(len(lmList)!=0): + fingers=[] + #thumb + if(lmList[tipId[0]][1]>lmList[tipId[0]-1][1]): + fingers.append(1) + else : + fingers.append(0) + #4 fingers + for id in range(1,len(tipId)): + + if(lmList[tipId[id]][2]