From 87b7b7429bc2d4e7bf7aa278b2a6e5c6afc08d45 Mon Sep 17 00:00:00 2001 From: Michal Sojka Date: Sun, 2 Dec 2018 00:02:58 +0100 Subject: [PATCH] Do not use virtual methods in FFT class 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 | 5 ----- src/fft.h | 11 +++++------ src/fft_cufft.h | 12 ++++++------ src/fft_fftw.h | 12 ++++++------ src/fft_opencv.h | 12 ++++++------ src/kcf.cpp | 11 ----------- src/kcf.h | 13 +++++++++++-- 7 files changed, 34 insertions(+), 42 deletions(-) diff --git a/src/fft.cpp b/src/fft.cpp index 1fe90d0..e6be093 100644 --- a/src/fft.cpp +++ b/src/fft.cpp @@ -3,11 +3,6 @@ #include #include "debug.h" -Fft::~Fft() -{ - -} - void Fft::init(unsigned width, unsigned height, unsigned num_of_feats, unsigned num_of_scales) { m_width = width; diff --git a/src/fft.h b/src/fft.h index f242a26..9f74de3 100644 --- a/src/fft.h +++ b/src/fft.h @@ -18,12 +18,11 @@ 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) { diff --git a/src/fft_cufft.h b/src/fft_cufft.h index 9a927aa..4241c06 100644 --- a/src/fft_cufft.h +++ b/src/fft_cufft.h @@ -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; diff --git a/src/fft_fftw.h b/src/fft_fftw.h index 7274f51..1137c6f 100644 --- a/src/fft_fftw.h +++ b/src/fft_fftw.h @@ -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; diff --git a/src/fft_opencv.h b/src/fft_opencv.h index 2371196..032989b 100644 --- a/src/fft_opencv.h +++ b/src/fft_opencv.h @@ -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; }; diff --git a/src/kcf.cpp b/src/kcf.cpp index 9950c89..bbadddd 100644 --- a/src/kcf.cpp +++ b/src/kcf.cpp @@ -6,17 +6,6 @@ #include "debug.h" #include -#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 #endif // OPENMP diff --git a/src/kcf.h b/src/kcf.h index 02fe814..ff322e8 100644 --- a/src/kcf.h +++ b/src/kcf.h @@ -13,7 +13,16 @@ #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) -- 2.39.2