# cv::error: (-215:Assertion failed) nfeatures > 0 in function 'cv::goodFeaturesToTrack'

- **ID:** `opencv/good-features-to-track-empty`
- **Domain:** opencv
- **Category:** assertion_error
- **Error Code:** `-215`
- **Verification:** ai_generated
- **Fix Rate:** 92%

## 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.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 4.5.5 | active | — | — |
| 4.6.0 | active | — | — |
| 4.7.0 | active | — | — |
| 4.8.0 | active | — | — |
| 4.9.0 | active | — | — |

## Workarounds

1. **Set maxCorners to a positive integer, e.g., corners = cv2.goodFeaturesToTrack(gray, maxCorners=100, qualityLevel=0.01, minDistance=10). Ensure maxCorners > 0.** (95% success)
   ```
   Set maxCorners to a positive integer, e.g., corners = cv2.goodFeaturesToTrack(gray, maxCorners=100, qualityLevel=0.01, minDistance=10). Ensure maxCorners > 0.
   ```
2. **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).** (90% success)
   ```
   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).
   ```
3. **Validate maxCorners before calling: if max_corners <= 0: raise ValueError('maxCorners must be positive'). Also ensure the image is grayscale and non-empty.** (85% success)
   ```
   Validate maxCorners before calling: if max_corners <= 0: raise ValueError('maxCorners must be positive'). Also ensure the image is grayscale and non-empty.
   ```

## Dead Ends

- **** — Increasing the qualityLevel parameter to a very high value (e.g., 0.99) hoping to find more corners but maxCorners is still 0 (30% fail)
- **** — Assuming the error is from the image being too dark and applying histogram equalization without fixing maxCorners (25% fail)
- **** — Passing maxCorners as a float (e.g., 0.5) which gets truncated to 0 in some language bindings (20% fail)
