cv2.error: opencv(4.5.5) d:\\a\\
时间: 2023-04-25 10:04:10 浏览: 238
这个错误表明,在使用 OpenCV 库时出现了一个错误。具体来说,它是在 d:\\a\\ 路径处发生的。可能是因为该路径不存在或者权限问题导致无法访问。建议检查文件路径是否正确,并确保程序具有读取该文件的权限。
相关问题
python中出现cv2.error: OpenCV(4.5.5) D:\a\opencv-python\opencv-python\opencv\modules\imgproc\src\contours.cpp:197: error: (-210:Unsupported format or combination of formats) [Start]FindContours supports only CV_8UC1 images when mode != CV_RETR_FLOODFILL otherwise supports CV_32SC1 images only in function 'cvStartFindContours_Impl'问题原因
这个错误通常是因为图像的格式不正确导致的。OpenCV中的cv2.findContours()函数只支持CV_8UC1和CV_32SC1格式的图像。
CV_8UC1表示8位无符号单通道图像,每个像素值的范围在0到255之间;CV_32SC1表示32位有符号单通道图像,每个像素值的范围在-2147483648到2147483647之间。
如果你的图像不是这两种格式之一,就会出现这个错误。你可以使用cv2.cvtColor()函数将图像转换为CV_8UC1格式,或者使用cv2.threshold()函数将图像二值化后再进行轮廓检测。
pts = cv2.perspectiveTransform(pts, H) cv2.error: OpenCV(4.5.5) :-1: error: (-5:Bad argument) in function 'perspectiveTransform' > Overload resolution failed: > - src is not a numpy array, neither a scalar > - Expected Ptr<cv::UMat> for argument 'src'
这个错误可能是由于pts不是numpy数组导致的。请确保将pts转换为numpy数组,如下所示:
```python
import numpy as np
# 计算图像2在图像1中的偏移量
h, w, _ = img2.shape
pts = [[0, 0], [0, h - 1], [w - 1, h - 1], [w - 1, 0]]
pts = np.array(pts)
pts = cv2.perspectiveTransform(pts.reshape(-1, 1, 2), H)
x_offset = int(min(pts[:, 0, 0]))
y_offset = int(min(pts[:, 0, 1]))
```
这里使用`reshape`将pts转换为形状为(N, 1, 2)的numpy数组,以便与cv2.perspectiveTransform函数的参数类型匹配。
阅读全文
相关推荐















