From: cyy Date: Fri, 5 Mar 2021 15:04:51 +0000 (+0800) Subject: Merge pull request #19565 from cyyever:minor_fix X-Git-Tag: submit/tizen/20220120.021815~1^2~162 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b450dd7a87bc69997a8417d94bdfb87427a9fe62;p=platform%2Fupstream%2Fopencv.git Merge pull request #19565 from cyyever:minor_fix Local objects optimization in calibration init * use emplace_back * use {} initilization * remove a tailing white space --- diff --git a/modules/calib3d/src/calibinit.cpp b/modules/calib3d/src/calibinit.cpp index 320b9ae85d..e25dd26d21 100644 --- a/modules/calib3d/src/calibinit.cpp +++ b/modules/calib3d/src/calibinit.cpp @@ -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])) boardIdx = parentIdx; - contour_quads.push_back(QuadCountour(pt, parentIdx)); + contour_quads.emplace_back(pt, parentIdx); } size_t total = contour_quads.size(); diff --git a/modules/calib3d/src/checkchessboard.cpp b/modules/calib3d/src/checkchessboard.cpp index 904604562d..97876d218c 100644 --- a/modules/calib3d/src/checkchessboard.cpp +++ b/modules/calib3d/src/checkchessboard.cpp @@ -78,7 +78,7 @@ static void icvGetQuadrangleHypotheses(const std::vector(box_size, class_id)); + quads.emplace_back(box_size, class_id); } } diff --git a/modules/calib3d/src/circlesgrid.cpp b/modules/calib3d/src/circlesgrid.cpp index d99480f882..df9534f755 100644 --- a/modules/calib3d/src/circlesgrid.cpp +++ b/modules/calib3d/src/circlesgrid.cpp @@ -384,15 +384,15 @@ void CirclesGridClusterFinder::rectifyPatternPoints(const std::vector 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 idealPoints; for(size_t idx=0; idx (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 //all 8 segments with one end in a corner std::vector 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(); diff --git a/modules/core/src/system.cpp b/modules/core/src/system.cpp index 901a503300..ef0d588113 100644 --- a/modules/core/src/system.cpp +++ b/modules/core/src/system.cpp @@ -345,7 +345,6 @@ struct HWFeatures HWFeatures(bool run_initialize = false) { - memset( have, 0, sizeof(have[0]) * MAX_FEATURE ); if (run_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); diff --git a/modules/imgproc/src/subdivision2d.cpp b/modules/imgproc/src/subdivision2d.cpp index c254c5f9c6..99248dba77 100644 --- a/modules/imgproc/src/subdivision2d.cpp +++ b/modules/imgproc/src/subdivision2d.cpp @@ -229,7 +229,7 @@ int Subdiv2D::newEdge() { if( freeQEdge <= 0 ) { - qedges.push_back(QuadEdge()); + qedges.emplace_back(); freeQEdge = (int)(qedges.size()-1); } int edge = freeQEdge*4;