Canny 边缘检测
- 原理
- 函数 Canny
edges = cv2.Canny(image,threshold1,threshold2) #两个阈值,1小2大
#两阈值越小细节越丰富
- 范例
1 import cv2
2
3 img = cv2.imread('./bomb.jpg')
4 edges = cv2.Canny(img,70,100)
5 cv2.imshow('XY',edges)
6 cv2.waitKey()
7 cv2.destroyAllWindows()
1 import cv2
2
3 cap = cv2.VideoCapture(0)
4
5 while True:
6 _,frame = cap.read()
7 edges = cv2.Canny(frame,120,190)
8 cv2.imshow('XY',edges)
9
10 k = cv2.waitKey(5) & 0xFF
11 if k == 27:
12 break
13
14 cv2.destroyAllWindows()
15 cap.realease()