{
  "id": "opencv/opticalflow-calcopticalflowfarneback-input-type-mismatch",
  "signature": "cv::error: (-215:Assertion failed) src1.type() == CV_8UC1 in function 'calcOpticalFlowFarneback'",
  "signature_zh": "cv::error: (-215:断言失败) src1.type() == CV_8UC1 在函数 'calcOpticalFlowFarneback' 中",
  "regex": "calcOpticalFlowFarneback.*Assertion failed.*src1\\.type\\(\\) == CV_8UC1",
  "domain": "opencv",
  "category": "type_error",
  "subcategory": null,
  "root_cause": "calcOpticalFlowFarneback requires the input image to be single-channel 8-bit (grayscale), but a multi-channel or different depth image was provided.",
  "root_cause_type": "generic",
  "root_cause_zh": "calcOpticalFlowFarneback 要求输入图像为单通道 8 位（灰度图），但提供了多通道或不同深度的图像。",
  "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": "The function signature expects a single channel; a 3-channel input will still trigger the assertion.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "The original multi-channel image remains unchanged, causing the assertion to fail again.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Convert the input image to grayscale before calling calcOpticalFlowFarneback: gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY); ensure gray is a single-channel 8-bit image.",
      "success_rate": 0.95,
      "how": "Convert the input image to grayscale before calling calcOpticalFlowFarneback: gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY); ensure gray is a single-channel 8-bit image.",
      "condition": "",
      "sources": []
    },
    {
      "action": "If the input is already grayscale but has a different depth (e.g., 16-bit), use cv2.convertScaleAbs to convert to CV_8U: gray = cv2.convertScaleAbs(gray, alpha=(255.0/65535.0)).",
      "success_rate": 0.85,
      "how": "If the input is already grayscale but has a different depth (e.g., 16-bit), use cv2.convertScaleAbs to convert to CV_8U: gray = cv2.convertScaleAbs(gray, alpha=(255.0/65535.0)).",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Convert the input image to grayscale before calling calcOpticalFlowFarneback: gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY); ensure gray is a single-channel 8-bit image.",
    "If the input is already grayscale but has a different depth (e.g., 16-bit), use cv2.convertScaleAbs to convert to CV_8U: gray = cv2.convertScaleAbs(gray, alpha=(255.0/65535.0))."
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://docs.opencv.org/4.x/dc/d6b/group__video__track.html#ga5d10ebbd59fe09c1f0f8e3c9d0d2c5b9",
  "official_doc_section": null,
  "error_code": "-215",
  "verification_tier": "ai_generated",
  "confidence": 0.88,
  "fix_success_rate": 0.9,
  "resolvable": "true",
  "first_seen": "2023-03-12",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}