MCPcopy Create free account
hub / github.com/OpenGVLab/HumanBench / kestrel_get_similar_matrix

Function kestrel_get_similar_matrix

PATH/helper/align.py:23–51  ·  view source on GitHub ↗
(src_points, dst_points)

Source from the content-addressed store, hash-verified

21
22
23def kestrel_get_similar_matrix(src_points, dst_points):
24 if src_points.size != dst_points.size:
25 print("error: the size of src_points and dst_points must be same",
26 "which is {0} vs. {1}".format(src_points.size, dst_points.size))
27 exit(-1)
28
29 dst_points = dst_points.T.reshape(-1)
30
31 point_num = src_points.shape[0]
32 new_src_points = np.zeros((point_num * 2, 4))
33 new_src_points[:point_num, :2] = src_points
34 new_src_points[:point_num, 2] = 1
35 new_src_points[:point_num, 3] = 0
36
37 new_src_points[point_num:, 0] = src_points[:, 1]
38 new_src_points[point_num:, 1] = -src_points[:, 0]
39 new_src_points[point_num:, 2] = 0
40 new_src_points[point_num:, 3] = 1
41
42 min_square_solution = np.linalg.lstsq(new_src_points, dst_points,
43 rcond=-1)[0]
44
45 trans_matrix = np.array([
46 [ min_square_solution[0], -min_square_solution[1], 0 ],
47 [ min_square_solution[1], min_square_solution[0], 0 ],
48 [ min_square_solution[2], min_square_solution[3], 1 ],
49 ])
50
51 return trans_matrix.T[:2]
52
53def transform(pts, M):
54 dst = np.matmul(pts, M[:, :2].T)

Callers 3

affine_imageMethod · 0.90
affine_imageMethod · 0.90
affine_alignSDKFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected