When running code I get an opencv cv2 error - python

This is the code im trying to run that I found on this video https://www.youtube.com/watch?v=Ax6P93r32KU
from tensorflow.keras.applications.mobilenet_v2 import preprocess_input
from tensorflow.keras.preprocessing.image import img_to_array
from tensorflow.keras.models import load_model
from imutils.video import VideoStream
import numpy as np
import imutils
import time
import cv2
import os
def detect_and_predict_mask(frame, faceNet, maskNet):
(h, w) = frame.shape[:2]
blob = cv2.dnn.blobFromImage(frame, 1.0, (224, 224),
(104.0, 177.0, 123.0))
faceNet.setInput(blob)
detections = faceNet.forward()
print(detections.shape)
faces = []
locs = []
preds = []
# loop over the detections
for i in range(0, detections.shape[2]):
confidence = detections[0, 0, i, 2]
if confidence > 0.5:
box = detections[0, 0, i, 3:7] * np.array([w, h, w, h])
(startX, startY, endX, endY) = box.astype("int")
(startX, startY) = (max(0, startX), max(0, startY))
(endX, endY) = (min(w - 1, endX), min(h - 1, endY))
face = frame[startY:endY, startX:endX]
face = cv2.cvtColor(face, cv2.COLOR_BGR2RGB)
face = cv2.resize(face, (224, 224))
face = img_to_array(face)
face = preprocess_input(face)
faces.append(face)
locs.append((startX, startY, endX, endY))
if len(faces) > 0:
faces = np.array(faces, dtype="float32")
preds = maskNet.predict(faces, batch_size=32)
return (locs, preds)
prototxtPath = r"face_detector\deploy.prototxt"
weightsPath = r"face_detector\res10_300x300_ssd_iter_140000.caffemodel"
faceNet = cv2.dnn.readNet(prototxtPath, weightsPath)
maskNet = load_model("mask_detector.model")
print("[INFO] starting video stream...")
vs = VideoStream(src=0).start()
while True:
frame = vs.read()
frame = imutils.resize(frame, width=400)
(locs, preds) = detect_and_predict_mask(frame, faceNet, maskNet)
for (box, pred) in zip(locs, preds):
# unpack the bounding box and predictions
(startX, startY, endX, endY) = box
(mask, withoutMask) = pred
label = "Mask" if mask > withoutMask else "No Mask"
color = (0, 255, 0) if label == "Mask" else (0, 0, 255)
label = "{}: {:.2f}%".format(label, max(mask, withoutMask) * 100)
cv2.putText(frame, label, (startX, startY - 10),
cv2.FONT_HERSHEY_SIMPLEX, 0.45, color, 2)
cv2.rectangle(frame, (startX, startY), (endX, endY), color, 2)
cv2.imshow("Frame", frame)
key = cv2.waitKey(1) & 0xFF
if key == ord("q"):
break
cv2.destroyAllWindows()
vs.stop()
This is what happens when I run the code
PS C:\Users\rainb> & C:/Users/rainb/AppData/Local/Programs/Python/Python38/python.exe
c:/Users/Public/Desktop/Python_Work/Face-Mask-Detection-master/detect_mask_video.py
2021-03-15 22:36:04.855886: W tensorflow/stream_executor/platform/default/dso_loader.cc:59] Could not
load dynamic library 'cudart64_101.dll'; dlerror: cudart64_101.dll not found
2021-03-15 22:36:04.866930: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart
dlerror if you do not have a GPU set up on your machine.
Traceback (most recent call last):
File "c:/Users/Public/Desktop/Python_Work/Face-Mask-Detection-master/detect_mask_video.py", line 77, in <module>
faceNet = cv2.dnn.readNet(prototxtPath, weightsPath)
cv2.error: OpenCV(4.2.0) C:\projects\opencv-python\opencv\modules\dnn\src\caffe\caffe_io.cpp:1121: error: (-2:Unspecified error) FAILED: fs.is_open(). Can't open "face_detector\deploy.prototxt" in function 'cv::dnn::ReadProtoFromTextFile'
The file location C:\projects\opencv-python\opencv\modules\dnn\src\caffe\caffe_io.cpp:1121: does not exist, and I was wondering how to change that file location to something else, or find a different way to fix the problem.

I think you have error in the file extension. May be file called deploy.proto.txt ?
And one moment yet, check the real path, where this file is storaged

