I'm dealing with some code in which a do a lot of 3x3 matrix multiplications an also some translation of 3d points using rotation matrices, etc. I decided to use OpenCV core functionalities for the mathematical operations. The possibility to use the recent constructor added to the cv::Mat
class to convert a cv::Point3d
directly to a 3x1 cv::Mat
reduces and simplifies the code greatly.
What I am wondering now is if there is a simple way to convert a 3x1 or 1x3 cv::Mat
to an cv::Point3d
? I always can do something like:
cv::Mat mat(3,1,CV_64FC1);
cv::Point3d p (mat.at<double>(0,0), mat.at<double>(1,0), mat.at<double>(2,0));
or
cv::Mat mat(3,1,CV_64FC1);
const double *data = mat.ptr<double>(0);
cv::Point3d p (data[0], data[1], data[2]);
I am very worried about the performance (avoid the 3 calls to at
method).