-28 opencv computation_error ai_generated true

cv::error: (-28:Insufficient number of valid points) in function 'cv::findHomography'

ID: opencv/feature-matching-insufficient-matches

Also available as: JSON · Markdown · 中文
82%Fix Rate
88%Confidence
1Evidence
2024-03-15First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
4.8.0 active — — —
4.9.0 active — — —
4.10.0 active — — —

Root Cause

The number of matched feature points between two images is below the minimum required for homography estimation.

generic

中文

两幅图像之间匹配的特征点数量低于单应性矩阵估计所需的最小值。

Official Documentation

https://docs.opencv.org/4.x/d9/d0c/group__calib3d.html#ga4abc2ece9fab9398f2e560d53c8c9780

Workarounds

  1. 85% success Increase the number of keypoints detected by using SIFT with nfeatures=5000 and then apply ratio test (Lowe's ratio < 0.75) to filter matches.
    Increase the number of keypoints detected by using SIFT with nfeatures=5000 and then apply ratio test (Lowe's ratio < 0.75) to filter matches.
  2. 80% success Use FLANN-based matcher with k=2 and then apply cross-check filtering (e.g., cv::BFMatcher with crossCheck=true) to retain only robust matches.
    Use FLANN-based matcher with k=2 and then apply cross-check filtering (e.g., cv::BFMatcher with crossCheck=true) to retain only robust matches.

中文步骤

  1. Increase the number of keypoints detected by using SIFT with nfeatures=5000 and then apply ratio test (Lowe's ratio < 0.75) to filter matches.
  2. Use FLANN-based matcher with k=2 and then apply cross-check filtering (e.g., cv::BFMatcher with crossCheck=true) to retain only robust matches.

Dead Ends

Common approaches that don't work:

  1. Lowering the RANSAC reprojection threshold to 1.0 to force more inliers 85% fail

    Excessively low threshold rejects valid matches, reducing inlier count further.

  2. Using ORB detector with default parameters without tuning 75% fail

    ORB may generate too few or low-quality matches for scenes with low texture or large viewpoint changes.