In [1]:
# Simple things first:
import numpy as np

mat = np.array([
    [1, 3, 4],
    [6, 9, 8],
    [6, 7, 9]])

print(mat)


[[1 3 4]
 [6 9 8]
 [6 7 9]]

In [2]:
[U, D, V] = np.linalg.svd(mat)

In [3]:
print(U)


[[-0.25545925 -0.60219924  0.75637071]
 [-0.69818735  0.65607252  0.28653669]
 [-0.66878622 -0.45489001 -0.58804768]]

In [4]:
print(D)


[19.19848638  1.66555095  1.28220936]

In [5]:
print(np.transpose(V))


[[-0.44051914  0.36318063 -0.82100105]
 [-0.61106731  0.54866225  0.57058434]
 [-0.65767746 -0.75304022  0.01976841]]

In [6]:
# Perspective transformation

# pick initial and final coords:
init_coords = [(0, 0), (1,1), (2, 2), (3,3)] # (xi, yi)
final_coords = [(0, 0), (1,1), (2, 2), (3,3)] # (xi',yi') # this should be auto-calculated

In [ ]: