void rectify(Mat& K1, Mat& R1, Mat& t1, Mat& K2, Mat& R2, Mat& t2, Size size, Mat& T1, Mat& T2) { Mat_<double> Kn1(3, 3), Kn2(3, 3); Mat_<double> c1(3, 1), c2(3, 1), v1(3, 1), v2(3, 1), v3(3, 1); K1.copyTo(Kn1); K2.copyTo(Kn2); // optical centers c1 = - R1.t() * t1; c2 = - R2.t() * t2; // x axis v1 = c2 - c1; // y axis v2 = Mat(R1.row(2).t()).cross(v1); // z axis v3 = v1.cross(v2); Mat_<double> m_R(3, 3); v1 = v1 / norm(v1); v2 = v2 / norm(v2); v3 = v3 / norm(v3); m_R(0, 0) = v1(0), m_R(0, 1) = v1(1), m_R(0, 2) = v1(2); m_R(1, 0) = v2(0), m_R(1, 1) = v2(1), m_R(1, 2) = v2(2); m_R(2, 0) = v3(0), m_R(2, 1) = v3(1), m_R(2, 2) = v3(2); T1 = (Kn1 * m_R) * (R1.t() * K1.inv()); T2 = (Kn2 * m_R) * (R2.t() * K2.inv()); // Image center displacement Mat_<double> o1(3, 1), o2(3, 1); o1(0) = 0.5 * size.width, o1(1) = 0.5 * size.height, o1(2) = 1.0; o2(0) = 0.5 * size.width, o2(1) = 0.5 * size.height, o2(2) = 1.0; Mat_<double> on1(3, 1), on2(3, 1), d1(2, 1), d2(2, 1); on1 = T1 * o1; on2 = T2 * o2; d1(0) = o1(0) - on1(0) / on1(2); d1(1) = o1(1) - on1(1) / on1(2); d2(0) = o2(0) - on2(0) / on1(2); d2(1) = o2(1) - on2(1) / on1(2); d1(1) = d2(1); Kn1(0, 2) = Kn1(0, 2) + d1(0); Kn1(1, 2) = Kn1(1, 2) + d1(1); Kn2(0, 2) = Kn2(0, 2) + d2(0); Kn2(1, 2) = Kn2(1, 2) + d2(1); T1 = (Kn1 * m_R) * (R1.t() * K1.inv()); T2 = (Kn2 * m_R) * (R2.t() * K2.inv()); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); convert_value = 1.2607; coma_here = false; current_op = NONE; operand_1 = 0.; operand_2 = 0.; connect(ui->actionQuitter, SIGNAL(triggered()), this, SLOT(close())); connect(ui->actionA_propos, SIGNAL(triggered()), this, SLOT(onAPropos())); connect(ui->actionA_propos_de_Qt, SIGNAL(triggered()), this, SLOT(onAProposDeQt())); connect(ui->actionParam_tres_conversion, SIGNAL(triggered()), this, SLOT(onParametreConversion())); connect(ui->pushButton_0, SIGNAL(clicked()), this, SLOT(on0())); connect(ui->pushButton_1, SIGNAL(clicked()), this, SLOT(on1())); connect(ui->pushButton_2, SIGNAL(clicked()), this, SLOT(on2())); connect(ui->pushButton_3, SIGNAL(clicked()), this, SLOT(on3())); connect(ui->pushButton_4, SIGNAL(clicked()), this, SLOT(on4())); connect(ui->pushButton_5, SIGNAL(clicked()), this, SLOT(on5())); connect(ui->pushButton_6, SIGNAL(clicked()), this, SLOT(on6())); connect(ui->pushButton_7, SIGNAL(clicked()), this, SLOT(on7())); connect(ui->pushButton_8, SIGNAL(clicked()), this, SLOT(on8())); connect(ui->pushButton_9, SIGNAL(clicked()), this, SLOT(on9())); connect(ui->pushButton_coma, SIGNAL(clicked()), this, SLOT(onComa())); connect(ui->pushButton_equal, SIGNAL(clicked()), this, SLOT(onEqual())); connect(ui->pushButton_divided, SIGNAL(clicked()), this, SLOT(onDivided())); connect(ui->pushButton_plus, SIGNAL(clicked()), this, SLOT(onPlus())); connect(ui->pushButton_minus, SIGNAL(clicked()), this, SLOT(onMinus())); connect(ui->pushButton_times, SIGNAL(clicked()), this, SLOT(onMultiplicate())); connect(ui->pushButton_dollar_euro, SIGNAL(clicked()), this, SLOT(onDollarEuro())); connect(ui->pushButton_euro_dollar, SIGNAL(clicked()), this, SLOT(onEuroDollar())); // shortcuts QShortcut *scDel = new QShortcut(QKeySequence("Del"), this); connect(scDel, SIGNAL(activated()), this, SLOT(clearLine())); QShortcut *scBackspace = new QShortcut(QKeySequence("Backspace"), this); connect(scBackspace, SIGNAL(activated()), this, SLOT(clearLastChar())); // QShortcut *scEnter = new QShortcut(QKeySequence("Enter"), this); // connect(scEnter, SIGNAL(activated()), this, SLOT(onEqual())); // QShortcut *sc0 = new QShortcut(QKeySequence("0"), this); // connect(scBackspace, SIGNAL(activated()), this, SLOT(on0())); }