MCPcopy Create free account
hub / github.com/alpha2phi/python-apps / findDistance

Method findDistance

computer-vision/hand_tracking.py:91–103  ·  view source on GitHub ↗
(self, p1, p2, img, draw=True, r=15, t=3)

Source from the content-addressed store, hash-verified

89 return fingers
90
91 def findDistance(self, p1, p2, img, draw=True, r=15, t=3):
92 x1, y1 = self.lmList[p1][1:]
93 x2, y2 = self.lmList[p2][1:]
94 cx, cy = (x1 + x2) // 2, (y1 + y2) // 2
95
96 if draw:
97 cv2.line(img, (x1, y1), (x2, y2), (255, 0, 255), t)
98 cv2.circle(img, (x1, y1), r, (255, 0, 255), cv2.FILLED)
99 cv2.circle(img, (x2, y2), r, (255, 0, 255), cv2.FILLED)
100 cv2.circle(img, (cx, cy), r, (0, 0, 255), cv2.FILLED)
101 length = math.hypot(x2 - x1, y2 - y1)
102
103 return length, img, [x1, y1, x2, y2, cx, cy]
104
105
106def main():

Callers 2

virtual_mouse.pyFile · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected