Looks deceptively. In the end, we know that the std or openCV vector can be easily transformed into a matrix as follows:
vector<Point> iptvec(10); Mat iP(iptvec);
The openCV cheatSheet suggests the opposite:
vector<Point2f> ptvec = Mat_ <Point2f>(iP);
However, there is one caveat: the matrix should have only one row or one column. To convert an arbitrary matrix, you must change:
int sz = iP.cols*iP.rows; vector<Point2f> ptvec = Mat <Point2f>(iP.reshape(1, sz));
Otherwise, you will receive an error message:
* OpenCV error: statement failed (dims == 2 && (sizes [0] == 1 || sizes [1] == 1 || sizes [0] * sizes [1] == 0)) in the create / file file / home /.../ OpenCV-2.4.2 / modules / core / src / matrix.cpp, line 1385 ...
source share