|
|
|
@@ -384,15 +384,15 @@ void CirclesGridClusterFinder::rectifyPatternPoints(const std::vector<cv::Point2
|
|
|
|
|
{
|
|
|
|
|
//indices of corner points in pattern
|
|
|
|
|
std::vector<Point> trueIndices;
|
|
|
|
|
trueIndices.push_back(Point(0, 0));
|
|
|
|
|
trueIndices.push_back(Point(patternSize.width - 1, 0));
|
|
|
|
|
trueIndices.emplace_back(0, 0);
|
|
|
|
|
trueIndices.emplace_back(patternSize.width - 1, 0);
|
|
|
|
|
if(isAsymmetricGrid)
|
|
|
|
|
{
|
|
|
|
|
trueIndices.push_back(Point(patternSize.width - 1, 1));
|
|
|
|
|
trueIndices.push_back(Point(patternSize.width - 1, patternSize.height - 2));
|
|
|
|
|
trueIndices.emplace_back(patternSize.width - 1, 1);
|
|
|
|
|
trueIndices.emplace_back(patternSize.width - 1, patternSize.height - 2);
|
|
|
|
|
}
|
|
|
|
|
trueIndices.push_back(Point(patternSize.width - 1, patternSize.height - 1));
|
|
|
|
|
trueIndices.push_back(Point(0, patternSize.height - 1));
|
|
|
|
|
trueIndices.emplace_back(patternSize.width - 1, patternSize.height - 1);
|
|
|
|
|
trueIndices.emplace_back(0, patternSize.height - 1);
|
|
|
|
|
|
|
|
|
|
std::vector<Point2f> idealPoints;
|
|
|
|
|
for(size_t idx=0; idx<trueIndices.size(); idx++)
|
|
|
|
@@ -401,11 +401,11 @@ void CirclesGridClusterFinder::rectifyPatternPoints(const std::vector<cv::Point2
|
|
|
|
|
int j = trueIndices[idx].x;
|
|
|
|
|
if(isAsymmetricGrid)
|
|
|
|
|
{
|
|
|
|
|
idealPoints.push_back(Point2f((2*j + i % 2)*squareSize, i*squareSize));
|
|
|
|
|
idealPoints.emplace_back((2*j + i % 2)*squareSize, i*squareSize);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
idealPoints.push_back(Point2f(j*squareSize, i*squareSize));
|
|
|
|
|
idealPoints.emplace_back(j*squareSize, i*squareSize);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -477,7 +477,7 @@ void Graph::addVertex(size_t id)
|
|
|
|
|
{
|
|
|
|
|
CV_Assert( !doesVertexExist( id ) );
|
|
|
|
|
|
|
|
|
|
vertices.insert(std::pair<size_t, Vertex> (id, Vertex()));
|
|
|
|
|
vertices.emplace(id, Vertex());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Graph::addEdge(size_t id1, size_t id2)
|
|
|
|
@@ -887,10 +887,9 @@ Mat CirclesGridFinder::rectifyGrid(Size detectedGridSize, const std::vector<Poin
|
|
|
|
|
convertPointsFromHomogeneous(dstKeypointsMat, dstKeypoints);
|
|
|
|
|
|
|
|
|
|
warpedKeypoints.clear();
|
|
|
|
|
for (size_t i = 0; i < dstKeypoints.size(); i++)
|
|
|
|
|
for (auto &pt:dstKeypoints)
|
|
|
|
|
{
|
|
|
|
|
Point2f pt = dstKeypoints[i];
|
|
|
|
|
warpedKeypoints.push_back(pt);
|
|
|
|
|
warpedKeypoints.emplace_back(std::move(pt));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return H;
|
|
|
|
@@ -1526,35 +1525,35 @@ void CirclesGridFinder::getCornerSegments(const std::vector<std::vector<size_t>
|
|
|
|
|
|
|
|
|
|
//all 8 segments with one end in a corner
|
|
|
|
|
std::vector<Segment> corner;
|
|
|
|
|
corner.push_back(Segment(keypoints[points[1][0]], keypoints[points[0][0]]));
|
|
|
|
|
corner.push_back(Segment(keypoints[points[0][0]], keypoints[points[0][1]]));
|
|
|
|
|
corner.emplace_back(keypoints[points[1][0]], keypoints[points[0][0]]);
|
|
|
|
|
corner.emplace_back(keypoints[points[0][0]], keypoints[points[0][1]]);
|
|
|
|
|
segments.push_back(corner);
|
|
|
|
|
cornerIndices.push_back(Point(0, 0));
|
|
|
|
|
firstSteps.push_back(Point(1, 0));
|
|
|
|
|
secondSteps.push_back(Point(0, 1));
|
|
|
|
|
cornerIndices.emplace_back(0, 0);
|
|
|
|
|
firstSteps.emplace_back(1, 0);
|
|
|
|
|
secondSteps.emplace_back(0, 1);
|
|
|
|
|
corner.clear();
|
|
|
|
|
|
|
|
|
|
corner.push_back(Segment(keypoints[points[0][w - 2]], keypoints[points[0][w - 1]]));
|
|
|
|
|
corner.push_back(Segment(keypoints[points[0][w - 1]], keypoints[points[1][w - 1]]));
|
|
|
|
|
corner.emplace_back(keypoints[points[0][w - 2]], keypoints[points[0][w - 1]]);
|
|
|
|
|
corner.emplace_back(keypoints[points[0][w - 1]], keypoints[points[1][w - 1]]);
|
|
|
|
|
segments.push_back(corner);
|
|
|
|
|
cornerIndices.push_back(Point(w - 1, 0));
|
|
|
|
|
firstSteps.push_back(Point(0, 1));
|
|
|
|
|
secondSteps.push_back(Point(-1, 0));
|
|
|
|
|
cornerIndices.emplace_back(w - 1, 0);
|
|
|
|
|
firstSteps.emplace_back(0, 1);
|
|
|
|
|
secondSteps.emplace_back(-1, 0);
|
|
|
|
|
corner.clear();
|
|
|
|
|
|
|
|
|
|
corner.push_back(Segment(keypoints[points[h - 2][w - 1]], keypoints[points[h - 1][w - 1]]));
|
|
|
|
|
corner.push_back(Segment(keypoints[points[h - 1][w - 1]], keypoints[points[h - 1][w - 2]]));
|
|
|
|
|
corner.emplace_back(keypoints[points[h - 2][w - 1]], keypoints[points[h - 1][w - 1]]);
|
|
|
|
|
corner.emplace_back(keypoints[points[h - 1][w - 1]], keypoints[points[h - 1][w - 2]]);
|
|
|
|
|
segments.push_back(corner);
|
|
|
|
|
cornerIndices.push_back(Point(w - 1, h - 1));
|
|
|
|
|
firstSteps.push_back(Point(-1, 0));
|
|
|
|
|
secondSteps.push_back(Point(0, -1));
|
|
|
|
|
cornerIndices.emplace_back(w - 1, h - 1);
|
|
|
|
|
firstSteps.emplace_back(-1, 0);
|
|
|
|
|
secondSteps.emplace_back(0, -1);
|
|
|
|
|
corner.clear();
|
|
|
|
|
|
|
|
|
|
corner.push_back(Segment(keypoints[points[h - 1][1]], keypoints[points[h - 1][0]]));
|
|
|
|
|
corner.push_back(Segment(keypoints[points[h - 1][0]], keypoints[points[h - 2][0]]));
|
|
|
|
|
cornerIndices.push_back(Point(0, h - 1));
|
|
|
|
|
firstSteps.push_back(Point(0, -1));
|
|
|
|
|
secondSteps.push_back(Point(1, 0));
|
|
|
|
|
corner.emplace_back(keypoints[points[h - 1][1]], keypoints[points[h - 1][0]]);
|
|
|
|
|
corner.emplace_back(keypoints[points[h - 1][0]], keypoints[points[h - 2][0]]);
|
|
|
|
|
cornerIndices.emplace_back(0, h - 1);
|
|
|
|
|
firstSteps.emplace_back(0, -1);
|
|
|
|
|
secondSteps.emplace_back(1, 0);
|
|
|
|
|
segments.push_back(corner);
|
|
|
|
|
corner.clear();
|
|
|
|
|
|
|
|
|
|