Skip to content

Commit ade16f9

Browse files
committed
file reading compatability for different os
1 parent af621c0 commit ade16f9

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

myCamera.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import face_recognition
1212
import requests
1313
import json
14+
from os.path import dirname, join
1415

1516
yid_counter = 0
1617
kal_counter = 0
@@ -60,7 +61,6 @@ def detect_and_predict_mask(frame, faceNet, maskNet):
6061
# pass the blob through the network and obtain the face detections
6162
faceNet.setInput(blob)
6263
detections = faceNet.forward()
63-
print(detections.shape)
6464

6565
# initialize our list of faces, their corresponding locations,
6666
# and the list of predictions from our face mask network
@@ -128,7 +128,7 @@ def detect_and_predict_mask(frame, faceNet, maskNet):
128128
# email sending URL
129129
URL = "https://facemask-alert.herokuapp.com/send?name=" + person_to_be_sent
130130
# URL = 'http://localhost:9000/send?name=' + person_to_be_sent
131-
131+
print('Yeah')
132132
# send request to email sending api
133133
r = requests.post(url=URL)
134134
print('The result is: ', r.json())
@@ -147,12 +147,19 @@ def detect_and_predict_mask(frame, faceNet, maskNet):
147147

148148

149149
# load our serialized face detector model from disk
150-
prototxtPath = r"face_detector/deploy.prototxt"
151-
weightsPath = r"face_detector/res10_300x300_ssd_iter_140000.caffemodel"
150+
prototxtPath = join(dirname(__file__), 'face_detector', "deploy.prototxt")
151+
# weightsPath = join(dirname(__file__), 'face_detector',
152+
# "face_detector/res10_300x300_ssd_iter_140000.caffemodel")
153+
# prototxtPath = r"face_detector/deploy.prototxt"
154+
weightsPath = join(dirname(__file__), 'face_detector',
155+
"res10_300x300_ssd_iter_140000.caffemodel")
156+
# weightsPath = r"face_detector/res10_300x300_ssd_iter_140000.caffemodel"
152157
faceNet = cv2.dnn.readNet(prototxtPath, weightsPath)
153158

154159
# load the face mask detector model from disk
155-
maskNet = load_model("face_mask.model")
160+
maskNet = load_model(
161+
join(dirname(__file__), "face_mask.model"))
162+
# maskNet = load_model("face_mask.model")
156163

157164

158165
class VideoCamera(object):

0 commit comments

Comments
 (0)