OpenCV Python rotate image by X degrees around specific point

前端 未结 9 1662
谎友^
谎友^ 2020-11-27 05:08

I\'m having a hard time finding examples for rotating an image around a specific point by a specific (often very small) angle in Python using OpenCV.

This is what I

9条回答
  •  离开以前
    2020-11-27 05:16

    You can easily rotate the images using opencv python-

    def funcRotate(degree=0):
        degree = cv2.getTrackbarPos('degree','Frame')
        rotation_matrix = cv2.getRotationMatrix2D((width / 2, height / 2), degree, 1)
        rotated_image = cv2.warpAffine(original, rotation_matrix, (width, height))
        cv2.imshow('Rotate', rotated_image)
    

    If you are thinking of creating a trackbar, then simply create a trackbar using cv2.createTrackbar() and the call the funcRotate()fucntion from your main script. Then you can easily rotate it to any degree you want. Full details about the implementation can be found here as well- Rotate images at any degree using Trackbars in opencv

提交回复
热议问题