From a29c814bd8b161799895d28965d4fdf76c9d5cca Mon Sep 17 00:00:00 2001 From: Julien Nabet Date: Fri, 29 Apr 2016 15:41:39 +0200 Subject: [PATCH] cppcheck: fix some reports All of these: (performance) Prefer prefix ++/-- operators for non-primitive types. [modules/calib3d/src/fundam.cpp:1049] -> [modules/calib3d/src/fundam.cpp:1049]: (style) Same expression on both sides of '&&'. --- apps/traincascade/cascadeclassifier.cpp | 6 +++--- modules/calib3d/src/circlesgrid.cpp | 20 ++++++++++---------- modules/calib3d/src/fundam.cpp | 2 +- modules/core/src/matmul.cpp | 2 +- modules/cudalegacy/test/NCVTest.hpp | 4 ++-- modules/features2d/src/agast.cpp | 4 ++-- modules/ts/src/ocl_test.cpp | 4 ++-- modules/videoio/src/cap_gphoto2.cpp | 2 +- samples/cpp/detect_blob.cpp | 6 +++--- samples/cpp/detect_mser.cpp | 10 +++++----- samples/cpp/facedetect.cpp | 2 +- samples/cpp/matchmethod_orb_akaze_brisk.cpp | 12 ++++++------ samples/cpp/smiledetect.cpp | 2 +- samples/tapi/ufacedetect.cpp | 2 +- 14 files changed, 39 insertions(+), 39 deletions(-) diff --git a/apps/traincascade/cascadeclassifier.cpp b/apps/traincascade/cascadeclassifier.cpp index d5def42c4a..b26daf1211 100644 --- a/apps/traincascade/cascadeclassifier.cpp +++ b/apps/traincascade/cascadeclassifier.cpp @@ -290,7 +290,7 @@ int CvCascadeClassifier::predict( int sampleIdx ) { CV_DbgAssert( sampleIdx < numPos + numNeg ); for (vector< Ptr >::iterator it = stageClassifiers.begin(); - it != stageClassifiers.end(); it++ ) + it != stageClassifiers.end();++it ) { if ( (*it)->predict( sampleIdx ) == 0.f ) return 0; @@ -365,7 +365,7 @@ void CvCascadeClassifier::writeStages( FileStorage &fs, const Mat& featureMap ) int i = 0; fs << CC_STAGES << "["; for( vector< Ptr >::const_iterator it = stageClassifiers.begin(); - it != stageClassifiers.end(); it++, i++ ) + it != stageClassifiers.end();++it, ++i ) { sprintf( cmnt, "stage %d", i ); cvWriteComment( fs.fs, cmnt, 0 ); @@ -557,7 +557,7 @@ void CvCascadeClassifier::getUsedFeaturesIdxMap( Mat& featureMap ) featureMap.setTo(Scalar(-1)); for( vector< Ptr >::const_iterator it = stageClassifiers.begin(); - it != stageClassifiers.end(); it++ ) + it != stageClassifiers.end();++it ) (*it)->markUsedFeaturesInMap( featureMap ); for( int fi = 0, idx = 0; fi < varCount; fi++ ) diff --git a/modules/calib3d/src/circlesgrid.cpp b/modules/calib3d/src/circlesgrid.cpp index 39abd8ac50..2038e520a4 100644 --- a/modules/calib3d/src/circlesgrid.cpp +++ b/modules/calib3d/src/circlesgrid.cpp @@ -129,7 +129,7 @@ void CirclesGridClusterFinder::hierarchicalClustering(const std::vector } patternPoints.reserve(clusters[patternClusterIdx].size()); - for(std::list::iterator it = clusters[patternClusterIdx].begin(); it != clusters[patternClusterIdx].end(); it++) + for(std::list::iterator it = clusters[patternClusterIdx].begin(); it != clusters[patternClusterIdx].end();++it) { patternPoints.push_back(points[*it]); } @@ -320,7 +320,7 @@ void CirclesGridClusterFinder::getSortedCorners(const std::vector & std::vector::const_iterator firstCornerIterator = std::find(hull2f.begin(), hull2f.end(), firstCorner); sortedCorners.clear(); - for(std::vector::const_iterator it = firstCornerIterator; it != hull2f.end(); it++) + for(std::vector::const_iterator it = firstCornerIterator; it != hull2f.end();++it) { std::vector::const_iterator itCorners = std::find(corners.begin(), corners.end(), *it); if(itCorners != corners.end()) @@ -328,7 +328,7 @@ void CirclesGridClusterFinder::getSortedCorners(const std::vector & sortedCorners.push_back(*it); } } - for(std::vector::const_iterator it = hull2f.begin(); it != firstCornerIterator; it++) + for(std::vector::const_iterator it = hull2f.begin(); it != firstCornerIterator;++it) { std::vector::const_iterator itCorners = std::find(corners.begin(), corners.end(), *it); if(itCorners != corners.end()) @@ -493,21 +493,21 @@ void Graph::floydWarshall(cv::Mat &distanceMatrix, int infinity) const const int n = (int)getVerticesCount(); distanceMatrix.create(n, n, CV_32SC1); distanceMatrix.setTo(infinity); - for (Vertices::const_iterator it1 = vertices.begin(); it1 != vertices.end(); it1++) + for (Vertices::const_iterator it1 = vertices.begin(); it1 != vertices.end();++it1) { distanceMatrix.at ((int)it1->first, (int)it1->first) = 0; - for (Neighbors::const_iterator it2 = it1->second.neighbors.begin(); it2 != it1->second.neighbors.end(); it2++) + for (Neighbors::const_iterator it2 = it1->second.neighbors.begin(); it2 != it1->second.neighbors.end();++it2) { CV_Assert( it1->first != *it2 ); distanceMatrix.at ((int)it1->first, (int)*it2) = edgeWeight; } } - for (Vertices::const_iterator it1 = vertices.begin(); it1 != vertices.end(); it1++) + for (Vertices::const_iterator it1 = vertices.begin(); it1 != vertices.end();++it1) { - for (Vertices::const_iterator it2 = vertices.begin(); it2 != vertices.end(); it2++) + for (Vertices::const_iterator it2 = vertices.begin(); it2 != vertices.end();++it2) { - for (Vertices::const_iterator it3 = vertices.begin(); it3 != vertices.end(); it3++) + for (Vertices::const_iterator it3 = vertices.begin(); it3 != vertices.end();++it3) { int i1 = (int)it1->first, i2 = (int)it2->first, i3 = (int)it3->first; int val1 = distanceMatrix.at (i2, i3); @@ -618,10 +618,10 @@ void CirclesGridFinder::rng2gridGraph(Graph &rng, std::vector &vect for (size_t i = 0; i < rng.getVerticesCount(); i++) { Graph::Neighbors neighbors1 = rng.getNeighbors(i); - for (Graph::Neighbors::iterator it1 = neighbors1.begin(); it1 != neighbors1.end(); it1++) + for (Graph::Neighbors::iterator it1 = neighbors1.begin(); it1 != neighbors1.end(); ++it1) { Graph::Neighbors neighbors2 = rng.getNeighbors(*it1); - for (Graph::Neighbors::iterator it2 = neighbors2.begin(); it2 != neighbors2.end(); it2++) + for (Graph::Neighbors::iterator it2 = neighbors2.begin(); it2 != neighbors2.end(); ++it2) { if (i < *it2) { diff --git a/modules/calib3d/src/fundam.cpp b/modules/calib3d/src/fundam.cpp index 20803a5fe2..4a7db9689d 100644 --- a/modules/calib3d/src/fundam.cpp +++ b/modules/calib3d/src/fundam.cpp @@ -1046,7 +1046,7 @@ void cv::convertPointsHomogeneous( InputArray _src, OutputArray _dst ) } double cv::sampsonDistance(InputArray _pt1, InputArray _pt2, InputArray _F) { - CV_Assert(_pt1.type() == CV_64F && _pt1.type() == CV_64F && _F.type() == CV_64F); + CV_Assert(_pt1.type() == CV_64F && _pt2.type() == CV_64F && _F.type() == CV_64F); CV_DbgAssert(_pt1.rows() == 3 && _F.size() == Size(3, 3) && _pt1.rows() == _pt2.rows()); Mat pt1(_pt1.getMat()); diff --git a/modules/core/src/matmul.cpp b/modules/core/src/matmul.cpp index bf58dd0f36..cf83ecea87 100644 --- a/modules/core/src/matmul.cpp +++ b/modules/core/src/matmul.cpp @@ -2414,7 +2414,7 @@ void cv::calcCovarMatrix( InputArray _src, OutputArray _covar, InputOutputArray Mat _data(static_cast(src.size()), size.area(), type); int i = 0; - for(std::vector::iterator each = src.begin(); each != src.end(); each++, i++ ) + for(std::vector::iterator each = src.begin(); each != src.end(); ++each, ++i ) { CV_Assert( (*each).size() == size && (*each).type() == type ); Mat dataRow(size.height, size.width, type, _data.ptr(i)); diff --git a/modules/cudalegacy/test/NCVTest.hpp b/modules/cudalegacy/test/NCVTest.hpp index 2c7b5f9050..23b1feef55 100644 --- a/modules/cudalegacy/test/NCVTest.hpp +++ b/modules/cudalegacy/test/NCVTest.hpp @@ -214,12 +214,12 @@ private: stream << "====================================================" << std::endl << std::endl; stream << "Test initialization report: " << std::endl; for (std::map::iterator it=report.statsText.begin(); - it != report.statsText.end(); it++) + it != report.statsText.end(); ++it) { stream << it->first << "=" << it->second << std::endl; } for (std::map::iterator it=report.statsNums.begin(); - it != report.statsNums.end(); it++) + it != report.statsNums.end(); ++it) { stream << it->first << "=" << it->second << std::endl; } diff --git a/modules/features2d/src/agast.cpp b/modules/features2d/src/agast.cpp index 39325905ac..a419e371e0 100644 --- a/modules/features2d/src/agast.cpp +++ b/modules/features2d/src/agast.cpp @@ -8033,7 +8033,7 @@ void AGAST(InputArray _img, std::vector& keypoints, int threshold, boo makeAgastOffsets(pixel_, (int)img.step, type); std::vector::iterator kpt; - for(kpt = kpts.begin(); kpt != kpts.end(); kpt++) + for(kpt = kpts.begin(); kpt != kpts.end(); ++kpt) { switch(type) { case AgastFeatureDetector::AGAST_5_8: @@ -8149,7 +8149,7 @@ void AGAST(InputArray _img, std::vector& keypoints, int threshold, boo } } } - currCorner++; + ++currCorner; } // collecting maximum corners diff --git a/modules/ts/src/ocl_test.cpp b/modules/ts/src/ocl_test.cpp index 69d10aac0d..abc8d95559 100644 --- a/modules/ts/src/ocl_test.cpp +++ b/modules/ts/src/ocl_test.cpp @@ -267,7 +267,7 @@ double TestUtils::checkRectSimilarity(const Size & sz, std::vector& ob1, s cv::Mat cpu_result(sz, CV_8UC1); cpu_result.setTo(0); - for (vector::const_iterator r = ob1.begin(); r != ob1.end(); r++) + for (vector::const_iterator r = ob1.begin(); r != ob1.end(); ++r) { cv::Mat cpu_result_roi(cpu_result, *r); cpu_result_roi.setTo(1); @@ -277,7 +277,7 @@ double TestUtils::checkRectSimilarity(const Size & sz, std::vector& ob1, s cv::Mat gpu_result(sz, CV_8UC1); gpu_result.setTo(0); - for(vector::const_iterator r2 = ob2.begin(); r2 != ob2.end(); r2++) + for(vector::const_iterator r2 = ob2.begin(); r2 != ob2.end(); ++r2) { cv::Mat gpu_result_roi(gpu_result, *r2); gpu_result_roi.setTo(1); diff --git a/modules/videoio/src/cap_gphoto2.cpp b/modules/videoio/src/cap_gphoto2.cpp index fd1b302d6d..7fa94f556f 100644 --- a/modules/videoio/src/cap_gphoto2.cpp +++ b/modules/videoio/src/cap_gphoto2.cpp @@ -981,7 +981,7 @@ CameraWidget * DigitalCameraCapture::findWidgetByName( CR(gp_widget_get_name(it->second, &name)); if (strstr(name, subName)) break; - it++; + ++it; } return (it != end) ? it->second : NULL; } diff --git a/samples/cpp/detect_blob.cpp b/samples/cpp/detect_blob.cpp index 879b47e69d..9c9670632f 100644 --- a/samples/cpp/detect_blob.cpp +++ b/samples/cpp/detect_blob.cpp @@ -159,14 +159,14 @@ int main(int argc, char *argv[]) String label; // Descriptor loop vector::iterator itDesc; - for (itDesc = typeDesc.begin(); itDesc != typeDesc.end(); itDesc++) + for (itDesc = typeDesc.begin(); itDesc != typeDesc.end(); ++itDesc) { vector keyImg1; if (*itDesc == "BLOB") { b = SimpleBlobDetector::create(*itBLOB); label = Legende(*itBLOB); - itBLOB++; + ++itBLOB; } try { @@ -181,7 +181,7 @@ int main(int argc, char *argv[]) sbd->detect(img, keyImg, Mat()); drawKeypoints(img, keyImg, result); int i = 0; - for (vector::iterator k = keyImg.begin(); k != keyImg.end(); k++, i++) + for (vector::iterator k = keyImg.begin(); k != keyImg.end(); ++k, ++i) circle(result, k->pt, (int)k->size, palette[i % 65536]); } namedWindow(*itDesc + label, WINDOW_AUTOSIZE); diff --git a/samples/cpp/detect_mser.cpp b/samples/cpp/detect_mser.cpp index a6a020c39c..8d16ec657a 100644 --- a/samples/cpp/detect_mser.cpp +++ b/samples/cpp/detect_mser.cpp @@ -466,7 +466,7 @@ int main(int argc, char *argv[]) // Descriptor loop vector::iterator itDesc; Mat result(img.rows, img.cols, CV_8UC3); - for (itDesc = typeDesc.begin(); itDesc != typeDesc.end(); itDesc++) + for (itDesc = typeDesc.begin(); itDesc != typeDesc.end(); ++itDesc) { vector keyImg1; if (*itDesc == "MSER"){ @@ -475,7 +475,7 @@ int main(int argc, char *argv[]) b = MSER::create(itMSER->delta, itMSER->minArea, itMSER->maxArea, itMSER->maxVariation, itMSER->minDiversity, itMSER->maxEvolution, itMSER->areaThreshold, itMSER->minMargin, itMSER->edgeBlurSize); label = Legende(*itMSER); - itMSER++; + ++itMSER; } else @@ -483,7 +483,7 @@ int main(int argc, char *argv[]) b = MSER::create(itMSER->delta, itMSER->minArea, itMSER->maxArea, itMSER->maxVariation, itMSER->minDiversity); b.dynamicCast()->setPass2Only(itMSER->pass2Only); label = Legende(*itMSER); - itMSER++; + ++itMSER; } } if (img.type()==CV_8UC3) @@ -513,9 +513,9 @@ int main(int argc, char *argv[]) int i = 0; //result = Scalar(0, 0, 0); int nbPixelInMSER=0; - for (vector >::iterator itr = region.begin(); itr != region.end(); itr++, i++) + for (vector >::iterator itr = region.begin(); itr != region.end(); ++itr, ++i) { - for (vector ::iterator itp = region[i].begin(); itp != region[i].end(); itp ++) + for (vector ::iterator itp = region[i].begin(); itp != region[i].end(); ++itp) { // all pixels belonging to region become blue result.at(itp->y, itp->x) = Vec3b(128, 0, 0); diff --git a/samples/cpp/facedetect.cpp b/samples/cpp/facedetect.cpp index 39717b7336..2cfe524a18 100644 --- a/samples/cpp/facedetect.cpp +++ b/samples/cpp/facedetect.cpp @@ -193,7 +193,7 @@ void detectAndDraw( Mat& img, CascadeClassifier& cascade, //|CASCADE_DO_ROUGH_SEARCH |CASCADE_SCALE_IMAGE, Size(30, 30) ); - for( vector::const_iterator r = faces2.begin(); r != faces2.end(); r++ ) + for( vector::const_iterator r = faces2.begin(); r != faces2.end(); ++r ) { faces.push_back(Rect(smallImg.cols - r->x - r->width, r->y, r->width, r->height)); } diff --git a/samples/cpp/matchmethod_orb_akaze_brisk.cpp b/samples/cpp/matchmethod_orb_akaze_brisk.cpp index 379b53ae1d..d96ad51fb3 100644 --- a/samples/cpp/matchmethod_orb_akaze_brisk.cpp +++ b/samples/cpp/matchmethod_orb_akaze_brisk.cpp @@ -59,7 +59,7 @@ int main(int argc, char *argv[]) // Descriptor loop vector::iterator itDesc; - for (itDesc = typeDesc.begin(); itDesc != typeDesc.end(); itDesc++) + for (itDesc = typeDesc.begin(); itDesc != typeDesc.end(); ++itDesc) { Ptr descriptorMatcher; // Match between img1 and img2 @@ -90,7 +90,7 @@ int main(int argc, char *argv[]) // or detect and compute descriptors in one step b->detectAndCompute(img2, Mat(),keyImg2, descImg2,false); // Match method loop - for (itMatcher = typeAlgoMatch.begin(); itMatcher != typeAlgoMatch.end(); itMatcher++){ + for (itMatcher = typeAlgoMatch.begin(); itMatcher != typeAlgoMatch.end(); ++itMatcher){ descriptorMatcher = DescriptorMatcher::create(*itMatcher); if ((*itMatcher == "BruteForce-Hamming" || *itMatcher == "BruteForce-Hamming(2)") && (b->descriptorType() == CV_32F || b->defaultNorm() <= NORM_L2SQR)) { @@ -135,7 +135,7 @@ int main(int argc, char *argv[]) cout << "in img1\tin img2\n"; // Use to compute distance between keyPoint matches and to evaluate match algorithm double cumSumDist2=0; - for (it = bestMatches.begin(); it != bestMatches.end(); it++) + for (it = bestMatches.begin(); it != bestMatches.end(); ++it) { cout << it->queryIdx << "\t" << it->trainIdx << "\t" << it->distance << "\n"; Point2d p=keyImg1[it->queryIdx].pt-keyImg2[it->trainIdx].pt; @@ -165,15 +165,15 @@ int main(int argc, char *argv[]) int i=0; cout << "Cumulative distance between keypoint match for different algorithm and feature detector \n\t"; cout << "We cannot say which is the best but we can say results are differents! \n\t"; - for (vector::iterator itMatcher = typeAlgoMatch.begin(); itMatcher != typeAlgoMatch.end(); itMatcher++) + for (vector::iterator itMatcher = typeAlgoMatch.begin(); itMatcher != typeAlgoMatch.end(); ++itMatcher) { cout<<*itMatcher<<"\t"; } cout << "\n"; - for (itDesc = typeDesc.begin(); itDesc != typeDesc.end(); itDesc++) + for (itDesc = typeDesc.begin(); itDesc != typeDesc.end(); ++itDesc) { cout << *itDesc << "\t"; - for (vector::iterator itMatcher = typeAlgoMatch.begin(); itMatcher != typeAlgoMatch.end(); itMatcher++, i++) + for (vector::iterator itMatcher = typeAlgoMatch.begin(); itMatcher != typeAlgoMatch.end(); ++itMatcher, ++i) { cout << desMethCmp[i]<<"\t"; } diff --git a/samples/cpp/smiledetect.cpp b/samples/cpp/smiledetect.cpp index f3f85764f7..f2f0bbf076 100644 --- a/samples/cpp/smiledetect.cpp +++ b/samples/cpp/smiledetect.cpp @@ -153,7 +153,7 @@ void detectAndDraw( Mat& img, CascadeClassifier& cascade, //|CASCADE_DO_ROUGH_SEARCH |CASCADE_SCALE_IMAGE, Size(30, 30) ); - for( vector::const_iterator r = faces2.begin(); r != faces2.end(); r++ ) + for( vector::const_iterator r = faces2.begin(); r != faces2.end(); ++r ) { faces.push_back(Rect(smallImg.cols - r->x - r->width, r->y, r->width, r->height)); } diff --git a/samples/tapi/ufacedetect.cpp b/samples/tapi/ufacedetect.cpp index f6dc0ce1d9..760ee7090d 100644 --- a/samples/tapi/ufacedetect.cpp +++ b/samples/tapi/ufacedetect.cpp @@ -195,7 +195,7 @@ void detectAndDraw( UMat& img, Mat& canvas, CascadeClassifier& cascade, //|CASCADE_DO_ROUGH_SEARCH |CASCADE_SCALE_IMAGE, Size(30, 30) ); - for( vector::const_iterator r = faces2.begin(); r != faces2.end(); r++ ) + for( vector::const_iterator r = faces2.begin(); r != faces2.end(); ++r ) { faces.push_back(Rect(smallImg.cols - r->x - r->width, r->y, r->width, r->height)); }