Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

asked 2018-07-24 01:14:17 -0500

Nbb gravatar image

Error in warpperspective()

I am trying to use the homography transform function but am getting this error

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-21-9d9128efcecc> in <module>()
---> 33 im_dst = cv2.warpPerspective(im, h, (im.shape[1],im.shape[0]))

TypeError: M data type = 19 is not supported

Below is my code

import numpy as np
import cv2
import matplotlib.pyplot as plt

# read homography matrix
h = []
with open('/home/ast/datasets/ewap/seq_eth/H.txt', 'r') as f:
    for line in f:
        print(line.strip().split())
        h.append(line.strip().split())
h = np.array(h)

# read image
im = cv2.imread('/home/haziq/datasets/ewap/seq_eth/seq_eth_1.jpg')

# transform
im_dst = cv2.warpPerspective(frame, h, (im.shape[1],im.shape[0]))

Here is the doc for the warpperspective() function https://docs.opencv.org/3.0-beta/modules/imgproc/doc/geometric_transformations.html?highlight=warpperspective#void%20warpPerspective(InputArray%20src,%20OutputArray%20dst,%20InputArray%20M,%20Size%20dsize,%20int%20flags,%20int%20borderMode,%20const%20Scalar&%20borderValue)

Error in warpperspective()

I am trying to use the homography transform function but am getting this error

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-21-9d9128efcecc> in <module>()
---> 33 im_dst = cv2.warpPerspective(im, h, (im.shape[1],im.shape[0]))

TypeError: M data type = 19 is not supported

Below is my code

import numpy as np
import cv2
import matplotlib.pyplot as plt

# read homography matrix
h = []
with open('/home/ast/datasets/ewap/seq_eth/H.txt', 'r') as f:
    for line in f:
        print(line.strip().split())
        h.append(line.strip().split())
h = np.array(h)

# read image
im = cv2.imread('/home/haziq/datasets/ewap/seq_eth/seq_eth_1.jpg')

# transform
im_dst = cv2.warpPerspective(frame, h, (im.shape[1],im.shape[0]))

Here is the doc for the warpperspective() function https://docs.opencv.org/3.0-beta/modules/imgproc/doc/geometric_transformations.html?highlight=warpperspective#void%20warpPerspective(InputArray%20src,%20OutputArray%20dst,%20InputArray%20M,%20Size%20dsize,%20int%20flags,%20int%20borderMode,%20const%20Scalar&%20borderValue)

this is what i have for h. i printed its content and shape

[['2.8128700e-02' '2.0091900e-03' '-4.6693600e+00']
 ['8.0625700e-04' '2.5195500e-02' '-5.0608800e+00']
 ['3.4555400e-04' '9.2512200e-05' '4.6255300e-01']]
(3, 3)