gray scale
canny edge detection
#main.py
import numpy as np
import cv2
cap = cv2.VideoCapture("assets/Santa Barbara.mp4")
high = 200
low = 100
trackbars_img = np.uint8(np.full((50, 500, 3), 255))
cv2.imshow('trackbars', trackbars_img)
def high_change(x):
global high
high = x
def low_change(x):
global low
low = x
cv2.createTrackbar('low', 'trackbars', 100, 150, low_change)
cv2.createTrackbar('high', 'trackbars', 200, 255, high_change)
while True:
ret, frame = cap.read()
width = int(cap.get(3))
height = int(cap.get(4))
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
canny = cv2.Canny(gray, low, high)
cv2.imshow('frame', frame)
cv2.imshow('gray', gray)
cv2.imshow('canny', canny)
if cv2.waitKey(1) == ord('q'):
break
if cv2.waitKey(1) == ord('p'):
# wait until any key is pressed
cv2.waitKey(-1)
cap.release()
cv2.destroyAllWindows()
reference:
No comments:
Post a Comment