]> rtime.felk.cvut.cz Git - hercules2020/kcf.git/blobdiff - src/complexmat.cuh
complexmat.cu: Remove unused member foreign_data
[hercules2020/kcf.git] / src / complexmat.cuh
index 7f19771203e199b63941d73858f9ea5dd1926b80..cf2e6ca2f0f3a89b74789932e47f13a267b41000 100644 (file)
@@ -7,7 +7,7 @@
 #include "cuda_runtime.h"
 #include "cufft.h"
 
-#include "cuda/cuda_error_check.cuh"
+#include "cuda_error_check.hpp"
 
 class ComplexMat {
   public:
@@ -15,18 +15,17 @@ class ComplexMat {
     uint rows;
     uint n_channels;
     uint n_scales = 1;
-    bool foreign_data = false;
-    cudaStream_t stream = nullptr;
 
     ComplexMat() : cols(0), rows(0), n_channels(0) {}
-    ComplexMat(uint _rows, uint _cols, uint _n_channels, cudaStream_t _stream)
-        : cols(_cols), rows(_rows), n_channels(_n_channels), stream(_stream)
+
+    ComplexMat(uint _rows, uint _cols, uint _n_channels, uint _n_scales = 1)
+        : cols(_cols), rows(_rows), n_channels(_n_channels * _n_scales), n_scales(_n_scales)
     {
         CudaSafeCall(cudaMalloc(&p_data, n_channels * cols * rows * sizeof(cufftComplex)));
     }
 
-    ComplexMat(uint _rows, uint _cols, uint _n_channels, uint _n_scales, cudaStream_t _stream)
-        : cols(_cols), rows(_rows), n_channels(_n_channels), n_scales(_n_scales), stream(_stream)
+    ComplexMat(cv::Size size, uint _n_channels, uint _n_scales = 1)
+        : cols(size.width), rows(size.height), n_channels(_n_channels * _n_channels), n_scales(_n_scales)
     {
         CudaSafeCall(cudaMalloc(&p_data, n_channels * cols * rows * sizeof(cufftComplex)));
     }
@@ -38,47 +37,37 @@ class ComplexMat {
         n_channels = other.n_channels;
         n_scales = other.n_scales;
         p_data = other.p_data;
-        stream = other.stream;
 
         other.p_data = nullptr;
     }
 
     ~ComplexMat()
     {
-        if (p_data != nullptr && !foreign_data) {
+        if (p_data != nullptr) {
             CudaSafeCall(cudaFree(p_data));
             p_data = nullptr;
         }
     }
 
-    void create(uint _rows, uint _cols, uint _n_channels, cudaStream_t _stream = nullptr)
+    void create(uint _rows, uint _cols, uint _n_channels)
     {
         rows = _rows;
         cols = _cols;
         n_channels = _n_channels;
-        stream = _stream;
         CudaSafeCall(cudaMalloc(&p_data, n_channels * cols * rows * sizeof(cufftComplex)));
     }
 
-    void create(uint _rows, uint _cols, uint _n_channels, uint _n_scales, cudaStream_t _stream = nullptr)
+    void create(uint _rows, uint _cols, uint _n_channels, uint _n_scales)
     {
         rows = _rows;
         cols = _cols;
         n_channels = _n_channels;
         n_scales = _n_scales;
-        stream = _stream;
         CudaSafeCall(cudaMalloc(&p_data, n_channels * cols * rows * sizeof(cufftComplex)));
     }
     // cv::Mat API compatibility
-    cv::Size size() { return cv::Size(cols, rows); }
-    int channels() { return n_channels; }
-    int channels() const { return n_channels; }
-
-    void set_stream(cudaStream_t _stream)
-    {
-        stream = _stream;
-        return;
-    }
+    cv::Size size() const { return cv::Size(cols, rows); }
+    uint channels() const { return n_channels; }
 
     void sqr_norm(DynMem &result) const;