1. Edge 검출 실습 코드
import cv2
import numpy as np
cap = cv2.VideoCapture(0)
if (cap.isOpened()== False):
print("Error opening video stream or file")
while(cap.isOpened()):
ret, frame = cap.read()
frame = cv2.flip(frame,-1)
if ret == True:
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
edges = cv2.Canny(gray, 20, 30)
edges_high_thresh = cv2.Canny(gray, 60, 120)
images = np.hstack((gray, edges, edges_high_thresh))
cv2.imshow('Frame', images)
if cv2.waitKey(25) & 0xFF == ord('q'):
break
else:
break
cap.release()
cv2.destroyAllWindows()
2. 출력결과