其中cv::Mat是显式定义的构造函数

Where are cv::Mat constructors explicitly defined?

本文关键字:定义 构造函数 cv Mat 其中      更新时间:2023-10-16

[1]在哪里cv::Mat数据结构构造函数明确(在C/c++)定义在OpenCV源代码?

我假设cv::Mat数据结构是动态分配给堆的,当像

这样的东西

cv::Mat mat(rows, cols, type);

调用

,但在

中找不到ANSI C或c++实现。

opencv / modules / core / src / matrix.cpp nor in

opencv / modules / core / src / datastructs.cpp .

SOLVED: cv::Mat在matrix.cpp中分配了一个fastMalloc()。这是在cv::Mat:create()函数中执行的。

[2]此外,我很想知道当执行图像处理操作时,cv::Mat将位于硬件中的哪个位置:

。总是在'主存' (SDRAM),

。总是在片上缓存(SRAM)中,

。或者两者的结合?

cv::Mat Mat (rows, cols, type);

这是内联构造函数,它在core/mat.hpp中实现:

inline Mat::Mat(int _rows, int _cols, int _type) : size(&rows)
{
    initEmpty();
    create(_rows, _cols, _type);
}

实际的构造函数在

…/core/core.hpp

class CV_EXPORTS Mat
{
public:
    //! default constructor
    Mat();
    //! constructs 2D matrix of the specified size and type
    // (_type is CV_8UC1, CV_64FC3, CV_32SC(12) etc.)
    Mat(int rows, int cols, int type);
    Mat(Size size, int type);
    //! constucts 2D matrix and fills it with the specified value _s.
    Mat(int rows, int cols, int type, const Scalar& s);
    Mat(Size size, int type, const Scalar& s);
    //! constructs n-dimensional matrix
    Mat(int ndims, const int* sizes, int type);
    Mat(int ndims, const int* sizes, int type, const Scalar& s);
    //! copy constructor
    Mat(const Mat& m);
    //! constructor for matrix headers pointing to user-allocated data
    Mat(int rows, int cols, int type, void* data, size_t step=AUTO_STEP);
    Mat(Size size, int type, void* data, size_t step=AUTO_STEP);
    Mat(int ndims, const int* sizes, int type, void* data, const size_t* steps=0);
 .....
};