Ask Your Question
1

conversion between CvMat* and cv::Mat

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

sasmn gravatar image

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

edit retag flag offensive close merge delete

Comments

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

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

1 answer

Sort by ยป oldest newest most voted
4

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

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

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...

edit flag offensive delete link more

Question Tools

1 follower

Stats

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

Seen: 3,795 times

Last updated: Jun 30 '15