Rotate Images with cv2.rotate

Tutorial

You can rotate images in cv2 in the following ways:

  • 90 degrees clockwise (cv2.ROTATE_90_CLOCKWISE)
  • 90 degrees counterclockwise (cv2.ROTATE_90_COUNTERCLOCKWISE)
  • 180 degrees clockwise (cv2.ROTATE_180)

You can rotate an image with the following code:


import cv2 

image = cv2.imread('image.jpeg')
rotated_image = cv2.rotate(image, cv2.ROTATE_90_CLOCKWISE)

Next Steps

OpenCV can be used with the open source supervision Python package.

supervision provides an extensive range of functionalities for working with computer vision models. With supervision, you can:

1. Process and filter detections and segmentation masks from a range of popular models (YOLOv5, Ultralytics YOLOv8, MMDetection, and more).
2. Process and filter classifications.
3. Compute confusion matrices.

And more! To learn about the full range of functionality in supervision, check out the supervision documentation.