根据cv :: Mat的文档,cv::Mat有一个带CvMat *参数和operator CvMat()成员函数的构造函数.因此,可以如下轻松地在两者之间进行复制.
cv::Mat m;
// populate m
CvMat n = m; // cv::Mat::operator CvMat() const;
m = cv::Mat(&n); // cv::Mat::Mat(const CvMat* m, bool copyData = false);
// or
m = cv::Mat(&n, true); // to copy the data
Run Code Online (Sandbox Code Playgroud)