Skip to content

Commit

Permalink
add an option to display a live preview of what remains in the image …
Browse files Browse the repository at this point in the history
…after applying the mask
  • Loading branch information
antocuni committed May 12, 2016
1 parent 4229bf3 commit d9264d0
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions bin/range-detector
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ def get_arguments():
help='Path to the image')
ap.add_argument('-w', '--webcam', required=False,
help='Use webcam', action='store_true')
ap.add_argument('-p', '--preview', required=False,
help='Show a preview of the image after applying the mask',
action='store_true')
args = vars(ap.parse_args())

if not xor(bool(args['image']), bool(args['webcam'])):
Expand Down Expand Up @@ -89,8 +92,12 @@ def main():

thresh = cv2.inRange(frame_to_thresh, (v1_min, v2_min, v3_min), (v1_max, v2_max, v3_max))

cv2.imshow("Original", image)
cv2.imshow("Thresh", thresh)
if args['preview']:
preview = cv2.bitwise_and(image, image, mask=thresh)
cv2.imshow("Preview", preview)
else:
cv2.imshow("Original", image)
cv2.imshow("Thresh", thresh)

if cv2.waitKey(1) & 0xFF is ord('q'):
break
Expand Down

0 comments on commit d9264d0

Please sign in to comment.