Embedded_game/qianrushi/makeQR/spintu.py
2025-01-02 12:48:11 +08:00

22 lines
641 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# -*- coding:utf-8 -*-
# @Author len
# @Create 2023/10/18 12:35
import cv2
import numpy as np
def rotate_image(image_path, angle):
# 读取图像
image = cv2.imread(image_path)
# 获取图像的尺寸和中心点
h, w = image.shape[:2]
center = (w // 2, h // 2)
# 获取旋转矩阵
M = cv2.getRotationMatrix2D(center=center, angle=-angle, scale=1.0)
# 进行仿射变换borderValue设置为白色255, 255, 255
rotated_image = cv2.warpAffine(src=image, M=M, dsize=(w, h), borderValue=(255, 255, 255))
return rotated_image
tu = rotate_image('QR/1.jpg',15)
cv2.imshow("tu", tu)
cv2.waitKey()