Merge contour from vector<Points>
I would like to form an external contour from different vector points. The individual contours are continuous and contain curved lines (1 pixel wide). The merged contour should connect the lines like as marked in red in the image below
=>
I would transfer the single points into a total vector. How can i determine the order I have to follow? I suppose every single contour must be ordered clockwise?
//xPts = vector<vector<int>> containing all x-Values of contour
int cntContours = xPts.size();
std::vector<cv::Point> contourMerged;
for (int cn = 0; cn < cntContours; cn++)
{
vector<double> xTmp = xPts[cn];
vector<double> yTmp = yPts[cn];
for (int pn = 0; pn < xTmp.size(); pn++)
{
cv::Point tmp;
int xt = (int)xTmp[pn];
int yt = (int)yTmp[pn];
tmp.x = xt;
tmp.y = yt;
contourMerged.push_back(tmp);
}
}
// close contour
contourMerged.push_back(contourMerged[0]);
Thank you!