From 42ab7fd876a4df6271cfadc93d322b644ffe3aa0 Mon Sep 17 00:00:00 2001 From: edgarriba Date: Wed, 16 Jul 2014 00:06:29 +0200 Subject: [PATCH] dls() no compiles --- modules/calib3d/src/dls.cpp | 314 ++++++++++++++++++++++++++++++++++++++- modules/calib3d/src/dls.h | 25 +++- modules/calib3d/src/solvepnp.cpp | 7 +- 3 files changed, 334 insertions(+), 12 deletions(-) diff --git a/modules/calib3d/src/dls.cpp b/modules/calib3d/src/dls.cpp index 8fbeb3e..e50ae1a 100644 --- a/modules/calib3d/src/dls.cpp +++ b/modules/calib3d/src/dls.cpp @@ -1,10 +1,21 @@ -#include +#include "precomp.hpp" #include "dls.h" +#include -dls::dls() +dls::dls(const cv::Mat& opoints, const cv::Mat& ipoints) : f1coeff(21), f2coeff(21), f3coeff(21) { - // TODO Auto-generated constructor stub + N = opoints.type() == CV_64F ? opoints.checkVector(3, CV_64F) : opoints.checkVector(3, CV_32F) ; + + H = cv::Mat::zeros(3, 3, opoints.type()); + A = cv::Mat::zeros(3, 9, opoints.type()); + D_mat = cv::Mat::zeros(9, 9, opoints.type()); + + + + init_vectors(opoints, ipoints); + build_coeff_mattrix(); + } @@ -12,3 +23,300 @@ dls::~dls() { // TODO Auto-generated destructor stub } + +void dls::init_vectors(const cv::Mat& opoints, const cv::Mat& ipoints) +{ + if(opoints.cols == 3) opoints.reshape(N, 3); + if(ipoints.cols == 2) ipoints.reshape(N, 2); + + p = opoints; + z = ipoints; + + // make z into unit vectors from normalized pixel coords + + z.push_back(cv::Mat::ones(1, N, opoints.type())); + + for (int i = 0; i < N; ++i) + { + cv::Mat & col_i = z.col(i); + double sr = std::pow(col_i.at(0), 2) + + std::pow(col_i.at(1), 2) + + std::pow(col_i.at(2), 2); + sr = std::sqrt(sr); + + col_i.at(0, i) /= sr; + col_i.at(1, i) /= sr; + col_i.at(2, i) /= sr; + + } +} + +void dls::build_coeff_mattrix() +{ + cv::Mat eye = cv::Mat::eye(3, 3, p.type()); + + // build coeff matrix + // An intermediate matrix, the inverse of what is called "H" in the paper + // (see eq. 25) + for (int i = 0; i < N; ++i) + { + cv::Mat z_dot = z.col(i)*z.col(i).t(); + + H += eye - z_dot ; + A += ( z_dot - eye ) * LeftMultVec(p.col(i)); + } + + cv::solve(H, A, A); + + for (int i = 0; i < N; ++i) + { + cv::Mat z_dot = z.col(i)*z.col(i).t(); + D_mat += cv::Mat(LeftMultVec(p.col(i))+A).t() * (eye-z_dot) * (LeftMultVec(p.col(i))+A); + } + + // put D into array + double D[10][10]; + for (int i = 0; i < 10; ++i) + { + for (int j = 0; j < 10; ++j) + { + D[i+1][j+1] = D_mat.at(i,j); + } + } + + // F1 COEFFICIENT + + f1coeff[1] = 2*D[1][6] - 2*D[1][8] + 2*D[5][6] - 2*D[5][8] + 2*D[6][1] + 2*D[6][5] + 2*D[6][9] - 2*D[8][1] - 2*D[8][5] - 2*D[8][9] + 2*D[9][6] - 2*D[9][8]; // constant term + f1coeff[2] = 6*D[1][2] + 6*D[1][4] + 6*D[2][1] - 6*D[2][5] - 6*D[2][9] + 6*D[4][1] - 6*D[4][5] - 6*D[4][9] - 6*D[5][2] - 6*D[5][4] - 6*D[9][2] - 6*D[9][4]; // s1^2 * s2 + f1coeff[3] = 4*D[1][7] - 4*D[1][3] + 8*D[2][6] - 8*D[2][8] - 4*D[3][1] + 4*D[3][5] + 4*D[3][9] + 8*D[4][6] - 8*D[4][8] + 4*D[5][3] - 4*D[5][7] + 8*D[6][2] + 8*D[6][4] + 4*D[7][1] - 4*D[7][5] - 4*D[7][9] - 8*D[8][2] - 8*D[8][4] + 4*D[9][3] - 4*D[9][7]; // s1 * s2 + f1coeff[4] = 4*D[1][2] - 4*D[1][4] + 4*D[2][1] - 4*D[2][5] - 4*D[2][9] + 8*D[3][6] - 8*D[3][8] - 4*D[4][1] + 4*D[4][5] + 4*D[4][9] - 4*D[5][2] + 4*D[5][4] + 8*D[6][3] + 8*D[6][7] + 8*D[7][6] - 8*D[7][8] - 8*D[8][3] - 8*D[8][7] - 4*D[9][2] + 4*D[9][4]; //s1 * s3 + f1coeff[5] = 8*D[2][2] - 8*D[3][3] - 8*D[4][4] + 8*D[6][6] + 8*D[7][7] - 8*D[8][8]; // s2 * s3 + f1coeff[6] = 4*D[2][6] - 2*D[1][7] - 2*D[1][3] + 4*D[2][8] - 2*D[3][1] + 2*D[3][5] - 2*D[3][9] + 4*D[4][6] + 4*D[4][8] + 2*D[5][3] + 2*D[5][7] + 4*D[6][2] + 4*D[6][4] - 2*D[7][1] + 2*D[7][5] - 2*D[7][9] + 4*D[8][2] + 4*D[8][4] - 2*D[9][3] - 2*D[9][7]; // s2^2 * s3 + f1coeff[7] = 2*D[2][5] - 2*D[1][4] - 2*D[2][1] - 2*D[1][2] - 2*D[2][9] - 2*D[4][1] + 2*D[4][5] - 2*D[4][9] + 2*D[5][2] + 2*D[5][4] - 2*D[9][2] - 2*D[9][4]; //s2^3 + f1coeff[8] = 4*D[1][9] - 4*D[1][1] + 8*D[3][3] + 8*D[3][7] + 4*D[5][5] + 8*D[7][3] + 8*D[7][7] + 4*D[9][1] - 4*D[9][9]; // s1 * s3^2 + f1coeff[9] = 4*D[1][1] - 4*D[5][5] - 4*D[5][9] + 8*D[6][6] - 8*D[6][8] - 8*D[8][6] + 8*D[8][8] - 4*D[9][5] - 4*D[9][9]; // s1 + f1coeff[10] = 2*D[1][3] + 2*D[1][7] + 4*D[2][6] - 4*D[2][8] + 2*D[3][1] + 2*D[3][5] + 2*D[3][9] - 4*D[4][6] + 4*D[4][8] + 2*D[5][3] + 2*D[5][7] + 4*D[6][2] - 4*D[6][4] + 2*D[7][1] + 2*D[7][5] + 2*D[7][9] - 4*D[8][2] + 4*D[8][4] + 2*D[9][3] + 2*D[9][7]; // s3 + f1coeff[11] = 2*D[1][2] + 2*D[1][4] + 2*D[2][1] + 2*D[2][5] + 2*D[2][9] - 4*D[3][6] + 4*D[3][8] + 2*D[4][1] + 2*D[4][5] + 2*D[4][9] + 2*D[5][2] + 2*D[5][4] - 4*D[6][3] + 4*D[6][7] + 4*D[7][6] - 4*D[7][8] + 4*D[8][3] - 4*D[8][7] + 2*D[9][2] + 2*D[9][4]; // s2 + f1coeff[12] = 2*D[2][9] - 2*D[1][4] - 2*D[2][1] - 2*D[2][5] - 2*D[1][2] + 4*D[3][6] + 4*D[3][8] - 2*D[4][1] - 2*D[4][5] + 2*D[4][9] - 2*D[5][2] - 2*D[5][4] + 4*D[6][3] + 4*D[6][7] + 4*D[7][6] + 4*D[7][8] + 4*D[8][3] + 4*D[8][7] + 2*D[9][2] + 2*D[9][4]; // s2 * s3^2 + f1coeff[13] = 6*D[1][6] - 6*D[1][8] - 6*D[5][6] + 6*D[5][8] + 6*D[6][1] - 6*D[6][5] - 6*D[6][9] - 6*D[8][1] + 6*D[8][5] + 6*D[8][9] - 6*D[9][6] + 6*D[9][8]; // s1^2 + f1coeff[14] = 2*D[1][8] - 2*D[1][6] + 4*D[2][3] + 4*D[2][7] + 4*D[3][2] - 4*D[3][4] - 4*D[4][3] - 4*D[4][7] - 2*D[5][6] + 2*D[5][8] - 2*D[6][1] - 2*D[6][5] + 2*D[6][9] + 4*D[7][2] - 4*D[7][4] + 2*D[8][1] + 2*D[8][5] - 2*D[8][9] + 2*D[9][6] - 2*D[9][8]; // s3^2 + f1coeff[15] = 2*D[1][8] - 2*D[1][6] - 4*D[2][3] + 4*D[2][7] - 4*D[3][2] - 4*D[3][4] - 4*D[4][3] + 4*D[4][7] + 2*D[5][6] - 2*D[5][8] - 2*D[6][1] + 2*D[6][5] - 2*D[6][9] + 4*D[7][2] + 4*D[7][4] + 2*D[8][1] - 2*D[8][5] + 2*D[8][9] - 2*D[9][6] + 2*D[9][8]; // s2^2 + f1coeff[16] = 2*D[3][9] - 2*D[1][7] - 2*D[3][1] - 2*D[3][5] - 2*D[1][3] - 2*D[5][3] - 2*D[5][7] - 2*D[7][1] - 2*D[7][5] + 2*D[7][9] + 2*D[9][3] + 2*D[9][7]; // s3^3 + f1coeff[17] = 4*D[1][6] + 4*D[1][8] + 8*D[2][3] + 8*D[2][7] + 8*D[3][2] + 8*D[3][4] + 8*D[4][3] + 8*D[4][7] - 4*D[5][6] - 4*D[5][8] + 4*D[6][1] - 4*D[6][5] - 4*D[6][9] + 8*D[7][2] + 8*D[7][4] + 4*D[8][1] - 4*D[8][5] - 4*D[8][9] - 4*D[9][6] - 4*D[9][8]; // s1 * s2 * s3 + f1coeff[18] = 4*D[1][5] - 4*D[1][1] + 8*D[2][2] + 8*D[2][4] + 8*D[4][2] + 8*D[4][4] + 4*D[5][1] - 4*D[5][5] + 4*D[9][9]; // s1 * s2^2 + f1coeff[19] = 6*D[1][3] + 6*D[1][7] + 6*D[3][1] - 6*D[3][5] - 6*D[3][9] - 6*D[5][3] - 6*D[5][7] + 6*D[7][1] - 6*D[7][5] - 6*D[7][9] - 6*D[9][3] - 6*D[9][7]; // s1^2 * s3 + f1coeff[20] = 4*D[1][1] - 4*D[1][5] - 4*D[1][9] - 4*D[5][1] + 4*D[5][5] + 4*D[5][9] - 4*D[9][1] + 4*D[9][5] + 4*D[9][9]; // s1^3 + + + // F2 COEFFICIENT + + f2coeff[1] = - 2*D[1][3] + 2*D[1][7] - 2*D[3][1] - 2*D[3][5] - 2*D[3][9] - 2*D[5][3] + 2*D[5][7] + 2*D[7][1] + 2*D[7][5] + 2*D[7][9] - 2*D[9][3] + 2*D[9][7]; // constant term + f2coeff[2] = 4*D[1][5] - 4*D[1][1] + 8*D[2][2] + 8*D[2][4] + 8*D[4][2] + 8*D[4][4] + 4*D[5][1] - 4*D[5][5] + 4*D[9][9]; // s1^2 * s2 + f2coeff[3] = 4*D[1][8] - 4*D[1][6] - 8*D[2][3] + 8*D[2][7] - 8*D[3][2] - 8*D[3][4] - 8*D[4][3] + 8*D[4][7] + 4*D[5][6] - 4*D[5][8] - 4*D[6][1] + 4*D[6][5] - 4*D[6][9] + 8*D[7][2] + 8*D[7][4] + 4*D[8][1] - 4*D[8][5] + 4*D[8][9] - 4*D[9][6] + 4*D[9][8]; // s1 * s2 + f2coeff[4] = 8*D[2][2] - 8*D[3][3] - 8*D[4][4] + 8*D[6][6] + 8*D[7][7] - 8*D[8][8]; // s1 * s3 + f2coeff[5] = 4*D[1][4] - 4*D[1][2] - 4*D[2][1] + 4*D[2][5] - 4*D[2][9] - 8*D[3][6] - 8*D[3][8] + 4*D[4][1] - 4*D[4][5] + 4*D[4][9] + 4*D[5][2] - 4*D[5][4] - 8*D[6][3] + 8*D[6][7] + 8*D[7][6] + 8*D[7][8] - 8*D[8][3] + 8*D[8][7] - 4*D[9][2] + 4*D[9][4]; // s2 * s3 + f2coeff[6] = 6*D[5][6] - 6*D[1][8] - 6*D[1][6] + 6*D[5][8] - 6*D[6][1] + 6*D[6][5] - 6*D[6][9] - 6*D[8][1] + 6*D[8][5] - 6*D[8][9] - 6*D[9][6] - 6*D[9][8]; // s2^2 * s3 + f2coeff[7] = 4*D[1][1] - 4*D[1][5] + 4*D[1][9] - 4*D[5][1] + 4*D[5][5] - 4*D[5][9] + 4*D[9][1] - 4*D[9][5] + 4*D[9][9]; // s2^3 + f2coeff[8] = 2*D[2][9] - 2*D[1][4] - 2*D[2][1] - 2*D[2][5] - 2*D[1][2] + 4*D[3][6] + 4*D[3][8] - 2*D[4][1] - 2*D[4][5] + 2*D[4][9] - 2*D[5][2] - 2*D[5][4] + 4*D[6][3] + 4*D[6][7] + 4*D[7][6] + 4*D[7][8] + 4*D[8][3] + 4*D[8][7] + 2*D[9][2] + 2*D[9][4]; // s1 * s3^2 + f2coeff[9] = 2*D[1][2] + 2*D[1][4] + 2*D[2][1] + 2*D[2][5] + 2*D[2][9] - 4*D[3][6] + 4*D[3][8] + 2*D[4][1] + 2*D[4][5] + 2*D[4][9] + 2*D[5][2] + 2*D[5][4] - 4*D[6][3] + 4*D[6][7] + 4*D[7][6] - 4*D[7][8] + 4*D[8][3] - 4*D[8][7] + 2*D[9][2] + 2*D[9][4]; // s1 + f2coeff[10] = 2*D[1][6] + 2*D[1][8] - 4*D[2][3] + 4*D[2][7] - 4*D[3][2] + 4*D[3][4] + 4*D[4][3] - 4*D[4][7] + 2*D[5][6] + 2*D[5][8] + 2*D[6][1] + 2*D[6][5] + 2*D[6][9] + 4*D[7][2] - 4*D[7][4] + 2*D[8][1] + 2*D[8][5] + 2*D[8][9] + 2*D[9][6] + 2*D[9][8]; // s3 + f2coeff[11] = 8*D[3][3] - 4*D[1][9] - 4*D[1][1] - 8*D[3][7] + 4*D[5][5] - 8*D[7][3] + 8*D[7][7] - 4*D[9][1] - 4*D[9][9]; // s2 + f2coeff[12] = 4*D[1][1] - 4*D[5][5] + 4*D[5][9] + 8*D[6][6] + 8*D[6][8] + 8*D[8][6] + 8*D[8][8] + 4*D[9][5] - 4*D[9][9]; // s2 * s3^2 + f2coeff[13] = 2*D[1][7] - 2*D[1][3] + 4*D[2][6] - 4*D[2][8] - 2*D[3][1] + 2*D[3][5] + 2*D[3][9] + 4*D[4][6] - 4*D[4][8] + 2*D[5][3] - 2*D[5][7] + 4*D[6][2] + 4*D[6][4] + 2*D[7][1] - 2*D[7][5] - 2*D[7][9] - 4*D[8][2] - 4*D[8][4] + 2*D[9][3] - 2*D[9][7]; // s1^2 + f2coeff[14] = 2*D[1][3] - 2*D[1][7] + 4*D[2][6] + 4*D[2][8] + 2*D[3][1] + 2*D[3][5] - 2*D[3][9] - 4*D[4][6] - 4*D[4][8] + 2*D[5][3] - 2*D[5][7] + 4*D[6][2] - 4*D[6][4] - 2*D[7][1] - 2*D[7][5] + 2*D[7][9] + 4*D[8][2] - 4*D[8][4] - 2*D[9][3] + 2*D[9][7]; // s3^2 + f2coeff[15] = 6*D[1][3] - 6*D[1][7] + 6*D[3][1] - 6*D[3][5] + 6*D[3][9] - 6*D[5][3] + 6*D[5][7] - 6*D[7][1] + 6*D[7][5] - 6*D[7][9] + 6*D[9][3] - 6*D[9][7]; // s2^2 + f2coeff[16] = 2*D[6][9] - 2*D[1][8] - 2*D[5][6] - 2*D[5][8] - 2*D[6][1] - 2*D[6][5] - 2*D[1][6] - 2*D[8][1] - 2*D[8][5] + 2*D[8][9] + 2*D[9][6] + 2*D[9][8]; // s3^3 + f2coeff[17] = 8*D[2][6] - 4*D[1][7] - 4*D[1][3] + 8*D[2][8] - 4*D[3][1] + 4*D[3][5] - 4*D[3][9] + 8*D[4][6] + 8*D[4][8] + 4*D[5][3] + 4*D[5][7] + 8*D[6][2] + 8*D[6][4] - 4*D[7][1] + 4*D[7][5] - 4*D[7][9] + 8*D[8][2] + 8*D[8][4] - 4*D[9][3] - 4*D[9][7]; // s1 * s2 * s3 + f2coeff[18] = 6*D[2][5] - 6*D[1][4] - 6*D[2][1] - 6*D[1][2] - 6*D[2][9] - 6*D[4][1] + 6*D[4][5] - 6*D[4][9] + 6*D[5][2] + 6*D[5][4] - 6*D[9][2] - 6*D[9][4]; // s1 * s2^2 + f2coeff[19] = 2*D[1][6] + 2*D[1][8] + 4*D[2][3] + 4*D[2][7] + 4*D[3][2] + 4*D[3][4] + 4*D[4][3] + 4*D[4][7] - 2*D[5][6] - 2*D[5][8] + 2*D[6][1] - 2*D[6][5] - 2*D[6][9] + 4*D[7][2] + 4*D[7][4] + 2*D[8][1] - 2*D[8][5] - 2*D[8][9] - 2*D[9][6] - 2*D[9][8]; // s1^2 * s3 + f2coeff[20] = 2*D[1][2] + 2*D[1][4] + 2*D[2][1] - 2*D[2][5] - 2*D[2][9] + 2*D[4][1] - 2*D[4][5] - 2*D[4][9] - 2*D[5][2] - 2*D[5][4] - 2*D[9][2] - 2*D[9][4]; // s1^3 + + + // F3 COEFFICIENT + + f3coeff[1] = 2*D[1][2] - 2*D[1][4] + 2*D[2][1] + 2*D[2][5] + 2*D[2][9] - 2*D[4][1] - 2*D[4][5] - 2*D[4][9] + 2*D[5][2] - 2*D[5][4] + 2*D[9][2] - 2*D[9][4]; // constant term + f3coeff[2] = 2*D[1][6] + 2*D[1][8] + 4*D[2][3] + 4*D[2][7] + 4*D[3][2] + 4*D[3][4] + 4*D[4][3] + 4*D[4][7] - 2*D[5][6] - 2*D[5][8] + 2*D[6][1] - 2*D[6][5] - 2*D[6][9] + 4*D[7][2] + 4*D[7][4] + 2*D[8][1] - 2*D[8][5] - 2*D[8][9] - 2*D[9][6] - 2*D[9][8]; // s1^2 * s2 + f3coeff[3] = 8*D[2][2] - 8*D[3][3] - 8*D[4][4] + 8*D[6][6] + 8*D[7][7] - 8*D[8][8]; // s1 * s2 + f3coeff[4] = 4*D[1][8] - 4*D[1][6] + 8*D[2][3] + 8*D[2][7] + 8*D[3][2] - 8*D[3][4] - 8*D[4][3] - 8*D[4][7] - 4*D[5][6] + 4*D[5][8] - 4*D[6][1] - 4*D[6][5] + 4*D[6][9] + 8*D[7][2] - 8*D[7][4] + 4*D[8][1] + 4*D[8][5] - 4*D[8][9] + 4*D[9][6] - 4*D[9][8]; // s1 * s3 + f3coeff[5] = 4*D[1][3] - 4*D[1][7] + 8*D[2][6] + 8*D[2][8] + 4*D[3][1] + 4*D[3][5] - 4*D[3][9] - 8*D[4][6] - 8*D[4][8] + 4*D[5][3] - 4*D[5][7] + 8*D[6][2] - 8*D[6][4] - 4*D[7][1] - 4*D[7][5] + 4*D[7][9] + 8*D[8][2] - 8*D[8][4] - 4*D[9][3] + 4*D[9][7]; // s2 * s3 + f3coeff[6] = 4*D[1][1] - 4*D[5][5] + 4*D[5][9] + 8*D[6][6] + 8*D[6][8] + 8*D[8][6] + 8*D[8][8] + 4*D[9][5] - 4*D[9][9]; // s2^2 * s3 + f3coeff[7] = 2*D[5][6] - 2*D[1][8] - 2*D[1][6] + 2*D[5][8] - 2*D[6][1] + 2*D[6][5] - 2*D[6][9] - 2*D[8][1] + 2*D[8][5] - 2*D[8][9] - 2*D[9][6] - 2*D[9][8]; // s2^3 + f3coeff[8] = 6*D[3][9] - 6*D[1][7] - 6*D[3][1] - 6*D[3][5] - 6*D[1][3] - 6*D[5][3] - 6*D[5][7] - 6*D[7][1] - 6*D[7][5] + 6*D[7][9] + 6*D[9][3] + 6*D[9][7]; // s1 * s3^2 + f3coeff[9] = 2*D[1][3] + 2*D[1][7] + 4*D[2][6] - 4*D[2][8] + 2*D[3][1] + 2*D[3][5] + 2*D[3][9] - 4*D[4][6] + 4*D[4][8] + 2*D[5][3] + 2*D[5][7] + 4*D[6][2] - 4*D[6][4] + 2*D[7][1] + 2*D[7][5] + 2*D[7][9] - 4*D[8][2] + 4*D[8][4] + 2*D[9][3] + 2*D[9][7]; // s1 + f3coeff[10] = 8*D[2][2] - 4*D[1][5] - 4*D[1][1] - 8*D[2][4] - 8*D[4][2] + 8*D[4][4] - 4*D[5][1] - 4*D[5][5] + 4*D[9][9]; // s3 + f3coeff[11] = 2*D[1][6] + 2*D[1][8] - 4*D[2][3] + 4*D[2][7] - 4*D[3][2] + 4*D[3][4] + 4*D[4][3] - 4*D[4][7] + 2*D[5][6] + 2*D[5][8] + 2*D[6][1] + 2*D[6][5] + 2*D[6][9] + 4*D[7][2] - 4*D[7][4] + 2*D[8][1] + 2*D[8][5] + 2*D[8][9] + 2*D[9][6] + 2*D[9][8]; // s2 + f3coeff[12] = 6*D[6][9] - 6*D[1][8] - 6*D[5][6] - 6*D[5][8] - 6*D[6][1] - 6*D[6][5] - 6*D[1][6] - 6*D[8][1] - 6*D[8][5] + 6*D[8][9] + 6*D[9][6] + 6*D[9][8]; // s2 * s3^2 + f3coeff[13] = 2*D[1][2] - 2*D[1][4] + 2*D[2][1] - 2*D[2][5] - 2*D[2][9] + 4*D[3][6] - 4*D[3][8] - 2*D[4][1] + 2*D[4][5] + 2*D[4][9] - 2*D[5][2] + 2*D[5][4] + 4*D[6][3] + 4*D[6][7] + 4*D[7][6] - 4*D[7][8] - 4*D[8][3] - 4*D[8][7] - 2*D[9][2] + 2*D[9][4]; // s1^2 + f3coeff[14] = 6*D[1][4] - 6*D[1][2] - 6*D[2][1] - 6*D[2][5] + 6*D[2][9] + 6*D[4][1] + 6*D[4][5] - 6*D[4][9] - 6*D[5][2] + 6*D[5][4] + 6*D[9][2] - 6*D[9][4]; // s3^2 + f3coeff[15] = 2*D[1][4] - 2*D[1][2] - 2*D[2][1] + 2*D[2][5] - 2*D[2][9] - 4*D[3][6] - 4*D[3][8] + 2*D[4][1] - 2*D[4][5] + 2*D[4][9] + 2*D[5][2] - 2*D[5][4] - 4*D[6][3] + 4*D[6][7] + 4*D[7][6] + 4*D[7][8] - 4*D[8][3] + 4*D[8][7] - 2*D[9][2] + 2*D[9][4]; // s2^2 + f3coeff[16] = 4*D[1][1] + 4*D[1][5] - 4*D[1][9] + 4*D[5][1] + 4*D[5][5] - 4*D[5][9] - 4*D[9][1] - 4*D[9][5] + 4*D[9][9]; // s3^3 + f3coeff[17] = 4*D[2][9] - 4*D[1][4] - 4*D[2][1] - 4*D[2][5] - 4*D[1][2] + 8*D[3][6] + 8*D[3][8] - 4*D[4][1] - 4*D[4][5] + 4*D[4][9] - 4*D[5][2] - 4*D[5][4] + 8*D[6][3] + 8*D[6][7] + 8*D[7][6] + 8*D[7][8] + 8*D[8][3] + 8*D[8][7] + 4*D[9][2] + 4*D[9][4]; // s1 * s2 * s3 + f3coeff[18] = 4*D[2][6] - 2*D[1][7] - 2*D[1][3] + 4*D[2][8] - 2*D[3][1] + 2*D[3][5] - 2*D[3][9] + 4*D[4][6] + 4*D[4][8] + 2*D[5][3] + 2*D[5][7] + 4*D[6][2] + 4*D[6][4] - 2*D[7][1] + 2*D[7][5] - 2*D[7][9] + 4*D[8][2] + 4*D[8][4] - 2*D[9][3] - 2*D[9][7]; // s1 * s2^2 + f3coeff[19] = 4*D[1][9] - 4*D[1][1] + 8*D[3][3] + 8*D[3][7] + 4*D[5][5] + 8*D[7][3] + 8*D[7][7] + 4*D[9][1] - 4*D[9][9]; // s1^2 * s3 + f3coeff[20] = 2*D[1][3] + 2*D[1][7] + 2*D[3][1] - 2*D[3][5] - 2*D[3][9] - 2*D[5][3] - 2*D[5][7] + 2*D[7][1] - 2*D[7][5] - 2*D[7][9] - 2*D[9][3] - 2*D[9][7]; // s1^3 + + // genereate random samples + std::vector u; + cv::randn(u, 100, 0.1); + + cv::Mat M2 = cayley_LS_M(f1coeff, f2coeff, f3coeff, u); + + +} + +cv::Mat dls::LeftMultVec(const cv::Mat& v) +{ + cv::Mat mat, row1, row2, row3; + + cv::hconcat(v.clone().t(), cv::Mat::zeros(1, 6, v.type()), row1); + cv::hconcat(cv::Mat::zeros(1, 3, v.type()), v.clone().t(), row2); + cv::hconcat(row2, cv::Mat::zeros(1, 3, v.type()), row2); + cv::hconcat(cv::Mat::zeros(1, 6, v.type()), v.clone().t(), row3); + + mat.push_back(row1); + mat.push_back(row2); + mat.push_back(row3); + + return mat; +} + +cv::Mat cayley_LS_M(const std::vector& a, const std::vector& b, const std::vector& c, const std::vector& u) +{ + + std::vector > M(120); + + M[0] = {u[1],0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,a[1],0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,b[1],0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,c[1],0}; + M[1] = {u[4],u[1],0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,a[1],a[10],0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,b[1],0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,b[10],0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,c[1],0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,c[10],0}; + M[2] = {0,u[4],u[1],0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,a[10],a[14],0,0,0,0,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a[3],a[17],a[5],0,0,a[10],0,0,0,a[9],0,0,0,a[1],0,a[4],0,0,0,0,b[3],0,0,0,0,b[11],b[1],0,0,0,0,0,0,0,0,0,0,b[9],0,0,0,0,b[4],0,0,b[10],0,0,0,b[17],b[5],0,0,0,c[5],0,c[1],0,0,0,0,0,c[10],0,0,c[3],c[9],0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,c[11],c[17],c[4]}; + M[14] = {0,0,0,0,0,u[2],0,0,0,0,0,u[3],0,u[4],u[1],0,0,0,0,0,0,0,0,0,0,0,0,0,a[11],0,0,0,0,a[5],a[17],0,a[12],0,0,a[14],0,a[9],a[1],a[4],0,0,0,a[10],0,a[8],0,a[3],0,0,b[17],0,b[1],b[11],0,b[5],b[10],0,b[9],0,0,b[3],0,0,0,0,0,b[4],0,0,0,0,b[8],0,0,b[14],0,0,0,0,b[12],0,0,0,c[12],c[3],c[10],0,0,0,0,0,c[14],0,0,c[17],c[4],0,0,0,0,0,c[1],0,0,0,0,c[9],0,0,c[11],0,0,c[5],0,c[8]}; + M[15] = {0,0,0,0,0,0,u[2],0,0,0,0,0,u[3],0,0,u[1],0,0,0,0,0,0,0,0,0,0,0,0,0,a[1],a[9],0,0,0,0,a[18],a[15],0,0,a[11],0,0,0,0,0,0,0,0,0,a[3],0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,b[1],b[9],b[3],0,0,b[11],0,0,0,b[18],b[15],0,0,0,c[15],0,0,0,0,0,c[1],0,c[11],0,0,0,0,0,0,0,0,0,0,c[9],0,0,0,0,0,0,0,0,0,0,c[18],c[3]}; + M[16] = {0,0,0,0,0,0,0,u[2],0,0,0,0,0,u[3],0,u[4],u[1],0,0,0,0,0,0,0,0,0,0,0,0,a[10],a[4],0,0,a[15],a[18],0,a[6],0,0,a[5],0,0,0,a[3],a[1],a[9],0,a[11],0,a[17],0,0,0,0,b[18],0,0,0,0,b[15],b[11],0,0,b[9],0,0,0,0,b[1],0,0,b[3],0,0,b[10],b[4],b[17],0,0,b[5],0,0,0,0,b[6],0,0,0,c[6],0,c[11],0,0,0,c[10],0,c[5],c[1],0,c[18],c[3],0,0,0,0,0,0,c[4],0,0,0,0,c[9],0,0,0,0,c[15],0,c[17]}; + M[17] = {0,0,0,0,0,0,0,0,u[2],0,0,0,0,0,u[3],0,u[4],u[1],0,0,0,0,0,0,0,0,0,0,a[15],a[14],a[8],0,0,a[6],0,0,0,0,0,a[12],0,a[3],a[11],a[17],a[10],a[4],a[9],a[5],0,0,0,a[18],0,0,0,0,b[11],b[15],0,b[6],b[5],0,b[3],b[4],0,b[18],b[9],0,b[10],0,0,b[17],0,0,b[14],b[8],0,0,0,b[12],0,0,0,0,0,0,0,0,0,c[18],c[5],0,0,0,c[14],0,c[12],c[10],0,0,c[17],0,c[9],0,0,0,c[11],c[8],0,0,0,c[3],c[4],0,c[15],0,0,c[6],0,0}; + M[18] = {0,0,0,0,0,0,0,0,0,u[2],0,0,0,0,0,0,0,0,u[1],0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,a[13],a[9],0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,a[1],0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,b[1],b[13],b[9],0,0,c[1],c[9],0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,c[13],0}; + M[19] = {0,0,0,0,0,0,0,0,0,0,u[2],0,0,0,0,0,0,0,u[4],u[1],0,0,0,0,0,0,0,0,0,0,0,0,a[1],a[9],a[13],a[19],a[4],0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,a[10],b[13],0,0,0,0,b[9],0,b[1],0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,b[10],b[19],b[4],0,0,c[10],c[4],0,0,0,0,0,0,0,0,0,0,c[13],0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,c[1],c[9],c[19],0}; + + M[20] = {0,0,0,0,0,0,0,0,0,0,0,u[2],0,0,0,0,0,0,0,u[4],u[1],0,0,0,0,0,0,a[1],a[9],0,0,0,a[10],a[4],a[19],0,a[8],0,0,0,0,0,0,0,0,0,0,0,0,0,0,a[13],0,a[14],b[19],b[1],0,b[9],0,b[4],0,b[10],0,0,0,b[13],0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,b[14],0,b[8],0,0,c[14],c[8],c[13],0,0,0,0,0,0,0,0,0,c[19],0,0,0,0,0,0,0,0,0,0,0,0,0,c[1],c[9],0,c[10],c[4],0,0}; + M[21] = {0,0,0,0,0,0,0,0,0,0,0,0,u[2],0,0,0,0,0,u[3],0,0,u[1],0,0,0,0,0,0,0,0,0,0,0,0,0,a[2],a[3],0,a[1],a[9],0,0,0,0,0,0,0,0,0,a[13],0,0,0,a[11],0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,b[13],0,b[1],b[9],0,0,b[11],b[2],b[3],0,0,c[11],c[3],0,0,0,c[1],0,0,0,c[9],0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,c[2],c[13]}; + M[22] = {0,0,0,0,0,0,0,0,0,0,0,0,0,u[2],0,0,0,0,0,u[3],0,u[4],u[1],0,0,0,0,0,0,0,0,0,a[11],a[3],a[2],0,a[17],0,a[10],a[4],a[1],0,0,a[13],0,0,0,a[9],0,a[19],0,0,0,a[5],b[2],0,0,0,0,b[3],b[9],b[11],0,0,0,0,0,0,0,0,0,b[13],b[1],0,0,0,b[19],0,b[10],b[4],0,0,b[5],0,b[17],0,0,c[5],c[17],0,c[9],0,c[10],0,0,c[1],c[4],0,0,c[2],c[13],0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,c[11],c[3],0,c[19]}; + M[23] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,u[2],0,0,0,0,0,u[3],0,u[4],u[1],0,0,0,a[11],a[3],0,0,0,a[5],a[17],0,0,0,0,a[14],a[8],a[10],a[13],a[9],a[19],0,0,0,a[4],0,0,0,a[2],0,a[12],0,b[11],b[9],b[3],0,b[17],b[4],b[5],b[13],0,0,b[2],0,0,0,0,0,b[19],b[10],0,0,0,0,0,b[14],b[8],0,0,b[12],0,0,0,0,c[12],0,c[2],c[4],0,c[14],0,0,c[10],c[8],0,0,0,c[19],0,0,0,0,0,c[9],0,0,0,0,c[13],0,c[11],c[3],0,c[5],c[17],0,0}; + M[24] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,u[2],0,0,0,0,0,u[3],0,0,u[1],0,0,0,0,a[9],a[13],0,0,0,0,0,a[18],0,a[11],a[3],0,0,0,0,0,0,0,0,0,a[2],0,0,a[1],a[15],0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,b[1],b[9],b[13],b[2],0,b[11],b[3],0,0,b[15],0,b[18],0,0,c[15],c[18],0,0,0,c[11],c[1],c[9],0,c[3],0,0,0,0,0,0,0,0,0,0,c[13],0,0,0,0,0,0,0,0,0,0,0,c[2]}; + M[25] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,u[2],0,0,0,0,0,u[3],0,u[4],u[1],0,0,0,a[4],a[19],0,a[15],a[18],0,0,0,0,a[5],a[17],a[11],0,0,a[2],a[9],a[13],0,a[3],0,0,0,0,a[10],a[6],0,0,0,0,0,b[18],b[3],b[15],0,b[13],0,0,0,0,b[9],0,0,b[2],b[11],b[10],b[4],b[19],0,0,b[5],b[17],0,0,b[6],0,0,0,0,c[6],0,0,c[3],0,c[5],c[10],c[4],c[11],c[17],c[9],0,0,c[2],0,0,0,0,0,0,c[19],0,0,0,0,c[13],0,0,0,c[15],c[18],0,0}; + M[26] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,u[2],0,0,0,0,0,u[3],0,u[4],u[1],a[15],a[18],a[8],0,0,a[6],0,0,0,0,0,a[12],0,a[5],a[2],a[3],0,a[4],a[19],a[13],a[17],0,0,0,0,a[14],0,0,b[15],b[3],b[18],0,0,b[17],b[6],b[2],b[19],0,0,b[13],0,b[4],0,0,0,b[5],b[14],b[8],0,0,0,b[12],0,0,0,0,0,0,0,0,0,0,0,c[17],0,c[12],c[14],c[8],c[5],0,c[4],0,0,0,0,c[13],0,0,0,c[3],0,0,0,0,c[2],c[19],c[15],c[18],0,c[6],0,0,0}; + M[27] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,u[3],0,0,0,0,0,0,0,0,0,0,0,0,0,a[11],a[3],0,0,0,0,0,a[7],0,0,a[15],0,0,0,0,0,0,0,0,0,a[18],0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,b[9],b[1],0,0,0,b[11],b[3],b[18],0,0,b[15],0,0,0,0,b[7],0,0,0,c[7],0,0,c[1],0,0,c[11],0,c[15],0,0,0,0,0,0,0,0,0,0,c[3],0,0,c[9],0,0,0,0,0,0,0,0,c[18]}; + M[28] = {0,0,0,0,0,0,u[3],0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,a[11],0,0,0,0,a[7],0,0,0,0,0,0,0,0,0,0,0,0,0,a[15],0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,b[1],0,0,0,0,0,b[11],b[15],0,0,0,0,0,0,b[7],0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,c[11],0,0,c[1],0,0,0,0,0,0,0,c[7],c[15]}; + + M[29] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,u[3],0,0,0,0,a[3],a[2],0,0,0,0,0,0,0,a[15],a[18],0,0,0,0,0,0,0,0,0,0,0,0,a[11],a[7],0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,b[13],b[9],0,0,b[11],b[3],b[2],0,0,b[15],b[18],0,0,b[7],0,0,0,0,c[7],0,0,0,c[9],c[15],c[11],c[3],0,c[18],0,0,0,0,0,0,0,0,0,0,c[2],0,0,c[13],0,0,0,0,0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0,a[16],0,0,0,0,0,0,0,a[12],0,0,0,0,0,0,0,0,0,0,b[14],0,0,b[12],0,0,0,0,0,b[16],0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,c[12],0,0,0,0,0,0,0,0,0,0,c[16],c[10],0,0,0,c[11],0,0,0,c[5],0,c[14],0,0,0,0,0,0,0,0}; + M[69] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,a[2],0,0,0,0,0,0,0,0,0,0,a[18],0,0,0,a[20],0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,b[20],0,0,0,b[2],0,0,0,b[18],0,0,0,c[18],0,0,0,0,0,0,0,c[20],0,0,0,0,c[2],0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; + + M[70] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,u[2],0,0,0,0,0,0,a[9],a[13],0,0,a[10],a[4],a[19],0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,a[14],a[20],0,a[8],0,b[9],0,b[13],b[10],b[19],0,b[4],0,0,0,b[20],0,0,0,0,0,0,0,0,0,0,0,0,0,0,b[14],0,b[8],0,0,0,c[14],c[8],0,c[20],0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,c[9],c[13],c[10],c[4],c[19],0,0}; + M[71] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,a[7],0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,b[7],b[5],0,0,b[15],0,b[6],0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,c[5],c[15],0,0,0,0,0,c[6],0,c[7],0,0,0,0,0,0,0}; + M[72] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,a[7],0,0,0,a[6],a[15],0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,b[7],b[6],b[14],0,b[15],b[5],0,b[12],0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,c[15],c[14],c[5],0,0,0,0,0,c[12],c[7],c[6],0,0,0,0,0,0,0}; + M[73] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,a[13],0,a[20],0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,b[20],b[13],0,0,0,c[13],c[20],0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; + M[74] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,u[3],0,0,0,a[17],0,0,a[7],0,0,0,0,0,a[6],0,a[15],0,0,0,a[3],a[2],0,a[18],0,0,0,0,a[5],0,0,0,0,0,0,0,b[18],b[7],0,b[2],0,0,0,b[13],b[3],b[19],b[4],0,b[15],b[5],b[17],0,0,0,b[6],0,0,0,0,0,0,0,0,0,0,0,c[18],c[4],c[6],c[5],c[17],c[15],0,c[3],0,0,0,0,0,0,c[13],0,0,0,0,0,c[19],0,c[2],0,0,0,c[7],0,0,0}; + M[75] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,u[2],0,0,0,0,0,0,0,0,0,0,0,0,0,0,a[2],a[1],a[9],a[13],0,0,0,0,0,0,0,0,0,a[20],a[11],0,0,a[3],0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,b[20],b[1],b[9],b[13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0,0,b[12],0,0,0,0,0,0,0,0,0,b[8],0,b[16],0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,c[16],0,0,0,c[17],c[8],0,0,c[18],c[12],0,c[6],0,0,0,0,0,0,0,0,0,0,0}; + + M[80] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,u[4],0,0,0,0,0,0,0,0,0,0,0,0,0,a[5],0,0,0,0,a[12],0,0,0,0,0,a[16],0,a[4],a[10],a[8],0,0,0,a[14],0,0,0,a[17],0,0,0,0,b[10],b[5],0,b[12],b[14],0,b[4],0,0,b[17],0,0,0,0,0,b[8],0,0,0,0,0,0,0,b[16],0,0,0,0,0,0,0,0,0,c[17],c[14],0,0,0,0,0,c[16],0,0,0,c[8],c[9],0,0,0,0,c[10],0,c[11],c[3],0,c[4],0,0,c[5],0,0,c[12],0,0}; + M[81] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,a[3],a[2],0,0,0,0,a[4],a[19],0,a[13],0,0,0,0,0,0,a[20],a[5],0,a[17],0,0,0,0,0,0,0,b[3],0,b[20],b[2],0,0,0,0,0,0,0,0,0,0,b[13],0,0,0,0,b[4],b[19],0,b[17],b[5],0,0,0,c[5],c[17],0,0,0,c[20],0,c[19],0,0,c[13],0,0,c[4],0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,c[3],c[2],0,0,0}; + M[82] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,a[6],0,0,0,0,0,0,0,0,0,0,0,0,0,0,a[15],a[18],0,a[7],0,0,0,0,0,0,0,0,0,0,0,0,b[7],0,0,b[18],b[4],0,0,b[3],b[15],b[17],b[5],0,0,0,b[6],0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,c[7],c[5],0,0,c[6],0,0,c[15],0,0,0,0,0,c[4],c[3],0,0,0,0,0,c[17],0,c[18],0,0,0,0,0,0,0}; + M[83] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,u[2],a[18],0,0,0,a[6],0,0,0,0,0,a[12],0,0,a[17],0,a[2],0,a[19],0,a[20],0,0,0,0,0,a[8],0,0,b[18],b[2],0,b[6],0,0,0,0,0,0,0,b[20],0,b[19],0,0,0,b[17],b[8],0,0,0,b[12],0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,c[8],0,c[17],0,c[19],c[12],0,0,0,c[20],0,0,0,c[2],0,0,0,0,0,0,c[18],0,c[6],0,0,0,0}; + M[84] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,u[3],0,0,0,0,0,0,0,0,0,0,0,0,a[5],a[17],0,0,a[7],0,0,0,0,0,a[6],0,0,0,a[18],a[11],a[3],0,a[15],0,0,0,0,0,0,0,0,0,0,0,b[7],b[15],0,0,b[3],0,0,0,b[9],b[11],b[4],b[10],b[18],0,0,b[5],b[17],0,0,0,b[6],0,0,0,0,0,0,0,0,0,0,c[15],c[10],0,0,c[5],0,c[6],c[11],0,0,c[18],0,0,0,c[9],0,0,c[17],0,0,c[4],0,c[3],0,0,0,0,c[7],0,0}; + M[85] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,u[2],0,0,0,a[19],0,a[15],a[18],0,0,0,0,a[5],a[17],0,a[3],0,0,0,a[13],a[20],0,a[2],0,0,a[6],0,a[4],0,0,0,0,0,b[15],0,b[2],b[18],0,b[20],0,0,0,0,b[13],0,0,0,b[3],b[4],b[19],0,0,b[5],b[17],0,b[6],0,0,0,0,0,c[6],0,0,0,c[2],0,c[17],c[4],c[19],c[3],0,c[13],c[5],0,0,0,0,0,0,0,0,0,0,0,0,0,c[20],0,0,c[15],c[18],0,0,0}; + M[86] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,a[18],0,0,0,0,0,a[17],0,0,a[2],0,0,0,a[20],0,0,0,a[6],0,0,0,a[19],0,0,0,0,0,b[18],0,0,0,0,0,0,0,0,0,b[20],0,0,0,b[2],b[19],0,0,0,b[17],0,0,0,b[6],0,0,0,c[6],0,0,0,0,0,0,0,c[19],0,c[2],0,c[20],c[17],0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,c[18],0,0,0,0}; + M[87] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,u[2],0,0,0,0,0,0,0,0,a[11],a[3],a[2],0,0,0,a[10],a[4],a[19],a[9],0,0,a[20],0,0,0,a[13],0,0,a[5],0,0,a[17],0,0,0,0,b[11],b[2],b[13],b[3],0,0,0,0,0,0,0,0,0,b[20],b[9],0,0,0,0,b[10],b[4],b[19],b[5],0,b[17],0,0,0,c[5],c[17],0,0,c[13],0,c[4],0,0,c[9],c[19],0,c[10],0,c[20],0,0,0,0,0,0,0,0,0,0,0,0,0,0,c[11],c[3],c[2],0,0}; + M[88] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,a[2],0,0,0,a[17],0,0,0,0,0,a[8],0,0,a[19],0,a[20],0,0,0,0,0,a[12],0,0,0,0,0,0,b[2],b[20],0,b[17],0,0,0,0,0,0,0,0,0,0,0,0,0,b[19],0,0,0,0,b[8],0,0,0,b[12],0,0,0,c[12],0,0,0,0,0,0,0,0,0,c[19],0,0,c[8],0,0,0,0,0,0,0,c[20],0,0,0,0,0,0,c[2],0,c[17],0,0,0,0}; + M[89] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,a[7],0,0,0,0,0,a[6],0,0,a[18],0,0,0,a[2],0,0,0,0,0,0,0,a[17],0,0,0,0,0,b[7],0,0,0,0,0,0,0,0,b[20],b[2],0,b[19],0,b[18],b[17],0,0,0,b[6],0,0,0,0,0,0,0,0,0,0,0,0,0,c[19],0,c[17],0,c[18],0,c[2],c[6],0,0,0,0,0,c[20],0,0,0,0,0,0,0,0,0,0,c[7],0,0,0,0}; + + M[90] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,a[12],0,0,0,0,0,0,0,0,0,0,0,0,a[16],0,a[8],0,0,0,0,0,0,0,0,0,0,0,0,b[12],b[8],0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,b[16],0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,c[16],0,0,0,0,0,c[19],0,0,0,c[2],c[8],0,c[17],0,0,0,0,c[12],0,0,0,0,0,0}; + M[91] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,u[2],0,0,0,a[3],a[2],0,0,a[5],a[17],0,0,0,0,a[14],a[8],0,a[4],a[20],a[13],0,0,0,0,a[19],0,0,a[12],0,0,0,0,b[3],b[13],b[2],b[5],0,b[19],b[17],b[20],0,0,0,0,0,0,0,0,0,b[4],0,0,0,0,b[14],b[8],0,b[12],0,0,0,0,0,c[12],0,0,0,c[19],0,c[8],0,0,c[4],0,0,c[14],0,0,0,0,0,0,0,c[13],0,0,0,0,c[20],0,c[3],c[2],c[5],c[17],0,0,0}; + M[92] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,u[4],0,0,0,0,0,0,0,0,0,0,a[6],a[16],0,0,0,0,0,0,0,0,0,0,0,a[17],a[5],0,a[14],a[8],a[4],a[12],0,0,0,0,0,0,0,0,b[5],b[6],0,0,b[12],0,b[17],b[8],0,0,b[4],0,b[14],0,0,0,0,0,b[16],0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,c[12],0,0,0,c[16],0,0,c[14],0,0,0,c[3],c[4],0,0,0,c[5],0,c[15],c[18],0,c[17],c[8],0,c[6],0,0,0,0,0}; + M[93] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,u[3],0,0,0,0,0,0,0,0,0,0,a[7],a[12],0,0,0,0,0,0,0,0,0,0,0,a[18],a[15],0,a[5],a[17],a[3],a[6],0,0,0,0,0,0,0,0,b[15],b[7],0,0,b[6],0,b[18],b[17],0,0,b[3],b[4],b[5],b[8],b[14],0,0,0,b[12],0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,c[6],c[14],0,0,c[12],0,0,c[5],0,0,0,0,c[3],0,c[4],0,c[15],0,0,0,c[8],c[18],c[17],0,c[7],0,0,0,0,0}; + M[94] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,a[2],0,0,0,0,0,a[19],0,0,a[20],0,0,0,0,0,0,0,a[17],0,0,0,0,0,0,0,0,0,b[2],0,0,0,0,0,0,0,0,0,0,0,0,0,b[20],0,0,0,0,b[19],0,0,0,b[17],0,0,0,c[17],0,0,0,0,0,0,0,0,0,c[20],0,0,c[19],0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,c[2],0,0,0,0}; + M[95] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,u[4],a[6],0,0,0,0,0,0,0,0,0,0,0,0,a[12],0,a[17],0,a[8],0,a[19],0,0,0,0,0,a[16],0,0,b[6],b[17],0,0,0,0,0,0,0,0,0,b[19],0,b[8],0,0,0,b[12],b[16],0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,c[16],0,c[12],0,c[8],0,0,0,c[2],c[19],0,0,0,c[17],0,c[18],0,0,0,0,c[6],0,0,0,0,0,0}; + M[96] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,u[4],0,0,0,a[5],a[17],0,0,0,a[12],0,0,0,0,0,a[16],0,a[14],a[19],a[4],0,0,0,0,a[8],0,0,0,0,0,0,0,b[5],b[4],b[17],0,0,b[8],b[12],b[19],0,0,0,0,0,0,0,0,0,b[14],0,0,0,0,0,b[16],0,0,0,0,0,0,0,0,0,0,0,c[8],0,c[16],0,0,c[14],0,0,0,0,0,c[13],0,0,0,0,c[4],0,c[3],c[2],0,c[19],0,c[5],c[17],0,c[12],0,0,0}; + M[97] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,a[6],0,a[12],0,a[17],0,0,0,0,0,0,0,0,0,b[6],0,0,0,0,0,0,0,0,0,b[17],b[8],b[12],0,b[16],0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,c[16],0,0,0,0,0,c[12],0,0,0,c[18],c[17],0,c[8],0,c[6],0,c[7],0,0,0,0,0,0,0,0,0,0,0}; + M[98] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,a[12],0,0,0,0,0,0,0,0,0,0,0,0,a[8],a[14],0,0,0,0,a[16],0,0,0,0,0,0,0,0,b[14],b[12],0,0,b[16],0,b[8],0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,c[16],0,0,0,0,0,0,0,0,0,0,c[4],0,0,0,c[3],c[14],0,c[5],c[17],0,c[8],0,0,c[12],0,0,0,0,0}; + M[99] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,a[7],0,a[6],0,a[18],0,0,0,0,0,0,0,0,0,b[7],0,0,0,0,0,0,0,b[8],0,b[18],b[17],b[6],0,b[12],0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,c[12],0,0,0,0,0,c[6],0,0,0,0,c[18],c[8],c[17],0,c[7],0,0,0,0,0,0,0,0,0,0,0,0,0}; + + M[100] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0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,0,0,0,0,0,a[10],0,0,0,0,a[14],a[8],0,a[16],0,0,0,0,0,0,0,0,0,0,0,0,0,0,a[4],0,0,b[8],0,0,b[10],0,b[14],0,0,0,0,0,b[4],0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,b[16],0,0,0,c[16],c[4],0,0,0,0,0,0,0,0,0,c[8],0,0,0,0,0,0,0,0,c[1],c[9],0,0,0,0,c[10],0,0,c[14],0,0}; + M[105] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,u[4],0,0,0,0,0,0,a[10],a[4],0,0,0,a[14],a[8],0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,a[19],0,a[16],0,b[10],0,b[4],0,b[8],0,b[14],0,0,0,b[19],0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,b[16],0,0,0,0,c[16],0,c[19],0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,c[9],c[13],0,0,0,c[10],c[4],0,c[14],c[8],0,0}; + M[106] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,a[4],a[19],0,0,a[14],a[8],0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,a[16],0,0,0,0,b[4],0,b[19],b[14],0,0,b[8],0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,b[16],0,0,0,0,0,c[16],0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,c[13],c[20],0,0,0,c[4],c[19],c[14],c[8],0,0,0}; + M[107] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,a[19],0,0,0,a[8],0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,a[16],0,0,0,0,0,0,b[19],0,0,b[8],0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,b[16],0,0,0,c[16],0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,c[20],0,0,0,0,c[19],0,c[8],0,0,0,0}; + M[108] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,a[20],0,0,0,0,0,0,0,0,0,0,0,a[1],0,a[9],0,0,a[13],0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,b[9],b[1],b[13],0,b[20],c[1],c[9],c[13],c[20],0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; + M[109] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,u[3],a[7],0,0,0,0,0,0,0,0,0,0,0,0,a[6],0,a[18],0,a[17],0,a[2],0,0,0,0,0,a[12],0,0,b[7],b[18],0,0,0,0,0,0,0,0,0,b[2],b[19],b[17],0,b[8],0,b[6],b[12],0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,c[8],0,c[12],0,c[6],0,c[17],0,0,0,0,c[2],0,c[19],0,c[18],0,0,0,0,0,0,c[7],0,0,0,0,0,0}; + + M[110] = {0,0,0,0,0,0,0,u[3],0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,a[5],0,0,0,a[7],0,0,0,0,0,0,0,0,a[15],0,a[11],0,0,0,a[6],0,0,0,0,b[7],0,0,0,0,0,0,0,0,b[11],0,0,0,b[1],0,b[10],0,b[15],0,0,0,b[5],b[6],0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,c[7],c[15],0,0,0,c[1],0,0,c[5],0,0,c[10],0,c[11],0,0,0,0,0,0,c[6]}; + M[111] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,u[2],0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,a[20],a[13],0,0,0,0,0,0,0,0,0,0,0,0,0,a[1],0,0,a[9],0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,b[1],0,b[9],b[20],b[13],0,c[1],c[9],c[13],0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,c[20],0}; + M[112] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,u[2],0,0,0,0,0,0,0,0,0,0,0,a[1],a[9],a[13],a[20],0,a[19],0,0,0,0,0,0,0,0,0,0,0,0,0,a[10],0,0,a[4],b[20],0,0,0,b[1],b[13],0,b[9],0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,b[10],0,b[4],0,b[19],0,c[10],c[4],c[19],0,0,0,0,0,0,0,0,0,0,c[20],0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,c[1],c[9],c[13],0,0}; + M[113] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,a[9],a[13],a[20],0,0,0,0,0,0,0,0,0,0,0,0,0,0,a[10],0,a[4],0,0,a[19],0,0,0,0,b[9],b[20],0,b[13],0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,b[4],b[10],b[19],0,0,c[10],c[4],c[19],0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,c[9],c[13],c[20],0,0}; + M[114] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,a[13],a[20],0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,a[4],0,a[19],0,0,0,0,0,0,0,b[13],0,0,b[20],0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,b[19],b[4],0,0,0,c[4],c[19],0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,c[13],c[20],0,0,0}; + M[115] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,a[20],0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,a[19],0,0,0,0,0,0,0,0,0,b[20],0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,b[19],0,0,0,c[19],0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,c[20],0,0,0,0}; + M[116] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,u[2],0,0,0,0,a[13],a[20],0,0,0,0,0,0,a[11],a[3],a[2],0,0,0,0,0,0,0,0,0,0,a[15],0,a[9],a[18],0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,b[9],b[13],b[20],0,b[11],b[3],b[2],b[15],0,b[18],0,0,0,c[15],c[18],0,0,0,0,c[3],c[9],c[13],0,c[2],0,c[11],0,0,0,0,0,0,0,0,c[20],0,0,0,0,0,0,0,0,0,0,0,0}; + M[117] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,a[20],0,0,0,0,0,0,0,a[3],a[2],0,0,0,0,0,0,0,0,0,a[15],0,a[18],0,a[13],0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,b[13],b[20],0,0,b[3],b[2],0,b[18],b[15],0,0,0,c[15],c[18],0,0,0,0,0,c[2],c[13],c[20],0,0,0,c[3],0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; + M[118] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,a[13],a[20],0,0,a[4],a[19],0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,a[14],0,a[8],0,0,0,0,b[13],0,b[20],b[4],0,0,b[19],0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,b[8],b[14],0,0,0,c[14],c[8],0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,c[13],c[20],c[4],c[19],0,0,0}; + M[119] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,a[20],0,0,0,a[19],0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,a[8],0,0,0,0,0,0,b[20],0,0,b[19],0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,b[8],0,0,0,c[8],0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,c[20],0,c[19],0,0,0,0}; + + + return cv::Mat(M).t(); +} diff --git a/modules/calib3d/src/dls.h b/modules/calib3d/src/dls.h index 329e804..f5483c8 100644 --- a/modules/calib3d/src/dls.h +++ b/modules/calib3d/src/dls.h @@ -1,17 +1,30 @@ -#ifndef dls_h -#define dls_h +#ifndef DLS_H +#define DLS_H -#include "opencv2/core/core_c.h" +#include "precomp.hpp" class dls { public: - dls(); + dls(const cv::Mat& opoints, const cv::Mat& ipoints); ~dls(); -private: + void init_vectors(const cv::Mat& opoints, const cv::Mat& ipoints); + void build_coeff_mattrix(); + cv::Mat LeftMultVec(const cv::Mat& v); + cv::Mat cayley_LS_M(const std::vector& a, const std::vector& b, const std::vector& c, const std::vector& u); +private: + cv::Mat H; // coeff matrix + cv::Mat A; + cv::Mat D_mat; + std::vector f1coeff; + std::vector f2coeff; + std::vector f3coeff; + cv::Mat p; // object points + cv::Mat z; // image points + int N; // number of input points }; -#endif +#endif // DLS_H diff --git a/modules/calib3d/src/solvepnp.cpp b/modules/calib3d/src/solvepnp.cpp index f204463..daa959e 100644 --- a/modules/calib3d/src/solvepnp.cpp +++ b/modules/calib3d/src/solvepnp.cpp @@ -41,10 +41,10 @@ //M*/ #include "precomp.hpp" +#include "dls.h" #include "epnp.h" #include "p3p.h" #include "opencv2/calib3d/calib3d_c.h" -#include "dls.h" #include using namespace cv; @@ -100,12 +100,13 @@ bool cv::solvePnP( InputArray _opoints, InputArray _ipoints, cv::Mat undistortedPoints; cv::undistortPoints(ipoints, undistortedPoints, cameraMatrix, distCoeffs); - //dls PnP; + + dls PnP(opoints, undistortedPoints); // DO SOMETHING cv::Mat R, rvec = _rvec.getMat(), tvec = _tvec.getMat(); - + return true; } else CV_Error(CV_StsBadArg, "The flags argument must be one of CV_ITERATIVE, CV_P3P or CV_EPNP"); -- 2.7.4