-
-
Save amarlearning/14a1b6cd4a291c3e4d4c8a93e2bc39d9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def hist_masking(frame, hist): | |
hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV) | |
dst = cv2.calcBackProject([hsv], [0, 1], hist, [0, 180, 0, 256], 1) | |
disc = cv2.getStructuringElement(cv2.MORPH_ELLIPSE, (31, 31)) | |
cv2.filter2D(dst, -1, disc, dst) | |
ret, thresh = cv2.threshold(dst, 150, 255, cv2.THRESH_BINARY) | |
thresh = cv2.merge((thresh, thresh, thresh)) | |
return cv2.bitwise_and(frame, thresh) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment