From a88e34b21b07f70123926fcb5c505d6afdf99807 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 24 Dec 2018 18:54:34 +0100 Subject: style/quality only No functional changes. - add `override' everywhere where missing - almost pass clang's `-Wweak-vtables' - avoid some float/double conversions - remove unused private members - make signedness conversions explicit - put stuff in right namespaces to aid analysis --- tracker-pt/module/camera.cpp | 10 ++++++---- tracker-pt/module/frame.cpp | 4 +++- tracker-pt/module/frame.hpp | 12 ++++++++++-- tracker-pt/module/module.cpp | 16 +++++++++++----- tracker-pt/module/module.hpp | 4 ++-- tracker-pt/module/point_extractor.cpp | 9 +++++++-- tracker-pt/pt-api.hpp | 9 +++++++++ tracker-pt/pt-settings.hpp | 11 ++++++++++- 8 files changed, 58 insertions(+), 17 deletions(-) (limited to 'tracker-pt') diff --git a/tracker-pt/module/camera.cpp b/tracker-pt/module/camera.cpp index 85439431..1b948932 100644 --- a/tracker-pt/module/camera.cpp +++ b/tracker-pt/module/camera.cpp @@ -19,6 +19,7 @@ #include using namespace pt_module; +namespace pt_module { Camera::Camera(const QString& module_name) : s { module_name } { @@ -141,10 +142,10 @@ bool Camera::start(int idx, int fps, int res_x, int res_y) void Camera::stop() { cap = nullptr; - desired_name = QString(); - active_name = QString(); - cam_info = pt_camera_info(); - cam_desired = pt_camera_info(); + desired_name = QString{}; + active_name = QString{}; + cam_info = {}; + cam_desired = {}; } bool Camera::get_frame_(cv::Mat& frame) @@ -171,3 +172,4 @@ void Camera::camera_deleter::operator()(cv::VideoCapture* cap) } } +} // ns pt_module diff --git a/tracker-pt/module/frame.cpp b/tracker-pt/module/frame.cpp index 6734edf6..7dd8c92f 100644 --- a/tracker-pt/module/frame.cpp +++ b/tracker-pt/module/frame.cpp @@ -4,7 +4,7 @@ #include -using namespace pt_module; +namespace pt_module { Preview& Preview::operator=(const pt_frame& frame_) { @@ -76,3 +76,5 @@ void Preview::ensure_size(cv::Mat& frame, int w, int h, int type) if (frame.cols != w || frame.rows != h) frame = cv::Mat(h, w, type); } + +} // ns pt_module diff --git a/tracker-pt/module/frame.hpp b/tracker-pt/module/frame.hpp index 49dde49e..d440bd67 100644 --- a/tracker-pt/module/frame.hpp +++ b/tracker-pt/module/frame.hpp @@ -5,6 +5,11 @@ #include #include +#ifdef __clang__ +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wweak-vtables" +#endif + namespace pt_module { struct Frame final : pt_frame @@ -29,8 +34,11 @@ struct Preview final : pt_preview private: static void ensure_size(cv::Mat& frame, int w, int h, int type); - bool fresh = true; - cv::Mat frame_copy, frame_color, frame_out, frame_out2; + cv::Mat frame_copy, frame_out; }; } // ns pt_module + +#ifdef __clang__ +# pragma clang diagnostic pop +#endif diff --git a/tracker-pt/module/module.cpp b/tracker-pt/module/module.cpp index 4731175a..f665face 100644 --- a/tracker-pt/module/module.cpp +++ b/tracker-pt/module/module.cpp @@ -12,7 +12,11 @@ static const QString module_name = "tracker-pt"; -using namespace pt_module; +#ifdef __clang__ +# pragma clang diagnostic ignored "-Wweak-vtables" +#endif + +namespace pt_module { struct pt_module_traits final : pt_runtime_traits { @@ -54,13 +58,15 @@ struct dialog_pt : TrackerDialog_PT dialog_pt(); }; -// ns pt_module - -using namespace pt_module; - dialog_pt::dialog_pt() : TrackerDialog_PT(module_name) {} QString metadata_pt::name() { return tr("PointTracker 1.1"); } QIcon metadata_pt::icon() { return QIcon(":/Resources/Logo_IR.png"); } +} + +// ns pt_module + +using namespace pt_module; + OPENTRACK_DECLARE_TRACKER(tracker_pt, dialog_pt, metadata_pt) diff --git a/tracker-pt/module/module.hpp b/tracker-pt/module/module.hpp index 3afe8bc9..0b3f12cf 100644 --- a/tracker-pt/module/module.hpp +++ b/tracker-pt/module/module.hpp @@ -13,8 +13,8 @@ class OTR_GENERIC_EXPORT metadata_pt : public Metadata { Q_OBJECT - QString name(); - QIcon icon(); + QString name() override; + QIcon icon() override; }; } // ns pt_module diff --git a/tracker-pt/module/point_extractor.cpp b/tracker-pt/module/point_extractor.cpp index f8c37351..c0756a40 100644 --- a/tracker-pt/module/point_extractor.cpp +++ b/tracker-pt/module/point_extractor.cpp @@ -30,7 +30,6 @@ #include using namespace types; -using namespace pt_module; // meanshift code written by Michael Welter @@ -84,6 +83,8 @@ static cv::Vec2d MeanShiftIteration(const cv::Mat &frame_gray, const vec2 &curre return current_center; } +namespace pt_module { + PointExtractor::PointExtractor(const QString& module_name) : s(module_name) { blobs.reserve(max_blobs); @@ -352,7 +353,9 @@ end: const f overlay_size = dpi > 1.5 ? 2 : 1; - cv::circle(preview_frame, p, iround((b.radius + 3.3) * c_ * c_fract), circle_color, overlay_size, cv::LINE_AA, fract_bits); + cv::circle(preview_frame, p, iround((b.radius + 3.3) * c_ * c_fract), + circle_color, (int)overlay_size, + cv::LINE_AA, fract_bits); char buf[16]; buf[sizeof(buf)-1] = '\0'; @@ -387,3 +390,5 @@ blob::blob(f radius, const vec2& pos, f brightness, const cv::Rect& rect) : { //qDebug() << "radius" << radius << "pos" << pos[0] << pos[1]; } + +} // ns pt_module diff --git a/tracker-pt/pt-api.hpp b/tracker-pt/pt-api.hpp index 6c36ebaf..300e4558 100644 --- a/tracker-pt/pt-api.hpp +++ b/tracker-pt/pt-api.hpp @@ -13,6 +13,11 @@ #include +#ifdef __clang__ +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wweak-vtables" +#endif + struct pt_camera_info final { using f = types::f; @@ -107,3 +112,7 @@ struct pt_runtime_traits template using pt_pointer = typename pt_runtime_traits::pointer; + +#ifdef __clang__ +# pragma clang diagnostic pop +#endif diff --git a/tracker-pt/pt-settings.hpp b/tracker-pt/pt-settings.hpp index 088dfe5a..2027302b 100644 --- a/tracker-pt/pt-settings.hpp +++ b/tracker-pt/pt-settings.hpp @@ -19,6 +19,11 @@ namespace pt_settings_detail { using namespace options; +#ifdef __clang__ +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wweak-vtables" +#endif + struct pt_settings final : options::opts { using slider_value = options::slider_value; @@ -57,9 +62,13 @@ struct pt_settings final : options::opts value threshold_slider { b, "threshold-slider", { 128, 0, 255 } }; explicit pt_settings(const QString& name) : opts(name) {} - ~pt_settings() = default; + ~pt_settings() override = default; }; +#ifdef __clang__ +# pragma clang diagnostic pop +#endif + } // ns pt_settings_detail using pt_settings = pt_settings_detail::pt_settings; -- cgit v1.2.3