opencv摄像头拍摄视频实时边缘提取(Canny)
上一篇笔者写过视频文件的边缘提取,这一篇是opencv调用摄像头实时提取的干货(此片参考过其他大佬代码,如有侵权请联系)
import cv2
import numpy as np
cap = cv2.VideoCapture(0)
while True:
_, frame = cap.read()
# if frame.isEmpty():
# break
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
frame = cv2.blur(frame, (7, 7))
frame = cv2.Canny(frame, 0, 30, 3)
cv2.imshow("Pick Picture:", frame)
a = cv2.waitKey(30)
if a == 27: # exit
break
cap.release()
del cv2
del np