Amould commited on
Commit
29e09a6
·
verified ·
1 Parent(s): 1c553d4

Update codes.py

Browse files
Files changed (1) hide show
  1. codes.py +19 -0
codes.py CHANGED
@@ -95,6 +95,25 @@ def workaround_matrix(Affine_mtrx0, acc = 2):
95
  Affine_mtrx_adj[:,:,2]*=acc
96
  return Affine_mtrx_adj
97
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
98
  def standarize_point(d, dim=128, flip = False):
99
  if flip:
100
  d = -d
 
95
  Affine_mtrx_adj[:,:,2]*=acc
96
  return Affine_mtrx_adj
97
 
98
+ def inv_AM(Affine_mtrx):
99
+ AM3 = mtrx3(Affine_mtrx)
100
+ AM_inv = torch.linalg.inv(AM3)
101
+ return AM_inv[:,0:2,:]
102
+
103
+ def mtrx3(Affine_mtrx):
104
+ mtrx_shape = Affine_mtrx.shape
105
+ if len(mtrx_shape)==3:
106
+ N_Mbatches = mtrx_shape[0]
107
+ AM3 = torch.zeros( [N_Mbatches,3,3]).to(device)
108
+ AM3[:,0:2,:] = Affine_mtrx
109
+ AM3[:,2,2] = 1
110
+ elif len(mtrx_shape)==2:
111
+ N_Mbatches = 1
112
+ AM3 = torch.zeros([3,3]).to(device)
113
+ AM3[0:2,:] = Affine_mtrx
114
+ AM3[2,2] = 1
115
+ return AM3
116
+
117
  def standarize_point(d, dim=128, flip = False):
118
  if flip:
119
  d = -d