original video: https://www.youtube.com/watch?v=ktXGUgVrVmI
blue filter
green filter
red filter
#main.py
import numpy as np
import cv2
cap = cv2.VideoCapture("assets/spinning led gyro toy.mp4")
while True:
ret, frame = cap.read()
width = int(cap.get(3))
height = int(cap.get(4))
hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV)
lower_blue = np.array([90, 50, 50])
upper_blue = np.array([130, 255, 255])
lower_green = np.array([50, 90, 50])
upper_green = np.array([255, 130, 255])
lower_red = np.array([50, 50, 90])
upper_red = np.array([255, 255, 130])
mask = cv2.inRange(hsv, lower_blue, upper_blue)
result = cv2.bitwise_and(frame, frame, mask=mask)
cv2.imshow('frame', result)
if cv2.waitKey(1) == ord('q'):
break
cap.release()
cv2.destroyAllWindows()
reference:
No comments:
Post a Comment