2 if pyjevois.pro:
import libjevoispro
as jevois
3 else:
import libjevois
as jevois
36 self.
pose = self.
mp_pose.Pose(model_complexity = 1, min_detection_confidence = 0.5,
37 min_tracking_confidence = 0.5)
44 idle, winw, winh = helper.startFrame()
47 x, y, w, h = helper.drawInputFrame(
"c", inframe,
False,
False)
48 helper.itext(
'JeVois-Pro Body Pose Skeleton Detection', 0, -1)
51 image = inframe.getCvRGBp()
52 iw, ih = image.shape[1], image.shape[0]
58 results = self.
pose.process(image)
61 if results.pose_landmarks
is not None:
62 draw_landmarks(helper, iw, ih, results.pose_landmarks, visibility_th = 0.5)
65 helper.drawRect(brect[0], brect[1], brect[2], brect[3], 0x6040ffff,
True)
68 fps = self.
timer.stop()
69 helper.iinfo(inframe, fps, winw, winh);
76 landmark_array = np.empty((0, 2), int)
78 for _, landmark
in enumerate(landmarks.landmark):
79 landmark_x = min(
int(landmark.x * iw), iw - 1)
80 landmark_y = min(
int(landmark.y * ih), ih - 1)
81 landmark_point = [np.array((landmark_x, landmark_y))]
82 landmark_array = np.append(landmark_array, landmark_point, axis=0)
83 x, y, w, h = cv2.boundingRect(landmark_array)
84 return [x, y, x + w, y + h]
87 def draw_line(helper, lp1, lp2, visibility_th, col):
88 if lp1[0] > visibility_th
and lp2[0] > visibility_th:
89 helper.drawLine(lp1[1][0], lp1[1][1], lp2[1][0], lp2[1][1], col)
96 for index, landmark
in enumerate(landmarks.landmark):
97 landmark_x = min(
int(landmark.x * iw), iw - 1)
98 landmark_y = min(
int(landmark.y * ih), ih - 1)
99 landmark_z = landmark.z
100 lp.append([landmark.visibility, (landmark_x, landmark_y)])
102 if landmark.visibility >= visibility_th:
103 helper.drawCircle(landmark_x, landmark_y, 5, col,
True)
104 helper.drawText(landmark_x - 7, landmark_y - 7,
"z:" +
str(round(landmark_z, 3)), 0xffff8080)
107 draw_line(helper, lp[1], lp[2], visibility_th, col)
108 draw_line(helper, lp[2], lp[3], visibility_th, col)
109 draw_line(helper, lp[4], lp[5], visibility_th, col)
110 draw_line(helper, lp[5], lp[6], visibility_th, col)
111 draw_line(helper, lp[9], lp[10], visibility_th, col)
112 draw_line(helper, lp[11], lp[12], visibility_th, col)
113 draw_line(helper, lp[11], lp[13], visibility_th, col)
114 draw_line(helper, lp[13], lp[15], visibility_th, col)
115 draw_line(helper, lp[12], lp[14], visibility_th, col)
116 draw_line(helper, lp[14], lp[16], visibility_th, col)
117 draw_line(helper, lp[15], lp[17], visibility_th, col)
118 draw_line(helper, lp[17], lp[19], visibility_th, col)
119 draw_line(helper, lp[19], lp[21], visibility_th, col)
120 draw_line(helper, lp[21], lp[15], visibility_th, col)
121 draw_line(helper, lp[16], lp[18], visibility_th, col)
122 draw_line(helper, lp[18], lp[20], visibility_th, col)
123 draw_line(helper, lp[20], lp[22], visibility_th, col)
124 draw_line(helper, lp[22], lp[16], visibility_th, col)
125 draw_line(helper, lp[11], lp[23], visibility_th, col)
126 draw_line(helper, lp[12], lp[24], visibility_th, col)
127 draw_line(helper, lp[23], lp[24], visibility_th, col)
130 draw_line(helper, lp[23], lp[25], visibility_th, col)
131 draw_line(helper, lp[25], lp[27], visibility_th, col)
132 draw_line(helper, lp[27], lp[29], visibility_th, col)
133 draw_line(helper, lp[29], lp[31], visibility_th, col)
134 draw_line(helper, lp[24], lp[26], visibility_th, col)
135 draw_line(helper, lp[26], lp[28], visibility_th, col)
136 draw_line(helper, lp[28], lp[30], visibility_th, col)
137 draw_line(helper, lp[30], lp[32], visibility_th, col)