gpt4 book ai didi

c++ - stereoCalibrate 中的术语标准错误

转载 作者:塔克拉玛干 更新时间:2023-11-03 07:48:10 26 4
gpt4 key购买 nike

我正在使用 stereoCalibrate,而 termCriteria 会抛出错误

' cv :: stereoCalibrate ' : can not convert parameter 13 ' cv :: TermCriteria ' to 'int'

我该如何解决?

#include <iostream>
#include "conio.h"
#include <sstream>
#include <time.h>
#include <stdio.h>

#include <opencv2/core.hpp>
#include <opencv2/core/utility.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/calib3d.hpp>
#include <opencv2/imgcodecs.hpp>
#include <opencv2/videoio.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>

using namespace std;
using namespace cv;

Mat captura0;
Mat gray0;
Mat captura1;
Mat gray1;
Mat centers;
vector<vector<Point2f>> cornes_global0;
vector<vector<Point2f>> cornes_global1;
vector<vector<Point3f>> vector3D;
vector<Point2f> corners0;
vector<Point2f> corners1;
Size patternsize (7,10);
int key1;
int c=1;

void main () {
VideoCapture camara0(0);
VideoCapture camara1(1);
if(!camara0.isOpened()){ // check if we succeeded
cout <<"no abrio camara 0 "<<endl;
}
if(!camara1.isOpened()){ // check if we succeeded
cout <<"no abrio cama 1 "<<endl;
}
while ( c!=15)
{
cout<<"Capturando "<<c<<" foto"<<endl;
key1 = waitKey(10);
camara0.read(captura0);
camara1.read(captura1);
imshow("camara 1", captura0);
imshow("camara 2", captura1);
if ((char)key1=='q'){
cvtColor(captura0, gray0, CV_BGR2GRAY);
cvtColor(captura1, gray1, CV_BGR2GRAY);
bool patternfound0= findChessboardCorners(gray0, patternsize,corners0, CALIB_CB_ADAPTIVE_THRESH + CALIB_CB_NORMALIZE_IMAGE + CALIB_CB_FAST_CHECK );
bool patternfound1= findChessboardCorners(gray1, patternsize,corners1, CALIB_CB_ADAPTIVE_THRESH + CALIB_CB_NORMALIZE_IMAGE + CALIB_CB_FAST_CHECK );
cout <<"patternfound0 "<<patternfound0<<endl;
cout <<"patternfound1 "<<patternfound1<<endl;
if(patternfound0==1 && patternfound1==1){
cornerSubPix(gray0, corners0,Size(11,11), Size(-1,-1),TermCriteria(CV_TERMCRIT_EPS + CV_TERMCRIT_ITER, 30, 0.1));
cornerSubPix(gray1, corners1,Size(11,11), Size(-1,-1),TermCriteria(CV_TERMCRIT_EPS + CV_TERMCRIT_ITER, 30, 0.1));
cout<<"se hallaron esquinas0 "<<patternfound0<<endl;
cout<<"se hallaron esquinas1 "<<patternfound0<<endl;
cornes_global0.push_back(corners0);
cornes_global1.push_back(corners1);
cout<<"Patrones: "<<c<<endl;
drawChessboardCorners(captura0, patternsize, Mat(corners0), patternfound0);
drawChessboardCorners(captura1, patternsize, Mat(corners1), patternfound1);
imshow("graficando esquinas0", captura0);
imshow("graficando esquinas1", captura1);


}
c++; // cantidad de pares de imagenes tomadas
}

}
vector3D.resize(c);
//vector3D.clear();
for (int k = 0; k < c; k++) // rellenamos el array de arrays de puntos 3f con la distancia de cada rectangulo
{ //del tablero de ajedrez,en eje Z, ponemos todo 0
for (int i = 0; i < 10; i++) // 10 esquinas internas en eje Y
{
for (int j = 0; j < 7; j++) // 7 esquinas internas en eje X
{
vector3D[k].push_back(Point3f(i*23.0, j*23.0, 0.0));
cout<<"la "<<k<<vector3D[k]<<endl;
}
}
}
Mat cameraMatrix1 = Mat::eye(3,3,CV_64FC1);
Mat cameraMatrix2 = Mat::eye(3,3,CV_64FC1);
Mat distCoeffs1;
Mat distCoeffs2;
Mat R, T, E, F;
Size imageSize = captura1.size();
cout<< "Calibrando camara..."<<endl;
int64 t = getTickCount();
double rms =stereoCalibrate(vector3D, cornes_global0, cornes_global1, cameraMatrix1,distCoeffs1,cameraMatrix2,distCoeffs2, imageSize, R, T, E, F,
TermCriteria(CV_TERMCRIT_ITER | CV_TERMCRIT_EPS, 100, 1e-5),CV_CALIB_FIX_ASPECT_RATIO + CV_CALIB_FIX_ASPECT_RATIO +CV_CALIB_ZERO_TANGENT_DIST+
CV_CALIB_SAME_FOCAL_LENGTH+ CV_CALIB_FIX_K3 + CV_CALIB_FIX_K4 + CV_CALIB_FIX_K5);
cout<<"ok "<<endl;
t=getTickCount() -t;


getch();
}

最佳答案

您可能正在使用 OpenCV 3.0,其中 flagscriteria 的顺序 has been swapped .

您需要将您的标志放在术语条件之前。您的编译器告诉您它无法将 TermCriteria 转换为 int,因为它需要 flags,实际上是 int

关于c++ - stereoCalibrate 中的术语标准错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34242357/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com