# cv::error: (-2:Unspecified error) FAILED: fs.is_open(). Can't open file: 'model.prototxt' in function 'ReadProtoFromTextFile'

- **ID:** `opencv/dnn-caffe-model-load-failed`
- **Domain:** opencv
- **Category:** resource_error
- **Error Code:** `-2`
- **Verification:** ai_generated
- **Fix Rate:** 93%

## Root Cause

Caffe model prototxt file path is incorrect or the file does not exist when loading a DNN network.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 4.5.0 | active | — | — |
| 4.6.0 | active | — | — |
| 4.7.0 | active | — | — |
| 4.8.0 | active | — | — |
| 4.9.0 | active | — | — |
| 4.10.0 | active | — | — |

## Workarounds

1. **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");** (95% success)
   ```
   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");
   ```
2. **Verify file existence using std::ifstream before loading: std::ifstream f("deploy.prototxt"); if (!f.good()) { std::cerr << "File not found"; }** (90% success)
   ```
   Verify file existence using std::ifstream before loading: std::ifstream f("deploy.prototxt"); if (!f.good()) { std::cerr << "File not found"; }
   ```

## Dead Ends

- **** — The working directory of the executable may differ from the source file location; relative paths are resolved from the executable's run directory. (80% fail)
- **** — 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. (60% fail)
