Ask Your Question

Revision history [back]

cvarrToMat Converts CvMat, IplImage , or CvMatND to Mat.

CvMat* A = cvCreateMat(10, 10, CV_32F);
cvSetIdentity(A);
IplImage A1; cvGetImage(A, &A1);
Mat B = cvarrToMat(A);
Mat B1 = cvarrToMat(&A1);
IplImage C = B;
CvMat C1 = B1;
// 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));

cvarrToMat Converts CvMat, IplImage , or CvMatND to Mat.

CvMat* A = cvCreateMat(10, 10, CV_32F);
cvSetIdentity(A);
IplImage A1; cvGetImage(A, &A1);
Mat B = cvarrToMat(A);
Mat B1 = cvarrToMat(&A1);
IplImage C = B;
CvMat C1 = B1;
// 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));

https://github.com/Itseez/opencv/blob/master/samples/cpp/image.cpp

cvarrToMat Converts CvMat, IplImage , or CvMatND to Mat.

Fixed the conversions using new syntax.

CvMat* A = cvCreateMat(10, 10, CV_32F);
cvSetIdentity(A);
IplImage A1; A1;
cvGetImage(A, &A1);
Mat B = cvarrToMat(A);
(A);
Mat B1 = cvarrToMat(&A1);
(A1);
IplImage C = B;
B.operator IplImage();
CvMat C1 = B1;
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));

https://github.com/Itseez/opencv/blob/master/samples/cpp/image.cpp