Skip to content

Commit

Permalink
Replacing np.int by np.int32 as np.int is no longer available startin…
Browse files Browse the repository at this point in the history
…g from numpy 1.24
  • Loading branch information
geaxgx committed Jan 14, 2023
1 parent 87111c1 commit 9773123
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion HandTracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ def lm_postprocess(self, hand, inference):
mat = cv2.getAffineTransform(src, dst)
lm_xy = np.expand_dims(hand.norm_landmarks[:,:2], axis=0)
# lm_z = hand.norm_landmarks[:,2:3] * hand.rect_w_a / 0.4
hand.landmarks = np.squeeze(cv2.transform(lm_xy, mat)).astype(np.int)
hand.landmarks = np.squeeze(cv2.transform(lm_xy, mat)).astype(np.int32)

# World landmarks
if self.use_world_landmarks:
Expand Down
2 changes: 1 addition & 1 deletion HandTrackerBpf.py
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ def lm_postprocess(self, hand, inference):
mat = cv2.getAffineTransform(src, dst)
lm_xy = np.expand_dims(hand.norm_landmarks[:,:2], axis=0)
# lm_z = hand.norm_landmarks[:,2:3] * hand.rect_w_a / 0.4
hand.landmarks = np.squeeze(cv2.transform(lm_xy, mat)).astype(np.int)
hand.landmarks = np.squeeze(cv2.transform(lm_xy, mat)).astype(np.int32)

# World landmarks
if self.use_world_landmarks:
Expand Down
2 changes: 1 addition & 1 deletion HandTrackerBpfEdge.py
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ def extract_hand_data(self, res, hand_idx):
hand.handedness = res["handedness"][hand_idx]
hand.label = "right" if hand.handedness > 0.5 else "left"
hand.norm_landmarks = np.array(res['rrn_lms'][hand_idx]).reshape(-1,3)
hand.landmarks = (np.array(res["sqn_lms"][hand_idx]) * self.frame_size).reshape(-1,2).astype(np.int)
hand.landmarks = (np.array(res["sqn_lms"][hand_idx]) * self.frame_size).reshape(-1,2).astype(np.int32)
if self.xyz:
hand.xyz = np.array(res["xyz"][hand_idx])
hand.xyz_zone = res["xyz_zone"][hand_idx]
Expand Down
2 changes: 1 addition & 1 deletion HandTrackerEdge.py
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ def extract_hand_data(self, res, hand_idx):
hand.handedness = res["handedness"][hand_idx]
hand.label = "right" if hand.handedness > 0.5 else "left"
hand.norm_landmarks = np.array(res['rrn_lms'][hand_idx]).reshape(-1,3)
hand.landmarks = (np.array(res["sqn_lms"][hand_idx]) * self.frame_size).reshape(-1,2).astype(np.int)
hand.landmarks = (np.array(res["sqn_lms"][hand_idx]) * self.frame_size).reshape(-1,2).astype(np.int32)
if self.xyz:
hand.xyz = np.array(res["xyz"][hand_idx])
hand.xyz_zone = res["xyz_zone"][hand_idx]
Expand Down
2 changes: 1 addition & 1 deletion HandTrackerRenderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def draw_hand(self, hand):
if self.show_rot_rect:
cv2.polylines(self.frame, [np.array(hand.rect_points)], True, (0,255,255), 2, cv2.LINE_AA)
if self.show_landmarks:
lines = [np.array([hand.landmarks[point] for point in line]).astype(np.int) for line in LINES_HAND]
lines = [np.array([hand.landmarks[point] for point in line]).astype(np.int32) for line in LINES_HAND]
if self.show_handedness == 3:
color = (0,255,0) if hand.handedness > 0.5 else (0,0,255)
else:
Expand Down
2 changes: 1 addition & 1 deletion examples/3d_visualization/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def __init__(self, tracker, mode_3d="image", smoothing=True):
def draw_hand(self, hand, i):
if self.mode_3d == "image":
# Denormalize z-component of 'norm_landmarks'
lm_z = (hand.norm_landmarks[:,2:3] * hand.rect_w_a / 0.4).astype(np.int)
lm_z = (hand.norm_landmarks[:,2:3] * hand.rect_w_a / 0.4).astype(np.int32)
# ... and concatenates with x and y components of 'landmarks'
points = np.hstack((hand.landmarks, lm_z))
radius = hand.rect_w_a / 30 # Thickness of segments depends on the hand size
Expand Down
4 changes: 2 additions & 2 deletions mediapipe_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -592,8 +592,8 @@ def __init__(self, scores=None, keypoints_norm=None, keypoints=None, score_thres
self.score_thresh = score_thresh
self.crop_region = crop_region
self.next_crop_region = next_crop_region
# self.keypoints_square = (self.keypoints_norm * self.crop_region.size).astype(np.int)
self.keypoints = (np.array([self.crop_region.xmin, self.crop_region.ymin]) + self.keypoints_norm * self.crop_region.size).astype(np.int)
# self.keypoints_square = (self.keypoints_norm * self.crop_region.size).astype(np.int32)
self.keypoints = (np.array([self.crop_region.xmin, self.crop_region.ymin]) + self.keypoints_norm * self.crop_region.size).astype(np.int32)

def print(self):
attrs = vars(self)
Expand Down

0 comments on commit 9773123

Please sign in to comment.