Skip to content

Commit

Permalink
Merge pull request #102 from Aayush-hub/master
Browse files Browse the repository at this point in the history
Added notification pop up
  • Loading branch information
chandrikadeb7 committed Jan 30, 2021
2 parents d4f2532 + 0dba2de commit a6daf39
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,6 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
<td align="center"><a href="https://github.com/abhinavmaharana"><img src="https://avatars0.githubusercontent.com/u/59000244?s=400&u=4d68a964de00ddf1d896a16264efef9498cb89cf&v=4" width="100px;" alt=""/><br /><sub><b>Abhinav Maharana
</b></sub></a><br />
<td align="center"><a href="https://github.com/Pisich"><img src="https://avatars1.githubusercontent.com/u/62033118?s=400&v=4" width="100px;" alt=""/><br /><sub><b>Carlos
</b></sub></a><br />
<td align="center"><a href="https://github.com/Aayush-hub"><img src="https://avatars0.githubusercontent.com/u/65889104?s=60&v=4" width="100px;" alt=""/><br /><sub><b>Aayush Garg
</b></sub></a><br />
9 changes: 8 additions & 1 deletion detect_mask_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import argparse
import cv2
import os

from plyer import notification
def mask_image():
# construct the argument parser and parse the arguments
ap = argparse.ArgumentParser()
Expand Down Expand Up @@ -87,6 +87,13 @@ def mask_image():
# the bounding box and text
label = "Mask" if mask > withoutMask else "No Mask"
color = (0, 255, 0) if label == "Mask" else (0, 0, 255)
if label == "No Mask":
notification.notify(
title = "***No Mask Detected***",
message = "Wear Mask to stay safe! ",
app_icon = "images/1.ico", #ico file should be downloaded
timeout = 1
)

# include the probability in the label
label = "{}: {:.2f}%".format(label, max(mask, withoutMask) * 100)
Expand Down
12 changes: 11 additions & 1 deletion detect_mask_video.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import time
import cv2
import os
from plyer import notification

def detect_and_predict_mask(frame, faceNet, maskNet):
# grab the dimensions of the frame and then construct a blob
Expand Down Expand Up @@ -125,7 +126,15 @@ def detect_and_predict_mask(frame, faceNet, maskNet):
# the bounding box and text
label = "Mask" if mask > withoutMask else "No Mask"
color = (0, 255, 0) if label == "Mask" else (0, 0, 255)

if label == "No Mask":
notification.notify(
title = "***No Mask Detected***",
message = "Wear Mask to stay safe! ",
app_icon = "images/1.ico", #ico file should be downloaded
timeout = 1
)


# include the probability in the label
label = "{}: {:.2f}%".format(label, max(mask, withoutMask) * 100)

Expand All @@ -151,3 +160,4 @@ def detect_and_predict_mask(frame, faceNet, maskNet):
# do a bit of cleanup
cv2.destroyAllWindows()
vs.stop()

Binary file added images/1.ico
Binary file not shown.

0 comments on commit a6daf39

Please sign in to comment.