我试着学习蟒蛇,不管有没有人戴过面具。
当我运行这段代码时
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()
我搞错了
---------------------------------------------------------------------------
error Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_13672/2145281415.py in <module>
34 prototxtPath = r"face_detector\deploy.prototxt"
35 weightsPath = r"face_detector\res10_300x300_ssd_iter_140000.caffemodel"
---> 36 faceNet = cv2.dnn.readNet(prototxtPath, weightsPath)
37
38 maskNet = load_model("mask_detector.model")
error: OpenCV(4.5.4) D:\a\opencv-python\opencv-python\opencv\modules\dnn\src\caffe\caffe_io.cpp:1126: error: (-2:Unspecified error) FAILED: fs.is_open(). Can't open "face_detector\deploy.prototxt" in function 'cv::dnn::ReadProtoFromTextFile'
我试着用同样的问题在google上搜索,但在某些文件中我遇到了问题。我的python项目文件在C:\Users\mfahm\anaconda3\Test.中。我弄错文件名了吗?
发布于 2022-05-26 01:54:44
我也遇到过类似的问题。结果发现你必须在你的道路上使用/而不是\。所以你的代码会变成这样
prototxtPath = "face_detector/deploy.prototxt"
weightsPath = "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()
我正在使用opencv 4.0.1
https://stackoverflow.com/questions/70118899
复制相似问题