1 | initial version |
The problem has been solved. Play around with low_gray values and leave constant high_gray 155. And the max always be 255. You can play around with low_gray but don't set too high than 200.
import cv2
import argparse
import datetime
import time
import numpy as np
cap = cv2.VideoCapture('test.mp4')
while(cap.isOpened()):
ret, frame = cap.read()
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV)
high_gray = np.array([150,255,255])
low_gray = np.array([20,50,199])
mask = cv2.inRange(gray, low_gray, high_gray)
res = cv2.bitwise_and(frame, frame, mask=mask)
cv2.imshow('frame', gray)
cv2.imshow('mask', mask)
cv2.imshow('res', res)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
cap.release()
cv2.destroyAllWindows()
2 | No.2 Revision |
The problem has been solved. Play around with low_gray values and leave constant high_gray 155. And the max always be 255. You can play around with low_gray but don't set too high than 200.
import cv2
import argparse
import datetime
import time
import numpy as np
cap = cv2.VideoCapture('test.mp4')
while(cap.isOpened()):
ret, frame = cap.read()
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV)
high_gray = np.array([150,255,255])
low_gray = np.array([20,50,199])
mask = cv2.inRange(gray, low_gray, high_gray)
res = cv2.bitwise_and(frame, frame, mask=mask)
cv2.imshow('frame', gray)
cv2.imshow('mask', mask)
cv2.imshow('res', res)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
cap.release()
cv2.destroyAllWindows()