python opencv图片旋转任意角度
python opencv图片旋转任意角度
import cv2 # Load the image img = cv2.imread("20230222100736979.jpg") # Get the image dimensions height, width = img.shape[:2] # Set the rotation angle angle = 25 # Calculate the rotation matrix rotation_matrix = cv2.getRotationMatrix2D((width/2, height/2), angle, 1) # Apply the rotation matrix to the image rotated_img = cv2.warpAffine(img, rotation_matrix, (width, height)) # Display the rotated image cv2.imshow("Rotated Image", rotated_img) cv2.waitKey(0) cv2.destroyAllWindows()
####################
QQ 3087438119