50 Rodrigues(rVec, rMat);
66 CVMatx44f glM((
float) rMat.at<
double>(0, 0), (
float) rMat.at<
double>(0, 1), (
float) rMat.at<
double>(0, 2), (
float) tVec.at<
double>(0, 0),
67 (
float)-rMat.at<
double>(1, 0), (
float)-rMat.at<
double>(1, 1), (
float)-rMat.at<
double>(1, 2), (
float)-tVec.at<
double>(1, 0),
68 (
float)-rMat.at<
double>(2, 0), (
float)-rMat.at<
double>(2, 1), (
float)-rMat.at<
double>(2, 2), (
float)-tVec.at<
double>(2, 0),
69 0.0f, 0.0f, 0.0f, 1.0f);
86 CVMatx33f rMat(glMat.val[0], -glMat.val[1], -glMat.val[2],
87 glMat.val[4], -glMat.val[5], -glMat.val[6],
88 glMat.val[8], -glMat.val[9], -glMat.val[10]);
91 Rodrigues(rMat, rVec);
94 tVec.at<
double>(0, 0) = glMat.val[3];
95 tVec.at<
double>(1, 0) = -glMat.val[7];
96 tVec.at<
double>(2, 0) = -glMat.val[11];
135 vector<float> weights)
137 if (vectors.size() == 1)
141 float totalWeights = 0.0f;
143 for (
int i = 0; i < vectors.size(); i++)
145 float weight = weights[i];
146 total += vectors[i] * weight;
147 totalWeights += weight;
150 return total / totalWeights;
154 vector<float> weights)
158 if (quaternions.size() == 1)
159 return quaternions[0];
161 SLQuat4f total(0.0f, 0.0f, 0.0f, 0.0f);
163 for (
int i = 0; i < quaternions.size(); i++)
165 SLQuat4f quaternion = quaternions[i];
166 float weight = weights[i];
168 if (i > 0 && quaternion.
dot(quaternions[0]) < 0.0)
171 total.
set(total.
x() + weight * quaternion.
x(),
172 total.
y() + weight * quaternion.
y(),
173 total.
z() + weight * quaternion.
z(),
174 total.
w() + weight * quaternion.
w());
static AvgFloat trackingTimesMS
Averaged time for video tracking in ms.
static AvgFloat optFlowTimesMS
Averaged time for video feature optical flow tracking in ms.
static void createRvecTvec(const CVMatx44f &glMat, CVMat &tVec, CVMat &rVec)
Creates the OpenCV rvec & tvec vectors from an column major OpenGL 4x4 matrix.
static AvgFloat detectTimesMS
Averaged time for video feature detection & description in ms.
static CVMatx44f calcObjectMatrix(const CVMatx44f &cameraObjectMat, const CVMatx44f &objectViewMat)
static cv::Matx44f createGLMatrix(const CVMat &tVec, const CVMat &rVec)
Create an OpenGL 4x4 matrix from an OpenCV translation & rotation vector.
static SLQuat4f averageQuaternion(vector< SLQuat4f > quaternions, vector< float > weights)
static AvgFloat detect1TimesMS
Averaged time for video feature detection subpart 1 in ms.
static void resetTimes()
Resets all static variables.
static AvgFloat detect2TimesMS
Averaged time for video feature detection subpart 2 in ms.
static AvgFloat matchTimesMS
Averaged time for video feature matching in ms.
static AvgFloat poseTimesMS
Averaged time for video feature pose estimation in ms.
CVMatx44f objectViewMat()
static CVVec3f averageVector(vector< CVVec3f > vectors, vector< float > weights)
void set(T x, T y, T z, T w)
T dot(const SLQuat4< T > &q) const
SLQuat4< T > normalized() const
void init(int numValues, T initValue)
Initializes the average value array to a given value.