{
  "id": "opencv/dnn-caffe-model-load-failed",
  "signature": "cv::error: (-2:Unspecified error) FAILED: fs.is_open(). Can't open file: 'model.prototxt' in function 'ReadProtoFromTextFile'",
  "signature_zh": "cv::error: (-2:未指定错误) 失败: fs.is_open()。无法打开文件: 'model.prototxt' 在函数 'ReadProtoFromTextFile' 中",
  "regex": "cv::error: \\(-2:Unspecified error\\) FAILED: fs\\.is_open\\(\\)\\. Can't open file: '.*\\.prototxt' in function 'ReadProtoFromTextFile'",
  "domain": "opencv",
  "category": "resource_error",
  "subcategory": null,
  "root_cause": "Caffe model prototxt file path is incorrect or the file does not exist when loading a DNN network.",
  "root_cause_type": "generic",
  "root_cause_zh": "加载DNN网络时，Caffe模型的prototxt文件路径不正确或文件不存在。",
  "versions": [
    {
      "version": "4.5.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "4.6.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "4.7.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "4.8.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "4.9.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "4.10.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "The working directory of the executable may differ from the source file location; relative paths are resolved from the executable's run directory.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "The function expects the prototxt file as the first argument; swapping arguments leads to a different error but often confuses users into thinking the file is missing.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Use an absolute path to the prototxt file. Example: cv::dnn::Net net = cv::dnn::readNetFromCaffe(\"/absolute/path/to/deploy.prototxt\", \"/absolute/path/to/model.caffemodel\");",
      "success_rate": 0.95,
      "how": "Use an absolute path to the prototxt file. Example: cv::dnn::Net net = cv::dnn::readNetFromCaffe(\"/absolute/path/to/deploy.prototxt\", \"/absolute/path/to/model.caffemodel\");",
      "condition": "",
      "sources": []
    },
    {
      "action": "Verify file existence using std::ifstream before loading: std::ifstream f(\"deploy.prototxt\"); if (!f.good()) { std::cerr << \"File not found\"; }",
      "success_rate": 0.9,
      "how": "Verify file existence using std::ifstream before loading: std::ifstream f(\"deploy.prototxt\"); if (!f.good()) { std::cerr << \"File not found\"; }",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Use an absolute path to the prototxt file. Example: cv::dnn::Net net = cv::dnn::readNetFromCaffe(\"/absolute/path/to/deploy.prototxt\", \"/absolute/path/to/model.caffemodel\");",
    "Verify file existence using std::ifstream before loading: std::ifstream f(\"deploy.prototxt\"); if (!f.good()) { std::cerr << \"File not found\"; }"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://docs.opencv.org/4.x/d6/d0f/group__dnn.html#ga29f34df9b6c6f0d44e5f3b9e2b8f0d4e",
  "official_doc_section": null,
  "error_code": "-2",
  "verification_tier": "ai_generated",
  "confidence": 0.87,
  "fix_success_rate": 0.93,
  "resolvable": "true",
  "first_seen": "2023-08-20",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}