Ask Your Question
0

Error in warpperspective()

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

Nbb gravatar image

updated 2018-07-24 01:55:06 -0500

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/modu...

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)
edit retag flag offensive close merge delete

Comments

please don't use 3 years old beta docs.

berak gravatar imageberak ( 2018-07-24 01:16:35 -0500 )edit

show, what you have in h please. (it expects a 3x3 matrix)

berak gravatar imageberak ( 2018-07-24 01:20:21 -0500 )edit

i have edited to show what I have for h. its a numpy.ndarray

Nbb gravatar imageNbb ( 2018-07-24 02:01:07 -0500 )edit

oops i think h is a string not float

Nbb gravatar imageNbb ( 2018-07-24 02:01:25 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2018-07-24 02:04:05 -0500

Nbb gravatar image

yes it was a string. sorry.. i just had to convert each element to a float.

edit flag offensive delete link more

Question Tools

1 follower

Stats

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

Seen: 588 times

Last updated: Jul 24 '18