将图像加载到现有Mat中 [英] Load image into existing Mat

查看:158
本文介绍了将图像加载到现有Mat中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法将图片加载到现有的Mat?如果没有,有没有办法控制OpenCV在下降cv :: imread时分配内存?

Is there a way to load an image into an existing Mat? If not, is there a way to control where OpenCV allocates memory when falling cv::imread?

推荐答案

你的类的构造函数接受imread的输入参数,并将图像直接加载(并分配)到你的类中。

I would simply make a constructor for your class that takes the input arguments of imread and loads (and allocates) the image directly into your class.

这样的东西:

class myClass {
private:
    Mat img;
public:
    myClass(const string fileName) {
        this->img = imread(fileName);
    }
}

这篇关于将图像加载到现有Mat中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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