{
  "id": "opencv/calib3d-fisheye-estimate-extrinsics-invalid",
  "signature": "cv::error: (-215:Assertion failed) npoints >= 0 && npoints == std::max(1, (int)objectPoints.size()) in function 'cv::fisheye::estimateExtrinsics'",
  "signature_zh": "cv::error: (-215:断言失败) npoints >= 0 && npoints == std::max(1, (int)objectPoints.size()) 在函数 'cv::fisheye::estimateExtrinsics' 中",
  "regex": "fisheye::estimateExtrinsics.*npoints",
  "domain": "opencv",
  "category": "assertion_error",
  "subcategory": null,
  "root_cause": "The number of image points (npoints) passed to fisheye::estimateExtrinsics does not match the number of object points, or objectPoints vector is empty.",
  "root_cause_type": "generic",
  "root_cause_zh": "传递给 fisheye::estimateExtrinsics 的图像点数 (npoints) 与物点数不匹配，或者 objectPoints 向量为空。",
  "versions": [
    {
      "version": "opencv-4.5.5",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "opencv-4.8.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "opencv-4.9.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Use cv::fisheye::calibrate instead of estimateExtrinsics",
      "why_fails": "calibrate is for full calibration, not for single-view extrinsic estimation. It requires multiple views and returns different outputs.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    },
    {
      "action": "Set npoints to a large constant like 100",
      "why_fails": "npoints must be exactly the size of the imagePoints vector. A hardcoded value will always mismatch unless coincidentally correct.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    },
    {
      "action": "Convert objectPoints to a vector of cv::Point3f instead of cv::Point3d",
      "why_fails": "The assertion checks size, not type. Type mismatch causes a different error, but size mismatch persists.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Ensure imagePoints and objectPoints have the same size: assert(imagePoints.size() == objectPoints.size()); Then call: cv::fisheye::estimateExtrinsics(objectPoints, imagePoints, K, D, rvec, tvec);",
      "success_rate": 0.9,
      "how": "Ensure imagePoints and objectPoints have the same size: assert(imagePoints.size() == objectPoints.size()); Then call: cv::fisheye::estimateExtrinsics(objectPoints, imagePoints, K, D, rvec, tvec);",
      "condition": "",
      "sources": []
    },
    {
      "action": "If using a chessboard, use cv::findChessboardCorners to get imagePoints and generate objectPoints with cv::fisheye::calcChessboardCorners. Example: std::vector<cv::Point3f> objp; cv::fisheye::calcChessboardCorners(cv::Size(9,6), 1.0f, objp); Then match sizes.",
      "success_rate": 0.85,
      "how": "If using a chessboard, use cv::findChessboardCorners to get imagePoints and generate objectPoints with cv::fisheye::calcChessboardCorners. Example: std::vector<cv::Point3f> objp; cv::fisheye::calcChessboardCorners(cv::Size(9,6), 1.0f, objp); Then match sizes.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Debug by printing sizes before the call: std::cout << 'obj size: ' << objectPoints.size() << ' img size: ' << imagePoints.size() << std::endl; If they differ, pad or trim the larger vector to match.",
      "success_rate": 0.8,
      "how": "Debug by printing sizes before the call: std::cout << 'obj size: ' << objectPoints.size() << ' img size: ' << imagePoints.size() << std::endl; If they differ, pad or trim the larger vector to match.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Ensure imagePoints and objectPoints have the same size: assert(imagePoints.size() == objectPoints.size()); Then call: cv::fisheye::estimateExtrinsics(objectPoints, imagePoints, K, D, rvec, tvec);",
    "If using a chessboard, use cv::findChessboardCorners to get imagePoints and generate objectPoints with cv::fisheye::calcChessboardCorners. Example: std::vector<cv::Point3f> objp; cv::fisheye::calcChessboardCorners(cv::Size(9,6), 1.0f, objp); Then match sizes.",
    "Debug by printing sizes before the call: std::cout << 'obj size: ' << objectPoints.size() << ' img size: ' << imagePoints.size() << std::endl; If they differ, pad or trim the larger vector to match."
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://docs.opencv.org/4.x/db/d58/group__calib3d__fisheye.html",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.83,
  "fix_success_rate": 0.86,
  "resolvable": "true",
  "first_seen": "2023-11-25",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}