Created
October 8, 2018 13:36
-
-
Save krjw/246d6022fe78deda79a9b4473b7dc795 to your computer and use it in GitHub Desktop.
Implementation of the IMemoryRegion of the arm compute library to import opencv data
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <arm_compute/runtime/IMemoryRegion.h> | |
class cvMatData : public arm_compute::IMemoryRegion | |
{ | |
public: | |
cvMatData(std::shared_ptr<uint8_t> memory) | |
: arm_compute::IMemoryRegion(sizeof(memory)) | |
, _memory(nullptr) | |
, _memory_owned(std::move(memory)) | |
{ | |
} | |
cvMatData(uint8_t *memory) | |
: arm_compute::IMemoryRegion(sizeof(memory)) | |
, _memory(memory) | |
, _memory_owned(nullptr) | |
{ | |
} | |
void *buffer() override | |
{ | |
return _memory; | |
} | |
void *buffer() const override | |
{ | |
return _memory; | |
} | |
void **handle() override | |
{ | |
return (void**)&_memory; | |
} | |
private: | |
uint8_t *_memory; | |
std::shared_ptr<uint8_t> _memory_owned; | |
}; | |
/* | |
Usage: | |
arm_compute::Image imageACL; | |
imageACL.allocator()->init(arm_compute::TensorInfo(imageCV.cols, imageCV.rows, arm_compute::Format::U8)); | |
imageACL.allocator()->import_memory(arm_compute::Memory(new cvMatData(imageCV.data))); | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment