MCPcopy Index your code
hub / github.com/dkpython7/open-cv-projects- / get_bounding_box

Method get_bounding_box

GYM/main.py:17–36  ·  view source on GitHub ↗

Get bounding box for specific landmarks

(self, landmarks, indices, frame_shape)

Source from the content-addressed store, hash-verified

15 self.bar_y = None
16
17 def get_bounding_box(self, landmarks, indices, frame_shape):
18 """Get bounding box for specific landmarks"""
19 h, w = frame_shape[:2]
20 points = []
21
22 for idx in indices:
23 lm = landmarks[idx]
24 x, y = int(lm.x * w), int(lm.y * h)
25 points.append([x, y])
26
27 points = np.array(points)
28 x, y, w_box, h_box = cv2.boundingRect(points)
29
30 padding = 20
31 x = max(0, x - padding)
32 y = max(0, y - padding)
33 w_box = w_box + 2 * padding
34 h_box = h_box + 2 * padding
35
36 return x, y, w_box, h_box
37
38 def process_frame(self, frame):
39 h, w = frame.shape[:2]

Callers 1

process_frameMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected