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!
you probably should discard the whole "per-pixel" approach as well.
what is the context ? what are you trying to achieve ?