如何在 Mat 中存储一维向量 <point2f> 以及如何在 Mat 中访问这些点?

how to store 1D vector<point2f> in Mat and how to access those points in Mat?

我有一个 point2f 的一维向量。我将这些点存储在大小为 6x6 的 2D Mat 中。现在如何获取这些积分?

感谢您的帮助:) 我现在整理了答案。

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) size 6x6 -> reshape-> do req changes or modification in the Mat -> 再次转换为 vectorx_output