{
  "id": "opencv/stereo-bm-disparity-type",
  "signature": "cv::error: (-215:Assertion failed) src1.type() == CV_8UC1 && src2.type() == CV_8UC1 in function 'cv::StereoBM::compute'",
  "signature_zh": "cv::error: (-215:断言失败) src1.type() == CV_8UC1 && src2.type() == CV_8UC1 在函数 'cv::StereoBM::compute' 中",
  "regex": "src1.type\\(\\) == CV_8UC1 && src2.type\\(\\) == CV_8UC1",
  "domain": "opencv",
  "category": "type_error",
  "subcategory": null,
  "root_cause": "The input images to StereoBM must be single-channel 8-bit grayscale images; color images or other types cause this assertion.",
  "root_cause_type": "generic",
  "root_cause_zh": "StereoBM 的输入图像必须是单通道 8 位灰度图像；彩色图像或其他类型会导致此断言。",
  "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"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Convert images to float32 before passing to StereoBM",
      "why_fails": "StereoBM requires CV_8UC1 (uint8), not float. Converting to float will cause a different type assertion error.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    },
    {
      "action": "Resize images to be larger",
      "why_fails": "The issue is data type, not image size.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    },
    {
      "action": "Use cv2.cvtColor with COLOR_BGR2GRAY on already grayscale images",
      "why_fails": "If the image is already single-channel, cvtColor will fail; the correct fix is to ensure the image is loaded as grayscale.",
      "fail_rate": 0.5,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Load images as grayscale using cv2.imread with cv2.IMREAD_GRAYSCALE flag, or convert color images to grayscale using cv2.cvtColor(img_left, cv2.COLOR_BGR2GRAY).",
      "success_rate": 0.95,
      "how": "Load images as grayscale using cv2.imread with cv2.IMREAD_GRAYSCALE flag, or convert color images to grayscale using cv2.cvtColor(img_left, cv2.COLOR_BGR2GRAY).",
      "condition": "",
      "sources": []
    },
    {
      "action": "Check the image type with img.dtype and img.shape before calling compute; ensure dtype is uint8 and len(shape)==2.",
      "success_rate": 0.85,
      "how": "Check the image type with img.dtype and img.shape before calling compute; ensure dtype is uint8 and len(shape)==2.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Load images as grayscale using cv2.imread with cv2.IMREAD_GRAYSCALE flag, or convert color images to grayscale using cv2.cvtColor(img_left, cv2.COLOR_BGR2GRAY).",
    "Check the image type with img.dtype and img.shape before calling compute; ensure dtype is uint8 and len(shape)==2."
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://docs.opencv.org/4.x/d9/d0c/group__calib3d.html",
  "official_doc_section": null,
  "error_code": "-215",
  "verification_tier": "ai_generated",
  "confidence": 0.87,
  "fix_success_rate": 0.9,
  "resolvable": "true",
  "first_seen": "2023-09-05",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}