GpuRgbMemory.hpp
835 Bytes
#include<string>
#include "../interface/DeviceRgbMemory.hpp"
#include "cuda_kernels.h"
#include "define.hpp"
#include "common_header.h"
using namespace std;
class GpuRgbMemory : public DeviceRgbMemory{
public:
GpuRgbMemory(int _channel, int _width, int _height, string _id, string _gpuid, bool _key_frame, bool _isused)
:DeviceRgbMemory(_channel, _width, _height, _id, _gpuid, _key_frame, _isused){
gpuid = _gpuid;
cudaSetDevice(atoi(gpuid.c_str()));
CHECK_CUDA(cudaMalloc((void **)&pHwRgb, data_size * sizeof(unsigned char)));
}
~GpuRgbMemory(){
if (pHwRgb) {
cudaSetDevice(atoi(gpuid.c_str()));
CHECK_CUDA(cudaFree(pHwRgb));
pHwRgb = nullptr;
}
}
string getGpuId() {
return gpuid;
}
private:
string gpuid;
};