HandTrackingModule.py
def findDistance(self, p1, p2, img, draw=True, r=15, t=3):
        """
        Find distance between two tip fingers
        """

        x1, y1 = self.lmList[p1][1:]
        x2, y2 = self.lmList[p2][1:]
        cx, cy = (x1 + x2) // 2, (y1 + y2) // 2

        if draw:
            cv2.line(img, (x1, y1), (x2, y2), (255, 0, 255), t)
            cv2.circle(img, (x1, y1), r, (255, 0, 255), cv2.FILLED)
            cv2.circle(img, (x2, y2), r, (255, 0, 255), cv2.FILLED)
            cv2.circle(img, (cx, cy), r, (0, 0, 255), cv2.FILLED)

        length = math.hypot(x2 - x1, y2 - y1)

        return length, img, [x1, y1, x2, y2, cx, cy]

        Find distance between two tip fingers
        
Find distance between two tip fingers
Find distance between two tip fingers
def findDistance(self, p1, p2, img, draw=True, r=15, t=3):
        x1, y1 = self.lmList[p1][1:]
        x2, y2 = self.lmList[p2][1:]
        cx, cy = (x1 + x2) // 2, (y1 + y2) // 2
        if draw:
            cv2.line(img, (x1, y1), (x2, y2), (255, 0, 255), t)
            cv2.circle(img, (x1, y1), r, (255, 0, 255), cv2.FILLED)
            cv2.circle(img, (x2, y2), r, (255, 0, 255), cv2.FILLED)
            cv2.circle(img, (cx, cy), r, (0, 0, 255), cv2.FILLED)
        length = math.hypot(x2 - x1, y2 - y1)
        return length, img, [x1, y1, x2, y2, cx, cy]
def findDistance ( self , p1 , p2 , img , draw = True , r = 15 , t = 3 ) : x1 , y1 = self . lmList [ p1 ] [ 1 : ] x2 , y2 = self . lmList [ p2 ] [ 1 : ] cx , cy = ( x1 + x2 ) // 2 , ( y1 + y2 ) // 2 if draw : cv2 . line ( img , ( x1 , y1 ) , ( x2 , y2 ) , ( 255 , 0 , 255 ) , t ) cv2 . circle ( img , ( x1 , y1 ) , r , ( 255 , 0 , 255 ) , cv2 . FILLED ) cv2 . circle ( img , ( x2 , y2 ) , r , ( 255 , 0 , 255 ) , cv2 . FILLED ) cv2 . circle ( img , ( cx , cy ) , r , ( 0 , 0 , 255 ) , cv2 . FILLED ) length = math . hypot ( x2 - x1 , y2 - y1 ) return length , img , [ x1 , y1 , x2 , y2 , cx , cy ]
Find distance between two tip fingers
Find distance between two tip fingers
"""
        Find distance between two tip fingers
        """
self
p1
p2
img
draw
r
t