match.py 421 B

1234567891011121314151617181920
  1. import cv2 as cv
  2. import numpy as np
  3. def rot_img_2(img: "np.ndarray") -> "list[np.ndarray]":
  4. if img.shape[0] > img.shape[1]: # 0: height, 1: width
  5. return [np.rot90(img), np.rot90(img, 3)]
  6. return [img, np.rot90(img, 2)]
  7. def main():
  8. img = cv.imread("img/1.jpg")
  9. rot = rot_img_2(img)
  10. cv.imshow("1", rot[0])
  11. cv.imshow("2", rot[1])
  12. cv.waitKey(0)
  13. if __name__ == '__main__':
  14. main()