将 arm_compute::Image 转换为 cv::Mat [英] convert arm_compute::Image to cv::Mat

查看:36
本文介绍了将 arm_compute::Image 转换为 cv::Mat的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有很多基于open cv的代码,但是Arm Compute库提高性能的方式有很多,所以我喜欢将一些arm计算库代码集成到我的项目中.有没有人试过在两个对应的 Image 结构之间进行转换?如果是这样,你做了什么?或者有没有办法共享指向底层数据缓冲区的指针,而无需复制图像数据,只需适当设置步幅和标志?

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?

推荐答案

我能够配置一个 arm_compute::Image 对应于我的 cv::Mat 属性,分配内存,并将其指向我的 cv 的数据部分:垫.

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.

通过这种方式,我可以使用 arm_compute 有效地处理我的图像,并维护我用于项目其余部分的 opencv 基础架构.

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

这篇关于将 arm_compute::Image 转换为 cv::Mat的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