January 2018
Intermediate to advanced
268 pages
6h 20m
English
In this section, we will see how to rotate a given image by a certain angle. We can do it using the following piece of code:
import cv2import numpy as npimg = cv2.imread('images/input.jpg')num_rows, num_cols = img.shape[:2]rotation_matrix = cv2.getRotationMatrix2D((num_cols/2, num_rows/2), 30, 0.7)img_rotation = cv2.warpAffine(img, rotation_matrix, (num_cols, num_rows))cv2.imshow('Rotation', img_rotation)cv2.waitKey()
If you run the preceding code, you will see an image like this:

Read now
Unlock full access