Ask Your Question

Revision history [back]

ValueError: setting an array element with a sequence.

hi first i computed a Mapping Matrix named homography using findHomography command

M, mask = cv2.findHomography(src_pts, dst_pts, cv2.RANSAC, 5.0)
homography = M, mask

then I defined a 3*3 Matrix named camera as camera = np.array([[800, 0, 240], [0, 800, 320], [0, 0, 1]]) and I Globalized this variable (camera) and defined a Function named (projection_matrix) :

global camera
camera = np.array([[800, 0, 240], [0, 800, 320], [0, 0, 1]])
def projection_matrix(homography):

then I called this Function. I want to Multiply Inversion Matrix Of camera to homography Mapping Matrix as:

homography = homography * (-1)
projection_matrix(homography)

# Multiply Inversion Matrix Of camera to homography Matrix

  rot_and_transl = np.dot(np.linalg.inv(camera), homography)

but Pycharm gives These Errors:

**TypeError: only size-1 arrays can be converted to Python scalars**

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "C:/Users/Ali Hoseyni/PycharmProjects/pythonProject/main.py", line 41, in <module>

rot_and_transl = np.dot(np.linalg.inv(camera), homography) File "<__array_function__ internals>", line 5, in dot

**ValueError: setting an array element with a sequence.**