# cv::error: (-228:Unknown error code 228) The homography mask has invalid size in function 'cv::findHomography'

- **ID:** `opencv/homography-mask-invalid-size`
- **Domain:** opencv
- **Category:** assertion_error
- **Error Code:** `-228`
- **Verification:** ai_generated
- **Fix Rate:** 94%

## Root Cause

The output mask passed to findHomography has a size that does not match the number of input point pairs.

## Version Compatibility

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

## Workarounds

1. **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);** (95% success)
   ```
   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);
   ```
2. **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].** (90% success)
   ```
   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].
   ```

## Dead Ends

- **** — The mask must have exactly as many rows as the number of point pairs; an arbitrary size causes an assertion failure. (80% fail)
- **** — 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. (65% fail)
