Rotate image by 90, 180 or 270 degrees

后端 未结 11 2238
一个人的身影
一个人的身影 2020-12-01 07:48

I need to rotate an image by either 90, 180 or 270 degrees. In OpenCV4Android I can use:

Imgproc.getRotationMatrix2D(new Point(center, center), degrees, 1);         


        
11条回答
  •  暖寄归人
    2020-12-01 08:42

    In python:

    # import the necessary packages
    import numpy as np
    import cv2
    
    # initialize the camera and grab a reference to the raw camera capture
    vs = cv2.VideoCapture(0)
    (ret, image_original) = vs.read()
    image_rotated_90 = np.rot90(image_original)
    image_rotated_180 = np.rot90(image_rotated_90)
    
    # show the frame and press any key to quit the image frame
    cv2.imshow("Frame", image_rotated_180)
    cv2.waitKey(0)
    

提交回复
热议问题