i also refer this same code...i also felt the same error..
datapath is not correct thats y...
if you run this in colab you might change the datapath
like this
prototxtPath ='/content/drive/MyDrive/MINIPROJECT/Face-Mask-Detection-master/face_detector/deploy.prototxt'- this is my datapath u correct just it with ur path

Related

How to add a counter for faces detected in this code

I followed a tutorial about making a face detection program with openCV with python, but now I want to add a counter in the top left with how many faces are detected by cam
this is the used code.
from tensorflow.keras.applications.mobilenet_v2 import preprocess_input
from tensorflow.keras.preprocessing.image import img_to_array
from tensorflow.keras.models import load_model
from imutils.video import VideoStream
import numpy as np
import imutils
import time
import cv2
import os
def detect_mask(frame, faceNet, maskNet):
(h, w) = frame.shape[:2]
blob = cv2.dnn.blobFromImage(frame, 1.0, (224, 224),
(104.0, 177.0, 123.0))
faceNet.setInput(blob)
detections = faceNet.forward()
print(detections.shape)
faces = []
# fixed the error with variable faces...Faces ===> faces
locs = []
preds = []
for i in range(0, detections.shape[2]):
confidence = detections[0, 0, i, 2]
if confidence > 0.5:
box = detections[0, 0, i, 3:7] * np.array([w, h, w, h])
(startX, startY, endX, endY) = box.astype("int")
(startX, startY) = (max(0, startX), max(0, startY))
(endX, endY) = (min(w - 1, endX), min(h - 1, endY))
face = frame[startY:endY, startX:endX]
face = cv2.cvtColor(face, cv2.COLOR_BGR2RGB)
face = cv2.resize(face, (224, 224))
face = img_to_array(face)
face = preprocess_input(face)
faces.append(face)
locs.append((startX, startY, endX, endY))
if len(faces) > 0:
faces = np.array(faces, dtype="float32")
preds = maskNet.predict(faces, batch_size=32)
return (locs, preds)
prototxtPath = r"face_detector\deploy.prototxt"
weightsPath = r"face_detector\res10_300x300_ssd_iter_140000.caffemodel"
faceNet = cv2.dnn.readNet(prototxtPath, weightsPath)
maskNet = load_model("training_model.model")
print("Starting video stream..")
vs = VideoStream(src=0).start()
while True:
frame = vs.read()
frame = imutils.resize(frame, width=400)
(locs, preds) = detect_mask(frame, faceNet, maskNet)
for (box, pred) in zip(locs, preds):
(startX, startY, endX, endY) = box
(mask, withoutMask) = pred
label = "There is a mask" if mask > withoutMask else "There is no mask"
color = (0, 255, 0) if label == "There is a mask" else (0, 0, 255)
label = "{}: {:.2f}%".format(label, max(mask, withoutMask) * 100)
cv2.putText(frame, label, (startX, startY - 10),
cv2.FONT_HERSHEY_SIMPLEX, 0.45, color, 2)
cv2.rectangle(frame, (startX, startY), (endX, endY), color, 2)
cv2.imshow("Frame", frame)
key = cv2.waitKey(1) & 0xFF
if key == ord("q"):
break
cv2.destroyAllWindows()
vs.stop()
Advanced Thanks! .....................................................................................................................................................................................................................................................................................................
If you try to understand what tutorial trying to do, It will be very easy for you to reach your goal yourself.
Hints: Duplicate below part of the code to print counter on the frame. Just change coordinates to locate top left of the frame and also add counter variable to increment every time when confidence level is > 0
label = "There is a mask" if mask > withoutMask else "There is no mask"
color = (0, 255, 0) if label == "There is a mask" else (0, 0, 255)
label = "{}: {:.2f}%".format(label, max(mask, withoutMask) * 100)
cv2.putText(frame, label, (startX, startY - 10),
cv2.FONT_HERSHEY_SIMPLEX, 0.45, color, 2)
cv2.rectangle(frame, (startX, startY), (endX, endY), color, 2)

Facemask Recognition using TFlite in Raspberry Pi 3B+ with Python3

