Commit 40f6d320 authored by edgarriba's avatar edgarriba

last update

parent 42ab7fd8
This source diff could not be displayed because it is too large. You can view the blob instead.
#ifndef DLS_H #ifndef DLS_H_
#define DLS_H #define DLS_H_
#include "precomp.hpp" #include "precomp.hpp"
using namespace std;
class dls class dls
{ {
public: public:
dls(const cv::Mat& opoints, const cv::Mat& ipoints); dls(const cv::Mat& opoints, const cv::Mat& ipoints);
~dls(); virtual ~dls();
template <typename OpointType, typename O, typename IpointType, typename I>
void init_points(const cv::Mat& opoints, const cv::Mat& ipoints)
{
for(int i = 0; i < N; i++)
{
p.at<O>(0,i) = opoints.at<OpointType>(0,i).x;
p.at<O>(1,i) = opoints.at<OpointType>(0,i).y;
p.at<O>(2,i) = opoints.at<OpointType>(0,i).z;
z.at<I>(0,i) = ipoints.at<IpointType>(0,i).x;
z.at<I>(1,i) = ipoints.at<IpointType>(0,i).y;
z.at<I>(2,i) = (I)1;
}
}
void init_vectors(const cv::Mat& opoints, const cv::Mat& ipoints); void norm_z_vector();
void build_coeff_mattrix(); void build_coeff_matrix();
cv::Mat LeftMultVec(const cv::Mat& v); cv::Mat LeftMultVec(const cv::Mat& v);
cv::Mat cayley_LS_M(const std::vector<double>& a, const std::vector<double>& b, const std::vector<double>& c, const std::vector<double>& u); cv::Mat cayley_LS_M(const std::vector<double>& a, const std::vector<double>& b,
const std::vector<double>& c, const std::vector<double>& u);
private: private:
cv::Mat H; // coeff matrix cv::Mat H, A, D_mat; // coeff matrix
cv::Mat A; cv::Mat p; // object points
cv::Mat D_mat; cv::Mat z; // image points
std::vector<double> f1coeff; int N; // number of input points
std::vector<double> f2coeff; std::vector<double> f1coeff, f2coeff, f3coeff;
std::vector<double> f3coeff;
cv::Mat p; // object points
cv::Mat z; // image points
int N; // number of input points
}; };
......
...@@ -100,11 +100,10 @@ bool cv::solvePnP( InputArray _opoints, InputArray _ipoints, ...@@ -100,11 +100,10 @@ bool cv::solvePnP( InputArray _opoints, InputArray _ipoints,
cv::Mat undistortedPoints; cv::Mat undistortedPoints;
cv::undistortPoints(ipoints, undistortedPoints, cameraMatrix, distCoeffs); cv::undistortPoints(ipoints, undistortedPoints, cameraMatrix, distCoeffs);
//dls PnP(opoints, undistortedPoints);
dls PnP(opoints, ipoints); // FOR TESTING
dls PnP(opoints, undistortedPoints); //TODO: DO SOMETHING WITH R and t
// DO SOMETHING
cv::Mat R, rvec = _rvec.getMat(), tvec = _tvec.getMat();
return true; return true;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment