(self, img, handNo=0, draw=True)
| 33 | return img |
| 34 | |
| 35 | def findPosition(self, img, handNo=0, draw=True): |
| 36 | xList = [] |
| 37 | yList = [] |
| 38 | bbox = [] |
| 39 | self.lmList = [] |
| 40 | if self.results.multi_hand_landmarks: |
| 41 | myHand = self.results.multi_hand_landmarks[handNo] |
| 42 | for id, lm in enumerate(myHand.landmark): |
| 43 | # print(id, lm) |
| 44 | h, w, c = img.shape |
| 45 | cx, cy = int(lm.x * w), int(lm.y * h) |
| 46 | xList.append(cx) |
| 47 | yList.append(cy) |
| 48 | # print(id, cx, cy) |
| 49 | self.lmList.append([id, cx, cy]) |
| 50 | if draw: |
| 51 | cv2.circle(img, (cx, cy), 5, (255, 0, 255), cv2.FILLED) |
| 52 | |
| 53 | xmin, xmax = min(xList), max(xList) |
| 54 | ymin, ymax = min(yList), max(yList) |
| 55 | bbox = xmin, ymin, xmax, ymax |
| 56 | |
| 57 | if draw: |
| 58 | cv2.rectangle( |
| 59 | img, (xmin - 20, ymin - 20), (xmax + 20, ymax + 20), (0, 255, 0), 2 |
| 60 | ) |
| 61 | |
| 62 | return self.lmList, bbox |
| 63 | |
| 64 | def fingersUp(self): |
| 65 | fingers = [] |
no outgoing calls
no test coverage detected