I try to use TFlite for my facemask recognition project. But the problem is it has errors. The problem can Stream. However, if it detects a human face/facemask the error will terminate the system.
Here's the error
Traceback (most recent call last):
File "/home/pi/Desktop/fm_detection/fm_tflite.py", line 113, in <module>
(mask, withoutMask) = pred
TypeError: cannot unpack non-iterable numpy.float32 object
Here's my coding
import tensorflow as tf
from tensorflow.keras.applications.mobilenet_v2 import preprocess_input
from tensorflow.keras.preprocessing.image import img_to_array
from tensorflow.keras.models import load_model
from imutils.video import VideoStream
from gpiozero import LED, Buzzer
import numpy as np
import imutils
import time
import cv2
import os
import sys
led = LED(19)
buzzer = Buzzer(26)
def detect_and_predict_mask(frame, faceNet, interpreter):
(h, w) = frame.shape[:2]
blob = cv2.dnn.blobFromImage(frame, 1.0, (224, 224),
(104.0, 177.0, 123.0))
faceNet.setInput(blob)
detections = faceNet.forward()
print(detections.shape)
faces = []
locs = []
preds = []
for i in range(0, detections.shape[2]):
confidence = detections[0, 0, i, 2]
if confidence > 0.5:
box = detections[0, 0, i, 3:7] * np.array([w, h, w, h])
(startX, startY, endX, endY) = box.astype("int")
(startX, startY) = (max(0, startX), max(0, startY))
(endX, endY) = (min(w - 1, endX), min(h - 1, endY))
face = frame[startY:endY, startX:endX]
face = cv2.cvtColor(face, cv2.COLOR_BGR2RGB)
face = cv2.resize(face, (224, 224))
face = img_to_array(face)
face = preprocess_input(face)
faces.append(face)
locs.append((startX, startY, endX, endY))
if len(faces) > 0:
faces = np.array(faces, dtype="float32")
#preds = maskNet.predict(faces, batch_size=32)
interpreter.allocate_tensors()
interpreter.set_tensor(interpreter.get_input_details()[0]["index"], faces)
interpreter.invoke()
preds = interpreter.tensor(interpreter.get_output_details()[0]["index"])()[0]
return (locs, preds)
# load our serialized facemask model from disk
prototxtPath = "/home/pi/Desktop/fm_detection/face_detector/deploy.prototxt"
weightsPath = "/home/pi/Desktop/fm_detection/face_detector/res10_300x300_ssd_iter_140000.caffemodel"
faceNet = cv2.dnn.readNet(prototxtPath, weightsPath)
#maskNet = load_model("facemask_model.model")
interpreter = tf.lite.Interpreter("facemask_model.tflite")
# initialize the video stream
print("[INFO] starting video stream...")
vs = VideoStream(src=1).start()
# loop over the frames
while True:
frame = vs.read()
frame = imutils.resize(frame, width=500)
(locs, preds) = detect_and_predict_mask(frame, faceNet, interpreter)
for (box, pred) in zip(locs, preds):
# unpack the bounding box and predictions
(startX, startY, endX, endY) = box
(mask, withoutMask) = pred
label = "Mask" if mask > withoutMask else "No Mask"
color = (0, 255, 0) if label == "Mask" else (0, 0, 255)
led.on() if mask > withoutMask else led.off()
buzzer.beep(0.1, 0.1, 1) if mask > withoutMask else led.off()
time.sleep(2)
led.off() if mask > withoutMask else led.off()
os.system("espeak -s 130 'THANK YOU'") if mask > withoutMask else led.off()
sys.exit() if sw2Press else buzzer.off()
cv2.putText(frame, label, (startX, startY - 10),
cv2.FONT_HERSHEY_SIMPLEX, 0.45, color, 2)
cv2.rectangle(frame, (startX, startY), (endX, endY), color, 2)
cv2.imshow("Frame", frame)
key = cv2.waitKey(1) & 0xFF
if key == ord("q"):
break
cv2.destroyAllWindows()
vs.stop()
The program will be stuck at the moment it detects the human face. Hope someone can help me.
Thank You

How can I capture images of people not wearing Face Mask and store images in local desktop? IN PYTHON

