opencv calibration_error ai_generated true

cv2.error: (-28:Insufficient number of valid points) in function 'calibrateCamera'

ID: opencv/calibration-insufficient-points

Also available as: JSON · Markdown
85%Fix Rate
88%Confidence
3Evidence
2023-01-01First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
4 active

Root Cause

Camera calibration fails because too few calibration images had detected corners. Need more images or better pattern detection.

generic

Workarounds

  1. 92% success Capture more calibration images (at least 15-20) at varied angles
    Tilt board at 30-45 degrees. Cover all regions of the frame. Vary distance from camera.

    Sources: https://docs.opencv.org/4.x/d0/d05/tutorial_dnn_googlenet.html

  2. 90% success Verify findChessboardCorners succeeds before adding to calibration set
    ret, corners = cv2.findChessboardCorners(gray, (9, 6))
    if ret:
        objpoints.append(objp)
        imgpoints.append(corners)
  3. 85% success Improve pattern detection with preprocessing
    gray = cv2.equalizeHist(gray)  # improve contrast
    cv2.findChessboardCorners(gray, (9,6), cv2.CALIB_CB_ADAPTIVE_THRESH)

Dead Ends

Common approaches that don't work:

  1. Reduce the number of required corners to match what was detected 85% fail

    Specifying fewer corners than the actual pattern causes wrong correspondences and bad calibration.

  2. Use low-resolution images to make corner detection faster 72% fail

    Lower resolution reduces corner detection accuracy and subpixel refinement quality.