convert arm_compute::Image to cv::Mat

二次信任 提交于 2019-12-13 12:35:22

问题


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?


回答1:


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));



回答2:


Update for ACL 18.05 or newer

You need to implement IMemoryRegion.h

I have created a gist for that: link



来源:https://stackoverflow.com/questions/49060558/convert-arm-computeimage-to-cvmat

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!