{
  "id": "opencv/homography-mask-invalid-size",
  "signature": "cv::error: (-228:Unknown error code 228) The homography mask has invalid size in function 'cv::findHomography'",
  "signature_zh": "cv::error: (-228:未知错误码228) 单应性矩阵掩码尺寸无效 在函数 'cv::findHomography' 中",
  "regex": "cv::error: \\(-228:Unknown error code 228\\) The homography mask has invalid size in function 'cv::findHomography'",
  "domain": "opencv",
  "category": "assertion_error",
  "subcategory": null,
  "root_cause": "The output mask passed to findHomography has a size that does not match the number of input point pairs.",
  "root_cause_type": "generic",
  "root_cause_zh": "传递给findHomography的输出掩码尺寸与输入点对数量不匹配。",
  "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 mask must have exactly as many rows as the number of point pairs; an arbitrary size causes an assertion failure.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "In certain overloads, omitting the mask is allowed, but if a mask is provided, it must be correctly sized; using an empty Mat can still trigger this error if the function expects a non-empty mask.",
      "fail_rate": 0.65,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Ensure the mask has the correct size: cv::Mat mask; cv::findHomography(srcPoints, dstPoints, cv::RANSAC, 3.0, mask); The mask is automatically resized by the function if passed as an output Mat. Do not pre-allocate it. Example: std::vector<cv::Point2f> src, dst; cv::Mat mask; cv::findHomography(src, dst, cv::RANSAC, 3.0, mask);",
      "success_rate": 0.95,
      "how": "Ensure the mask has the correct size: cv::Mat mask; cv::findHomography(srcPoints, dstPoints, cv::RANSAC, 3.0, mask); The mask is automatically resized by the function if passed as an output Mat. Do not pre-allocate it. Example: std::vector<cv::Point2f> src, dst; cv::Mat mask; cv::findHomography(src, dst, cv::RANSAC, 3.0, mask);",
      "condition": "",
      "sources": []
    },
    {
      "action": "If using Python, simply call mask = None and let the function handle it: mask = cv.findHomography(src_pts, dst_pts, cv.RANSAC, 3.0, mask=None)[1].",
      "success_rate": 0.9,
      "how": "If using Python, simply call mask = None and let the function handle it: mask = cv.findHomography(src_pts, dst_pts, cv.RANSAC, 3.0, mask=None)[1].",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Ensure the mask has the correct size: cv::Mat mask; cv::findHomography(srcPoints, dstPoints, cv::RANSAC, 3.0, mask); The mask is automatically resized by the function if passed as an output Mat. Do not pre-allocate it. Example: std::vector<cv::Point2f> src, dst; cv::Mat mask; cv::findHomography(src, dst, cv::RANSAC, 3.0, mask);",
    "If using Python, simply call mask = None and let the function handle it: mask = cv.findHomography(src_pts, dst_pts, cv.RANSAC, 3.0, mask=None)[1]."
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://docs.opencv.org/4.x/d9/d0c/group__calib3d.html#ga4abc2e5c3f5b8c9e8f6d7a5b6c0d1e2f",
  "official_doc_section": null,
  "error_code": "-228",
  "verification_tier": "ai_generated",
  "confidence": 0.87,
  "fix_success_rate": 0.94,
  "resolvable": "true",
  "first_seen": "2024-03-12",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}