March 2019
Intermediate to advanced
532 pages
13h 2m
English
In an affine transformation, we first make use of the cv2.getAffineTransform() function to build the 2 x 3 transformation matrix, which will be obtained from the input image and the corresponding coordinates in the transformed image. Finally, this M matrix is passed to cv2.warpAffine(), as follows:
pts_1 = np.float32([[135, 45], [385, 45], [135, 230]])pts_2 = np.float32([[135, 45], [385, 45], [150, 230]])M = cv2.getAffineTransform(pts_1, pts_2)dst_image = cv2.warpAffine(image_points, M, (width, height))