{
  "id": "opencv/good-features-to-track-empty",
  "signature": "cv::error: (-215:Assertion failed) nfeatures > 0 in function 'cv::goodFeaturesToTrack'",
  "signature_zh": "cv::error: (-215：断言失败) nfeatures > 0 在函数 'cv::goodFeaturesToTrack' 中",
  "regex": "cv::error:\\s*\\(-215:Assertion failed\\) nfeatures > 0 in function 'cv::goodFeaturesToTrack'",
  "domain": "opencv",
  "category": "assertion_error",
  "subcategory": null,
  "root_cause": "goodFeaturesToTrack was called with maxCorners set to 0 or a negative value, which is invalid because the function requires at least one corner to detect.",
  "root_cause_type": "generic",
  "root_cause_zh": "goodFeaturesToTrack 被调用时 maxCorners 设置为 0 或负值，这是无效的，因为该函数至少需要检测一个角点。",
  "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": "Increasing the qualityLevel parameter to a very high value (e.g., 0.99) hoping to find more corners but maxCorners is still 0",
      "fail_rate": 0.3,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Assuming the error is from the image being too dark and applying histogram equalization without fixing maxCorners",
      "fail_rate": 0.25,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Passing maxCorners as a float (e.g., 0.5) which gets truncated to 0 in some language bindings",
      "fail_rate": 0.2,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Set maxCorners to a positive integer, e.g., corners = cv2.goodFeaturesToTrack(gray, maxCorners=100, qualityLevel=0.01, minDistance=10). Ensure maxCorners > 0.",
      "success_rate": 0.95,
      "how": "Set maxCorners to a positive integer, e.g., corners = cv2.goodFeaturesToTrack(gray, maxCorners=100, qualityLevel=0.01, minDistance=10). Ensure maxCorners > 0.",
      "condition": "",
      "sources": []
    },
    {
      "action": "If the number of corners to detect is unknown, use a reasonable default like 1000 and then filter later: corners = cv2.goodFeaturesToTrack(gray, maxCorners=1000, qualityLevel=0.01, minDistance=10).",
      "success_rate": 0.9,
      "how": "If the number of corners to detect is unknown, use a reasonable default like 1000 and then filter later: corners = cv2.goodFeaturesToTrack(gray, maxCorners=1000, qualityLevel=0.01, minDistance=10).",
      "condition": "",
      "sources": []
    },
    {
      "action": "Validate maxCorners before calling: if max_corners <= 0: raise ValueError('maxCorners must be positive'). Also ensure the image is grayscale and non-empty.",
      "success_rate": 0.85,
      "how": "Validate maxCorners before calling: if max_corners <= 0: raise ValueError('maxCorners must be positive'). Also ensure the image is grayscale and non-empty.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "将 maxCorners 设置为正整数，例如：corners = cv2.goodFeaturesToTrack(gray, maxCorners=100, qualityLevel=0.01, minDistance=10)。确保 maxCorners > 0。",
    "如果未知要检测的角点数量，使用合理的默认值如 1000，然后后续过滤：corners = cv2.goodFeaturesToTrack(gray, maxCorners=1000, qualityLevel=0.01, minDistance=10)。",
    "在调用前验证 maxCorners：if max_corners <= 0: raise ValueError('maxCorners must be positive')。同时确保图像是灰度且非空。"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://docs.opencv.org/4.x/dd/d1a/group__imgproc__feature.html#ga1d6bb77486c8f92d79c8793ad995d541",
  "official_doc_section": null,
  "error_code": "-215",
  "verification_tier": "ai_generated",
  "confidence": 0.81,
  "fix_success_rate": 0.92,
  "resolvable": "true",
  "first_seen": "2023-04-18",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}