@@ -56,49 +56,49 @@ def compute_limb_regularization_matrix(gt_3d):
5656 Returns:
5757 R: 3x3 rotation matrix to align limbs to vertical
5858 """
59- # 定义腿部连接对 (起点, 终点 )
59+ # Define limb connection pairs (start, end )
6060 limb_connections = [
6161 (8 , 14 ), # left_front_thigh → left_front_knee
6262 (9 , 15 ), # right_front_thigh → right_front_knee
6363 (10 , 16 ), # left_back_thigh → left_back_knee
6464 (11 , 17 ), # right_back_thigh → right_back_knee
6565 ]
6666
67- # 计算所有连接的方向向量
68- # 注意:这些连接是从近端(大腿/膝盖)到远端(爪子),方向是向下的
69- # 为了让它们朝向竖直向上,我们需要反转方向
67+ # Compute direction vectors for all connections.
68+ # These connections go from proximal (thigh/knee) to distal (paw), so they
69+ # point downward; we reverse them to point upward.
7070 limb_vectors = []
7171 for start_idx , end_idx in limb_connections :
72- # 反转方向:从end到start(从爪子指向身体,即向上)
72+ # Reverse direction: end -> start (from paw toward body, upward).
7373 vec = gt_3d [start_idx ] - gt_3d [end_idx ]
74- # 归一化
74+ # Normalize.
7575 vec_norm = np .linalg .norm (vec )
76- if vec_norm > 1e-6 : # 避免除零
76+ if vec_norm > 1e-6 : # Avoid division by zero.
7777 vec = vec / vec_norm
7878 limb_vectors .append (vec )
7979
8080 if len (limb_vectors ) == 0 :
81- return np .eye (3 ) # 如果没有有效向量,返回单位矩阵
81+ return np .eye (3 ) # No valid vectors, return identity.
8282
83- # 计算平均方向
83+ # Compute average direction.
8484 avg_direction = np .mean (limb_vectors , axis = 0 )
8585 avg_direction = avg_direction / (np .linalg .norm (avg_direction ) + 1e-8 )
8686
87- # 目标方向:竖直向上 (0, 0, 1)
87+ # Target direction: vertical up (0, 0, 1).
8888 target_direction = np .array ([0.0 , 0.0 , 1.0 ])
8989
90- # 计算旋转矩阵,将avg_direction对齐到target_direction
91- # 使用Rodrigues公式
90+ # Compute rotation matrix to align avg_direction to target_direction.
91+ # Use Rodrigues' rotation formula.
9292 v = np .cross (avg_direction , target_direction )
9393 c = np .dot (avg_direction , target_direction )
9494
95- # 如果两个向量已经对齐或相反
95+ # If the two vectors are already aligned or opposite.
9696 if np .linalg .norm (v ) < 1e-6 :
9797 if c > 0 :
98- return np .eye (3 ) # 已经对齐
98+ return np .eye (3 ) # Already aligned.
9999 else :
100- # 相反方向,旋转180度
101- # 找一个垂直轴
100+ # Opposite direction, rotate 180 degrees.
101+ # Choose a perpendicular axis.
102102 if abs (avg_direction [0 ]) < 0.9 :
103103 axis = np .array ([1.0 , 0.0 , 0.0 ])
104104 else :
@@ -107,7 +107,7 @@ def compute_limb_regularization_matrix(gt_3d):
107107 axis = axis / np .linalg .norm (axis )
108108 return 2 * np .outer (axis , axis ) - np .eye (3 )
109109
110- # Rodrigues旋转公式
110+ # Rodrigues rotation formula.
111111 s = np .linalg .norm (v )
112112 kmat = np .array ([[0 , - v [2 ], v [1 ]],
113113 [v [2 ], 0 , - v [0 ]],
@@ -119,7 +119,7 @@ def compute_limb_regularization_matrix(gt_3d):
119119
120120def apply_regularization (pose_3d , R ):
121121 """
122- 应用正则化矩阵到3D姿态
122+ Apply regularization matrix to 3D pose.
123123
124124 Args:
125125 pose_3d: numpy array of shape (J, 3)
@@ -432,7 +432,7 @@ def euler_sample(c_2d, y_local, steps, model_3d):
432432 # print("\n=== Regularization Debug Info ===")
433433 # print(f"Rotation matrix R:\n{R_reg}")
434434
435- # # 验证正则化后的平均方向
435+ # # Validate average limb direction after regularization.
436436 # limb_connections = [
437437 # (8, 14), (9, 15), (10, 16), (11, 17)
438438 # ]
0 commit comments