Traceback (most recent call last): File "C:\Users\86158\PycharmProjects\pythonProject\11111111.py", line 22, in <module> kp_left, des_left = orb.compute(img_left, [cv2.KeyPoint(x[1], x[0], 5) for x in keypoints_left]) File "C:\Users\86158\PycharmProjects\pythonProject\11111111.py", line 22, in <listcomp> kp_left, des_left = orb.compute(img_left, [cv2.KeyPoint(x[1], x[0], 5) for x in keypoints_left]) cv2.error: OpenCV(4.6.0) :-1: error: (-5:Bad argument) in function 'KeyPoint' > Overload resolution failed: > - Argument 'x' can not be safely parsed to 'float'
时间: 2024-02-15 15:06:04 浏览: 38
这个错误通常是由于关键点的坐标类型不正确引起的。你可以尝试将关键点的坐标类型从整数转换为浮点数类型,如下所示:
```python
# 选取角点
keypoints_left = np.float32([np.array([x[1], x[0]], dtype=np.float32) for x in np.argwhere(harris_left > 0.01 * harris_left.max())])
keypoints_right = np.float32([np.array([x[1], x[0]], dtype=np.float32) for x in np.argwhere(harris_right > 0.01 * harris_right.max())])
# 计算描述符
orb = cv2.ORB_create()
kp_left, des_left = orb.compute(img_left, [cv2.KeyPoint(x[0], x[1], 5) for x in keypoints_left])
kp_right, des_right = orb.compute(img_right, [cv2.KeyPoint(x[0], x[1], 5) for x in keypoints_right])
```
在这里,我们首先将角点的坐标类型转换为浮点数类型(float32),然后再使用ORB.compute函数计算描述符时,将坐标的顺序也进行了修改。
这个修改应该可以解决你遇到的问题,如果还有其他问题,请随时告诉我。
相关问题
Traceback (most recent call last): File "C:\Users\Amtec\PycharmProjects\pythonProject\main.py", line 2, in <module> import cx_Oracle
这个错误信息表明在文件 "C:\Users\Amtec\PycharmProjects\pythonProject\main.py" 第 2 行,在导入 cx_Oracle 模块时发生了 ImportError 错误。这可能是因为你没有安装 cx_Oracle 模块或者安装的版本不兼容。你可以尝试以下两种方法解决这个问题:
1.使用 pip 安装 cx_Oracle 模块
```shell
pip install cx_Oracle
```
2.下载并安装适合你的 Python 版本和操作系统的 cx_Oracle 模块,下载地址为:https://www.oracle.com/database/technologies/instant-client/downloads.html
Traceback (most recent call last): File "C:\Users\86158\PycharmProjects\pythonProject\youhua.py", line 37, in <module> diff = cv2.absdiff(img_right_transformed, img_left)
这个错误提示是因为拼接后的两张图像的尺寸不一样导致的,`cv2.absdiff()`函数要求两张图像的尺寸必须一致。
你可以尝试在拼接前将右侧图像的尺寸调整为与左侧图像相同,比如:
```python
h, w = img_left.shape[:2]
img_right_transformed = cv2.warpPerspective(img_right, M, (w * 2, h))
# 将右侧图像调整为与左侧图像尺寸相同
img_right_transformed = img_right_transformed[:, :w, :]
```
这样就可以保证两张图像的尺寸一致,避免上述错误。