Ask Your Question

conversion between CvMat* and cv::Mat

asked 2015-06-30 07:38:18 -0500

sasmn gravatar image

how can I convert CvMat* to cv::Mat ?

edit retag flag offensive close merge delete


I would suggest not using CvMat... Where do you need it?

thdrksdfthmn gravatar imagethdrksdfthmn ( 2015-06-30 09:02:57 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2015-06-30 08:28:32 -0500

updated 2015-06-30 19:38:44 -0500

unxnut gravatar image

cvarrToMat Converts CvMat, IplImage , or CvMatND to Mat.

Fixed the conversions using new syntax.

CvMat* A = cvCreateMat(10, 10, CV_32F);
IplImage A1;
cvGetImage(A, &A1);
Mat B (A);
Mat B1 (A1);
IplImage C = B.operator IplImage();
CvMat C1 = B1.operator CvMat();
// now A, A1, B, B1, C and C1 are different headers
// for the same 10x10 floating-point array.
// note that you will need to use "&"
// to pass C & C1 to OpenCV functions, for example:
printf("%g\n", cvNorm(&C1, 0, CV_L2));

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower


Asked: 2015-06-30 07:38:18 -0500

Seen: 2,758 times

Last updated: Jun 30 '15