You need to complete the following steps:
- Import the modules:
import cv2import numpy as np
- Generate an initial points set. Then create a set of rotated points by applying a rotation matrix to the initial points. Also, add a portion of noise to our rotated points:
pts = np.random.multivariate_normal([150, 300], [[1024, 512], [512, 1024]], 50)rmat = cv2.getRotationMatrix2D((0, 0), 30, 1)[:, :2]rpts = np.matmul(pts, rmat.transpose())rpts_noise = rpts + np.random.multivariate_normal([0, 0], [[200, 0], [0, 200]], len(pts))
- Solve the orthogonal Procrustes problem using Singular Value Decomposition (SVD) and get an estimate of the rotation matrix:
M = np.matmul(pts.transpose(), rpts_noise)sigma, u, v_t = cv2.SVDecomp(M)rmat_est ...