THIS IS MY PYTHON CODE SO FAR,
This code generates a live stream video from the webcam and detects facemask and no facemask people,
now I want to take pictures of people who are not wearing face mask and store images of those in the local directory.
please help me to find the solution to this issue
I already have a data set of no mask and mask
now I want to take picture of those not wearing face mask and save in the local directory using the webcam live videostram
from tensorflow.keras.preprocessing.image import img_to_array
from tensorflow.keras.models import load_model
from imutils.video import VideoStream
import numpy as np
import imutils
import time
import cv2
import os
import time
lowConfidence = 0.75
def detectAndPredictMask(frame, faceNet, maskNet):
(h, w) = frame.shape[:2]
blob = cv2.dnn.blobFromImage(frame, 1.0, (224, 224),
(104.0, 177.0, 123.0))
faceNet.setInput(blob)
detections = faceNet.forward()
faces = []
locs = []
preds = []
for i in range(0, detections.shape[2]):
confidence = detections[0, 0, i, 2]
if confidence > lowConfidence:
box = detections[0, 0, i, 3:7] * np.array([w, h, w, h])
(startX, startY, endX, endY) = box.astype("int")
(startX, startY) = (max(0, startX), max(0, startY))
(endX, endY) = (min(w - 1, endX), min(h - 1, endY))
face = frame[startY:endY, startX:endX]
face = cv2.cvtColor(face, cv2.COLOR_BGR2RGB)
face = cv2.resize(face, (224, 224))
face = img_to_array(face)
face = preprocess_input(face)
faces.append(face)
locs.append((startX, startY, endX, endY))
if len(faces) > 0:
faces = np.array(faces, dtype="float32")
preds = maskNet.predict(faces, batch_size=32)
return (locs, preds)
prototxtPath = r"deploy.prototxt"
weightsPath = r"res10_300x300_ssd_iter_140000.caffemodel"
faceNet = cv2.dnn.readNet(prototxtPath, weightsPath)
maskNet = load_model("mask_detector.model")
vs = VideoStream(src=0).start()
while True:
frame = vs.read()
frame = imutils.resize(frame, width=900)
(locs, preds) = detectAndPredictMask(frame, faceNet, maskNet)
for (box, pred) in zip(locs, preds):
(startX, startY, endX, endY) = box
(mask, withoutMask) = pred
label = "Mask" if mask > withoutMask else "No Mask"
color = (0, 255, 0) if label == "Mask" else (0, 0, 255)
if label =="Mask":
print("MASK DETECTED")
else:
print("MASK NOT DETECETED")
label = "{}: {:.2f}%".format(label, max(mask, withoutMask) * 100)
cv2.putText(frame, label, (startX, startY - 10),
cv2.FONT_HERSHEY_SIMPLEX, 0.45, color, 2)
cv2.rectangle(frame, (startX, startY), (endX, endY), color, 2)
cv2.imshow("PROMENADE FACE MASK DETECTOR", frame)
key = cv2.waitKey(1) & 0xFF
if key == ord("q"):
break
cv2.destroyAllWindows()
vs.stop()
cv2.imwrite('path_to_desktop/filename.jpg', face)
read more about imwrite() here
Within detectAndPredictMask your code is looping over detections and is extracting a slice of frame and assigning it to face (face = frame[startY:endY, startX:endX]). face contains a OpenCV compatible image. Use imwrite before face = img_to_array(face) as there image is trasformed to a Numpy array.

When running face recognition OpenCV I get IOerror

