-215
opencv
type_error
ai_generated
true
cv::error: (-215:断言失败) src.type() == CV_32FC2 || src.type() == CV_64FC2 在函数 'cv::fisheye::undistortPoints' 中
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%修复率
85%置信度
1证据数
2024-05-12首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 4.5.5 | active | — | — | — |
| 4.8.0 | active | — | — | — |
| 4.9.0 | active | — | — | — |
根因分析
fisheye::undistortPoints 要求输入点为双通道浮点或双精度数组,但输入类型或通道数错误。
English
fisheye::undistortPoints requires input points as a 2-channel float or double array, but the input has wrong type or channel count.
官方文档
https://docs.opencv.org/4.x/db/d58/group__calib3d__fisheye.html#ga3b8e9c3c3c3c3c3c3c3c3c3c3c3c3c3解决方案
-
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)
无效尝试
常见但无效的做法:
-
60% 失败
Single-channel float (CV_32F) is not a 2-channel array; the function expects interleaved x,y coordinates.
-
70% 失败
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% 失败
OpenCV does not support float16 for this function; only float32 or float64.