2

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

我假设一个 cv::Mat 数据结构是动态分配给堆的,比如

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

被调用,但在

opencv / modules / core / src / matrix.cpp也不在

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

已解决:matrix.cppcv::Mat中分配了一个。这是在函数内执行的。fastMalloc()cv::Mat:create()

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

. 始终在“主存储器”(SDRAM)中,

. 始终在片上高速缓存 (SRAM) 中,

. 还是两者的某种组合?

4

2 回答 2

2

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);
}
于 2012-12-23T19:10:12.697 回答
1

实际的构造函数在

.../核心/核心.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);
 .....

};
于 2013-10-23T18:53:17.273 回答