Convert point vector to Mat
Hi, my objective is to obtain the right side of this image.
I thought I'd see the image as a polygon because I have the coordinates of the vertices, and then transform the vector that has the vertices in a matrix (cvMat).
My thought is correct or is there a simpler way to get this submatrix?
With the following code I can draw the polygon but I need to convert it to a matrix.
Point normImgTop, normImgEyebrowInner, normImgCNoseTip, normImgCNoseBase, normImgTipOfChin, normImgTopLip, normImgDownLip, normImgBottom, normImgTopRight, normImgBottomRight;
(...)
std::vector<Point> contour;
Mat roi(poseNormImg.rows, poseNormImg.cols, CV_8UC1);
contour.push_back(normImgTop);
contour.push_back(normImgEyebrowInner);
contour.push_back(normImgCNoseTip);
contour.push_back(normImgCNoseBase);
contour.push_back(normImgTopLip);
contour.push_back(normImgDownLip);
contour.push_back(normImgTipOfChin);
contour.push_back(normImgBottom);
contour.push_back(normImgBottomRight);
contour.push_back(normImgTopRight);
const cv::Point *pts = (const cv::Point*) Mat(contour).data;
int npts = Mat(contour).rows;
std::cout << "Number of polygon vertices: " << npts << std::endl;
// draw the polygon
polylines(roi, &pts,&npts, 1,
true, // draw closed contour (i.e. joint end to start)
Scalar(0,255,0),// colour RGB ordering (here = green)
3, // line thickness
CV_AA, 0);
I'm using OpenCV 2.4.6.1 and C++.
Thank you
hmm, the error seems to come from cvConvertImage, you don't show enough code ?
Hi, thank you for your answer. I rephrased my question and added some code.