mirror of
https://github.com/opencv/opencv.git
synced 2025-08-06 14:36:36 +08:00
Merge pull request #19565 from cyyever:minor_fix
Local objects optimization in calibration init * use emplace_back * use {} initilization * remove a tailing white space
This commit is contained in:
parent
2e429268ff
commit
b450dd7a87
@ -1842,7 +1842,7 @@ void ChessBoardDetector::generateQuads(const cv::Mat& image_, int flags)
|
|||||||
if (boardIdx != parentIdx && (boardIdx < 0 || contour_child_counter[boardIdx] < contour_child_counter[parentIdx]))
|
if (boardIdx != parentIdx && (boardIdx < 0 || contour_child_counter[boardIdx] < contour_child_counter[parentIdx]))
|
||||||
boardIdx = parentIdx;
|
boardIdx = parentIdx;
|
||||||
|
|
||||||
contour_quads.push_back(QuadCountour(pt, parentIdx));
|
contour_quads.emplace_back(pt, parentIdx);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t total = contour_quads.size();
|
size_t total = contour_quads.size();
|
||||||
|
@ -78,7 +78,7 @@ static void icvGetQuadrangleHypotheses(const std::vector<std::vector< cv::Point
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
quads.push_back(std::pair<float, int>(box_size, class_id));
|
quads.emplace_back(box_size, class_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -384,15 +384,15 @@ void CirclesGridClusterFinder::rectifyPatternPoints(const std::vector<cv::Point2
|
|||||||
{
|
{
|
||||||
//indices of corner points in pattern
|
//indices of corner points in pattern
|
||||||
std::vector<Point> trueIndices;
|
std::vector<Point> trueIndices;
|
||||||
trueIndices.push_back(Point(0, 0));
|
trueIndices.emplace_back(0, 0);
|
||||||
trueIndices.push_back(Point(patternSize.width - 1, 0));
|
trueIndices.emplace_back(patternSize.width - 1, 0);
|
||||||
if(isAsymmetricGrid)
|
if(isAsymmetricGrid)
|
||||||
{
|
{
|
||||||
trueIndices.push_back(Point(patternSize.width - 1, 1));
|
trueIndices.emplace_back(patternSize.width - 1, 1);
|
||||||
trueIndices.push_back(Point(patternSize.width - 1, patternSize.height - 2));
|
trueIndices.emplace_back(patternSize.width - 1, patternSize.height - 2);
|
||||||
}
|
}
|
||||||
trueIndices.push_back(Point(patternSize.width - 1, patternSize.height - 1));
|
trueIndices.emplace_back(patternSize.width - 1, patternSize.height - 1);
|
||||||
trueIndices.push_back(Point(0, patternSize.height - 1));
|
trueIndices.emplace_back(0, patternSize.height - 1);
|
||||||
|
|
||||||
std::vector<Point2f> idealPoints;
|
std::vector<Point2f> idealPoints;
|
||||||
for(size_t idx=0; idx<trueIndices.size(); idx++)
|
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;
|
int j = trueIndices[idx].x;
|
||||||
if(isAsymmetricGrid)
|
if(isAsymmetricGrid)
|
||||||
{
|
{
|
||||||
idealPoints.push_back(Point2f((2*j + i % 2)*squareSize, i*squareSize));
|
idealPoints.emplace_back((2*j + i % 2)*squareSize, i*squareSize);
|
||||||
}
|
}
|
||||||
else
|
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 ) );
|
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)
|
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);
|
convertPointsFromHomogeneous(dstKeypointsMat, dstKeypoints);
|
||||||
|
|
||||||
warpedKeypoints.clear();
|
warpedKeypoints.clear();
|
||||||
for (size_t i = 0; i < dstKeypoints.size(); i++)
|
for (auto &pt:dstKeypoints)
|
||||||
{
|
{
|
||||||
Point2f pt = dstKeypoints[i];
|
warpedKeypoints.emplace_back(std::move(pt));
|
||||||
warpedKeypoints.push_back(pt);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return H;
|
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
|
//all 8 segments with one end in a corner
|
||||||
std::vector<Segment> corner;
|
std::vector<Segment> corner;
|
||||||
corner.push_back(Segment(keypoints[points[1][0]], keypoints[points[0][0]]));
|
corner.emplace_back(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[0][0]], keypoints[points[0][1]]);
|
||||||
segments.push_back(corner);
|
segments.push_back(corner);
|
||||||
cornerIndices.push_back(Point(0, 0));
|
cornerIndices.emplace_back(0, 0);
|
||||||
firstSteps.push_back(Point(1, 0));
|
firstSteps.emplace_back(1, 0);
|
||||||
secondSteps.push_back(Point(0, 1));
|
secondSteps.emplace_back(0, 1);
|
||||||
corner.clear();
|
corner.clear();
|
||||||
|
|
||||||
corner.push_back(Segment(keypoints[points[0][w - 2]], keypoints[points[0][w - 1]]));
|
corner.emplace_back(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 - 1]], keypoints[points[1][w - 1]]);
|
||||||
segments.push_back(corner);
|
segments.push_back(corner);
|
||||||
cornerIndices.push_back(Point(w - 1, 0));
|
cornerIndices.emplace_back(w - 1, 0);
|
||||||
firstSteps.push_back(Point(0, 1));
|
firstSteps.emplace_back(0, 1);
|
||||||
secondSteps.push_back(Point(-1, 0));
|
secondSteps.emplace_back(-1, 0);
|
||||||
corner.clear();
|
corner.clear();
|
||||||
|
|
||||||
corner.push_back(Segment(keypoints[points[h - 2][w - 1]], keypoints[points[h - 1][w - 1]]));
|
corner.emplace_back(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 - 1][w - 1]], keypoints[points[h - 1][w - 2]]);
|
||||||
segments.push_back(corner);
|
segments.push_back(corner);
|
||||||
cornerIndices.push_back(Point(w - 1, h - 1));
|
cornerIndices.emplace_back(w - 1, h - 1);
|
||||||
firstSteps.push_back(Point(-1, 0));
|
firstSteps.emplace_back(-1, 0);
|
||||||
secondSteps.push_back(Point(0, -1));
|
secondSteps.emplace_back(0, -1);
|
||||||
corner.clear();
|
corner.clear();
|
||||||
|
|
||||||
corner.push_back(Segment(keypoints[points[h - 1][1]], keypoints[points[h - 1][0]]));
|
corner.emplace_back(keypoints[points[h - 1][1]], keypoints[points[h - 1][0]]);
|
||||||
corner.push_back(Segment(keypoints[points[h - 1][0]], keypoints[points[h - 2][0]]));
|
corner.emplace_back(keypoints[points[h - 1][0]], keypoints[points[h - 2][0]]);
|
||||||
cornerIndices.push_back(Point(0, h - 1));
|
cornerIndices.emplace_back(0, h - 1);
|
||||||
firstSteps.push_back(Point(0, -1));
|
firstSteps.emplace_back(0, -1);
|
||||||
secondSteps.push_back(Point(1, 0));
|
secondSteps.emplace_back(1, 0);
|
||||||
segments.push_back(corner);
|
segments.push_back(corner);
|
||||||
corner.clear();
|
corner.clear();
|
||||||
|
|
||||||
|
@ -345,7 +345,6 @@ struct HWFeatures
|
|||||||
|
|
||||||
HWFeatures(bool run_initialize = false)
|
HWFeatures(bool run_initialize = false)
|
||||||
{
|
{
|
||||||
memset( have, 0, sizeof(have[0]) * MAX_FEATURE );
|
|
||||||
if (run_initialize)
|
if (run_initialize)
|
||||||
initialize();
|
initialize();
|
||||||
}
|
}
|
||||||
@ -730,7 +729,7 @@ struct HWFeatures
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool have[MAX_FEATURE+1];
|
bool have[MAX_FEATURE+1]{};
|
||||||
};
|
};
|
||||||
|
|
||||||
static HWFeatures featuresEnabled(true), featuresDisabled = HWFeatures(false);
|
static HWFeatures featuresEnabled(true), featuresDisabled = HWFeatures(false);
|
||||||
|
@ -229,7 +229,7 @@ int Subdiv2D::newEdge()
|
|||||||
{
|
{
|
||||||
if( freeQEdge <= 0 )
|
if( freeQEdge <= 0 )
|
||||||
{
|
{
|
||||||
qedges.push_back(QuadEdge());
|
qedges.emplace_back();
|
||||||
freeQEdge = (int)(qedges.size()-1);
|
freeQEdge = (int)(qedges.size()-1);
|
||||||
}
|
}
|
||||||
int edge = freeQEdge*4;
|
int edge = freeQEdge*4;
|
||||||
|
Loading…
Reference in New Issue
Block a user