How to get a matrix section in opencv
I have this matrix in openCV:
cv::Matx44d m;
and I want to get the top left 3x3 matrix from this matrix. What's the easiest and fastest way to do this?
I can do it in the following ways:
cv::Matx44d m;
cv::Matx33d o;
for(int i=0;i<3;i++)
{
for(int j=0;j<3;j++)
{
o(i,j)=m(i,j);
}
}
but I am looking for an easier and faster way if it exists!
+3
source to share
3 answers
Matx has a get_minor () function that does exactly what you want. I don't see it in the OpenCV documentation, but it is present inside the implementation. In your case, it would be:
o = m.get_minor<3,3>(0,0);
Template parameters <3,3> are the height and width of the small matrix. The value (0,0) is the starting point from which the matrix is ββclipped.
+6
source to share