This is the code im trying to run that I found on this video https://www.youtube.com/watch?v=Ax6P93r32KU
I have never used OpenCV, and I do not understand the error.
The code is designed to detect if someone from a live feed is wearing a mask or not.
from tensorflow.keras.applications.mobilenet_v2 import preprocess_input
from tensorflow.keras.preprocessing.image import img_to_array
from tensorflow.keras.models import load_model
from imutils.video import VideoStream
import numpy as np
import imutils
import time
import cv2
import os
def detect_and_predict_mask(frame, faceNet, maskNet):
(h, w) = frame.shape[:2]
blob = cv2.dnn.blobFromImage(frame, 1.0, (224, 224),
(104.0, 177.0, 123.0))
faceNet.setInput(blob)
detections = faceNet.forward()
print(detections.shape)
faces = []
locs = []
preds = []
# loop over the detections
for i in range(0, detections.shape[2]):
confidence = detections[0, 0, i, 2]
if confidence > 0.5:
box = detections[0, 0, i, 3:7] * np.array([w, h, w, h])
(startX, startY, endX, endY) = box.astype("int")
(startX, startY) = (max(0, startX), max(0, startY))
(endX, endY) = (min(w - 1, endX), min(h - 1, endY))
face = frame[startY:endY, startX:endX]
face = cv2.cvtColor(face, cv2.COLOR_BGR2RGB)
face = cv2.resize(face, (224, 224))
face = img_to_array(face)
face = preprocess_input(face)
faces.append(face)
locs.append((startX, startY, endX, endY))
if len(faces) > 0:
faces = np.array(faces, dtype="float32")
preds = maskNet.predict(faces, batch_size=32)
return (locs, preds)
prototxtPath = r""C:\Users\Public\Desktop\Python_Work\Face-Mask-Detection-master\face_detector\deploy.prototxt"
weightsPath = r"C:\Users\Public\Desktop\Python_Work\Face-Mask-Detection-master\face_detector\res10_300x300_ssd_iter_140000.caffemodel"
faceNet = cv2.dnn.readNet(prototxtPath, weightsPath)
maskNet = load_model("mask_detector.model")
print("[INFO] starting video stream...")
vs = VideoStream(src=0).start()
while True:
frame = vs.read()
frame = imutils.resize(frame, width=400)
(locs, preds) = detect_and_predict_mask(frame, faceNet, maskNet)
for (box, pred) in zip(locs, preds):
# unpack the bounding box and predictions
(startX, startY, endX, endY) = box
(mask, withoutMask) = pred
label = "Mask" if mask > withoutMask else "No Mask"
color = (0, 255, 0) if label == "Mask" else (0, 0, 255)
label = "{}: {:.2f}%".format(label, max(mask, withoutMask) * 100)
cv2.putText(frame, label, (startX, startY - 10),
cv2.FONT_HERSHEY_SIMPLEX, 0.45, color, 2)
cv2.rectangle(frame, (startX, startY), (endX, endY), color, 2)
cv2.imshow("Frame", frame)
key = cv2.waitKey(1) & 0xFF
if key == ord("q"):
break
cv2.destroyAllWindows()
vs.stop()
This is what happens in the terminal when I run the code:
PS C:\Users\Public\Desktop\Python_Work> &
C:/Users/rainb/AppData/Local/Programs/Python/Python38/python.exe
c:/Users/Public/Desktop/Python_Work/Face-Mask-Detection-master/detect_mask_video.py
2021-03-16 00:55:39.090747: W tensorflow/stream_executor/platform/default/dso_loader.cc:59] Could not
load dynamic library 'cudart64_101.dll'; dlerror: cudart64_101.dll not found
2021-03-16 00:55:39.099661: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart
dlerror if you do not have a GPU set up on your machine.
Traceback (most recent call last):
File "c:/Users/Public/Desktop/Python_Work/Face-Mask-Detection-master/detect_mask_video.py", line
80, in <module>
maskNet = load_model("mask_detector.model")
File "C:\Users\rainb\AppData\Local\Programs\Python\Python38\lib\site-
packages\tensorflow\python\keras\saving\save.py", line 186, in load_model
loader_impl.parse_saved_model(filepath)
File "C:\Users\rainb\AppData\Local\Programs\Python\Python38\lib\site-
packages\tensorflow\python\saved_model\loader_impl.py", line 110, in parse_saved_model
raise IOError("SavedModel file does not exist at: %s/{%s|%s}" %
OSError: SavedModel file does not exist at:
mask_detector.model/{saved_model.pbtxt|saved_model.pb}
PS C:\Users\Public\Desktop\Python_Work>
I have the model file in the same folder as the rest of the project.
Please try to install the exact same version of dependencies that are mention in requirements.txt
keras==2.3.1
imutils==0.5.3
numpy==1.18.2
opencv-python==4.2.0.*
matplotlib==3.2.1
argparse==1.1
scipy==1.4.1
scikit-learn==0.23.1
pillow==7.2.0
streamlit==0.65.2
playsound
pyobjc
You have one too many quotation marks on your prototxtPath and
also change the path of maskNet as below:
maskNet = load_model(r"C:\Users\Public\Desktop\Python_Work\Face-Mask-Detection-master\mask_detector.model")

I am making masked face detection application with OpenCV that detect faces that wear masks but I got an error

from tensorflow.keras.applications.mobilenet_v2 import preprocess_input
from tensorflow.keras.preprocessing.image import img_to_array
from tensorflow.keras.models import load_model
from imutils.video import VideoStream
import numpy as np
import argparse
import imutils
import time
import cv2
import os
def detect_and_predict_mask(frame, faceNet, maskNet):
(h, w) = frame.shape[:2]
blob = cv2.dnn.blobFromImage(frame, 1.0, (300, 300),
(104.0, 177.0, 123.0))
faceNet.setInput(blob)
detections = faceNet.forward()
faces = []
locs = []
preds = []
for i in range(0, detections.shape[2]):
confidence = detections[0, 0, i, 2]
if confidence > args["confidence"]:
box = detections[0, 0, i, 3:7] * np.array([w, h, w, h])
(startX, startY, endX, endY) = box.astype("int")
(startX, startY) = (max(0, startX), max(0, startY))
(endX, endY) = (min(w - 1, endX), min(h - 1, endY))
face = frame[startY:endY, startX:endX]
face = cv2.cvtColor(face, cv2.COLOR_BGR2RGB)
face = cv2.resize(face, (224, 224))
face = img_to_array(face)
face = preprocess_input(face)
face = np.expand_dims(face, axis=0)
faces.append(face)
locs.append((startX, startY, endX, endY))
if len(faces) > 0:
preds = maskNet.predict(faces)
return (locs, preds)
ap = argparse.ArgumentParser()
ap.add_argument("-f", "--face", type=str,
default="face_detector",
help="path to face detector model directory")
ap.add_argument("-m", "--model", type=str,
default="mask_detector.model",
help="path to trained face mask detector model")
ap.add_argument("-c", "--confidence", type=float, default=0.5,
help="minimum probability to filter weak detections")
args = vars(ap.parse_args())
print("[INFO] loading face detector model...")
prototxtPath = os.path.sep.join([args["face"], "deploy.prototxt"])
weightsPath = os.path.sep.join([args["face"],
"res10_300x300_ssd_iter_140000.caffemodel"])
faceNet = cv2.dnn.readNet(prototxtPath, weightsPath)
print("[INFO] loading face mask detector model...")
maskNet = load_model(args["model"])
print("[INFO] starting video stream...")
vs = VideoStream(src=0).start()
time.sleep(2.0)
while True:
frame = vs.read()
frame = imutils.resize(frame, width=400)
(locs, preds) = detect_and_predict_mask(frame, faceNet, maskNet)
for (box, pred) in zip(locs, preds):
(startX, startY, endX, endY) = box
(mask, withoutMask) = pred
label = "Mask" if mask > withoutMask else "No Mask"
color = (0, 255, 0) if label == "Mask" else (0, 0, 255)
label = "{}: {:.2f}%".format(label, max(mask, withoutMask) * 100)
cv2.putText(frame, label, (startX, startY - 10),
cv2.FONT_HERSHEY_SIMPLEX, 0.45, color, 2)
cv2.rectangle(frame, (startX, startY), (endX, endY), color, 2)
cv2.imshow("Frame", frame)
key = cv2.waitKey(1) & 0xFF
if key == ord("q"):
break
cv2.destroyAllWindows()
vs.stop()
Is there any modules that I need to import
Or is it all imported correctly.
I do not debug it
I reformat file one time.
I have got all of the needed xml and jpg files.
I have import all of the modules that is needed... I think so
Below is the error
Can you help me pls Im new to OpenCV and got an complicated error like this
Thanks to all of Stackoverflow community for help:)
C:\Users\Toshiba\Desktop\python_temelleri\venv\Scripts\python.exe C:/Users/Toshiba/Desktop/python_temelleri/detect_mask_video.py
2020-08-28 16:47:05.729423: W tensorflow/stream_executor/platform/default/dso_loader.cc:59] Could not load dynamic library 'cudart64_101.dll'; dlerror: cudart64_101.dll not found
2020-08-28 16:47:05.730054: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.
Traceback (most recent call last):
File "C:/Users/Toshiba/Desktop/python_temelleri/detect_mask_video.py", line 60, in <module>
faceNet = cv2.dnn.readNet(prototxtPath, weightsPath)
cv2.error: OpenCV(4.4.0) C:\Users\appveyor\AppData\Local\Temp\1\pip-req-build-2b5g8ysb\opencv\modules\dnn\src\caffe\caffe_io.cpp:1121: error: (-2:Unspecified error) FAILED: fs.is_open(). Can't open "face_detector\deploy.prototxt" in function 'cv::dnn::ReadProtoFromTextFile'
[INFO] loading face detector model...
Process finished with exit code 1
You either don't provide models or the paths to the model are not correct. print the values of prototxtPath and weightsPath to check if you provide correct paths to the models.

Categories

Resources