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. 출력결과

'이미지, 영상 처리 > 실습코드' 카테고리의 다른 글

BGR 사진을 RGB로 변환  (0) 2022.07.05
[OpenCV] Motion Detecting  (0) 2022.07.05
[OpenCV] 이미지 캡쳐  (0) 2022.07.05

+ Recent posts