summaryrefslogtreecommitdiffhomepage
path: root/tracker-aruco/ftnoir_tracker_aruco.h
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2016-06-24 09:09:22 +0200
committerStanislaw Halik <sthalik@misaki.pl>2016-06-24 15:47:22 +0200
commit8b9f88d4ed1482ed508826801e559962970dbc96 (patch)
tree0879e1342814f8b00293220d9f93f239eb4b4911 /tracker-aruco/ftnoir_tracker_aruco.h
parent6d2cc8cf667c4e166c754698faac770a99aceeee (diff)
tracker/aruco: fix crash after opencv update
Some new matrix element type requirements came up after opencv update Also, - switch to matrices of known sizes wherever possible - split into functions for readability - use member variables rather than locals to ensure heap allocation There was also breakage wrt "unknown element type" deep in opencv that only happens on release mode with no symbols. It's unknown to me whether the issue got fixed or variable reordering made it corrupt something else. It appears to work however. -fstack-protector-all doesn't show any errors at all. @kblomster says it worked in rc49p2. Looks like -fipa-pta has a miscompilation despite finally working to begin with. Reported-by: @kblomster Issue: #375
Diffstat (limited to 'tracker-aruco/ftnoir_tracker_aruco.h')
-rw-r--r--tracker-aruco/ftnoir_tracker_aruco.h49
1 files changed, 43 insertions, 6 deletions
diff --git a/tracker-aruco/ftnoir_tracker_aruco.h b/tracker-aruco/ftnoir_tracker_aruco.h
index bef27ac7..fb207f6f 100644
--- a/tracker-aruco/ftnoir_tracker_aruco.h
+++ b/tracker-aruco/ftnoir_tracker_aruco.h
@@ -9,16 +9,20 @@
#include "ui_aruco-trackercontrols.h"
#include "ar_video_widget.h"
+#include "opentrack-compat/options.hpp"
+#include "trans_calib.h"
+#include "opentrack/plugin-api.hpp"
+#include "opentrack/opencv-camera-dialog.hpp"
+#include "include/markerdetector.h"
+
#include <QObject>
#include <QThread>
#include <QMutex>
#include <QHBoxLayout>
#include <QDialog>
#include <QTimer>
-#include "opentrack-compat/options.hpp"
-#include "trans_calib.h"
-#include "opentrack/plugin-api.hpp"
-#include "opentrack/opencv-camera-dialog.hpp"
+
+#include <cinttypes>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
@@ -48,7 +52,7 @@ class Tracker : protected QThread, public ITracker
{
Q_OBJECT
friend class TrackerControls;
- static constexpr double c_search_window = 1.3;
+ static constexpr float c_search_window = 1.3f;
public:
Tracker();
~Tracker() override;
@@ -57,6 +61,19 @@ public:
void run() override;
void getRT(cv::Matx33d &r, cv::Vec3d &t);
private:
+ bool detect_with_roi();
+ bool detect_without_roi();
+ bool open_camera();
+ void set_intrinsics();
+ void update_fps(double dt);
+ void draw_ar(bool ok);
+ void clamp_last_roi();
+ void set_points();
+ void draw_centroid();
+ bool set_last_roi();
+ void set_rmat();
+ void set_roi_from_projection();
+
cv::VideoCapture camera;
QMutex camera_mtx;
QMutex mtx;
@@ -65,9 +82,29 @@ private:
ArucoVideoWidget* videoWidget;
settings s;
double pose[6];
- cv::Mat frame;
+ cv::Mat frame, grayscale, color;
cv::Matx33d r;
+ std::vector<cv::Point3f> obj_points;
+ cv::Matx33d intrinsics;
+ cv::Matx14f dist_coeffs;
+ aruco::MarkerDetector detector;
+ std::vector<aruco::Marker> markers;
cv::Vec3d t;
+ cv::Vec3d rvec, tvec, rvec_, tvec_;
+ std::vector<cv::Point2f> roi_projection;
+ std::vector<cv::Point2f> repr2;
+ std::vector<cv::Point3f> centroid;
+ cv::Matx33d m_r, m_q, rmat;
+ cv::Vec3d euler;
+ std::vector<cv::Point3f> roi_points;
+ cv::Rect last_roi;
+ double freq, cur_fps;
+ std::uint64_t last_time;
+
+ static constexpr float size_min = 0.05f;
+ static constexpr float size_max = 0.3f;
+
+ static constexpr double alpha_ = .985;
};
class TrackerControls : public ITrackerDialog, protected camera_dialog