Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

What is the difference between pointer access of cv::Mat and CvMat?

Hello!

I have a question regarding a certain difference between CvMat and cv::Mat. I am aware that cv::Mat is the C++ "version" of CvMat and they should work identically. But I encountered a problem two days ago, which cannot get my head around: In an OpenCv source code I found the following line of code, which I would like to reuse for my own project:

cv::Ptr<cvmat> err = cvCreateMat(1, count, CV_32FC1); ...
double median = count % 2 != 0 ?
err->data.fl[count / 2] : (err->data.fl[count / 2 - 1] + err->data.fl[count / 2])*0.5;

Since the old C API is declared as deprecated in the documentary I would like to update it the new C++ API. Unfortunately I have not found a way to implement this. I tried:

cv::Mat err(1, count, CV_32FC1);
double median = count % 2 != 0 ?
err.data[count / 2] : (err.data[count / 2 - 1] + err.data[count / 2])*0.5;

As far as I understand the documentation of both types, they should be equal but unfortunately both ways yield different results. Did I overlook something?

Thanks in advance!

What is the difference between pointer access of cv::Mat and CvMat?

Hello!

I have a question regarding a certain difference between CvMat and cv::Mat. I am aware that cv::Mat is the C++ "version" of CvMat and they should work identically. But I encountered a problem two days ago, which I cannot get get my head around: In an OpenCv source code I found the following line of code, which I would like to reuse for my own project:

cv::Ptr<cvmat> err = cvCreateMat(1, count, CV_32FC1); ...
double median = count % 2 != 0 ?
err->data.fl[count / 2] : (err->data.fl[count / 2 - 1] + err->data.fl[count / 2])*0.5;

Since the old C API is declared as deprecated in the documentary I would like to update it the new C++ API. Unfortunately I have not found a way to implement this. I tried:

cv::Mat err(1, count, CV_32FC1);
double median = count % 2 != 0 ?
err.data[count / 2] : (err.data[count / 2 - 1] + err.data[count / 2])*0.5;

As far as I understand the documentation of both types, they should be equal but unfortunately both ways yield different results. Did I overlook something?

Thanks in advance!

What is the difference between pointer access of cv::Mat and CvMat?

Hello!

I have a question regarding a certain difference between CvMat and cv::Mat. I am aware that cv::Mat is the C++ "version" of CvMat and they should work identically. But I encountered a problem two days ago, which I cannot get my head around: In an OpenCv source code I found the following line of code, which I would like to reuse for my own project:

cv::Ptr<cvmat> err = cvCreateMat(1, count, CV_32FC1); ...
double median = count % 2 != 0 ?
err->data.fl[count / 2] : (err->data.fl[count / 2 - 1] + err->data.fl[count / 2])*0.5;

Since the old C API is declared as deprecated in the documentary I would like to update it the new C++ API. Unfortunately I have not found a way to implement this. I tried:

cv::Mat err(1, count, CV_32FC1);
double median = count % 2 != 0 ?
err.data[count / 2] : (err.data[count / 2 - 1] + err.data[count / 2])*0.5;

As far as I understand the documentation of both types, they should be equal but unfortunately both ways yield different results. Did I overlook something?

Thanks in advance!

What is the difference between pointer access of cv::Mat and CvMat?

Hello!

I have a question regarding a certain difference between CvMat and cv::Mat. I am aware that cv::Mat is the C++ "version" of CvMat and they should work identically. But I encountered a problem two days ago, which I cannot get my head around: In an OpenCv source code I found the following line of code, which I would like to reuse for my own project:

cv::Ptr<cvmat> err = cvCreateMat(1, count, CV_32FC1); ...
double median = count % 2 != 0 ?
err->data.fl[count / 2] : (err->data.fl[count / 2 - 1] + err->data.fl[count / 2])*0.5;

Since the old C API is declared as deprecated in the documentary I would like to update it to the new C++ API. Unfortunately I have not found a way to implement this. I tried:

cv::Mat err(1, count, CV_32FC1);
double median = count % 2 != 0 ?
err.data[count / 2] : (err.data[count / 2 - 1] + err.data[count / 2])*0.5;

As far as I understand the documentation of both types, they should be equal but unfortunately both ways yield different results. Did I overlook something?

Thanks in advance!