]> rtime.felk.cvut.cz Git - hercules2020/kcf.git/commitdiff
Do not use virtual methods in FFT class
authorMichal Sojka <michal.sojka@cvut.cz>
Sat, 1 Dec 2018 23:02:58 +0000 (00:02 +0100)
committerMichal Sojka <michal.sojka@cvut.cz>
Sat, 1 Dec 2018 23:03:00 +0000 (00:03 +0100)
This will become useful in next commit, where we will try to make
ComplexMat sizes constexpr. ComplexMat will become a template class
and therefore Fft classes will need to have template methods. Since it
is not possible to have virtual template methods, we are removing
virtual methods here.

src/fft.cpp
src/fft.h
src/fft_cufft.h
src/fft_fftw.h
src/fft_opencv.h
src/kcf.cpp
src/kcf.h

index 1fe90d05c4bd0273151ebad1030237375cd1bab6..e6be093194333041eb0778fb89c357ea2d7376c9 100644 (file)
@@ -3,11 +3,6 @@
 #include <cassert>
 #include "debug.h"
 
-Fft::~Fft()
-{
-
-}
-
 void Fft::init(unsigned width, unsigned height, unsigned num_of_feats, unsigned num_of_scales)
 {
     m_width = width;
index f242a265d925df7040ec375bc750e440878a0654..9f74de387fc6ff6e3d263bf2e305bbe0a0fa86d0 100644 (file)
--- a/src/fft.h
+++ b/src/fft.h
 class Fft
 {
 public:
-    virtual void init(unsigned width, unsigned height, unsigned num_of_feats, unsigned num_of_scales);
-    virtual void set_window(const MatDynMem &window);
-    virtual void forward(const MatScales &real_input, ComplexMat &complex_result);
-    virtual void forward_window(MatScaleFeats &patch_feats_in, ComplexMat &complex_result, MatScaleFeats &tmp);
-    virtual void inverse(ComplexMat &complex_input, MatScales &real_result);
-    virtual ~Fft() = 0;
+    void init(unsigned width, unsigned height, unsigned num_of_feats, unsigned num_of_scales);
+    void set_window(const MatDynMem &window);
+    void forward(const MatScales &real_input, ComplexMat &complex_result);
+    void forward_window(MatScaleFeats &patch_feats_in, ComplexMat &complex_result, MatScaleFeats &tmp);
+    void inverse(ComplexMat &complex_input, MatScales &real_result);
 
     static cv::Size freq_size(cv::Size space_size)
     {
index 9a927aa3a40c204c8aa947a54012e182200d3f92..4241c0664f7cbe86bf4a836e305a92250110b34f 100644 (file)
@@ -15,12 +15,12 @@ class cuFFT : public Fft
 {
 public:
     cuFFT();
-    void init(unsigned width, unsigned height, unsigned num_of_feats, unsigned num_of_scales) override;
-    void set_window(const MatDynMem &window) override;
-    void forward(const MatScales &real_input, ComplexMat &complex_result) override;
-    void forward_window(MatScaleFeats &patch_feats_in, ComplexMat &complex_result, MatScaleFeats &tmp) override;
-    void inverse(ComplexMat &complex_input, MatScales &real_result) override;
-    ~cuFFT() override;
+    void init(unsigned width, unsigned height, unsigned num_of_feats, unsigned num_of_scales);
+    void set_window(const MatDynMem &window);
+    void forward(const MatScales &real_input, ComplexMat &complex_result);
+    void forward_window(MatScaleFeats &patch_feats_in, ComplexMat &complex_result, MatScaleFeats &tmp);
+    void inverse(ComplexMat &complex_input, MatScales &real_result);
+    ~cuFFT();
 
 protected:
     cufftHandle create_plan_fwd(uint howmany) const;
index 7274f514c80a0c3e725ce9ca1b12e3a6a8eccf88..1137c6f98e0086b2a01edadcb31693b995c41243 100644 (file)
@@ -13,12 +13,12 @@ class Fftw : public Fft
 {
   public:
     Fftw();
-    void init(unsigned width, unsigned height, unsigned num_of_feats, unsigned num_of_scales) override;
-    void set_window(const MatDynMem &window) override;
-    void forward(const MatScales &real_input, ComplexMat &complex_result) override;
-    void forward_window(MatScaleFeats &patch_feats_in, ComplexMat &complex_result, MatScaleFeats &tmp) override;
-    void inverse(ComplexMat &complex_input, MatScales &real_result) override;
-    ~Fftw() override;
+    void init(unsigned width, unsigned height, unsigned num_of_feats, unsigned num_of_scales);
+    void set_window(const MatDynMem &window);
+    void forward(const MatScales &real_input, ComplexMat &complex_result);
+    void forward_window(MatScaleFeats &patch_feats_in, ComplexMat &complex_result, MatScaleFeats &tmp);
+    void inverse(ComplexMat &complex_input, MatScales &real_result);
+    ~Fftw();
 
 protected:
     fftwf_plan create_plan_fwd(uint howmany) const;
index 23711968419b896e12d46300c05a79f6478bdf09..032989b422b0148b47464b6db53f5b3de5783e6d 100644 (file)
@@ -7,12 +7,12 @@
 class FftOpencv : public Fft
 {
 public:
-    void init(unsigned width, unsigned height, unsigned num_of_feats, unsigned num_of_scales) override;
-    void set_window(const MatDynMem &window) override;
-    void forward(const MatScales &real_input, ComplexMat &complex_result) override;
-    void forward_window(MatScaleFeats &patch_feats_in, ComplexMat &complex_result, MatScaleFeats &tmp) override;
-    void inverse(ComplexMat &complex_input, MatScales &real_result) override;
-    ~FftOpencv() override;
+    void init(unsigned width, unsigned height, unsigned num_of_feats, unsigned num_of_scales);
+    void set_window(const MatDynMem &window);
+    void forward(const MatScales &real_input, ComplexMat &complex_result);
+    void forward_window(MatScaleFeats &patch_feats_in, ComplexMat &complex_result, MatScaleFeats &tmp);
+    void inverse(ComplexMat &complex_input, MatScales &real_result);
+    ~FftOpencv();
 private:
     cv::Mat m_window;
 };
index 9950c8901634fc5da56029a0ca53d0be4451db97..bbaddddf3576e49b4bbd713fc3444dedd79b1ff5 100644 (file)
@@ -6,17 +6,6 @@
 #include "debug.h"
 #include <limits>
 
-#ifdef FFTW
-#include "fft_fftw.h"
-#define FFT Fftw
-#elif defined(CUFFT)
-#include "fft_cufft.h"
-#define FFT cuFFT
-#else
-#include "fft_opencv.h"
-#define FFT FftOpencv
-#endif
-
 #ifdef OPENMP
 #include <omp.h>
 #endif // OPENMP
index 02fe814f816d299babb5f8007417630b047c4017..ff322e8373bc367da2da0211e635b056aed6f76a 100644 (file)
--- a/src/kcf.h
+++ b/src/kcf.h
 #endif
 
 #include "cnfeat.hpp"
-#include "fft.h"
+#ifdef FFTW
+#include "fft_fftw.h"
+#define FFT Fftw
+#elif defined(CUFFT)
+#include "fft_cufft.h"
+#define FFT cuFFT
+#else
+#include "fft_opencv.h"
+#define FFT FftOpencv
+#endif
 #include "pragmas.h"
 
 class Kcf_Tracker_Private;
@@ -79,7 +88,7 @@ public:
     double getFilterResponse() const; // Measure of tracking accuracy
 
 private:
-    Fft &fft;
+    FFT &fft;
 
     // Initial pose of tracked object in internal image coordinates
     // (scaled by p_downscale_factor if p_resize_image)