-215
opencv
type_error
ai_generated
true
cv::error: (-215:Assertion failed) src.type() == CV_32FC2 || src.type() == CV_64FC2 in function 'cv::fisheye::undistortPoints'
ID: opencv/calib3d-fisheye-undistort-points-dtype
90%Fix Rate
85%Confidence
1Evidence
2024-05-12First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 4.5.5 | active | — | — | — |
| 4.8.0 | active | — | — | — |
| 4.9.0 | active | — | — | — |
Root Cause
fisheye::undistortPoints requires input points as a 2-channel float or double array, but the input has wrong type or channel count.
generic中文
fisheye::undistortPoints 要求输入点为双通道浮点或双精度数组,但输入类型或通道数错误。
Official Documentation
https://docs.opencv.org/4.x/db/d58/group__calib3d__fisheye.html#ga3b8e9c3c3c3c3c3c3c3c3c3c3c3c3c3Workarounds
-
95% success pts = np.array([[x1, y1], [x2, y2]], dtype=np.float32) undistorted = cv2.fisheye.undistortPoints(pts, K, D)
pts = np.array([[x1, y1], [x2, y2]], dtype=np.float32) undistorted = cv2.fisheye.undistortPoints(pts, K, D)
-
90% success pts = np.array([[[x1, y1]], [[x2, y2]]], dtype=np.float64) undistorted = cv2.fisheye.undistortPoints(pts, K, D, P=K)
pts = np.array([[[x1, y1]], [[x2, y2]]], dtype=np.float64) undistorted = cv2.fisheye.undistortPoints(pts, K, D, P=K)
中文步骤
pts = np.array([[x1, y1], [x2, y2]], dtype=np.float32) undistorted = cv2.fisheye.undistortPoints(pts, K, D)
pts = np.array([[[x1, y1]], [[x2, y2]]], dtype=np.float64) undistorted = cv2.fisheye.undistortPoints(pts, K, D, P=K)
Dead Ends
Common approaches that don't work:
-
60% fail
Single-channel float (CV_32F) is not a 2-channel array; the function expects interleaved x,y coordinates.
-
70% fail
Python list of tuples is not a numpy array with correct dtype; OpenCV expects np.ndarray with shape (N,1,2) or (N,2).
-
80% fail
OpenCV does not support float16 for this function; only float32 or float64.