HandTrackingModule.py
def findPosition(self, img, handNo=0, draw=True):
        """
        Get landmarks positions (from previus findHands) and optionally redraw on landmark
        """
        xList, yList, bbox = [], [], []
        self.lmList = []
        if self.results.multi_hand_landmarks:
            myHand = self.results.multi_hand_landmarks[handNo]
            for id, lm in enumerate(myHand.landmark):
                h, w, _ = img.shape
                cx, cy = int(lm.x * w), int(lm.y * h)
                xList.append(cx)
                yList.append(cy)
                self.lmList.append([id, cx, cy])
                if draw:
                    cv2.circle(img, (cx, cy), 5, (255, 0, 255), cv2.FILLED)

            xmin, xmax, ymin, ymax = min(xList), max(xList), min(yList), max(yList)
            bbox = xmin, ymin, xmax, ymax
            if draw:
                cv2.rectangle(
                    img, (xmin - 20, ymin - 20), (xmax + 20, ymax + 20), (0, 255, 0), 2
                )

        return self.lmList, bbox

        Get landmarks positions (from previus findHands) and optionally redraw on landmark
        
Get landmarks positions (from previus findHands) and optionally redraw on landmark
Get landmarks positions ( from previus findHands ) and optionally redraw on landmark
def findPosition(self, img, handNo=0, draw=True):
        xList, yList, bbox = [], [], []
        self.lmList = []
        if self.results.multi_hand_landmarks:
            myHand = self.results.multi_hand_landmarks[handNo]
            for id, lm in enumerate(myHand.landmark):
                h, w, _ = img.shape
                cx, cy = int(lm.x * w), int(lm.y * h)
                xList.append(cx)
                yList.append(cy)
                self.lmList.append([id, cx, cy])
                if draw:
                    cv2.circle(img, (cx, cy), 5, (255, 0, 255), cv2.FILLED)
            xmin, xmax, ymin, ymax = min(xList), max(xList), min(yList), max(yList)
            bbox = xmin, ymin, xmax, ymax
            if draw:
                cv2.rectangle(
                    img, (xmin - 20, ymin - 20), (xmax + 20, ymax + 20), (0, 255, 0), 2
                )
        return self.lmList, bbox
def findPosition ( self , img , handNo = 0 , draw = True ) : xList , yList , bbox = [ ] , [ ] , [ ] self . lmList = [ ] if self . results . multi_hand_landmarks : myHand = self . results . multi_hand_landmarks [ handNo ] for id , lm in enumerate ( myHand . landmark ) : h , w , _ = img . shape cx , cy = int ( lm . x * w ) , int ( lm . y * h ) xList . append ( cx ) yList . append ( cy ) self . lmList . append ( [ id , cx , cy ] ) if draw : cv2 . circle ( img , ( cx , cy ) , 5 , ( 255 , 0 , 255 ) , cv2 . FILLED ) xmin , xmax , ymin , ymax = min ( xList ) , max ( xList ) , min ( yList ) , max ( yList ) bbox = xmin , ymin , xmax , ymax if draw : cv2 . rectangle ( img , ( xmin - 20 , ymin - 20 ) , ( xmax + 20 , ymax + 20 ) , ( 0 , 255 , 0 ) , 2 ) return self . lmList , bbox
Get landmarks positions (from previus findHands) and optionally redraw on landmark
Get landmarks positions ( from previus findHands ) and optionally redraw on landmark
"""
        Get landmarks positions (from previus findHands) and optionally redraw on landmark
        """
self
img
handNo
draw