> m <- spdep::sphet(pts, z, nb, method="eigen") Error: 'sphet' is not an exported object from 'namespace:spdep'
时间: 2023-12-06 16:40:26 浏览: 24
这个错误可能是因为`spdep`包中没有导出`sphet`函数,可以尝试使用`spdep:::sphet`来调用该函数。不过,需要注意的是,使用三个冒号调用非导出函数可能导致一些不可预见的问题,因为这些函数没有经过完整的测试和文档化。如果使用`spdep:::sphet`仍然无法解决问题,可以尝试更新`spdep`包或者使用其他的空间依赖性分析函数。
相关问题
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函数的参数类型匹配。
H, _ = cv2.findHomography(pts2, pts1, cv2.RANSAC) cv2.error: OpenCV(4.5.5) :-1: error: (-5:Bad argument) in function 'findHomography' > Overload resolution failed: > - srcPoints is not a numpy array, neither a scalar > - Expected Ptr<cv::UMat> for argument 'srcPoints' > - srcPoints is not a numpy array, neither a scalar > - Expected Ptr<cv::UMat> for argument 'srcPoints' 进程已结束,退出代码1
这个错误可能是由于pts1和pts2不是numpy数组导致的。请确保将pts1和pts2转换为numpy数组,如下所示:
```python
import numpy as np
# 提取匹配到的关键点的坐标
pts1 = []
pts2 = []
for match in matches:
pts1.append(kp1[match.queryIdx].pt)
pts2.append(kp2[match.trainIdx].pt)
# 转换为numpy数组
pts1 = np.array(pts1)
pts2 = np.array(pts2)
# 计算变换矩阵
H, _ = cv2.findHomography(pts2, pts1, cv2.RANSAC)
```
如果仍然存在问题,请检查pts1和pts2的形状是否正确。它们应该是形状为(N, 2)的numpy数组,其中N是关键点的数量。