{
  "id": "opencv/dnn-blob-from-image-empty",
  "signature": "cv::error: (-215:Assertion failed) !blob.empty() in function 'cv::dnn::blobFromImage'",
  "signature_zh": "cv::error: (-215：断言失败) !blob.empty() 在函数 'cv::dnn::blobFromImage' 中",
  "regex": "cv::error:\\s*\\(-215:Assertion failed\\) !blob.empty\\(\\) in function 'cv::dnn::blobFromImage'",
  "domain": "opencv",
  "category": "assertion_error",
  "subcategory": null,
  "root_cause": "blobFromImage failed because the input image is empty (not loaded or corrupted), or the preprocessing parameters (e.g., size or mean subtraction) caused an empty blob.",
  "root_cause_type": "generic",
  "root_cause_zh": "blobFromImage 失败，因为输入图像为空（未加载或损坏），或者预处理参数（如尺寸或均值减法）导致 blob 为空。",
  "versions": [
    {
      "version": "4.5.5",
      "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"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Changing the mean subtraction values arbitrarily without checking if the image was loaded correctly",
      "fail_rate": 0.35,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Assuming the error is from the model architecture and re-downloading the model files",
      "fail_rate": 0.25,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Increasing the blob size to a large value like (1, 3, 1000, 1000) hoping it will bypass the empty check",
      "fail_rate": 0.2,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Verify image loading: img = cv2.imread('path'); if img is None: raise ValueError('Image not loaded'). Then check img.shape before calling blobFromImage.",
      "success_rate": 0.95,
      "how": "Verify image loading: img = cv2.imread('path'); if img is None: raise ValueError('Image not loaded'). Then check img.shape before calling blobFromImage.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Ensure the blob size matches the model input. Example: blob = cv2.dnn.blobFromImage(img, 1.0, (224, 224), (104, 117, 123), swapRB=True, crop=False). Print blob.shape to confirm non-empty.",
      "success_rate": 0.9,
      "how": "Ensure the blob size matches the model input. Example: blob = cv2.dnn.blobFromImage(img, 1.0, (224, 224), (104, 117, 123), swapRB=True, crop=False). Print blob.shape to confirm non-empty.",
      "condition": "",
      "sources": []
    },
    {
      "action": "If using swapRB=True, ensure the image is in BGR order (default for imread). If the image is already RGB, set swapRB=False to avoid channel mismatch.",
      "success_rate": 0.85,
      "how": "If using swapRB=True, ensure the image is in BGR order (default for imread). If the image is already RGB, set swapRB=False to avoid channel mismatch.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "验证图像加载：img = cv2.imread('path'); if img is None: raise ValueError('Image not loaded')。然后在调用 blobFromImage 前检查 img.shape。",
    "确保 blob 尺寸匹配模型输入。示例：blob = cv2.dnn.blobFromImage(img, 1.0, (224, 224), (104, 117, 123), swapRB=True, crop=False)。打印 blob.shape 确认非空。",
    "如果使用 swapRB=True，确保图像是 BGR 顺序（imread 默认）。如果图像已经是 RGB，设置 swapRB=False 以避免通道不匹配。"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://docs.opencv.org/4.x/d6/d0f/group__dnn.html#ga29f34df9376379a603acd8df581ac8d7",
  "official_doc_section": null,
  "error_code": "-215",
  "verification_tier": "ai_generated",
  "confidence": 0.83,
  "fix_success_rate": 0.9,
  "resolvable": "true",
  "first_seen": "2023-11-05",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}