我有一个point2f的一维向量。我将这些点存储在大小为6x6的2D Mat中。现在如何访问这些点?
答案 0 :(得分:0)
感谢您的帮助:)我现在对答案进行了排序。
vector<Point2f>centers(36); //I have 1D vector of points which is of size 36
Mat new_mat = Mat(centers).reshape(6, 6); //1d vector to 6x6matrix
**/*Actually the Point2f, when stored in Mat makes use of the channels for storing the float values*/**
Mat test = new_mat.reshape(2, 6);// this makes 6 channels into two rows
**/*My objective here is to transpose the vector which is now stored in Mat*/**
Mat q1 = test.t();//transposed 6 channel mat
vector<Point2f>x(q1.begin<Point2f>(), q1.end<Point2f>());//transposed vector
现在我们可以通过test.at(0,1)或相应地访问存储在Mat中的Point2f。
摘要: vectorx-> Mat(2D)尺寸6x6-> reshape->在Mat中进行必要的更改或修改->再次转换为vectorx_output