summaryrefslogtreecommitdiffhomepage
path: root/FTNoIR_Tracker_PT
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2014-01-08 23:53:45 +0100
committerStanislaw Halik <sthalik@misaki.pl>2014-01-08 23:53:45 +0100
commitd6855de1a83fd54c43384de218d61252de7a7a1b (patch)
tree597eabaf6a3004d29fca266cbe3e0afe8d20f73e /FTNoIR_Tracker_PT
parent0a32ae32452b02fae0036f9c5099b043d0c9052e (diff)
fix crash due to mismatched float/double
Diffstat (limited to 'FTNoIR_Tracker_PT')
-rw-r--r--FTNoIR_Tracker_PT/point_tracker.cpp11
-rw-r--r--FTNoIR_Tracker_PT/point_tracker.h14
-rw-r--r--FTNoIR_Tracker_PT/trans_calib.cpp4
3 files changed, 16 insertions, 13 deletions
diff --git a/FTNoIR_Tracker_PT/point_tracker.cpp b/FTNoIR_Tracker_PT/point_tracker.cpp
index 263be43a..9f0fb59e 100644
--- a/FTNoIR_Tracker_PT/point_tracker.cpp
+++ b/FTNoIR_Tracker_PT/point_tracker.cpp
@@ -105,8 +105,8 @@ void PointTracker::reset()
dt_valid = 0;
reset_velocities();
// assume identity rotation again
- X_CM.R = cv::Matx33d::eye();
- X_CM.t = cv::Vec3f();
+ X_CM.R = cv::Matx33f::eye();
+ X_CM.t = cv::Vec3f(0, 0, 1);
}
void PointTracker::reset_velocities()
@@ -168,7 +168,7 @@ bool PointTracker::track(const vector<Vec2f>& points, float fov, float dt, int w
void PointTracker::predict(float dt)
{
// predict with constant velocity
- Matx33d R;
+ Matx33f R;
Rodrigues(dt*v_r, R);
X_CM.R = R*X_CM.R;
X_CM.t += dt * v_t;
@@ -273,7 +273,10 @@ void PointTracker::POSIT(float fov, int w, int h)
cv::Rodrigues(rvec, rmat);
// finally, find the closer solution
- cv::Mat expected = cv::Mat(X_CM.R);
+ cv::Mat expected(3, 3, CV_64FC1);
+ for (int i = 0; i < 3; i++)
+ for (int j = 0; j < 3; j++)
+ expected.at<double>(i, j) = X_CM.R(i, j);
cv::Mat eye = cv::Mat::eye(3, 3, CV_64FC1);
double dev1 = norm(eye - expected * rmat.t());
double dev2 = norm(eye - expected * rmat);
diff --git a/FTNoIR_Tracker_PT/point_tracker.h b/FTNoIR_Tracker_PT/point_tracker.h
index 823d75c0..ac43489e 100644
--- a/FTNoIR_Tracker_PT/point_tracker.h
+++ b/FTNoIR_Tracker_PT/point_tracker.h
@@ -21,11 +21,11 @@
class FrameTrafo
{
public:
- FrameTrafo() : R(cv::Matx33d::eye()), t(0,0,0) {}
- FrameTrafo(const cv::Matx33d& R, const cv::Vec3d& t) : R(R),t(t) {}
+ FrameTrafo() : R(cv::Matx33f::eye()), t(0,0,0) {}
+ FrameTrafo(const cv::Matx33f& R, const cv::Vec3f& t) : R(R),t(t) {}
- cv::Matx33d R;
- cv::Vec3d t;
+ cv::Matx33f R;
+ cv::Vec3f t;
};
inline FrameTrafo operator*(const FrameTrafo& X, const FrameTrafo& Y)
@@ -33,17 +33,17 @@ inline FrameTrafo operator*(const FrameTrafo& X, const FrameTrafo& Y)
return FrameTrafo(X.R*Y.R, X.R*Y.t + X.t);
}
-inline FrameTrafo operator*(const cv::Matx33d& X, const FrameTrafo& Y)
+inline FrameTrafo operator*(const cv::Matx33f& X, const FrameTrafo& Y)
{
return FrameTrafo(X*Y.R, X*Y.t);
}
-inline FrameTrafo operator*(const FrameTrafo& X, const cv::Matx33d& Y)
+inline FrameTrafo operator*(const FrameTrafo& X, const cv::Matx33f& Y)
{
return FrameTrafo(X.R*Y, X.t);
}
-inline cv::Vec3f operator*(const FrameTrafo& X, const cv::Vec3d& v)
+inline cv::Vec3f operator*(const FrameTrafo& X, const cv::Vec3f& v)
{
return X.R*v + X.t;
}
diff --git a/FTNoIR_Tracker_PT/trans_calib.cpp b/FTNoIR_Tracker_PT/trans_calib.cpp
index 9b75a1b6..b2e0ead0 100644
--- a/FTNoIR_Tracker_PT/trans_calib.cpp
+++ b/FTNoIR_Tracker_PT/trans_calib.cpp
@@ -40,5 +40,5 @@ void TranslationCalibrator::update(const Matx33f& R_CM_k, const Vec3f& t_CM_k)
Vec3f TranslationCalibrator::get_estimate()
{
Vec6f x = P.inv() * y;
- return Vec3f(-x[0], -x[1], -x[2]);
-} \ No newline at end of file
+ return Vec3f(-x[0], -x[1], -x[2]);
+}