convert arm_compute::Image to cv::Mat

2019-05-25 10:58发布

I have a lot of code that is based on open cv but there are many ways in which the Arm Compute library improves performance, so id like to integrate some arm compute library code into my project. Has anyone tried converting between the two corresponding Image structures? If so, what did you do? Or is there a way to share a pointer to the underlying data buffer without needing to copy image data and just set strides and flags appropriately?

2条回答
爷的心禁止访问
2楼-- · 2019-05-25 11:16

I was able to configure an arm_compute::Image corresponding to my cv::Mat properties, allocate the memory, and point it to the data portion of my cv:Mat.

This way, I can process my image efficiently using arm_compute and maintain the opencv infrastructure I had for the rest of my project.

// cv::Mat mat defined and initialized above
arm_compute::Image image;

image.allocator()->init(arm_compute::TensorInfo(mat.cols, mat.rows, Format::U8));
image.allocator()->allocate();
image.allocator()->import_memory(Memory(mat.data));
查看更多
我想做一个坏孩纸
3楼-- · 2019-05-25 11:35

Update for ACL 18.05 or newer

You need to implement IMemoryRegion.h

I have created a gist for that: link

查看更多
登录 后发表回答