【问题标题】:Can't open prototxt无法打开prototxt
【发布时间】:2020-04-22 03:18:29
【问题描述】:
   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)

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

我没有找到任何有用的东西

【问题讨论】:

  • 文件C:\Users\osama\Desktop\opencv-face-recognitio\face_detection_model\deploy.prototxt.txt真的存在吗?
  • 是的,我在没有 .txt 的情况下尝试过,但不起作用
  • 你能在文本编辑器中打开这个文件吗?这条路正确吗?也许 Windows 没有显示真正的扩展名,它不仅仅是.txt。您也可以查看print( os.listdir(r"C:\Users\osama\Desktop\opencv-face-recognitio\face_detection_model\") )
  • 不,我无法在文本编辑器中打开它,但路径正确
  • 我试过你的代码但是我有一个错误 FileNotFoundError: [WinError 3] The system cannot find the path specified: 'C:\\Users\\osama\\Desktop\\opencv-face-recognitio \\face_detection_model\\deploy.prototxt'

标签: python opencv deep-learning face-detection


【解决方案1】:

我被困在这个问题上好几天了。 这个solution on github 终于为我工作了。

from os.path import dirname, join

protoPath = join(dirname(__file__), "deploy.prototxt")
modelPath = join(dirname(__file__), "openCVs_facedetector")

操作系统:windows10

【讨论】:

    猜你喜欢
    • 2014-07-26
    • 2019-01-06
    • 2021-12-01
    • 2017-02-06
    • 2020-08-29
    • 2018-09-22
    • 2023-04-06
    • 2017-12-14
    • 2011-05-07
    相关资源
    最近更新 更多