Copy data from cv::Mat to CvMat and viceversa
c++, opencv
Solution
According to the documentation for cv::Mat, `cv::Mat` has a constructor that takes a `CvMat *` argument and an `operator CvMat()` member function. 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
Problem
how can i copy data from cv::Mat to CvMat and viceversa in OpenCV?