Ask Your Question
1

conversion between CvMat* and cv::Mat

asked Jun 30 '15

sasmn gravatar image

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

Preview: (hide)

Comments

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

thdrksdfthmn gravatar imagethdrksdfthmn (Jun 30 '15)edit

1 answer

Sort by » oldest newest most voted
4

answered Jun 30 '15

updated Jul 1 '15

unxnut gravatar image

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;
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));

https://github.com/Itseez/opencv/blob...

Preview: (hide)

Question Tools

1 follower

Stats

Asked: Jun 30 '15

Seen: 3,848 times

Last updated: Jun 30 '15