OpenCV perspective transform in python

前端 未结 3 1827
灰色年华
灰色年华 2021-01-14 10:47

I\'m trying to rectify an image in python. I have a Homography H (from a rotation matrix that rotates around the x, y and z axis) that looks like this for example: [

相关标签:
3条回答
  • 2021-01-14 11:19

    It says the image should be np.float32 or np.float64.

    So convert the image first by img_cv2 = np.float32(img_cv2).

    Then apply the cv2.perspectiveTransform() and cv2.warpPerspective()

    Check this tutorial for demo

    0 讨论(0)
  • 2021-01-14 11:32

    I think what you want is cv2.warpPerspective (see documentation (link)), not cv2.perspectiveTransform.

    0 讨论(0)
  • 2021-01-14 11:43

    The source and destination image must be floating point data.

    cv2.perspectiveTransform(src, m[, dst]) → dst

    Parameters:

    • src – input two-channel or three-channel floating-point array; each element is a 2D/3D vector to be transformed.
    • dst – output array of the same size and type as src.
    • m – 3x3 or 4x4 floating-point transformation matrix.

    Refer:http://docs.opencv.org/modules/core/doc/operations_on_arrays.html?highlight=perspectivetransform#cv2.perspectiveTransform

    So convert the 8U image to the appropriate datatype.

    0 讨论(0)
提交回复
热议问题