MatManager.hpp
1011 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
/*
NOTES
Mat reservations should return a handle instead of a pointer
*/
#include <pthread.h>
#include <semaphore.h>
#include <opencv2/opencv.hpp>
#include <opencv2/gpu/gpu.hpp>
using namespace cv;
using namespace cv::gpu;
namespace br { namespace cuda {
class MatManager {
private:
int _numMats;
uint8_t** _mats; // holds all the mats
bool* _matTaken; // holds whether or not they are taken
int* _matsDimension; // holds the dimension of the Mats
pthread_mutex_t* _matTakenLock; // lock for matTaken table
pthread_mutex_t* _matsDimensionLock; // lock for _matsDimension table and _mats table
sem_t* _matSemaphore;
public:
typedef int matindex;
MatManager(int num);
int reserve(Mat &mat);
void upload(matindex reservedMatIndex, Mat& mat);
void download(matindex reservedMatIndex, Mat& dstMat);
void release(matindex matIndex);
uint8_t* get_mat_pointer_from_index(matindex matIndex);
~MatManager();
};
}}