-215
opencv
type_error
ai_generated
true
cv::error: (-215:断言失败) distCoeffs.type() == CV_32FC1 || distCoeffs.type() == CV_64FC1 在函数 'undistortPoints' 中
cv::error: (-215:Assertion failed) distCoeffs.type() == CV_32FC1 || distCoeffs.type() == CV_64FC1 in function 'undistortPoints'
ID: opencv/undistort-points-empty
88%修复率
87%置信度
1证据数
2023-09-10首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 4.5.0 | active | — | — | — |
| 4.8.0 | active | — | — | — |
| 4.10.0 | active | — | — | — |
根因分析
传递给 cv::undistortPoints 的畸变系数矩阵必须为 CV_32FC1 或 CV_64FC1 类型;其他类型会导致断言失败。
English
The distortion coefficients matrix passed to cv::undistortPoints must be of type CV_32FC1 or CV_64FC1; other types cause an assertion failure.
官方文档
https://docs.opencv.org/4.x/d9/d0c/group__calib3d.html#ga55b3f9b9c3f0c9b8e1f0a5b7c3e1f解决方案
-
将 distCoeffs 转换为 CV_32FC1:distCoeffs.convertTo(distCoeffs, CV_32F);
-
如果没有畸变,传递零矩阵:cv::Mat::zeros(1, 5, CV_64FC1) 或 cv::Mat::zeros(1, 8, CV_64FC1)。
无效尝试
常见但无效的做法:
-
90% 失败
The function expects a single-channel matrix for distortion coefficients; multi-channel types are not accepted and trigger the assertion.
-
70% 失败
An empty Mat has type CV_8UC1 by default; the assertion fails because it is neither CV_32FC1 nor CV_64FC1. Use cv::Mat() with proper type or a zero matrix.