[英]Copy data from cv::Mat to CvMat and viceversa
如何在OpenCV中将数据从cv :: Mat复制到CvMat,反之亦然?
According to the documentation for cv::Mat , cv::Mat
has a constructor that takes a CvMat *
argument and an operator CvMat()
member function. 根据cv :: Mat的文档 , cv::Mat
具有一个构造函数,该构造函数带有CvMat *
参数和一个operator CvMat()
成员函数。 Therefore copying between the two can be accomplished easily as follows. 因此,可以如下轻松地完成两者之间的复制。
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
According to opencv documentation ( http://docs.opencv.org/2.4/modules/core/doc/basic_structures.html ): 根据opencv文档( http://docs.opencv.org/2.4/modules/core/doc/basic_structures.html ):
"Backward conversion from Mat to CvMat or IplImage is provided via cast operators Mat::operator CvMat() const and Mat::operator IplImage(). The operators do NOT copy the data." “通过强制转换运算符Mat :: operator CvMat()const和Mat :: operator IplImage()提供了从Mat到CvMat或IplImage的向后转换。这些运算符不会复制数据。”
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.