无法打开prototxt文件。

huangapple go评论84阅读模式
英文:

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

huangapple
  • 本文由 发表于 2020年1月3日 22:49:16
  • 转载请务必保留本文链接:https://go.coder-hub.com/59580608.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定