我尝试将图像左移10个像素时出现错误:(-215:声明失败)函数“重新映射”中的ifunc!= 0

时间:2019-01-20 13:18:03

标签: python opencv image-processing

我正在尝试使用以下方法将图像左移10个像素:

import cv2

# image being received from another source
image = received_from_some_source()

transformed = cv2.warpAffine(image, np.float32([[1, 0, -10], [0, 1, 0]]), (image.shape[1], image.shape[0]), borderMode=cv2.BORDER_REPLICATE)


cv2.imwrite("shifted.png", transformed)

但是我收到一条错误消息:

Traceback (most recent call last):\n  File \"/home/snippets/ad/CVResult.py\", line 29, in func_wrapper\n    ans = 
func(self)\n  File \"run.py\", line 230, in test_shiftimageleft\n    student = ps1.shift_image_left(np.copy(test_image), shift)\n  File 
\"/home/snippets/ad/workspace/ps1.py\", line 196, in shift_image_left\n    transformed = cv2.warpAffine(temp_image, 
np.float32([[1, 0, -1 * shift], [0, 1, 0]]), (temp_image.shape[1], temp_image.shape[0]), borderMode=cv2.BORDER_REPLICATE)\nerror: 

OpenCV(4.0.0) /io/opencv/modules/imgproc/src/imgwarp.cpp:1805: 
error: (-215:Assertion failed) ifunc != 0 in function 'remap'\n\n"

这可能是什么原因?

0 个答案:

没有答案