英文:
Can't open prototxt
问题
以下是您提供的代码部分的中文翻译:
protoPath = os.path.sep.join([r"C:\Users\osama\Desktop\opencv-face recognitio\face_detection_model", "deploy.prototxt.txt"])
modelPath = os.path.sep.join([r"C:\Users\osama\Desktop\opencv-face-recognitio\face_detection_model", "res10_300x300_ssd_iter_140000.caffemodel"])
detector = cv2.dnn.readNetFromCaffe(protoPath, modelPath)
这是您的代码,但我尝试了一切仍然无法打开它。
detector = cv2.dnn.readNetFromCaffe(protoPath, modelPath)
错误:OpenCV(4.1.2) C:\projects\opencv-python\opencv\modules\dnn\src\caffe\caffe_io.cpp:1121: 错误:(-2:未指定错误) 失败:fs.is_open()。无法打开 "C:\Users\osama\Desktop\opencv-face-recognitio\face_detection_model\deploy.prototxt.txt" 在函数 'cv::dnn::ReadProtoFromTextFile' 中。
我没有找到任何有用的信息。
英文:
protoPath = os.path.sep.join([r"C:\Users\osama\Desktop\opencv-face recognitio\face_detection_model",
"deploy.prototxt.txt"])
modelPath = os.path.sep.join([r"C:\Users\osama\Desktop\opencv-face-recognitio\face_detection_model",
"res10_300x300_ssd_iter_140000.caffemodel"])
detector = cv2.dnn.readNetFromCaffe(protoPath, modelPath)
this is the code but i tried everything and is still can't open it
detector = cv2.dnn.readNetFromCaffe(protoPath, modelPath)
error: OpenCV(4.1.2) C:\projects\opencv-python\opencv\modules\dnn\src\caffe\caffe_io.cpp:1121: error: (-2:Unspecified error) FAILED: fs.is_open(). Can't open "C:\Users\osama\Desktop\opencv-face-recognitio\face_detection_model\deploy.prototxt.txt" in function 'cv::dnn::ReadProtoFromTextFile
i did't find anything useful
答案1
得分: 4
I was stuck on this for days.
This solution on github worked for me finally.
from os.path import dirname, join
protoPath = join(dirname(file), "deploy.prototxt")
modelPath = join(dirname(file), "openCVs_facedetector")
os: windows10
英文:
I was stuck on this for days.
This solution on github worked for me finally.
from os.path import dirname, join
protoPath = join(dirname(__file__), "deploy.prototxt")
modelPath = join(dirname(__file__), "openCVs_facedetector")
os: windows10
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论