- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
完整错误:
OpenCV Error: Assertion failed (nimages > 0 && nimages ==
(int)imagePoints1.total() && (!imgPtMat2 || nimages ==
(int)imagePoints2.total())) in collectCalibrationData, file C:\OpenCV
\sources\modules\calib3d\src\calibration.cpp, line 3164
代码:
cv::VideoCapture kalibrowanyPlik; //the video
cv::Mat frame;
cv::Mat testTwo; //undistorted
cv::Mat cameraMatrix = (cv::Mat_<double>(3, 3) << 2673.579, 0, 1310.689, 0, 2673.579, 914.941, 0, 0, 1);
cv::Mat distortMat = (cv::Mat_<double>(1, 4) << -0.208143, 0.235290, 0.001005, 0.001339);
cv::Mat intrinsicMatrix = (cv::Mat_<double>(3, 3) << 1, 0, 0, 0, 1, 0, 0, 0, 1);
cv::Mat distortCoeffs = cv::Mat::zeros(8, 1, CV_64F);
//there are two sets for testing purposes. Values for the first two came from GML camera calibration app.
std::vector<cv::Mat> rvecs;
std::vector<cv::Mat> tvecs;
std::vector<std::vector<cv::Point2f> > imagePoints;
std::vector<std::vector<cv::Point3f> > objectPoints;
kalibrowanyPlik.open("625.avi");
//cv::namedWindow("Distorted", CV_WINDOW_AUTOSIZE); //gotta see things
//cv::namedWindow("Undistorted", CV_WINDOW_AUTOSIZE);
int maxFrames = kalibrowanyPlik.get(CV_CAP_PROP_FRAME_COUNT);
int success = 0; //so we can do the calibration only after we've got a bunch
for(int i=0; i<maxFrames-1; i++) {
kalibrowanyPlik.read(frame);
std::vector<cv::Point2f> corners; //creating these here so they're effectively reset each time
std::vector<cv::Point3f> objectCorners;
int sizeX = kalibrowanyPlik.get(CV_CAP_PROP_FRAME_WIDTH); //imageSize
int sizeY = kalibrowanyPlik.get(CV_CAP_PROP_FRAME_HEIGHT);
cv::cvtColor(frame, frame, CV_BGR2GRAY); //must be gray
cv::Size patternsize(9,6); //interior number of corners
bool patternfound = cv::findChessboardCorners(frame, patternsize, corners, cv::CALIB_CB_ADAPTIVE_THRESH + cv::CALIB_CB_NORMALIZE_IMAGE + cv::CALIB_CB_FAST_CHECK); //finding them corners
if(patternfound == false) { //gotta know
qDebug() << "failure";
}
if(patternfound) {
qDebug() << "success!";
std::vector<cv::Point3f> objectCorners; //low priority issue - if I don't do this here, it becomes empty. Not sure why.
for(int y=0; y<6; ++y) {
for(int x=0; x<9; ++x) {
objectCorners.push_back(cv::Point3f(x*28,y*28,0)); //filling the array
}
}
cv::cornerSubPix(frame, corners, cv::Size(11, 11), cv::Size(-1, -1),
cv::TermCriteria(CV_TERMCRIT_EPS + CV_TERMCRIT_ITER, 30, 0.1));
cv::cvtColor(frame, frame, CV_GRAY2BGR); //I don't want gray lines
imagePoints.push_back(corners); //filling array of arrays with pixel coord array
objectPoints.push_back(objectCorners); //filling array of arrays with real life coord array, or rather copies of the same thing over and over
cout << corners << endl << objectCorners;
cout << endl << objectCorners.size() << "___" << objectPoints.size() << "___" << corners.size() << "___" << imagePoints.size() << endl;
cv::drawChessboardCorners(frame, patternsize, cv::Mat(corners), patternfound); //drawing.
if(success > 5) {
double rms = cv::calibrateCamera(objectPoints, corners, cv::Size(sizeX, sizeY), intrinsicMatrix, distortCoeffs, rvecs, tvecs, cv::CALIB_USE_INTRINSIC_GUESS);
//error - caused by passing CORNERS instead of IMAGEPOINTS. Also, imageSize is 640x480, and I've set the central point to 1310... etc
cout << endl << intrinsicMatrix << endl << distortCoeffs << endl;
cout << "\nrms - " << rms << endl;
}
success = success + 1;
//cv::imshow("Distorted", frame);
//cv::imshow("Undistorted", testTwo);
}
}
我读了一点书 (This was an especially informative read) ,包括在 StackOverflow 上制作的十几个线程,我发现这个错误是由不均匀的 imagePoints 和 objectPoints 或它们部分为空或为空或零(以及无帮助的教程链接)引起的。事实并非如此 - .size() 检查的输出是:
54___7___54___7
对于 objectCorners(现实坐标)、objectPoints(插入的数组数)以及角点(像素坐标)和 imagePoints。它们也不为空,输出为:
(...)
277.6792, 208.92903;
241.83429, 208.93048;
206.99866, 208.84637;
(...)
84, 56, 0;
112, 56, 0;
140, 56, 0;
168, 56, 0;
(...)
示例框架:
我知道这很乱,但到目前为止我正在努力完成代码而不是获得准确的阅读。
每一个都有 54 行。有没有人对导致错误的原因有任何想法?我在 Windows 7 上使用 OpenCV 2.4.8 和 Qt Creator 5.4。
最佳答案
首先,角点和图像点必须进行切换,正如您已经注意到的那样。
在大多数情况下(如果不是全部),size <= 25 足以获得良好的结果。 633 左右的焦距并不奇怪,这意味着焦距是 633 * 传感器尺寸。 CCD 或 CMOS 尺寸必须与您的相机一起在说明上的某个位置。找出它,乘以 633,结果就是您的焦距。
减少使用图像数量的一个建议:使用从不同视点拍摄的图像。来自 10 个不同视点的 10 张图像比来自相同(或附近)视点的 100 张图像带来更好的结果。这是视频不是好的输入的原因之一。我猜你的代码,所有传递给 calibratecamera 的图像可能是从附近的视点。如果是这样,校准精度会降低。
关于c++ - OpenCV calibrateCamera - 断言失败 (nimages > 0 && nimages == (int)imagePoints1.total(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31340517/
我想知道使用cvCalibrateCamera2来查找两个相机之间的旋转和平移的可能性有多大。 以您刚刚完成棋盘校准的场景为例,其中棋盘对于两个图像平面都是可见的。如果我然后将一个相机中的这些点作为
我正在校准我的相机,以消除图像失真。为了实现这个目标,我正在使用 OpenCV 库的校准相机功能。所以我用棋盘在真实引用系统中取点来提取点数。然后我用mm将这些点转换成真实的引用系。所以最后我得到两个
几天来,我一直在用棋盘示例进行相机校准。一切都很好(找到并显示角,然后馈送到数组)直到我调用最终函数 calibrateCamera。比我得到断言错误: OpenCV 错误:calibrateCame
我正在使用圆网格校准相机。相机位于 table 上方的固定位置,因此我使用单张图像进行校准。 (我将使用的所有对象都是平的,并且与我的校准图像在同一张 table 上。)我将圆心的真实位置放入 obj
我正在使用 calibrateCamera 执行相机校准。部分输出是一组 Rodrigues 旋转矢量和 3-D 平移矢量。 我对相机的世界位置感兴趣。如果我直接绘制翻译点,结果看起来不正确。我觉得我
我正在尝试为三角测量过程获取一个3x4 相机矩阵,但是calibrateCamera()仅返回 3x3 和 4x1 矩阵。 如何从这些矩阵中得到 3x4? 提前致谢! 最佳答案 calibrateCa
一段时间以来,我一直在尝试使用 Opencv calibrateCamera() 函数来校准我的相机。我遵循了 opencv 示例程序中描述的相同过程。我试图首先加载 10 9 x 6 棋盘图像。然后
我正在尝试让calibrateCamera在我的Node.js后端上工作。该库运行正常,但是如果输入错误,我会遇到OpenCV函数无法给出任何错误消息的麻烦。我有点在黑暗中飞翔。 但这不是重点。我已经
我想将 findChessboardCorners 与 calibrateCamera 一起使用,但在使用 calibrateCamera 时遇到错误。输出不是很有帮助。 OpenCV Error:
我正在使用 OpenCV 的 calibrateCamera 并试图了解它如何计算重投影误差以及该误差代表什么。它似乎是投影点和测量图像点之间的(欧几里得)距离的 RMS——对吗?然而,最终的重投影误
当我尝试使用 cv2.calibrateCamera 校准相机时出现以下错误: rms, camera_matrix, dist_coefs, rvecs, tvecs = cv2.calibrate
我试图从函数 cv::calibrateCamera() 中获取 cameraMatrix,实际上我不确定我做的是否正确,我最初的想法是: 获取来自同一相机的两张输入图像。 提取image_1和ima
我有一个 python 脚本,它使用 calibratecamera2 方法从棋盘的几个 View 校准相机。成功校准后,我追踪所有原始点并绘制一些图并再次计算重新投影误差。令我惊讶的是,opencv
我正在尝试使用 cv::calibrateCamera 来校准相机+投影仪系统。虽然它有时似乎有效,但在许多情况下,估计的解决方案似乎与正确的解决方案相去甚远。 这是一个显示问题的代码示例(包括所有数
我正在使用 VisualStudio 2010 和 OpenCV 3.0。我想校准相机,我遇到的问题与 this 中描述的基本相同去年发的帖子,一直没回复。我正在调用 calibrateCamera,
我有一个立体相机装置。我已经捕获了一个 chessboardPattern 序列(相同的序列,每次曝光两张照片)。我使用 cv2.calibrateCamera 对各个相机执行了单个相机校准。 我的问
背景: 我目前正在使用 OpenCV 进行立体视觉项目。我正在尝试从一组两个校正图像创建视差图,但我没有得到我期望的结果。查看校正后的图像时,图像之间存在明显的垂直偏移,校正后不应存在。我目前正在寻找
我正在尝试使用OpenCV calibrateCamera函数来校准我的MSFT LifeCam 3000 HD网络摄像头。为此,我了解需要知道fx和fy(x和y轴的焦距)。但是,我很难找到这些信息。
大家好,我一直在使用 Python 和 OpenCV 深入研究计算机视觉,并尝试校准我购买的两台相机,以便进行一些 3D 立体重建,但我遇到了一些问题。 我主要关注的是这个tutorial为了分别校准
calibrateCamera 的定义是:CV_EXPORTS_W double calibrateCamera( InputArrayOfArrays objectPoints,InputArray
我是一名优秀的程序员,十分优秀!