]> rtime.felk.cvut.cz Git - hercules2020/kcf.git/commitdiff
Make KCF member variables constexpr where possible
authorMichal Sojka <michal.sojka@cvut.cz>
Mon, 26 Nov 2018 21:31:28 +0000 (22:31 +0100)
committerMichal Sojka <michal.sojka@cvut.cz>
Mon, 26 Nov 2018 21:46:51 +0000 (22:46 +0100)
This is to prepare the code for constexprification need for PREMization :-)

src/kcf.cpp
src/kcf.h

index 399ef4ef2d572b8cbac5a464fe7d1a95f775a83d..9950c8901634fc5da56029a0ca53d0be4451db97 100644 (file)
@@ -211,9 +211,9 @@ void KCF_Tracker::init(cv::Mat &img, const cv::Rect &bbox, int fit_size_x, int f
 #ifndef BIG_BATCH
     for (auto scale: p_scales)
         for (auto angle : p_angles)
-            d->threadctxs.emplace_back(feature_size, p_num_of_feats, scale, angle);
+            d->threadctxs.emplace_back(feature_size, (int)p_num_of_feats, scale, angle);
 #else
-    d->threadctxs.emplace_back(feature_size, p_num_of_feats, p_scales, p_angles);
+    d->threadctxs.emplace_back(feature_size, (int)p_num_of_feats, p_scales, p_angles);
 #endif
 
     gaussian_correlation.reset(new GaussianCorrelation(1, p_num_of_feats, feature_size));
index 18f132d76215a9bf608ffe879b4d2a85b596d006..02fe814f816d299babb5f8007417630b047c4017 100644 (file)
--- a/src/kcf.h
+++ b/src/kcf.h
@@ -47,13 +47,13 @@ class KCF_Tracker
 public:
     bool m_debug {false};
     enum class vd {NONE, PATCH, RESPONSE} m_visual_debug {vd::NONE};
-    const bool m_use_scale {true};
-    const bool m_use_color {true};
-    const bool m_use_subpixel_localization {true};
-    const bool m_use_subgrid_scale {true};
-    const bool m_use_subgrid_angle {true};
-    const bool m_use_cnfeat {true};
-    const bool m_use_linearkernel {false};
+    constexpr static bool m_use_scale {true};
+    constexpr static bool m_use_color {true};
+    constexpr static bool m_use_subpixel_localization {true};
+    constexpr static bool m_use_subgrid_scale {true};
+    constexpr static bool m_use_subgrid_angle {true};
+    constexpr static bool m_use_cnfeat {true};
+    constexpr static bool m_use_linearkernel {false};
     const int p_cell_size = 4;            //4 for hog (= bin_size)
 
     /*
@@ -94,8 +94,8 @@ private:
 
     bool p_resize_image = false;
 
-    const double p_downscale_factor = 0.5;
-    const double p_floating_error = 0.0001;
+    constexpr static double p_downscale_factor = 0.5;
+    constexpr static double p_floating_error = 0.0001;
 
     const double p_padding = 1.5;
     const double p_output_sigma_factor = 0.1;
@@ -106,16 +106,16 @@ private:
     cv::Size p_windows_size;              // size of the patch to find the tracked object in
     cv::Size fit_size;                    // size to which rescale the patch for better FFT performance
 
-    const uint p_num_scales = m_use_scale ? 5 : 1;
-    const double p_scale_step = 1.03;
+    constexpr static uint p_num_scales = m_use_scale ? 5 : 1;
+    constexpr static double p_scale_step = 1.03;
     double p_min_max_scale[2];
     std::vector<double> p_scales;
 
-    const uint p_num_angles = 3;
-    const int p_angle_step = 10;
+    constexpr static uint p_num_angles = 3;
+    constexpr static int p_angle_step = 10;
     std::vector<double> p_angles;
 
-    const int p_num_of_feats = 31 + (m_use_color ? 3 : 0) + (m_use_cnfeat ? 10 : 0);
+    constexpr static int p_num_of_feats = 31 + (m_use_color ? 3 : 0) + (m_use_cnfeat ? 10 : 0);
     cv::Size feature_size;
 
     std::unique_ptr<Kcf_Tracker_Private> d;