D:\python3.8\python.exe D:/pythonProject1/canny.py Traceback (most recent call last): File "D:/pythonProject1/canny.py", line 26, in <module> img_canny = canny(gray_smoothed, low_threshold, high_threshold) File "D:\python3.8\lib\site-packages\skimage\feature\_canny.py", line 314, in canny raise ValueError("low_threshold should be lower then high_threshold") ValueError: low_threshold should be lower then high_threshold 进程已结束,退出代码1
时间: 2024-02-06 17:09:32 浏览: 221
Canny.rar_canny _site:www.pudn.com_物体检测
这个错误提示是因为你在调用canny函数时,传入的低阈值参数小于了高阈值参数。可以检查一下你传入的参数是否正确,或者尝试交换一下参数的位置。下面是一个示例代码:
```python
import cv2
import numpy as np
def canny(image, low_threshold, high_threshold):
return cv2.Canny(image, low_threshold, high_threshold)
if __name__ == '__main__':
img = cv2.imread('test.jpg', 0)
gray_smoothed = cv2.GaussianBlur(img, (3, 3), 0)
low_threshold = 50
high_threshold = 150
img_canny = canny(gray_smoothed, low_threshold, high_threshold)
cv2.imshow('Canny', img_canny)
cv2.waitKey(0)
cv2.destroyAllWindows()
```
你可以将上述代码保存为canny.py,并且将一张图片命名为test.jpg放在相同的目录下,然后运行代码。
阅读全文