forked from Smorodov/Multitarget-tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgpu_allocator.h
More file actions
44 lines (34 loc) · 835 Bytes
/
gpu_allocator.h
File metadata and controls
44 lines (34 loc) · 835 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#ifndef GPU_ALLOCATOR_H
#define GPU_ALLOCATOR_H
#include <cuda_runtime.h>
#include <opencv2/core/core.hpp>
#include <opencv2/core/cuda.hpp>
using GpuMat = cv::cuda::GpuMat;
using namespace cv;
/**
* A simple linear allocator class to allocate storage for cv::GpuMat objects.
* This feature was added in OpenCV 3.0.
*/
class GPUAllocator : public GpuMat::Allocator
{
public:
GPUAllocator(size_t size);
~GPUAllocator();
void reset();
public:
/**
* @name GpuMat::Allocator interface
*/
///@{
bool allocate(GpuMat* mat, int rows, int cols, size_t elemSize);
void free(GpuMat* mat);
///@}
private:
cudaError_t grow(void** dev_ptr, size_t size);
private:
void* base_ptr_;
void* current_ptr_;
size_t total_size_;
size_t current_size_;
};
#endif // GPU_ALLOCATOR_H