Shazia Akbar
View Shazia Akbar's Github repositories View Shazia Akbar's profile on LinkedIn View Shazia Akbar's Google Scholar page

Converting between cv::Mat and CvMat

Conversion between cv::Mat and CvMat in OpenCV can be achieved by simply casting or making a deep copy of the matrix.

cv::Mat originalMat = cv::imread("image.jpg"); //read image
CvMat newMat = originalMat; //pointer to original mat

originalMat = cv::Mat(&newMat); //cv::Mat::Mat(const CvMat* m, bool copyData = false);
originalMat = cv::Mat(&newMat, true); //deep copy

Comments are closed