From 2a6fb2867e2fc639e0675eed8abb1688de4539ec Mon Sep 17 00:00:00 2001 From: Andrey Kamaev Date: Sun, 24 Feb 2013 20:14:01 +0400 Subject: [PATCH 1/2] Remove all using directives for STL namespace and members Made all STL usages explicit to be able automatically find all usages of particular class or function. --- apps/traincascade/HOGfeatures.cpp | 1 + apps/traincascade/HOGfeatures.h | 10 +- apps/traincascade/boost.cpp | 12 +- apps/traincascade/boost.h | 2 +- apps/traincascade/cascadeclassifier.cpp | 18 +- apps/traincascade/cascadeclassifier.h | 14 +- apps/traincascade/features.cpp | 2 +- apps/traincascade/haarfeatures.cpp | 10 +- apps/traincascade/haarfeatures.h | 4 +- apps/traincascade/imagestorage.cpp | 18 +- apps/traincascade/imagestorage.h | 8 +- apps/traincascade/lbpfeatures.h | 2 +- apps/traincascade/traincascade.cpp | 2 +- apps/traincascade/traincascade_features.h | 6 +- modules/androidcamera/src/camera_activity.cpp | 21 +- modules/calib3d/perf/perf_cicrlesGrid.cpp | 2 +- modules/calib3d/src/calibinit.cpp | 8 +- modules/calib3d/src/calibration.cpp | 34 +- modules/calib3d/src/circlesgrid.cpp | 147 ++- modules/calib3d/src/epnp.cpp | 1 - modules/calib3d/src/five-point.cpp | 575 ++++++------ modules/calib3d/src/modelest.cpp | 9 +- modules/calib3d/src/p3p.cpp | 2 - modules/calib3d/src/polynom_solver.cpp | 7 +- modules/calib3d/src/quadsubpix.cpp | 30 +- modules/calib3d/src/solvepnp.cpp | 18 +- modules/calib3d/src/stereobm.cpp | 14 +- modules/calib3d/src/stereosgbm.cpp | 70 +- .../calib3d/test/test_cameracalibration.cpp | 5 +- .../calib3d/test/test_chessboardgenerator.cpp | 10 +- .../calib3d/test/test_chessboardgenerator.hpp | 12 +- modules/calib3d/test/test_cornerssubpix.cpp | 1 + modules/calib3d/test/test_modelest.cpp | 1 + .../include/opencv2/contrib/contrib.hpp | 76 +- .../include/opencv2/contrib/hybridtracker.hpp | 10 +- .../include/opencv2/contrib/openfabmap.hpp | 104 ++- modules/contrib/src/ba.cpp | 14 +- modules/contrib/src/basicretinafilter.cpp | 14 +- modules/contrib/src/basicretinafilter.hpp | 1 - modules/contrib/src/bowmsctrainer.cpp | 2 +- modules/contrib/src/chamfermatching.cpp | 4 +- modules/contrib/src/chowliutree.cpp | 20 +- modules/contrib/src/colormap.cpp | 4 +- modules/contrib/src/colortracker.cpp | 1 - .../contrib/src/detection_based_tracker.cpp | 19 +- modules/contrib/src/facerec.cpp | 78 +- modules/contrib/src/featuretracker.cpp | 8 +- modules/contrib/src/hybridtracker.cpp | 3 +- modules/contrib/src/imagelogpolprojection.cpp | 12 +- modules/contrib/src/lda.cpp | 81 +- modules/contrib/src/logpolar_bsm.cpp | 80 +- modules/contrib/src/magnoretinafilter.cpp | 2 +- modules/contrib/src/octree.cpp | 16 +- modules/contrib/src/openfabmap.cpp | 134 +-- modules/contrib/src/retinafilter.cpp | 2 +- modules/contrib/src/rgbdodometry.cpp | 24 +- modules/contrib/src/selfsimilarity.cpp | 6 +- modules/contrib/src/spinimages.cpp | 209 +++-- modules/contrib/src/stereovar.cpp | 8 +- modules/contrib/src/templatebuffer.hpp | 4 +- modules/core/doc/xml_yaml_persistence.rst | 6 +- modules/core/include/opencv2/core/core.hpp | 248 +++--- modules/core/include/opencv2/core/mat.hpp | 34 +- .../core/include/opencv2/core/operations.hpp | 132 ++- modules/core/src/algorithm.cpp | 227 +++-- modules/core/src/command_line_parser.cpp | 144 +-- modules/core/src/convert.cpp | 14 +- modules/core/src/datastructs.cpp | 6 +- modules/core/src/drawing.cpp | 36 +- modules/core/src/gpumat.cpp | 158 ++-- modules/core/src/mathfuncs.cpp | 14 +- modules/core/src/matmul.cpp | 2 +- modules/core/src/matrix.cpp | 116 +-- modules/core/src/opengl_interop.cpp | 24 +- modules/core/src/out.cpp | 2 +- modules/core/src/persistence.cpp | 56 +- modules/core/src/rand.cpp | 12 +- modules/core/src/system.cpp | 14 +- .../include/opencv2/features2d/features2d.hpp | 324 +++---- modules/features2d/perf/perf_fast.cpp | 4 +- modules/features2d/perf/perf_orb.cpp | 6 +- modules/features2d/src/bagofwords.cpp | 12 +- modules/features2d/src/blobdetector.cpp | 20 +- modules/features2d/src/brisk.cpp | 20 +- modules/features2d/src/descriptors.cpp | 30 +- modules/features2d/src/detectors.cpp | 38 +- modules/features2d/src/draw.cpp | 26 +- modules/features2d/src/dynamic.cpp | 10 +- modules/features2d/src/evaluation.cpp | 67 +- modules/features2d/src/fast.cpp | 2 +- modules/features2d/src/features2d_init.cpp | 2 +- modules/features2d/src/freak.cpp | 10 +- modules/features2d/src/keypoint.cpp | 30 +- modules/features2d/src/matchers.cpp | 176 ++-- modules/features2d/src/mser.cpp | 10 +- modules/features2d/src/orb.cpp | 68 +- modules/features2d/src/stardetector.cpp | 6 +- modules/features2d/test/test_brisk.cpp | 1 + modules/features2d/test/test_fast.cpp | 1 + .../features2d/test/test_nearestneighbors.cpp | 1 + modules/features2d/test/test_orb.cpp | 1 + modules/flann/include/opencv2/flann/flann.hpp | 20 +- modules/gpu/include/opencv2/gpu/gpu.hpp | 40 +- modules/gpu/src/arithm.cpp | 5 +- modules/gpu/src/bilateral_filter.cpp | 3 +- modules/gpu/src/blend.cpp | 1 - modules/gpu/src/brute_force_matcher.cpp | 127 ++- modules/gpu/src/calib3d.cpp | 9 +- modules/gpu/src/cascadeclassifier.cpp | 27 +- modules/gpu/src/cudastream.cpp | 4 +- modules/gpu/src/error.cpp | 19 +- modules/gpu/src/fast.cpp | 1 - modules/gpu/src/gftt.cpp | 7 +- modules/gpu/src/global_motion.cpp | 1 - modules/gpu/src/hog.cpp | 36 +- modules/gpu/src/hough.cpp | 31 +- modules/gpu/src/match_template.cpp | 1 - modules/gpu/src/mssegmentation.cpp | 16 +- modules/gpu/src/optflowbm.cpp | 3 +- modules/gpu/src/optical_flow.cpp | 1 - modules/gpu/src/optical_flow_farneback.cpp | 3 +- modules/gpu/src/orb.cpp | 3 +- modules/gpu/src/pyrlk.cpp | 1 - modules/gpu/src/softcascade.cpp | 6 +- modules/gpu/src/speckle_filtering.cpp | 2 +- modules/gpu/src/split_merge.cpp | 9 +- modules/gpu/src/stereobp.cpp | 15 +- modules/gpu/src/stereocsbp.cpp | 5 +- modules/gpu/src/surf.cpp | 31 +- modules/gpu/src/tvl1flow.cpp | 3 +- .../include/opencv2/highgui/highgui.hpp | 62 +- modules/highgui/perf/perf_input.cpp | 2 +- modules/highgui/perf/perf_output.cpp | 2 +- modules/highgui/src/bitstrm.cpp | 6 +- modules/highgui/src/bitstrm.hpp | 8 +- modules/highgui/src/cap.cpp | 8 +- modules/highgui/src/cap_avfoundation.mm | 4 - modules/highgui/src/cap_qtkit.mm | 30 +- modules/highgui/src/grfmt_base.cpp | 14 +- modules/highgui/src/grfmt_base.hpp | 24 +- modules/highgui/src/grfmt_bmp.cpp | 2 +- modules/highgui/src/grfmt_bmp.hpp | 2 +- modules/highgui/src/grfmt_exr.cpp | 2 +- modules/highgui/src/grfmt_exr.hpp | 2 +- modules/highgui/src/grfmt_jpeg.cpp | 6 +- modules/highgui/src/grfmt_jpeg.hpp | 2 +- modules/highgui/src/grfmt_jpeg2000.cpp | 4 +- modules/highgui/src/grfmt_jpeg2000.hpp | 2 +- modules/highgui/src/grfmt_png.cpp | 2 +- modules/highgui/src/grfmt_png.hpp | 2 +- modules/highgui/src/grfmt_pxm.cpp | 4 +- modules/highgui/src/grfmt_pxm.hpp | 4 +- modules/highgui/src/grfmt_sunras.cpp | 2 +- modules/highgui/src/grfmt_sunras.hpp | 2 +- modules/highgui/src/grfmt_tiff.cpp | 10 +- modules/highgui/src/grfmt_tiff.hpp | 6 +- modules/highgui/src/loadsave.cpp | 38 +- modules/highgui/src/window.cpp | 56 +- modules/highgui/src/window_cocoa.mm | 1 - modules/highgui/test/test_drawing.cpp | 1 + modules/highgui/test/test_grfmt.cpp | 6 +- .../include/opencv2/imgproc/imgproc.hpp | 42 +- modules/imgproc/perf/perf_canny.cpp | 4 +- .../perf/perf_cornerEigenValsAndVecs.cpp | 4 +- modules/imgproc/perf/perf_cornerHarris.cpp | 4 +- modules/imgproc/perf/perf_filter2d.cpp | 4 +- .../imgproc/perf/perf_goodFeaturesToTrack.cpp | 4 +- modules/imgproc/perf/perf_houghLines.cpp | 4 +- modules/imgproc/src/color.cpp | 12 +- modules/imgproc/src/convhull.cpp | 16 +- modules/imgproc/src/deriv.cpp | 2 +- modules/imgproc/src/featureselect.cpp | 8 +- modules/imgproc/src/filter.cpp | 20 +- modules/imgproc/src/floodfill.cpp | 2 +- modules/imgproc/src/gabor.cpp | 2 +- modules/imgproc/src/generalized_hough.cpp | 73 +- modules/imgproc/src/geometry.cpp | 6 +- modules/imgproc/src/grabcut.cpp | 10 +- modules/imgproc/src/histogram.cpp | 94 +- modules/imgproc/src/hough.cpp | 42 +- modules/imgproc/src/imgwarp.cpp | 6 +- modules/imgproc/src/linefit.cpp | 6 +- modules/imgproc/src/morph.cpp | 10 +- modules/imgproc/src/phasecorr.cpp | 2 +- modules/imgproc/src/precomp.hpp | 2 +- modules/imgproc/src/rotcalipers.cpp | 26 +- modules/imgproc/src/segmentation.cpp | 4 +- modules/imgproc/src/shapedescr.cpp | 20 +- modules/imgproc/src/smooth.cpp | 24 +- modules/imgproc/src/subdivision2d.cpp | 16 +- modules/imgproc/src/templmatch.cpp | 6 +- modules/imgproc/src/undistort.cpp | 6 +- modules/java/generator/gen_java.py | 58 +- modules/java/generator/src/cpp/converters.cpp | 146 +-- .../generator/src/cpp/features2d_manual.hpp | 120 +-- .../legacy/include/opencv2/legacy/legacy.hpp | 146 +-- modules/legacy/src/calonder.cpp | 2 - modules/legacy/src/em.cpp | 8 +- modules/legacy/src/features2d.cpp | 4 +- modules/legacy/src/oneway.cpp | 54 +- modules/legacy/src/optflowbm.cpp | 4 +- modules/legacy/src/planardetect.cpp | 110 +-- modules/legacy/src/stereogc.cpp | 2 - .../legacy/test/test_bruteforcematcher.cpp | 1 + modules/ml/include/opencv2/ml/ml.hpp | 10 +- modules/ml/src/em.cpp | 6 +- modules/ml/src/gbt.cpp | 19 +- modules/ml/src/tree.cpp | 4 +- .../include/opencv2/nonfree/features2d.hpp | 24 +- modules/nonfree/perf/perf_surf.cpp | 6 +- modules/nonfree/src/sift.cpp | 30 +- modules/nonfree/src/surf.cpp | 72 +- .../include/opencv2/objdetect/objdetect.hpp | 106 +-- modules/objdetect/src/cascadedetect.cpp | 112 +-- modules/objdetect/src/cascadedetect.hpp | 14 +- modules/objdetect/src/datamatrix.cpp | 35 +- modules/objdetect/src/haar.cpp | 4 +- modules/objdetect/src/hog.cpp | 54 +- modules/objdetect/src/latentsvmdetector.cpp | 16 +- .../objdetect/test/test_latentsvmdetector.cpp | 1 + modules/ocl/include/opencv2/ocl/ocl.hpp | 41 +- modules/ocl/src/arithm.cpp | 841 +++++++++--------- modules/ocl/src/binarycaching.hpp | 13 +- modules/ocl/src/blend.cpp | 21 +- modules/ocl/src/brute_force_matcher.cpp | 348 ++++---- modules/ocl/src/build_warps.cpp | 109 ++- modules/ocl/src/canny.cpp | 187 ++-- modules/ocl/src/color.cpp | 106 +-- modules/ocl/src/columnsum.cpp | 15 +- modules/ocl/src/fft.cpp | 23 +- modules/ocl/src/filtering.cpp | 249 +++--- modules/ocl/src/haar.cpp | 94 +- modules/ocl/src/hog.cpp | 215 +++-- modules/ocl/src/hough.cpp | 89 +- modules/ocl/src/imgproc.cpp | 633 +++++++------ modules/ocl/src/initialization.cpp | 91 +- modules/ocl/src/interpolate_frames.cpp | 79 +- modules/ocl/src/match_template.cpp | 245 +++-- modules/ocl/src/matrix_operations.cpp | 187 ++-- modules/ocl/src/mcwutil.cpp | 18 +- modules/ocl/src/mcwutil.hpp | 9 +- modules/ocl/src/mssegmentation.cpp | 16 +- modules/ocl/src/precomp.hpp | 24 +- modules/ocl/src/pyrdown.cpp | 22 +- modules/ocl/src/pyrlk.cpp | 241 +++-- modules/ocl/src/pyrup.cpp | 23 +- modules/ocl/src/split_merge.cpp | 153 ++-- modules/ocl/src/surf.cpp | 155 ++-- modules/photo/src/arrays.hpp | 2 +- modules/photo/src/denoising.cpp | 10 +- .../src/fast_nlmeans_denoising_invoker.hpp | 5 +- ...fast_nlmeans_denoising_invoker_commons.hpp | 1 - .../fast_nlmeans_multi_denoising_invoker.hpp | 9 +- modules/photo/test/test_inpaint.cpp | 1 + modules/python/src2/cv2.cpp | 91 +- modules/python/src2/gen2.py | 5 +- .../opencv2/softcascade/softcascade.hpp | 2 +- modules/softcascade/perf/perf_precomp. | 0 .../src/integral_channel_builder.cpp | 2 +- modules/softcascade/src/softcascade.cpp | 18 +- modules/stitching/perf/perf_stich.cpp | 10 +- modules/stitching/src/autocalib.cpp | 23 +- modules/stitching/src/blenders.cpp | 42 +- modules/stitching/src/camera.cpp | 2 - modules/stitching/src/exposure_compensate.cpp | 44 +- modules/stitching/src/matchers.cpp | 39 +- modules/stitching/src/motion_estimators.cpp | 99 +-- modules/stitching/src/seam_finders.cpp | 144 ++- modules/stitching/src/stitcher.cpp | 46 +- modules/stitching/src/util.cpp | 38 +- modules/stitching/src/warpers.cpp | 42 +- .../video/include/opencv2/video/tracking.hpp | 6 +- modules/video/src/bgfg_gaussmix.cpp | 24 +- modules/video/src/bgfg_gaussmix2.cpp | 4 +- modules/video/src/lkpyramid.cpp | 8 +- modules/video/src/motempl.cpp | 2 +- modules/video/src/simpleflow.cpp | 34 +- modules/video/src/simpleflow.hpp | 2 - modules/video/src/tvl1flow.cpp | 5 +- .../opencv2/videostab/fast_marching_inl.hpp | 5 +- modules/videostab/src/clp.hpp | 8 +- modules/videostab/src/deblurring.cpp | 2 - modules/videostab/src/fast_marching.cpp | 4 +- modules/videostab/src/frame_source.cpp | 6 +- modules/videostab/src/global_motion.cpp | 40 +- modules/videostab/src/inpainting.cpp | 22 +- modules/videostab/src/log.cpp | 2 - modules/videostab/src/motion_stabilizing.cpp | 24 +- modules/videostab/src/optical_flow.cpp | 2 - modules/videostab/src/outlier_rejection.cpp | 4 +- modules/videostab/src/stabilizer.cpp | 20 +- modules/videostab/src/wobble_suppression.cpp | 2 - samples/c/find_obj_ferns.cpp | 2 + samples/c/one_way_sample.cpp | 1 + samples/cpp/calibration_artificial.cpp | 6 +- samples/cpp/distrans.cpp | 1 + samples/cpp/generic_descriptor_match.cpp | 1 + samples/cpp/matcher_simple.cpp | 1 + samples/cpp/matching_to_many_images.cpp | 2 +- samples/cpp/phase_corr.cpp | 6 +- samples/cpp/segment_objects.cpp | 1 + samples/cpp/select3dobj.cpp | 1 + .../ImgTrans/HoughCircle_Demo.cpp | 1 + .../features2D/SURF_FlannMatcher.cpp | 1 + .../features2D/SURF_Homography.cpp | 1 + .../objectDetection/objectDetection.cpp | 4 +- .../objectDetection/objectDetection2.cpp | 4 +- samples/gpu/brox_optical_flow.cpp | 1 + samples/gpu/morphology.cpp | 1 + samples/ocl/facedetect.cpp | 8 +- 310 files changed, 5744 insertions(+), 5964 deletions(-) delete mode 100644 modules/softcascade/perf/perf_precomp. diff --git a/apps/traincascade/HOGfeatures.cpp b/apps/traincascade/HOGfeatures.cpp index 9a562fcad..8bbdee609 100644 --- a/apps/traincascade/HOGfeatures.cpp +++ b/apps/traincascade/HOGfeatures.cpp @@ -4,6 +4,7 @@ #include "HOGfeatures.h" #include "cascadeclassifier.h" +using namespace std; CvHOGFeatureParams::CvHOGFeatureParams() { diff --git a/apps/traincascade/HOGfeatures.h b/apps/traincascade/HOGfeatures.h index a7f33f608..329c6072c 100644 --- a/apps/traincascade/HOGfeatures.h +++ b/apps/traincascade/HOGfeatures.h @@ -26,13 +26,13 @@ public: virtual void writeFeatures( FileStorage &fs, const Mat& featureMap ) const; protected: virtual void generateFeatures(); - virtual void integralHistogram(const Mat &img, vector &histogram, Mat &norm, int nbins) const; + virtual void integralHistogram(const Mat &img, std::vector &histogram, Mat &norm, int nbins) const; class Feature { public: Feature(); Feature( int offset, int x, int y, int cellW, int cellH ); - float calc( const vector &_hists, const Mat &_normSum, size_t y, int featComponent ) const; + float calc( const std::vector &_hists, const Mat &_normSum, size_t y, int featComponent ) const; void write( FileStorage &fs ) const; void write( FileStorage &fs, int varIdx ) const; @@ -43,10 +43,10 @@ protected: int p0, p1, p2, p3; } fastRect[N_CELLS]; }; - vector features; + std::vector features; Mat normSum; //for nomalization calculation (L1 or L2) - vector hist; + std::vector hist; }; inline float CvHOGEvaluator::operator()(int varIdx, int sampleIdx) const @@ -57,7 +57,7 @@ inline float CvHOGEvaluator::operator()(int varIdx, int sampleIdx) const return features[featureIdx].calc( hist, normSum, sampleIdx, componentIdx); } -inline float CvHOGEvaluator::Feature::calc( const vector& _hists, const Mat& _normSum, size_t y, int featComponent ) const +inline float CvHOGEvaluator::Feature::calc( const std::vector& _hists, const Mat& _normSum, size_t y, int featComponent ) const { float normFactor; float res; diff --git a/apps/traincascade/boost.cpp b/apps/traincascade/boost.cpp index d94539409..ea12c194e 100644 --- a/apps/traincascade/boost.cpp +++ b/apps/traincascade/boost.cpp @@ -160,10 +160,10 @@ CvCascadeBoostParams::CvCascadeBoostParams( int _boostType, void CvCascadeBoostParams::write( FileStorage &fs ) const { - String boostTypeStr = boost_type == CvBoost::DISCRETE ? CC_DISCRETE_BOOST : + string boostTypeStr = boost_type == CvBoost::DISCRETE ? CC_DISCRETE_BOOST : boost_type == CvBoost::REAL ? CC_REAL_BOOST : boost_type == CvBoost::LOGIT ? CC_LOGIT_BOOST : - boost_type == CvBoost::GENTLE ? CC_GENTLE_BOOST : String(); + boost_type == CvBoost::GENTLE ? CC_GENTLE_BOOST : string(); CV_Assert( !boostTypeStr.empty() ); fs << CC_BOOST_TYPE << boostTypeStr; fs << CC_MINHITRATE << minHitRate; @@ -175,7 +175,7 @@ void CvCascadeBoostParams::write( FileStorage &fs ) const bool CvCascadeBoostParams::read( const FileNode &node ) { - String boostTypeStr; + string boostTypeStr; FileNode rnode = node[CC_BOOST_TYPE]; rnode >> boostTypeStr; boost_type = !boostTypeStr.compare( CC_DISCRETE_BOOST ) ? CvBoost::DISCRETE : @@ -213,10 +213,10 @@ void CvCascadeBoostParams::printDefaults() const void CvCascadeBoostParams::printAttrs() const { - String boostTypeStr = boost_type == CvBoost::DISCRETE ? CC_DISCRETE_BOOST : + string boostTypeStr = boost_type == CvBoost::DISCRETE ? CC_DISCRETE_BOOST : boost_type == CvBoost::REAL ? CC_REAL_BOOST : boost_type == CvBoost::LOGIT ? CC_LOGIT_BOOST : - boost_type == CvBoost::GENTLE ? CC_GENTLE_BOOST : String(); + boost_type == CvBoost::GENTLE ? CC_GENTLE_BOOST : string(); CV_Assert( !boostTypeStr.empty() ); cout << "boostType: " << boostTypeStr << endl; cout << "minHitRate: " << minHitRate << endl; @@ -226,7 +226,7 @@ void CvCascadeBoostParams::printAttrs() const cout << "maxWeakCount: " << weak_count << endl; } -bool CvCascadeBoostParams::scanAttr( const String prmName, const String val) +bool CvCascadeBoostParams::scanAttr( const string prmName, const string val) { bool res = true; diff --git a/apps/traincascade/boost.h b/apps/traincascade/boost.h index 16f7c2ce1..2a080484b 100644 --- a/apps/traincascade/boost.h +++ b/apps/traincascade/boost.h @@ -17,7 +17,7 @@ struct CvCascadeBoostParams : CvBoostParams bool read( const FileNode &node ); virtual void printDefaults() const; virtual void printAttrs() const; - virtual bool scanAttr( const String prmName, const String val); + virtual bool scanAttr( const std::string prmName, const std::string val); }; struct CvCascadeBoostTrainData : CvDTreeTrainData diff --git a/apps/traincascade/cascadeclassifier.cpp b/apps/traincascade/cascadeclassifier.cpp index 00674ff8e..66f687691 100644 --- a/apps/traincascade/cascadeclassifier.cpp +++ b/apps/traincascade/cascadeclassifier.cpp @@ -24,10 +24,10 @@ CvCascadeParams::CvCascadeParams( int _stageType, int _featureType ) : stageType void CvCascadeParams::write( FileStorage &fs ) const { - String stageTypeStr = stageType == BOOST ? CC_BOOST : String(); + string stageTypeStr = stageType == BOOST ? CC_BOOST : string(); CV_Assert( !stageTypeStr.empty() ); fs << CC_STAGE_TYPE << stageTypeStr; - String featureTypeStr = featureType == CvFeatureParams::HAAR ? CC_HAAR : + string featureTypeStr = featureType == CvFeatureParams::HAAR ? CC_HAAR : featureType == CvFeatureParams::LBP ? CC_LBP : featureType == CvFeatureParams::HOG ? CC_HOG : 0; @@ -41,7 +41,7 @@ bool CvCascadeParams::read( const FileNode &node ) { if ( node.empty() ) return false; - String stageTypeStr, featureTypeStr; + string stageTypeStr, featureTypeStr; FileNode rnode = node[CC_STAGE_TYPE]; if ( !rnode.isString() ) return false; @@ -96,7 +96,7 @@ void CvCascadeParams::printAttrs() const cout << "sampleHeight: " << winSize.height << endl; } -bool CvCascadeParams::scanAttr( const String prmName, const String val ) +bool CvCascadeParams::scanAttr( const string prmName, const string val ) { bool res = true; if( !prmName.compare( "-stageType" ) ) @@ -126,9 +126,9 @@ bool CvCascadeParams::scanAttr( const String prmName, const String val ) //---------------------------- CascadeClassifier -------------------------------------- -bool CvCascadeClassifier::train( const String _cascadeDirName, - const String _posFilename, - const String _negFilename, +bool CvCascadeClassifier::train( const string _cascadeDirName, + const string _posFilename, + const string _negFilename, int _numPos, int _numNeg, int _precalcValBufSize, int _precalcIdxBufSize, int _numStages, @@ -399,7 +399,7 @@ bool CvCascadeClassifier::readStages( const FileNode &node) #define ICV_HAAR_PARENT_NAME "parent" #define ICV_HAAR_NEXT_NAME "next" -void CvCascadeClassifier::save( const String filename, bool baseFormat ) +void CvCascadeClassifier::save( const string filename, bool baseFormat ) { FileStorage fs( filename, FileStorage::WRITE ); @@ -491,7 +491,7 @@ void CvCascadeClassifier::save( const String filename, bool baseFormat ) fs << "}"; } -bool CvCascadeClassifier::load( const String cascadeDirName ) +bool CvCascadeClassifier::load( const string cascadeDirName ) { FileStorage fs( cascadeDirName + CC_PARAMS_FILENAME, FileStorage::READ ); if ( !fs.isOpened() ) diff --git a/apps/traincascade/cascadeclassifier.h b/apps/traincascade/cascadeclassifier.h index 6890068c2..3eb50b526 100644 --- a/apps/traincascade/cascadeclassifier.h +++ b/apps/traincascade/cascadeclassifier.h @@ -77,7 +77,7 @@ public: void printDefaults() const; void printAttrs() const; - bool scanAttr( const String prmName, const String val ); + bool scanAttr( const std::string prmName, const std::string val ); int stageType; int featureType; @@ -87,9 +87,9 @@ public: class CvCascadeClassifier { public: - bool train( const String _cascadeDirName, - const String _posFilename, - const String _negFilename, + bool train( const std::string _cascadeDirName, + const std::string _posFilename, + const std::string _negFilename, int _numPos, int _numNeg, int _precalcValBufSize, int _precalcIdxBufSize, int _numStages, @@ -99,8 +99,8 @@ public: bool baseFormatSave = false ); private: int predict( int sampleIdx ); - void save( const String cascadeDirName, bool baseFormat = false ); - bool load( const String cascadeDirName ); + void save( const std::string cascadeDirName, bool baseFormat = false ); + bool load( const std::string cascadeDirName ); bool updateTrainingSet( double& acceptanceRatio ); int fillPassedSamples( int first, int count, bool isPositive, int64& consumed ); @@ -117,7 +117,7 @@ private: Ptr stageParams; Ptr featureEvaluator; - vector< Ptr > stageClassifiers; + std::vector< Ptr > stageClassifiers; CvCascadeImageReader imgReader; int numStages, curNumSamples; int numPos, numNeg; diff --git a/apps/traincascade/features.cpp b/apps/traincascade/features.cpp index effa4dcc5..9629509f3 100644 --- a/apps/traincascade/features.cpp +++ b/apps/traincascade/features.cpp @@ -24,7 +24,7 @@ CvParams::CvParams() : name( "params" ) {} void CvParams::printDefaults() const { cout << "--" << name << "--" << endl; } void CvParams::printAttrs() const {} -bool CvParams::scanAttr( const String, const String ) { return false; } +bool CvParams::scanAttr( const string, const string ) { return false; } //---------------------------- FeatureParams -------------------------------------- diff --git a/apps/traincascade/haarfeatures.cpp b/apps/traincascade/haarfeatures.cpp index 0298b42a7..9f8bce083 100644 --- a/apps/traincascade/haarfeatures.cpp +++ b/apps/traincascade/haarfeatures.cpp @@ -25,9 +25,9 @@ void CvHaarFeatureParams::init( const CvFeatureParams& fp ) void CvHaarFeatureParams::write( FileStorage &fs ) const { CvFeatureParams::write( fs ); - String modeStr = mode == BASIC ? CC_MODE_BASIC : + string modeStr = mode == BASIC ? CC_MODE_BASIC : mode == CORE ? CC_MODE_CORE : - mode == ALL ? CC_MODE_ALL : String(); + mode == ALL ? CC_MODE_ALL : string(); CV_Assert( !modeStr.empty() ); fs << CC_MODE << modeStr; } @@ -40,7 +40,7 @@ bool CvHaarFeatureParams::read( const FileNode &node ) FileNode rnode = node[CC_MODE]; if( !rnode.isString() ) return false; - String modeStr; + string modeStr; rnode >> modeStr; mode = !modeStr.compare( CC_MODE_BASIC ) ? BASIC : !modeStr.compare( CC_MODE_CORE ) ? CORE : @@ -58,13 +58,13 @@ void CvHaarFeatureParams::printDefaults() const void CvHaarFeatureParams::printAttrs() const { CvFeatureParams::printAttrs(); - String mode_str = mode == BASIC ? CC_MODE_BASIC : + string mode_str = mode == BASIC ? CC_MODE_BASIC : mode == CORE ? CC_MODE_CORE : mode == ALL ? CC_MODE_ALL : 0; cout << "mode: " << mode_str << endl; } -bool CvHaarFeatureParams::scanAttr( const String prmName, const String val) +bool CvHaarFeatureParams::scanAttr( const string prmName, const string val) { if ( !CvFeatureParams::scanAttr( prmName, val ) ) { diff --git a/apps/traincascade/haarfeatures.h b/apps/traincascade/haarfeatures.h index 64739027a..472822bb8 100644 --- a/apps/traincascade/haarfeatures.h +++ b/apps/traincascade/haarfeatures.h @@ -23,7 +23,7 @@ public: virtual void printDefaults() const; virtual void printAttrs() const; - virtual bool scanAttr( const String prm, const String val); + virtual bool scanAttr( const std::string prm, const std::string val); int mode; }; @@ -64,7 +64,7 @@ protected: } fastRect[CV_HAAR_FEATURE_MAX]; }; - vector features; + std::vector features; Mat sum; /* sum images (each row represents image) */ Mat tilted; /* tilted sum images (each row represents image) */ Mat normfactor; /* normalization factor */ diff --git a/apps/traincascade/imagestorage.cpp b/apps/traincascade/imagestorage.cpp index 0f749f9b0..9faf84aa0 100644 --- a/apps/traincascade/imagestorage.cpp +++ b/apps/traincascade/imagestorage.cpp @@ -7,7 +7,9 @@ #include #include -bool CvCascadeImageReader::create( const String _posFilename, const String _negFilename, Size _winSize ) +using namespace std; + +bool CvCascadeImageReader::create( const string _posFilename, const string _negFilename, Size _winSize ) { return posReader.create(_posFilename) && negReader.create(_negFilename, _winSize); } @@ -22,21 +24,21 @@ CvCascadeImageReader::NegReader::NegReader() stepFactor = 0.5F; } -bool CvCascadeImageReader::NegReader::create( const String _filename, Size _winSize ) +bool CvCascadeImageReader::NegReader::create( const string _filename, Size _winSize ) { - String dirname, str; + string dirname, str; std::ifstream file(_filename.c_str()); if ( !file.is_open() ) return false; size_t pos = _filename.rfind('\\'); char dlmrt = '\\'; - if (pos == String::npos) + if (pos == string::npos) { pos = _filename.rfind('/'); dlmrt = '/'; } - dirname = pos == String::npos ? "" : _filename.substr(0, pos) + dlmrt; + dirname = pos == string::npos ? "" : _filename.substr(0, pos) + dlmrt; while( !file.eof() ) { std::getline(file, str); @@ -64,8 +66,8 @@ bool CvCascadeImageReader::NegReader::nextImg() round = round % (winSize.width * winSize.height); last %= count; - _offset.x = min( (int)round % winSize.width, src.cols - winSize.width ); - _offset.y = min( (int)round / winSize.width, src.rows - winSize.height ); + _offset.x = std::min( (int)round % winSize.width, src.cols - winSize.width ); + _offset.y = std::min( (int)round / winSize.width, src.rows - winSize.height ); if( !src.empty() && src.type() == CV_8UC1 && offset.x >= 0 && offset.y >= 0 ) break; @@ -126,7 +128,7 @@ CvCascadeImageReader::PosReader::PosReader() vec = 0; } -bool CvCascadeImageReader::PosReader::create( const String _filename ) +bool CvCascadeImageReader::PosReader::create( const string _filename ) { if ( file ) fclose( file ); diff --git a/apps/traincascade/imagestorage.h b/apps/traincascade/imagestorage.h index 91a4e5e87..dd08e664d 100644 --- a/apps/traincascade/imagestorage.h +++ b/apps/traincascade/imagestorage.h @@ -8,7 +8,7 @@ using namespace cv; class CvCascadeImageReader { public: - bool create( const String _posFilename, const String _negFilename, Size _winSize ); + bool create( const std::string _posFilename, const std::string _negFilename, Size _winSize ); void restart() { posReader.restart(); } bool getNeg(Mat &_img) { return negReader.get( _img ); } bool getPos(Mat &_img) { return posReader.get( _img ); } @@ -19,7 +19,7 @@ private: public: PosReader(); virtual ~PosReader(); - bool create( const String _filename ); + bool create( const std::string _filename ); bool get( Mat &_img ); void restart(); @@ -35,12 +35,12 @@ private: { public: NegReader(); - bool create( const String _filename, Size _winSize ); + bool create( const std::string _filename, Size _winSize ); bool get( Mat& _img ); bool nextImg(); Mat src, img; - vector imgFilenames; + std::vector imgFilenames; Point offset, point; float scale; float scaleFactor; diff --git a/apps/traincascade/lbpfeatures.h b/apps/traincascade/lbpfeatures.h index 30c35374d..d4397c442 100644 --- a/apps/traincascade/lbpfeatures.h +++ b/apps/traincascade/lbpfeatures.h @@ -34,7 +34,7 @@ protected: Rect rect; int p[16]; }; - vector features; + std::vector features; Mat sum; }; diff --git a/apps/traincascade/traincascade.cpp b/apps/traincascade/traincascade.cpp index 5a969f434..dfb49b507 100644 --- a/apps/traincascade/traincascade.cpp +++ b/apps/traincascade/traincascade.cpp @@ -9,7 +9,7 @@ using namespace std; int main( int argc, char* argv[] ) { CvCascadeClassifier classifier; - String cascadeDirName, vecName, bgName; + string cascadeDirName, vecName, bgName; int numPos = 2000; int numNeg = 1000; int numStages = 20; diff --git a/apps/traincascade/traincascade_features.h b/apps/traincascade/traincascade_features.h index 019a4b9b3..dde0f1a7f 100644 --- a/apps/traincascade/traincascade_features.h +++ b/apps/traincascade/traincascade_features.h @@ -33,7 +33,7 @@ float calcNormFactor( const Mat& sum, const Mat& sqSum ); template -void _writeFeatures( const vector features, FileStorage &fs, const Mat& featureMap ) +void _writeFeatures( const std::vector features, FileStorage &fs, const Mat& featureMap ) { fs << FEATURES << "["; const Mat_& featureMap_ = (const Mat_&)featureMap; @@ -58,8 +58,8 @@ public: // from|to screen virtual void printDefaults() const; virtual void printAttrs() const; - virtual bool scanAttr( const String prmName, const String val ); - String name; + virtual bool scanAttr( const std::string prmName, const std::string val ); + std::string name; }; class CvFeatureParams : public CvParams diff --git a/modules/androidcamera/src/camera_activity.cpp b/modules/androidcamera/src/camera_activity.cpp index 508159b17..9ea54d78b 100644 --- a/modules/androidcamera/src/camera_activity.cpp +++ b/modules/androidcamera/src/camera_activity.cpp @@ -28,9 +28,6 @@ #include #include - -using namespace std; - class CameraWrapperConnector { public: @@ -50,7 +47,7 @@ private: static std::string getDefaultPathLibFolder(); static CameraActivity::ErrorCode connectToLib(); static CameraActivity::ErrorCode getSymbolFromLib(void * libHandle, const char* symbolName, void** ppSymbol); - static void fillListWrapperLibs(const string& folderPath, vector& listLibs); + static void fillListWrapperLibs(const std::string& folderPath, std::vector& listLibs); static InitCameraConnectC pInitCameraC; static CloseCameraConnectC pCloseCameraC; @@ -168,7 +165,7 @@ CameraActivity::ErrorCode CameraWrapperConnector::connectToLib() } dlerror(); - string folderPath = getPathLibFolder(); + std::string folderPath = getPathLibFolder(); if (folderPath.empty()) { LOGD("Trying to find native camera in default OpenCV packages"); @@ -177,12 +174,12 @@ CameraActivity::ErrorCode CameraWrapperConnector::connectToLib() LOGD("CameraWrapperConnector::connectToLib: folderPath=%s", folderPath.c_str()); - vector listLibs; + std::vector listLibs; fillListWrapperLibs(folderPath, listLibs); - std::sort(listLibs.begin(), listLibs.end(), std::greater()); + std::sort(listLibs.begin(), listLibs.end(), std::greater()); void * libHandle=0; - string cur_path; + std::string cur_path; for(size_t i = 0; i < listLibs.size(); i++) { cur_path=folderPath + listLibs[i]; LOGD("try to load library '%s'", listLibs[i].c_str()); @@ -248,7 +245,7 @@ CameraActivity::ErrorCode CameraWrapperConnector::getSymbolFromLib(void* libHand return CameraActivity::NO_ERROR; } -void CameraWrapperConnector::fillListWrapperLibs(const string& folderPath, vector& listLibs) +void CameraWrapperConnector::fillListWrapperLibs(const std::string& folderPath, std::vector& listLibs) { DIR *dp; struct dirent *ep; @@ -290,7 +287,7 @@ std::string CameraWrapperConnector::getDefaultPathLibFolder() } } - return string(); + return std::string(); } std::string CameraWrapperConnector::getPathLibFolder() @@ -361,10 +358,10 @@ std::string CameraWrapperConnector::getPathLibFolder() LOGE("Could not get library name and base address"); } - return string(); + return std::string(); } -void CameraWrapperConnector::setPathLibFolder(const string& path) +void CameraWrapperConnector::setPathLibFolder(const std::string& path) { pathLibFolder=path; } diff --git a/modules/calib3d/perf/perf_cicrlesGrid.cpp b/modules/calib3d/perf/perf_cicrlesGrid.cpp index 523fdf099..0b0a10017 100644 --- a/modules/calib3d/perf/perf_cicrlesGrid.cpp +++ b/modules/calib3d/perf/perf_cicrlesGrid.cpp @@ -22,7 +22,7 @@ PERF_TEST_P(String_Size, asymm_circles_grid, testing::Values( ) ) { - String filename = getDataPath(get<0>(GetParam())); + string filename = getDataPath(get<0>(GetParam())); Size gridSize = get<1>(GetParam()); Mat frame = imread(filename); diff --git a/modules/calib3d/src/calibinit.cpp b/modules/calib3d/src/calibinit.cpp index 5e6ea1d28..44ef0fa61 100644 --- a/modules/calib3d/src/calibinit.cpp +++ b/modules/calib3d/src/calibinit.cpp @@ -1903,7 +1903,7 @@ bool cv::findChessboardCorners( InputArray _image, Size patternSize, OutputArray corners, int flags ) { int count = patternSize.area()*2; - vector tmpcorners(count+1); + std::vector tmpcorners(count+1); Mat image = _image.getMat(); CvMat c_image = image; bool ok = cvFindChessboardCorners(&c_image, patternSize, (CvPoint2D32f*)&tmpcorners[0], &count, flags ) > 0; @@ -1949,11 +1949,11 @@ bool cv::findCirclesGrid( InputArray _image, Size patternSize, CV_Assert(isAsymmetricGrid ^ isSymmetricGrid); Mat image = _image.getMat(); - vector centers; + std::vector centers; - vector keypoints; + std::vector keypoints; blobDetector->detect(image, keypoints); - vector points; + std::vector points; for (size_t i = 0; i < keypoints.size(); i++) { points.push_back (keypoints[i].pt); diff --git a/modules/calib3d/src/calibration.cpp b/modules/calib3d/src/calibration.cpp index e48393502..5937864e9 100644 --- a/modules/calib3d/src/calibration.cpp +++ b/modules/calib3d/src/calibration.cpp @@ -546,7 +546,7 @@ CV_IMPL int cvRodrigues2( const CvMat* src, CvMat* dst, CvMat* jacobian ) ry = src->data.db[step]; rz = src->data.db[step*2]; } - theta = sqrt(rx*rx + ry*ry + rz*rz); + theta = std::sqrt(rx*rx + ry*ry + rz*rz); if( theta < DBL_EPSILON ) { @@ -632,7 +632,7 @@ CV_IMPL int cvRodrigues2( const CvMat* src, CvMat* dst, CvMat* jacobian ) ry = R[2] - R[6]; rz = R[3] - R[1]; - s = sqrt((rx*rx + ry*ry + rz*rz)*0.25); + s = std::sqrt((rx*rx + ry*ry + rz*rz)*0.25); c = (R[0] + R[4] + R[8] - 1)*0.5; c = c > 1. ? 1. : c < -1. ? -1. : c; theta = acos(c); @@ -646,14 +646,14 @@ CV_IMPL int cvRodrigues2( const CvMat* src, CvMat* dst, CvMat* jacobian ) else { t = (R[0] + 1)*0.5; - rx = sqrt(MAX(t,0.)); + rx = std::sqrt(MAX(t,0.)); t = (R[4] + 1)*0.5; - ry = sqrt(MAX(t,0.))*(R[1] < 0 ? -1. : 1.); + ry = std::sqrt(MAX(t,0.))*(R[1] < 0 ? -1. : 1.); t = (R[8] + 1)*0.5; - rz = sqrt(MAX(t,0.))*(R[2] < 0 ? -1. : 1.); + rz = std::sqrt(MAX(t,0.))*(R[2] < 0 ? -1. : 1.); if( fabs(rx) < fabs(ry) && fabs(rx) < fabs(rz) && (R[5] > 0) != (ry*rz > 0) ) rz = -rz; - theta /= sqrt(rx*rx + ry*ry + rz*rz); + theta /= std::sqrt(rx*rx + ry*ry + rz*rz); rx *= theta; ry *= theta; rz *= theta; @@ -1249,8 +1249,8 @@ CV_IMPL void cvFindExtrinsicCameraParams2( const CvMat* objectPoints, cvGetCol( &matH, &_h1, 0 ); _h2 = _h1; _h2.data.db++; _h3 = _h2; _h3.data.db++; - h1_norm = sqrt(h[0]*h[0] + h[3]*h[3] + h[6]*h[6]); - h2_norm = sqrt(h[1]*h[1] + h[4]*h[4] + h[7]*h[7]); + h1_norm = std::sqrt(h[0]*h[0] + h[3]*h[3] + h[6]*h[6]); + h2_norm = std::sqrt(h[1]*h[1] + h[4]*h[4] + h[7]*h[7]); cvScale( &_h1, &_h1, 1./MAX(h1_norm, DBL_EPSILON) ); cvScale( &_h2, &_h2, 1./MAX(h2_norm, DBL_EPSILON) ); @@ -1424,7 +1424,7 @@ CV_IMPL void cvInitIntrinsicParams2D( const CvMat* objectPoints, } for( j = 0; j < 4; j++ ) - n[j] = 1./sqrt(n[j]); + n[j] = 1./std::sqrt(n[j]); for( j = 0; j < 3; j++ ) { @@ -1438,8 +1438,8 @@ CV_IMPL void cvInitIntrinsicParams2D( const CvMat* objectPoints, } cvSolve( matA, _b, &_f, CV_NORMAL + CV_SVD ); - a[0] = sqrt(fabs(1./f[0])); - a[4] = sqrt(fabs(1./f[1])); + a[0] = std::sqrt(fabs(1./f[0])); + a[4] = std::sqrt(fabs(1./f[1])); if( aspectRatio != 0 ) { double tf = (a[0] + a[4])/(aspectRatio + 1.); @@ -2721,7 +2721,7 @@ CV_IMPL int cvStereoRectifyUncalibrated( cvMatMul( &T, &E2, &E2 ); int mirror = e2[0] < 0; - double d = MAX(sqrt(e2[0]*e2[0] + e2[1]*e2[1]),DBL_EPSILON); + double d = MAX(std::sqrt(e2[0]*e2[0] + e2[1]*e2[1]),DBL_EPSILON); double alpha = e2[0]/d; double beta = e2[1]/d; double r[] = @@ -2841,7 +2841,7 @@ void cv::reprojectImageTo3D( InputArray _disparity, int x, cols = disparity.cols; CV_Assert( cols >= 0 ); - vector _sbuf(cols+1), _dbuf(cols*3+1); + std::vector _sbuf(cols+1), _dbuf(cols*3+1); float* sbuf = &_sbuf[0], *dbuf = &_dbuf[0]; double minDisparity = FLT_MAX; @@ -2958,7 +2958,7 @@ cvRQDecomp3x3( const CvMat *matrixM, CvMat *matrixR, CvMat *matrixQ, */ s = matM[2][1]; c = matM[2][2]; - z = 1./sqrt(c * c + s * s + DBL_EPSILON); + z = 1./std::sqrt(c * c + s * s + DBL_EPSILON); c *= z; s *= z; @@ -2977,7 +2977,7 @@ cvRQDecomp3x3( const CvMat *matrixM, CvMat *matrixR, CvMat *matrixQ, */ s = -matR[2][0]; c = matR[2][2]; - z = 1./sqrt(c * c + s * s + DBL_EPSILON); + z = 1./std::sqrt(c * c + s * s + DBL_EPSILON); c *= z; s *= z; @@ -2997,7 +2997,7 @@ cvRQDecomp3x3( const CvMat *matrixM, CvMat *matrixR, CvMat *matrixQ, s = matM[1][0]; c = matM[1][1]; - z = 1./sqrt(c * c + s * s + DBL_EPSILON); + z = 1./std::sqrt(c * c + s * s + DBL_EPSILON); c *= z; s *= z; @@ -3683,7 +3683,7 @@ static void adjust3rdMatrix(InputArrayOfArrays _imgpt1_0, const Mat& R1, const Mat& R3, const Mat& P1, Mat& P3 ) { size_t n1 = _imgpt1_0.total(), n3 = _imgpt3_0.total(); - vector imgpt1, imgpt3; + std::vector imgpt1, imgpt3; for( int i = 0; i < (int)std::min(n1, n3); i++ ) { diff --git a/modules/calib3d/src/circlesgrid.cpp b/modules/calib3d/src/circlesgrid.cpp index 853e3ada5..3bd46200d 100644 --- a/modules/calib3d/src/circlesgrid.cpp +++ b/modules/calib3d/src/circlesgrid.cpp @@ -53,10 +53,9 @@ #endif using namespace cv; -using namespace std; #ifdef DEBUG_CIRCLES -void drawPoints(const vector &points, Mat &outImage, int radius = 2, Scalar color = Scalar::all(255), int thickness = -1) +void drawPoints(const std::vector &points, Mat &outImage, int radius = 2, Scalar color = Scalar::all(255), int thickness = -1) { for(size_t i=0; i &points, Mat &outImage, int radius = 2, S } #endif -void CirclesGridClusterFinder::hierarchicalClustering(const vector points, const Size &patternSz, vector &patternPoints) +void CirclesGridClusterFinder::hierarchicalClustering(const std::vector points, const Size &patternSz, std::vector &patternPoints) { #ifdef HAVE_TEGRA_OPTIMIZATION if(tegra::hierarchicalClustering(points, patternSz, patternPoints)) @@ -96,7 +95,7 @@ void CirclesGridClusterFinder::hierarchicalClustering(const vector poin } } - vector > clusters(points.size()); + std::vector > clusters(points.size()); for(size_t i=0; i poin } } -void CirclesGridClusterFinder::findGrid(const std::vector points, cv::Size _patternSize, vector& centers) +void CirclesGridClusterFinder::findGrid(const std::vector points, cv::Size _patternSize, std::vector& centers) { patternSize = _patternSize; centers.clear(); @@ -143,7 +142,7 @@ void CirclesGridClusterFinder::findGrid(const std::vector points, c return; } - vector patternPoints; + std::vector patternPoints; hierarchicalClustering(points, patternSize, patternPoints); if(patternPoints.empty()) { @@ -156,18 +155,18 @@ void CirclesGridClusterFinder::findGrid(const std::vector points, c imshow("pattern points", patternPointsImage); #endif - vector hull2f; + std::vector hull2f; convexHull(Mat(patternPoints), hull2f, false); const size_t cornersCount = isAsymmetricGrid ? 6 : 4; if(hull2f.size() < cornersCount) return; - vector corners; + std::vector corners; findCorners(hull2f, corners); if(corners.size() != cornersCount) return; - vector outsideCorners, sortedCorners; + std::vector outsideCorners, sortedCorners; if(isAsymmetricGrid) { findOutsideCorners(corners, outsideCorners); @@ -179,7 +178,7 @@ void CirclesGridClusterFinder::findGrid(const std::vector points, c if(sortedCorners.size() != cornersCount) return; - vector rectifiedPatternPoints; + std::vector rectifiedPatternPoints; rectifyPatternPoints(patternPoints, sortedCorners, rectifiedPatternPoints); if(patternPoints.size() != rectifiedPatternPoints.size()) return; @@ -190,7 +189,7 @@ void CirclesGridClusterFinder::findGrid(const std::vector points, c void CirclesGridClusterFinder::findCorners(const std::vector &hull2f, std::vector &corners) { //find angles (cosines) of vertices in convex hull - vector angles; + std::vector angles; for(size_t i=0; i imshow("corners", cornersImage); #endif - vector tangentVectors(corners.size()); + std::vector tangentVectors(corners.size()); for(size_t k=0; k & Point2f center = std::accumulate(corners.begin(), corners.end(), Point2f(0.0f, 0.0f)); center *= 1.0 / corners.size(); - vector centerToCorners; + std::vector centerToCorners; for(size_t i=0; i & std::vector::const_iterator firstCornerIterator = std::find(hull2f.begin(), hull2f.end(), firstCorner); sortedCorners.clear(); - for(vector::const_iterator it = firstCornerIterator; it != hull2f.end(); it++) + for(std::vector::const_iterator it = firstCornerIterator; it != hull2f.end(); it++) { - vector::const_iterator itCorners = std::find(corners.begin(), corners.end(), *it); + std::vector::const_iterator itCorners = std::find(corners.begin(), corners.end(), *it); if(itCorners != corners.end()) { sortedCorners.push_back(*it); } } - for(vector::const_iterator it = hull2f.begin(); it != firstCornerIterator; it++) + for(std::vector::const_iterator it = hull2f.begin(); it != firstCornerIterator; it++) { - vector::const_iterator itCorners = std::find(corners.begin(), corners.end(), *it); + std::vector::const_iterator itCorners = std::find(corners.begin(), corners.end(), *it); if(itCorners != corners.end()) { sortedCorners.push_back(*it); @@ -354,7 +353,7 @@ void CirclesGridClusterFinder::getSortedCorners(const std::vector & void CirclesGridClusterFinder::rectifyPatternPoints(const std::vector &patternPoints, const std::vector &sortedCorners, std::vector &rectifiedPatternPoints) { //indices of corner points in pattern - vector trueIndices; + std::vector trueIndices; trueIndices.push_back(Point(0, 0)); trueIndices.push_back(Point(patternSize.width - 1, 0)); if(isAsymmetricGrid) @@ -365,7 +364,7 @@ void CirclesGridClusterFinder::rectifyPatternPoints(const std::vector idealPoints; + std::vector idealPoints; for(size_t idx=0; idx else idealPt = Point2f(j*squareSize, i*squareSize); - vector query = Mat(idealPt); + std::vector query = Mat(idealPt); int knn = 1; - vector indices(knn); - vector dists(knn); + std::vector indices(knn); + std::vector dists(knn); flannIndex.knnSearch(query, indices, dists, knn, flann::SearchParams()); centers.push_back(patternPoints.at(indices[0])); @@ -439,7 +438,7 @@ void Graph::addVertex(size_t id) { assert( !doesVertexExist( id ) ); - vertices.insert(pair (id, Vertex())); + vertices.insert(std::pair (id, Vertex())); } void Graph::addEdge(size_t id1, size_t id2) @@ -534,7 +533,7 @@ CirclesGridFinder::Segment::Segment(cv::Point2f _s, cv::Point2f _e) : { } -void computeShortestPath(Mat &predecessorMatrix, int v1, int v2, vector &path); +void computeShortestPath(Mat &predecessorMatrix, int v1, int v2, std::vector &path); void computePredecessorMatrix(const Mat &dm, int verticesCount, Mat &predecessorMatrix); CirclesGridFinderParameters::CirclesGridFinderParameters() @@ -557,7 +556,7 @@ CirclesGridFinderParameters::CirclesGridFinderParameters() gridType = SYMMETRIC_GRID; } -CirclesGridFinder::CirclesGridFinder(Size _patternSize, const vector &testKeypoints, +CirclesGridFinder::CirclesGridFinder(Size _patternSize, const std::vector &testKeypoints, const CirclesGridFinderParameters &_parameters) : patternSize(static_cast (_patternSize.width), static_cast (_patternSize.height)) { @@ -575,11 +574,11 @@ bool CirclesGridFinder::findHoles() { case CirclesGridFinderParameters::SYMMETRIC_GRID: { - vector vectors, filteredVectors, basis; + std::vector vectors, filteredVectors, basis; Graph rng(0); computeRNG(rng, vectors); filterOutliersByDensity(vectors, filteredVectors); - vector basisGraphs; + std::vector basisGraphs; findBasis(filteredVectors, basis, basisGraphs); findMCS(basis, basisGraphs); break; @@ -587,12 +586,12 @@ bool CirclesGridFinder::findHoles() case CirclesGridFinderParameters::ASYMMETRIC_GRID: { - vector vectors, tmpVectors, filteredVectors, basis; + std::vector vectors, tmpVectors, filteredVectors, basis; Graph rng(0); computeRNG(rng, tmpVectors); rng2gridGraph(rng, vectors); filterOutliersByDensity(vectors, filteredVectors); - vector basisGraphs; + std::vector basisGraphs; findBasis(filteredVectors, basis, basisGraphs); findMCS(basis, basisGraphs); eraseUsedGraph(basisGraphs); @@ -635,7 +634,7 @@ void CirclesGridFinder::rng2gridGraph(Graph &rng, std::vector &vect } } -void CirclesGridFinder::eraseUsedGraph(vector &basisGraphs) const +void CirclesGridFinder::eraseUsedGraph(std::vector &basisGraphs) const { for (size_t i = 0; i < holes.size(); i++) { @@ -666,7 +665,7 @@ bool CirclesGridFinder::isDetectionCorrect() if (holes.size() != patternSize.height) return false; - set vertices; + std::set vertices; for (size_t i = 0; i < holes.size(); i++) { if (holes[i].size() != patternSize.width) @@ -714,7 +713,7 @@ bool CirclesGridFinder::isDetectionCorrect() return false; } - set vertices; + std::set vertices; for (size_t i = 0; i < largeHoles->size(); i++) { if (largeHoles->at(i).size() != lw) @@ -750,12 +749,12 @@ bool CirclesGridFinder::isDetectionCorrect() return false; } -void CirclesGridFinder::findMCS(const vector &basis, vector &basisGraphs) +void CirclesGridFinder::findMCS(const std::vector &basis, std::vector &basisGraphs) { holes.clear(); Path longestPath; size_t bestGraphIdx = findLongestPath(basisGraphs, longestPath); - vector holesRow = longestPath.vertices; + std::vector holesRow = longestPath.vertices; while (holesRow.size() > std::max(patternSize.width, patternSize.height)) { @@ -809,14 +808,14 @@ void CirclesGridFinder::findMCS(const vector &basis, vector &bas } } -Mat CirclesGridFinder::rectifyGrid(Size detectedGridSize, const vector& centers, - const vector &keypoints, vector &warpedKeypoints) +Mat CirclesGridFinder::rectifyGrid(Size detectedGridSize, const std::vector& centers, + const std::vector &keypoints, std::vector &warpedKeypoints) { assert( !centers.empty() ); const float edgeLength = 30; const Point2f offset(150, 150); - vector dstPoints; + std::vector dstPoints; bool isClockwiseBefore = getDirection(centers[0], centers[detectedGridSize.width - 1], centers[centers.size() - 1]) < 0; @@ -834,7 +833,7 @@ Mat CirclesGridFinder::rectifyGrid(Size detectedGridSize, const vector& Mat H = findHomography(Mat(centers), Mat(dstPoints), CV_RANSAC); //Mat H = findHomography( Mat( corners ), Mat( dstPoints ) ); - vector srcKeypoints; + std::vector srcKeypoints; for (size_t i = 0; i < keypoints.size(); i++) { srcKeypoints.push_back(keypoints[i]); @@ -842,7 +841,7 @@ Mat CirclesGridFinder::rectifyGrid(Size detectedGridSize, const vector& Mat dstKeypointsMat; transform(Mat(srcKeypoints), dstKeypointsMat, H); - vector dstKeypoints; + std::vector dstKeypoints; convertPointsFromHomogeneous(dstKeypointsMat, dstKeypoints); warpedKeypoints.clear(); @@ -871,7 +870,7 @@ size_t CirclesGridFinder::findNearestKeypoint(Point2f pt) const return bestIdx; } -void CirclesGridFinder::addPoint(Point2f pt, vector &points) +void CirclesGridFinder::addPoint(Point2f pt, std::vector &points) { size_t ptIdx = findNearestKeypoint(pt); if (norm(keypoints[ptIdx] - pt) > parameters.minDistanceToAddKeypoint) @@ -886,8 +885,8 @@ void CirclesGridFinder::addPoint(Point2f pt, vector &points) } } -void CirclesGridFinder::findCandidateLine(vector &line, size_t seedLineIdx, bool addRow, Point2f basisVec, - vector &seeds) +void CirclesGridFinder::findCandidateLine(std::vector &line, size_t seedLineIdx, bool addRow, Point2f basisVec, + std::vector &seeds) { line.clear(); seeds.clear(); @@ -914,8 +913,8 @@ void CirclesGridFinder::findCandidateLine(vector &line, size_t seedLineI assert( line.size() == seeds.size() ); } -void CirclesGridFinder::findCandidateHoles(vector &above, vector &below, bool addRow, Point2f basisVec, - vector &aboveSeeds, vector &belowSeeds) +void CirclesGridFinder::findCandidateHoles(std::vector &above, std::vector &below, bool addRow, Point2f basisVec, + std::vector &aboveSeeds, std::vector &belowSeeds) { above.clear(); below.clear(); @@ -931,7 +930,7 @@ void CirclesGridFinder::findCandidateHoles(vector &above, vector assert( below.size() == belowSeeds.size() ); } -bool CirclesGridFinder::areCentersNew(const vector &newCenters, const vector > &holes) +bool CirclesGridFinder::areCentersNew(const std::vector &newCenters, const std::vector > &holes) { for (size_t i = 0; i < newCenters.size(); i++) { @@ -948,8 +947,8 @@ bool CirclesGridFinder::areCentersNew(const vector &newCenters, const ve } void CirclesGridFinder::insertWinner(float aboveConfidence, float belowConfidence, float minConfidence, bool addRow, - const vector &above, const vector &below, - vector > &holes) + const std::vector &above, const std::vector &below, + std::vector > &holes) { if (aboveConfidence < minConfidence && belowConfidence < minConfidence) return; @@ -996,8 +995,8 @@ void CirclesGridFinder::insertWinner(float aboveConfidence, float belowConfidenc } } -float CirclesGridFinder::computeGraphConfidence(const vector &basisGraphs, bool addRow, - const vector &points, const vector &seeds) +float CirclesGridFinder::computeGraphConfidence(const std::vector &basisGraphs, bool addRow, + const std::vector &points, const std::vector &seeds) { assert( points.size() == seeds.size() ); float confidence = 0; @@ -1042,9 +1041,9 @@ float CirclesGridFinder::computeGraphConfidence(const vector &basisGraphs } -void CirclesGridFinder::addHolesByGraph(const vector &basisGraphs, bool addRow, Point2f basisVec) +void CirclesGridFinder::addHolesByGraph(const std::vector &basisGraphs, bool addRow, Point2f basisVec) { - vector above, below, aboveSeeds, belowSeeds; + std::vector above, below, aboveSeeds, belowSeeds; findCandidateHoles(above, below, addRow, basisVec, aboveSeeds, belowSeeds); float aboveConfidence = computeGraphConfidence(basisGraphs, addRow, above, aboveSeeds); float belowConfidence = computeGraphConfidence(basisGraphs, addRow, below, belowSeeds); @@ -1052,7 +1051,7 @@ void CirclesGridFinder::addHolesByGraph(const vector &basisGraphs, bool a insertWinner(aboveConfidence, belowConfidence, parameters.minGraphConfidence, addRow, above, below, holes); } -void CirclesGridFinder::filterOutliersByDensity(const vector &samples, vector &filteredSamples) +void CirclesGridFinder::filterOutliersByDensity(const std::vector &samples, std::vector &filteredSamples) { if (samples.empty()) CV_Error( 0, "samples is empty" ); @@ -1077,7 +1076,7 @@ void CirclesGridFinder::filterOutliersByDensity(const vector &samples, CV_Error( 0, "filteredSamples is empty" ); } -void CirclesGridFinder::findBasis(const vector &samples, vector &basis, vector &basisGraphs) +void CirclesGridFinder::findBasis(const std::vector &samples, std::vector &basis, std::vector &basisGraphs) { basis.clear(); Mat bestLabels; @@ -1088,7 +1087,7 @@ void CirclesGridFinder::findBasis(const vector &samples, vector basisIndices; + std::vector basisIndices; //TODO: only remove duplicate for (int i = 0; i < clustersCount; i++) { @@ -1113,7 +1112,7 @@ void CirclesGridFinder::findBasis(const vector &samples, vector > clusters(2), hulls(2); + std::vector > clusters(2), hulls(2); for (int k = 0; k < (int)samples.size(); k++) { int label = bestLabels.at (k, 0); @@ -1223,7 +1222,7 @@ void computePredecessorMatrix(const Mat &dm, int verticesCount, Mat &predecessor } } -static void computeShortestPath(Mat &predecessorMatrix, size_t v1, size_t v2, vector &path) +static void computeShortestPath(Mat &predecessorMatrix, size_t v1, size_t v2, std::vector &path) { if (predecessorMatrix.at ((int)v1, (int)v2) < 0) { @@ -1235,10 +1234,10 @@ static void computeShortestPath(Mat &predecessorMatrix, size_t v1, size_t v2, ve path.push_back(v2); } -size_t CirclesGridFinder::findLongestPath(vector &basisGraphs, Path &bestPath) +size_t CirclesGridFinder::findLongestPath(std::vector &basisGraphs, Path &bestPath) { - vector longestPaths(1); - vector confidences; + std::vector longestPaths(1); + std::vector confidences; size_t bestGraphIdx = 0; const int infinity = -1; @@ -1305,7 +1304,7 @@ size_t CirclesGridFinder::findLongestPath(vector &basisGraphs, Path &best return bestGraphIdx; } -void CirclesGridFinder::drawBasis(const vector &basis, Point2f origin, Mat &drawImg) const +void CirclesGridFinder::drawBasis(const std::vector &basis, Point2f origin, Mat &drawImg) const { for (size_t i = 0; i < basis.size(); i++) { @@ -1314,7 +1313,7 @@ void CirclesGridFinder::drawBasis(const vector &basis, Point2f origin, } } -void CirclesGridFinder::drawBasisGraphs(const vector &basisGraphs, Mat &drawImage, bool drawEdges, +void CirclesGridFinder::drawBasisGraphs(const std::vector &basisGraphs, Mat &drawImage, bool drawEdges, bool drawVertices) const { //const int vertexRadius = 1; @@ -1390,7 +1389,7 @@ Size CirclesGridFinder::getDetectedGridSize() const return Size((int)holes[0].size(), (int)holes.size()); } -void CirclesGridFinder::getHoles(vector &outHoles) const +void CirclesGridFinder::getHoles(std::vector &outHoles) const { outHoles.clear(); @@ -1403,7 +1402,7 @@ void CirclesGridFinder::getHoles(vector &outHoles) const } } -static bool areIndicesCorrect(Point pos, vector > *points) +static bool areIndicesCorrect(Point pos, std::vector > *points) { if (pos.y < 0 || pos.x < 0) return false; @@ -1414,8 +1413,8 @@ void CirclesGridFinder::getAsymmetricHoles(std::vector &outHoles) c { outHoles.clear(); - vector largeCornerIndices, smallCornerIndices; - vector firstSteps, secondSteps; + std::vector largeCornerIndices, smallCornerIndices; + std::vector firstSteps, secondSteps; size_t cornerIdx = getFirstCorner(largeCornerIndices, smallCornerIndices, firstSteps, secondSteps); CV_Assert(largeHoles != 0 && smallHoles != 0) ; @@ -1472,9 +1471,9 @@ bool CirclesGridFinder::areSegmentsIntersecting(Segment seg1, Segment seg2) */ } -void CirclesGridFinder::getCornerSegments(const vector > &points, vector > &segments, - vector &cornerIndices, vector &firstSteps, - vector &secondSteps) const +void CirclesGridFinder::getCornerSegments(const std::vector > &points, std::vector > &segments, + std::vector &cornerIndices, std::vector &firstSteps, + std::vector &secondSteps) const { segments.clear(); cornerIndices.clear(); @@ -1486,7 +1485,7 @@ void CirclesGridFinder::getCornerSegments(const vector > &points, ; //all 8 segments with one end in a corner - vector 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]])); segments.push_back(corner); @@ -1535,7 +1534,7 @@ void CirclesGridFinder::getCornerSegments(const vector > &points, } } -bool CirclesGridFinder::doesIntersectionExist(const vector &corner, const vector > &segments) +bool CirclesGridFinder::doesIntersectionExist(const std::vector &corner, const std::vector > &segments) { for (size_t i = 0; i < corner.size(); i++) { @@ -1552,11 +1551,11 @@ bool CirclesGridFinder::doesIntersectionExist(const vector &corner, con return false; } -size_t CirclesGridFinder::getFirstCorner(vector &largeCornerIndices, vector &smallCornerIndices, vector< - Point> &firstSteps, vector &secondSteps) const +size_t CirclesGridFinder::getFirstCorner(std::vector &largeCornerIndices, std::vector &smallCornerIndices, std::vector< + Point> &firstSteps, std::vector &secondSteps) const { - vector > largeSegments; - vector > smallSegments; + std::vector > largeSegments; + std::vector > smallSegments; getCornerSegments(*largeHoles, largeSegments, largeCornerIndices, firstSteps, secondSteps); getCornerSegments(*smallHoles, smallSegments, smallCornerIndices, firstSteps, secondSteps); diff --git a/modules/calib3d/src/epnp.cpp b/modules/calib3d/src/epnp.cpp index 7f4782ce0..7fb63254d 100644 --- a/modules/calib3d/src/epnp.cpp +++ b/modules/calib3d/src/epnp.cpp @@ -1,5 +1,4 @@ #include -using namespace std; #include "precomp.hpp" #include "epnp.h" diff --git a/modules/calib3d/src/five-point.cpp b/modules/calib3d/src/five-point.cpp index 28cf703a2..3c93d7b3a 100644 --- a/modules/calib3d/src/five-point.cpp +++ b/modules/calib3d/src/five-point.cpp @@ -3,31 +3,30 @@ #include "_modelest.h" #include -using namespace cv; -using namespace std; +using namespace cv; class CvEMEstimator : public CvModelEstimator2 { public: - CvEMEstimator(); - virtual int runKernel( const CvMat* m1, const CvMat* m2, CvMat* model ); - virtual int run5Point( const CvMat* _q1, const CvMat* _q2, CvMat* _ematrix ); -protected: - bool reliable( const CvMat* m1, const CvMat* m2, const CvMat* model ); - virtual void calibrated_fivepoint_helper( double *eet, double* at ); + CvEMEstimator(); + virtual int runKernel( const CvMat* m1, const CvMat* m2, CvMat* model ); + virtual int run5Point( const CvMat* _q1, const CvMat* _q2, CvMat* _ematrix ); +protected: + bool reliable( const CvMat* m1, const CvMat* m2, const CvMat* model ); + virtual void calibrated_fivepoint_helper( double *eet, double* at ); virtual void computeReprojError( const CvMat* m1, const CvMat* m2, const CvMat* model, CvMat* error ); -}; +}; // Input should be a vector of n 2D points or a Nx2 matrix -Mat cv::findEssentialMat( InputArray _points1, InputArray _points2, double focal, Point2d pp, - int method, double prob, double threshold, OutputArray _mask) +Mat cv::findEssentialMat( InputArray _points1, InputArray _points2, double focal, Point2d pp, + int method, double prob, double threshold, OutputArray _mask) { - Mat points1, points2; - _points1.getMat().copyTo(points1); - _points2.getMat().copyTo(points2); + Mat points1, points2; + _points1.getMat().copyTo(points1); + _points2.getMat().copyTo(points2); int npoints = points1.checkVector(2); CV_Assert( npoints >= 5 && points2.checkVector(2) == npoints && @@ -35,231 +34,231 @@ Mat cv::findEssentialMat( InputArray _points1, InputArray _points2, double focal if (points1.channels() > 1) { - points1 = points1.reshape(1, npoints); - points2 = points2.reshape(1, npoints); + points1 = points1.reshape(1, npoints); + points2 = points2.reshape(1, npoints); } - - points1.convertTo(points1, CV_64F); - points2.convertTo(points2, CV_64F); - points1.col(0) = (points1.col(0) - pp.x) / focal; - points2.col(0) = (points2.col(0) - pp.x) / focal; - points1.col(1) = (points1.col(1) - pp.y) / focal; - points2.col(1) = (points2.col(1) - pp.y) / focal; - + points1.convertTo(points1, CV_64F); + points2.convertTo(points2, CV_64F); + + points1.col(0) = (points1.col(0) - pp.x) / focal; + points2.col(0) = (points2.col(0) - pp.x) / focal; + points1.col(1) = (points1.col(1) - pp.y) / focal; + points2.col(1) = (points2.col(1) - pp.y) / focal; + // Reshape data to fit opencv ransac function - points1 = points1.reshape(2, 1); - points2 = points2.reshape(2, 1); + points1 = points1.reshape(2, 1); + points2 = points2.reshape(2, 1); - Mat E(3, 3, CV_64F); - CvEMEstimator estimator; + Mat E(3, 3, CV_64F); + CvEMEstimator estimator; - CvMat p1 = points1; - CvMat p2 = points2; - CvMat _E = E; - CvMat* tempMask = cvCreateMat(1, npoints, CV_8U); - - assert(npoints >= 5); - threshold /= focal; - int count = 1; + CvMat p1 = points1; + CvMat p2 = points2; + CvMat _E = E; + CvMat* tempMask = cvCreateMat(1, npoints, CV_8U); + + assert(npoints >= 5); + threshold /= focal; + int count = 1; if (npoints == 5) { - E.create(3 * 10, 3, CV_64F); - _E = E; - count = estimator.runKernel(&p1, &p2, &_E); - E = E.rowRange(0, 3 * count) * 1.0; - Mat(tempMask).setTo(true); + E.create(3 * 10, 3, CV_64F); + _E = E; + count = estimator.runKernel(&p1, &p2, &_E); + E = E.rowRange(0, 3 * count) * 1.0; + Mat(tempMask).setTo(true); } else if (method == CV_RANSAC) { - estimator.runRANSAC(&p1, &p2, &_E, tempMask, threshold, prob); + estimator.runRANSAC(&p1, &p2, &_E, tempMask, threshold, prob); } else { - estimator.runLMeDS(&p1, &p2, &_E, tempMask, prob); + estimator.runLMeDS(&p1, &p2, &_E, tempMask, prob); } if (_mask.needed()) { - _mask.create(1, npoints, CV_8U, -1, true); - Mat mask = _mask.getMat(); - Mat(tempMask).copyTo(mask); + _mask.create(1, npoints, CV_8U, -1, true); + Mat mask = _mask.getMat(); + Mat(tempMask).copyTo(mask); } - - return E; + + return E; } -int cv::recoverPose( InputArray E, InputArray _points1, InputArray _points2, OutputArray _R, OutputArray _t, - double focal, Point2d pp, - InputOutputArray _mask) +int cv::recoverPose( InputArray E, InputArray _points1, InputArray _points2, OutputArray _R, OutputArray _t, + double focal, Point2d pp, + InputOutputArray _mask) { - Mat points1, points2; - _points1.getMat().copyTo(points1); - _points2.getMat().copyTo(points2); - + Mat points1, points2; + _points1.getMat().copyTo(points1); + _points2.getMat().copyTo(points2); + int npoints = points1.checkVector(2); CV_Assert( npoints >= 0 && points2.checkVector(2) == npoints && points1.type() == points2.type()); if (points1.channels() > 1) { - points1 = points1.reshape(1, npoints); - points2 = points2.reshape(1, npoints); + points1 = points1.reshape(1, npoints); + points2 = points2.reshape(1, npoints); } - points1.convertTo(points1, CV_64F); - points2.convertTo(points2, CV_64F); + points1.convertTo(points1, CV_64F); + points2.convertTo(points2, CV_64F); - points1.col(0) = (points1.col(0) - pp.x) / focal; - points2.col(0) = (points2.col(0) - pp.x) / focal; - points1.col(1) = (points1.col(1) - pp.y) / focal; - points2.col(1) = (points2.col(1) - pp.y) / focal; + points1.col(0) = (points1.col(0) - pp.x) / focal; + points2.col(0) = (points2.col(0) - pp.x) / focal; + points1.col(1) = (points1.col(1) - pp.y) / focal; + points2.col(1) = (points2.col(1) - pp.y) / focal; - points1 = points1.t(); - points2 = points2.t(); - - Mat R1, R2, t; - decomposeEssentialMat(E, R1, R2, t); - Mat P0 = Mat::eye(3, 4, R1.type()); - Mat P1(3, 4, R1.type()), P2(3, 4, R1.type()), P3(3, 4, R1.type()), P4(3, 4, R1.type()); - P1(Range::all(), Range(0, 3)) = R1 * 1.0; P1.col(3) = t * 1.0; - P2(Range::all(), Range(0, 3)) = R2 * 1.0; P2.col(3) = t * 1.0; - P3(Range::all(), Range(0, 3)) = R1 * 1.0; P3.col(3) = -t * 1.0; - P4(Range::all(), Range(0, 3)) = R2 * 1.0; P4.col(3) = -t * 1.0; + points1 = points1.t(); + points2 = points2.t(); - // Do the cheirality check. + Mat R1, R2, t; + decomposeEssentialMat(E, R1, R2, t); + Mat P0 = Mat::eye(3, 4, R1.type()); + Mat P1(3, 4, R1.type()), P2(3, 4, R1.type()), P3(3, 4, R1.type()), P4(3, 4, R1.type()); + P1(Range::all(), Range(0, 3)) = R1 * 1.0; P1.col(3) = t * 1.0; + P2(Range::all(), Range(0, 3)) = R2 * 1.0; P2.col(3) = t * 1.0; + P3(Range::all(), Range(0, 3)) = R1 * 1.0; P3.col(3) = -t * 1.0; + P4(Range::all(), Range(0, 3)) = R2 * 1.0; P4.col(3) = -t * 1.0; + + // Do the cheirality check. // Notice here a threshold dist is used to filter - // out far away points (i.e. infinite points) since - // there depth may vary between postive and negtive. - double dist = 50.0; - Mat Q; - triangulatePoints(P0, P1, points1, points2, Q); - Mat mask1 = Q.row(2).mul(Q.row(3)) > 0; - Q.row(0) /= Q.row(3); - Q.row(1) /= Q.row(3); - Q.row(2) /= Q.row(3); - Q.row(3) /= Q.row(3); - mask1 = (Q.row(2) < dist) & mask1; - Q = P1 * Q; - mask1 = (Q.row(2) > 0) & mask1; - mask1 = (Q.row(2) < dist) & mask1; + // out far away points (i.e. infinite points) since + // there depth may vary between postive and negtive. + double dist = 50.0; + Mat Q; + triangulatePoints(P0, P1, points1, points2, Q); + Mat mask1 = Q.row(2).mul(Q.row(3)) > 0; + Q.row(0) /= Q.row(3); + Q.row(1) /= Q.row(3); + Q.row(2) /= Q.row(3); + Q.row(3) /= Q.row(3); + mask1 = (Q.row(2) < dist) & mask1; + Q = P1 * Q; + mask1 = (Q.row(2) > 0) & mask1; + mask1 = (Q.row(2) < dist) & mask1; - triangulatePoints(P0, P2, points1, points2, Q); - Mat mask2 = Q.row(2).mul(Q.row(3)) > 0; - Q.row(0) /= Q.row(3); - Q.row(1) /= Q.row(3); - Q.row(2) /= Q.row(3); - Q.row(3) /= Q.row(3); - mask2 = (Q.row(2) < dist) & mask2; - Q = P2 * Q; - mask2 = (Q.row(2) > 0) & mask2; - mask2 = (Q.row(2) < dist) & mask2; + triangulatePoints(P0, P2, points1, points2, Q); + Mat mask2 = Q.row(2).mul(Q.row(3)) > 0; + Q.row(0) /= Q.row(3); + Q.row(1) /= Q.row(3); + Q.row(2) /= Q.row(3); + Q.row(3) /= Q.row(3); + mask2 = (Q.row(2) < dist) & mask2; + Q = P2 * Q; + mask2 = (Q.row(2) > 0) & mask2; + mask2 = (Q.row(2) < dist) & mask2; - triangulatePoints(P0, P3, points1, points2, Q); - Mat mask3 = Q.row(2).mul(Q.row(3)) > 0; - Q.row(0) /= Q.row(3); - Q.row(1) /= Q.row(3); - Q.row(2) /= Q.row(3); - Q.row(3) /= Q.row(3); - mask3 = (Q.row(2) < dist) & mask3; - Q = P3 * Q; - mask3 = (Q.row(2) > 0) & mask3; - mask3 = (Q.row(2) < dist) & mask3; + triangulatePoints(P0, P3, points1, points2, Q); + Mat mask3 = Q.row(2).mul(Q.row(3)) > 0; + Q.row(0) /= Q.row(3); + Q.row(1) /= Q.row(3); + Q.row(2) /= Q.row(3); + Q.row(3) /= Q.row(3); + mask3 = (Q.row(2) < dist) & mask3; + Q = P3 * Q; + mask3 = (Q.row(2) > 0) & mask3; + mask3 = (Q.row(2) < dist) & mask3; - triangulatePoints(P0, P4, points1, points2, Q); - Mat mask4 = Q.row(2).mul(Q.row(3)) > 0; - Q.row(0) /= Q.row(3); - Q.row(1) /= Q.row(3); - Q.row(2) /= Q.row(3); - Q.row(3) /= Q.row(3); - mask4 = (Q.row(2) < dist) & mask4; - Q = P4 * Q; - mask4 = (Q.row(2) > 0) & mask4; - mask4 = (Q.row(2) < dist) & mask4; + triangulatePoints(P0, P4, points1, points2, Q); + Mat mask4 = Q.row(2).mul(Q.row(3)) > 0; + Q.row(0) /= Q.row(3); + Q.row(1) /= Q.row(3); + Q.row(2) /= Q.row(3); + Q.row(3) /= Q.row(3); + mask4 = (Q.row(2) < dist) & mask4; + Q = P4 * Q; + mask4 = (Q.row(2) > 0) & mask4; + mask4 = (Q.row(2) < dist) & mask4; - // If _mask is given, then use it to filter outliers. + // If _mask is given, then use it to filter outliers. if (_mask.needed()) { - _mask.create(1, npoints, CV_8U, -1, true); - Mat mask = _mask.getMat(); - bitwise_and(mask, mask1, mask1); - bitwise_and(mask, mask2, mask2); - bitwise_and(mask, mask3, mask3); - bitwise_and(mask, mask4, mask4); + _mask.create(1, npoints, CV_8U, -1, true); + Mat mask = _mask.getMat(); + bitwise_and(mask, mask1, mask1); + bitwise_and(mask, mask2, mask2); + bitwise_and(mask, mask3, mask3); + bitwise_and(mask, mask4, mask4); } - CV_Assert(_R.needed() && _t.needed()); - _R.create(3, 3, R1.type()); - _t.create(3, 1, t.type()); + CV_Assert(_R.needed() && _t.needed()); + _R.create(3, 3, R1.type()); + _t.create(3, 1, t.type()); - int good1 = countNonZero(mask1); - int good2 = countNonZero(mask2); - int good3 = countNonZero(mask3); - int good4 = countNonZero(mask4); + int good1 = countNonZero(mask1); + int good2 = countNonZero(mask2); + int good3 = countNonZero(mask3); + int good4 = countNonZero(mask4); if (good1 >= good2 && good1 >= good3 && good1 >= good4) { - R1.copyTo(_R.getMat()); - t.copyTo(_t.getMat()); - if (_mask.needed()) mask1.copyTo(_mask.getMat()); - return good1; + R1.copyTo(_R.getMat()); + t.copyTo(_t.getMat()); + if (_mask.needed()) mask1.copyTo(_mask.getMat()); + return good1; } else if (good2 >= good1 && good2 >= good3 && good2 >= good4) { - R2.copyTo(_R.getMat()); - t.copyTo(_t.getMat()); - if (_mask.needed()) mask2.copyTo(_mask.getMat()); - return good2; + R2.copyTo(_R.getMat()); + t.copyTo(_t.getMat()); + if (_mask.needed()) mask2.copyTo(_mask.getMat()); + return good2; } else if (good3 >= good1 && good3 >= good2 && good3 >= good4) { - t = -t; - R1.copyTo(_R.getMat()); - t.copyTo(_t.getMat()); - if (_mask.needed()) mask3.copyTo(_mask.getMat()); - return good3; + t = -t; + R1.copyTo(_R.getMat()); + t.copyTo(_t.getMat()); + if (_mask.needed()) mask3.copyTo(_mask.getMat()); + return good3; } - else + else { - t = -t; - R2.copyTo(_R.getMat()); - t.copyTo(_t.getMat()); - if (_mask.needed()) mask4.copyTo(_mask.getMat()); - return good4; + t = -t; + R2.copyTo(_R.getMat()); + t.copyTo(_t.getMat()); + if (_mask.needed()) mask4.copyTo(_mask.getMat()); + return good4; } } -void cv::decomposeEssentialMat( InputArray _E, OutputArray _R1, OutputArray _R2, OutputArray _t ) +void cv::decomposeEssentialMat( InputArray _E, OutputArray _R1, OutputArray _R2, OutputArray _t ) { - Mat E; - _E.getMat().copyTo(E); - E = E.reshape(1, 3); + Mat E; + _E.getMat().copyTo(E); + E = E.reshape(1, 3); - assert(E.cols == 3 && E.rows == 3); - - Mat D, U, Vt; - SVD::compute(E, D, U, Vt); - - if (determinant(U) < 0) U = -U; - if (determinant(Vt) < 0) Vt = -Vt; - - Mat W = (Mat_(3, 3) << 0, 1, 0, -1, 0, 0, 0, 0, 1); - W.convertTo(W, E.type()); - - Mat R1, R2, t; - R1 = U * W * Vt; - R2 = U * W.t() * Vt; - t = U.col(2) * 1.0; + assert(E.cols == 3 && E.rows == 3); - _R1.create(3, 3, E.type()); - _R2.create(3, 3, E.type()); - _t.create(3, 1, E.type()); - R1.copyTo(_R1.getMat()); - R2.copyTo(_R2.getMat()); - t.copyTo(_t.getMat()); + Mat D, U, Vt; + SVD::compute(E, D, U, Vt); + + if (determinant(U) < 0) U = -U; + if (determinant(Vt) < 0) Vt = -Vt; + + Mat W = (Mat_(3, 3) << 0, 1, 0, -1, 0, 0, 0, 0, 1); + W.convertTo(W, E.type()); + + Mat R1, R2, t; + R1 = U * W * Vt; + R2 = U * W.t() * Vt; + t = U.col(2) * 1.0; + + _R1.create(3, 3, E.type()); + _R2.create(3, 3, E.type()); + _t.create(3, 1, E.type()); + R1.copyTo(_R1.getMat()); + R2.copyTo(_R2.getMat()); + t.copyTo(_t.getMat()); } @@ -271,150 +270,150 @@ CvEMEstimator::CvEMEstimator() int CvEMEstimator::runKernel( const CvMat* m1, const CvMat* m2, CvMat* model ) { - return run5Point(m1, m2, model); + return run5Point(m1, m2, model); } // Notice to keep compatibility with opencv ransac, q1 and q2 have -// to be of 1 row x n col x 2 channel. +// to be of 1 row x n col x 2 channel. int CvEMEstimator::run5Point( const CvMat* q1, const CvMat* q2, CvMat* ematrix ) { - Mat Q1 = Mat(q1).reshape(1, q1->cols); - Mat Q2 = Mat(q2).reshape(1, q2->cols); + Mat Q1 = Mat(q1).reshape(1, q1->cols); + Mat Q2 = Mat(q2).reshape(1, q2->cols); - int n = Q1.rows; - Mat Q(n, 9, CV_64F); - Q.col(0) = Q1.col(0).mul( Q2.col(0) ); - Q.col(1) = Q1.col(1).mul( Q2.col(0) ); - Q.col(2) = Q2.col(0) * 1.0; - Q.col(3) = Q1.col(0).mul( Q2.col(1) ); - Q.col(4) = Q1.col(1).mul( Q2.col(1) ); - Q.col(5) = Q2.col(1) * 1.0; - Q.col(6) = Q1.col(0) * 1.0; - Q.col(7) = Q1.col(1) * 1.0; - Q.col(8) = 1.0; + int n = Q1.rows; + Mat Q(n, 9, CV_64F); + Q.col(0) = Q1.col(0).mul( Q2.col(0) ); + Q.col(1) = Q1.col(1).mul( Q2.col(0) ); + Q.col(2) = Q2.col(0) * 1.0; + Q.col(3) = Q1.col(0).mul( Q2.col(1) ); + Q.col(4) = Q1.col(1).mul( Q2.col(1) ); + Q.col(5) = Q2.col(1) * 1.0; + Q.col(6) = Q1.col(0) * 1.0; + Q.col(7) = Q1.col(1) * 1.0; + Q.col(8) = 1.0; - Mat U, W, Vt; - SVD::compute(Q, W, U, Vt, SVD::MODIFY_A | SVD::FULL_UV); - - Mat EE = Mat(Vt.t()).colRange(5, 9) * 1.0; - Mat AA(20, 10, CV_64F); - EE = EE.t(); - calibrated_fivepoint_helper((double*)EE.data, (double*)AA.data); - AA = AA.t(); - EE = EE.t(); + Mat U, W, Vt; + SVD::compute(Q, W, U, Vt, SVD::MODIFY_A | SVD::FULL_UV); - Mat A(10, 20, CV_64F); - int perm[20] = {0, 3, 1, 2, 4, 10, 6, 12, 5, 11, 7, 13, 16, 8, 14, 17, 9, 15, 18, 19}; + Mat EE = Mat(Vt.t()).colRange(5, 9) * 1.0; + Mat AA(20, 10, CV_64F); + EE = EE.t(); + calibrated_fivepoint_helper((double*)EE.data, (double*)AA.data); + AA = AA.t(); + EE = EE.t(); + + Mat A(10, 20, CV_64F); + int perm[20] = {0, 3, 1, 2, 4, 10, 6, 12, 5, 11, 7, 13, 16, 8, 14, 17, 9, 15, 18, 19}; for (int i = 0; i < 20; i++) - A.col(i) = AA.col(perm[i]) * 1.0; + A.col(i) = AA.col(perm[i]) * 1.0; - A = A.colRange(0, 10).inv() * A.colRange(10, 20); - - double b[3 * 13]; - Mat B(3, 13, CV_64F, b); + A = A.colRange(0, 10).inv() * A.colRange(10, 20); + + double b[3 * 13]; + Mat B(3, 13, CV_64F, b); for (int i = 0; i < 3; i++) { - Mat arow1 = A.row(i * 2 + 4) * 1.0; - Mat arow2 = A.row(i * 2 + 5) * 1.0; - Mat row1(1, 13, CV_64F, Scalar(0.0)); - Mat row2(1, 13, CV_64F, Scalar(0.0)); + Mat arow1 = A.row(i * 2 + 4) * 1.0; + Mat arow2 = A.row(i * 2 + 5) * 1.0; + Mat row1(1, 13, CV_64F, Scalar(0.0)); + Mat row2(1, 13, CV_64F, Scalar(0.0)); - row1.colRange(1, 4) = arow1.colRange(0, 3) * 1.0; - row1.colRange(5, 8) = arow1.colRange(3, 6) * 1.0; - row1.colRange(9, 13) = arow1.colRange(6, 10) * 1.0; + row1.colRange(1, 4) = arow1.colRange(0, 3) * 1.0; + row1.colRange(5, 8) = arow1.colRange(3, 6) * 1.0; + row1.colRange(9, 13) = arow1.colRange(6, 10) * 1.0; - row2.colRange(0, 3) = arow2.colRange(0, 3) * 1.0; - row2.colRange(4, 7) = arow2.colRange(3, 6) * 1.0; - row2.colRange(8, 12) = arow2.colRange(6, 10) * 1.0; - - B.row(i) = row1 - row2; + row2.colRange(0, 3) = arow2.colRange(0, 3) * 1.0; + row2.colRange(4, 7) = arow2.colRange(3, 6) * 1.0; + row2.colRange(8, 12) = arow2.colRange(6, 10) * 1.0; + + B.row(i) = row1 - row2; } - double c[11]; - Mat coeffs(1, 11, CV_64F, c); - c[10] = (b[0]*b[17]*b[34]+b[26]*b[4]*b[21]-b[26]*b[17]*b[8]-b[13]*b[4]*b[34]-b[0]*b[21]*b[30]+b[13]*b[30]*b[8]); - c[9] = (b[26]*b[4]*b[22]+b[14]*b[30]*b[8]+b[13]*b[31]*b[8]+b[1]*b[17]*b[34]-b[13]*b[5]*b[34]+b[26]*b[5]*b[21]-b[0]*b[21]*b[31]-b[26]*b[17]*b[9]-b[1]*b[21]*b[30]+b[27]*b[4]*b[21]+b[0]*b[17]*b[35]-b[0]*b[22]*b[30]+b[13]*b[30]*b[9]+b[0]*b[18]*b[34]-b[27]*b[17]*b[8]-b[14]*b[4]*b[34]-b[13]*b[4]*b[35]-b[26]*b[18]*b[8]); - c[8] = (b[14]*b[30]*b[9]+b[14]*b[31]*b[8]+b[13]*b[31]*b[9]-b[13]*b[4]*b[36]-b[13]*b[5]*b[35]+b[15]*b[30]*b[8]-b[13]*b[6]*b[34]+b[13]*b[30]*b[10]+b[13]*b[32]*b[8]-b[14]*b[4]*b[35]-b[14]*b[5]*b[34]+b[26]*b[4]*b[23]+b[26]*b[5]*b[22]+b[26]*b[6]*b[21]-b[26]*b[17]*b[10]-b[15]*b[4]*b[34]-b[26]*b[18]*b[9]-b[26]*b[19]*b[8]+b[27]*b[4]*b[22]+b[27]*b[5]*b[21]-b[27]*b[17]*b[9]-b[27]*b[18]*b[8]-b[1]*b[21]*b[31]-b[0]*b[23]*b[30]-b[0]*b[21]*b[32]+b[28]*b[4]*b[21]-b[28]*b[17]*b[8]+b[2]*b[17]*b[34]+b[0]*b[18]*b[35]-b[0]*b[22]*b[31]+b[0]*b[17]*b[36]+b[0]*b[19]*b[34]-b[1]*b[22]*b[30]+b[1]*b[18]*b[34]+b[1]*b[17]*b[35]-b[2]*b[21]*b[30]); - c[7] = (b[14]*b[30]*b[10]+b[14]*b[32]*b[8]-b[3]*b[21]*b[30]+b[3]*b[17]*b[34]+b[13]*b[32]*b[9]+b[13]*b[33]*b[8]-b[13]*b[4]*b[37]-b[13]*b[5]*b[36]+b[15]*b[30]*b[9]+b[15]*b[31]*b[8]-b[16]*b[4]*b[34]-b[13]*b[6]*b[35]-b[13]*b[7]*b[34]+b[13]*b[30]*b[11]+b[13]*b[31]*b[10]+b[14]*b[31]*b[9]-b[14]*b[4]*b[36]-b[14]*b[5]*b[35]-b[14]*b[6]*b[34]+b[16]*b[30]*b[8]-b[26]*b[20]*b[8]+b[26]*b[4]*b[24]+b[26]*b[5]*b[23]+b[26]*b[6]*b[22]+b[26]*b[7]*b[21]-b[26]*b[17]*b[11]-b[15]*b[4]*b[35]-b[15]*b[5]*b[34]-b[26]*b[18]*b[10]-b[26]*b[19]*b[9]+b[27]*b[4]*b[23]+b[27]*b[5]*b[22]+b[27]*b[6]*b[21]-b[27]*b[17]*b[10]-b[27]*b[18]*b[9]-b[27]*b[19]*b[8]+b[0]*b[17]*b[37]-b[0]*b[23]*b[31]-b[0]*b[24]*b[30]-b[0]*b[21]*b[33]-b[29]*b[17]*b[8]+b[28]*b[4]*b[22]+b[28]*b[5]*b[21]-b[28]*b[17]*b[9]-b[28]*b[18]*b[8]+b[29]*b[4]*b[21]+b[1]*b[19]*b[34]-b[2]*b[21]*b[31]+b[0]*b[20]*b[34]+b[0]*b[19]*b[35]+b[0]*b[18]*b[36]-b[0]*b[22]*b[32]-b[1]*b[23]*b[30]-b[1]*b[21]*b[32]+b[1]*b[18]*b[35]-b[1]*b[22]*b[31]-b[2]*b[22]*b[30]+b[2]*b[17]*b[35]+b[1]*b[17]*b[36]+b[2]*b[18]*b[34]); - c[6] = (-b[14]*b[6]*b[35]-b[14]*b[7]*b[34]-b[3]*b[22]*b[30]-b[3]*b[21]*b[31]+b[3]*b[17]*b[35]+b[3]*b[18]*b[34]+b[13]*b[32]*b[10]+b[13]*b[33]*b[9]-b[13]*b[4]*b[38]-b[13]*b[5]*b[37]-b[15]*b[6]*b[34]+b[15]*b[30]*b[10]+b[15]*b[32]*b[8]-b[16]*b[4]*b[35]-b[13]*b[6]*b[36]-b[13]*b[7]*b[35]+b[13]*b[31]*b[11]+b[13]*b[30]*b[12]+b[14]*b[32]*b[9]+b[14]*b[33]*b[8]-b[14]*b[4]*b[37]-b[14]*b[5]*b[36]+b[16]*b[30]*b[9]+b[16]*b[31]*b[8]-b[26]*b[20]*b[9]+b[26]*b[4]*b[25]+b[26]*b[5]*b[24]+b[26]*b[6]*b[23]+b[26]*b[7]*b[22]-b[26]*b[17]*b[12]+b[14]*b[30]*b[11]+b[14]*b[31]*b[10]+b[15]*b[31]*b[9]-b[15]*b[4]*b[36]-b[15]*b[5]*b[35]-b[26]*b[18]*b[11]-b[26]*b[19]*b[10]-b[27]*b[20]*b[8]+b[27]*b[4]*b[24]+b[27]*b[5]*b[23]+b[27]*b[6]*b[22]+b[27]*b[7]*b[21]-b[27]*b[17]*b[11]-b[27]*b[18]*b[10]-b[27]*b[19]*b[9]-b[16]*b[5]*b[34]-b[29]*b[17]*b[9]-b[29]*b[18]*b[8]+b[28]*b[4]*b[23]+b[28]*b[5]*b[22]+b[28]*b[6]*b[21]-b[28]*b[17]*b[10]-b[28]*b[18]*b[9]-b[28]*b[19]*b[8]+b[29]*b[4]*b[22]+b[29]*b[5]*b[21]-b[2]*b[23]*b[30]+b[2]*b[18]*b[35]-b[1]*b[22]*b[32]-b[2]*b[21]*b[32]+b[2]*b[19]*b[34]+b[0]*b[19]*b[36]-b[0]*b[22]*b[33]+b[0]*b[20]*b[35]-b[0]*b[23]*b[32]-b[0]*b[25]*b[30]+b[0]*b[17]*b[38]+b[0]*b[18]*b[37]-b[0]*b[24]*b[31]+b[1]*b[17]*b[37]-b[1]*b[23]*b[31]-b[1]*b[24]*b[30]-b[1]*b[21]*b[33]+b[1]*b[20]*b[34]+b[1]*b[19]*b[35]+b[1]*b[18]*b[36]+b[2]*b[17]*b[36]-b[2]*b[22]*b[31]); - c[5] = (-b[14]*b[6]*b[36]-b[14]*b[7]*b[35]+b[14]*b[31]*b[11]-b[3]*b[23]*b[30]-b[3]*b[21]*b[32]+b[3]*b[18]*b[35]-b[3]*b[22]*b[31]+b[3]*b[17]*b[36]+b[3]*b[19]*b[34]+b[13]*b[32]*b[11]+b[13]*b[33]*b[10]-b[13]*b[5]*b[38]-b[15]*b[6]*b[35]-b[15]*b[7]*b[34]+b[15]*b[30]*b[11]+b[15]*b[31]*b[10]+b[16]*b[31]*b[9]-b[13]*b[6]*b[37]-b[13]*b[7]*b[36]+b[13]*b[31]*b[12]+b[14]*b[32]*b[10]+b[14]*b[33]*b[9]-b[14]*b[4]*b[38]-b[14]*b[5]*b[37]-b[16]*b[6]*b[34]+b[16]*b[30]*b[10]+b[16]*b[32]*b[8]-b[26]*b[20]*b[10]+b[26]*b[5]*b[25]+b[26]*b[6]*b[24]+b[26]*b[7]*b[23]+b[14]*b[30]*b[12]+b[15]*b[32]*b[9]+b[15]*b[33]*b[8]-b[15]*b[4]*b[37]-b[15]*b[5]*b[36]+b[29]*b[5]*b[22]+b[29]*b[6]*b[21]-b[26]*b[18]*b[12]-b[26]*b[19]*b[11]-b[27]*b[20]*b[9]+b[27]*b[4]*b[25]+b[27]*b[5]*b[24]+b[27]*b[6]*b[23]+b[27]*b[7]*b[22]-b[27]*b[17]*b[12]-b[27]*b[18]*b[11]-b[27]*b[19]*b[10]-b[28]*b[20]*b[8]-b[16]*b[4]*b[36]-b[16]*b[5]*b[35]-b[29]*b[17]*b[10]-b[29]*b[18]*b[9]-b[29]*b[19]*b[8]+b[28]*b[4]*b[24]+b[28]*b[5]*b[23]+b[28]*b[6]*b[22]+b[28]*b[7]*b[21]-b[28]*b[17]*b[11]-b[28]*b[18]*b[10]-b[28]*b[19]*b[9]+b[29]*b[4]*b[23]-b[2]*b[22]*b[32]-b[2]*b[21]*b[33]-b[1]*b[24]*b[31]+b[0]*b[18]*b[38]-b[0]*b[24]*b[32]+b[0]*b[19]*b[37]+b[0]*b[20]*b[36]-b[0]*b[25]*b[31]-b[0]*b[23]*b[33]+b[1]*b[19]*b[36]-b[1]*b[22]*b[33]+b[1]*b[20]*b[35]+b[2]*b[19]*b[35]-b[2]*b[24]*b[30]-b[2]*b[23]*b[31]+b[2]*b[20]*b[34]+b[2]*b[17]*b[37]-b[1]*b[25]*b[30]+b[1]*b[18]*b[37]+b[1]*b[17]*b[38]-b[1]*b[23]*b[32]+b[2]*b[18]*b[36]); - c[4] = (-b[14]*b[6]*b[37]-b[14]*b[7]*b[36]+b[14]*b[31]*b[12]+b[3]*b[17]*b[37]-b[3]*b[23]*b[31]-b[3]*b[24]*b[30]-b[3]*b[21]*b[33]+b[3]*b[20]*b[34]+b[3]*b[19]*b[35]+b[3]*b[18]*b[36]-b[3]*b[22]*b[32]+b[13]*b[32]*b[12]+b[13]*b[33]*b[11]-b[15]*b[6]*b[36]-b[15]*b[7]*b[35]+b[15]*b[31]*b[11]+b[15]*b[30]*b[12]+b[16]*b[32]*b[9]+b[16]*b[33]*b[8]-b[13]*b[6]*b[38]-b[13]*b[7]*b[37]+b[14]*b[32]*b[11]+b[14]*b[33]*b[10]-b[14]*b[5]*b[38]-b[16]*b[6]*b[35]-b[16]*b[7]*b[34]+b[16]*b[30]*b[11]+b[16]*b[31]*b[10]-b[26]*b[19]*b[12]-b[26]*b[20]*b[11]+b[26]*b[6]*b[25]+b[26]*b[7]*b[24]+b[15]*b[32]*b[10]+b[15]*b[33]*b[9]-b[15]*b[4]*b[38]-b[15]*b[5]*b[37]+b[29]*b[5]*b[23]+b[29]*b[6]*b[22]+b[29]*b[7]*b[21]-b[27]*b[20]*b[10]+b[27]*b[5]*b[25]+b[27]*b[6]*b[24]+b[27]*b[7]*b[23]-b[27]*b[18]*b[12]-b[27]*b[19]*b[11]-b[28]*b[20]*b[9]-b[16]*b[4]*b[37]-b[16]*b[5]*b[36]+b[0]*b[19]*b[38]-b[0]*b[24]*b[33]+b[0]*b[20]*b[37]-b[29]*b[17]*b[11]-b[29]*b[18]*b[10]-b[29]*b[19]*b[9]+b[28]*b[4]*b[25]+b[28]*b[5]*b[24]+b[28]*b[6]*b[23]+b[28]*b[7]*b[22]-b[28]*b[17]*b[12]-b[28]*b[18]*b[11]-b[28]*b[19]*b[10]-b[29]*b[20]*b[8]+b[29]*b[4]*b[24]+b[2]*b[18]*b[37]-b[0]*b[25]*b[32]+b[1]*b[18]*b[38]-b[1]*b[24]*b[32]+b[1]*b[19]*b[37]+b[1]*b[20]*b[36]-b[1]*b[25]*b[31]+b[2]*b[17]*b[38]+b[2]*b[19]*b[36]-b[2]*b[24]*b[31]-b[2]*b[22]*b[33]-b[2]*b[23]*b[32]+b[2]*b[20]*b[35]-b[1]*b[23]*b[33]-b[2]*b[25]*b[30]); - c[3] = (-b[14]*b[6]*b[38]-b[14]*b[7]*b[37]+b[3]*b[19]*b[36]-b[3]*b[22]*b[33]+b[3]*b[20]*b[35]-b[3]*b[23]*b[32]-b[3]*b[25]*b[30]+b[3]*b[17]*b[38]+b[3]*b[18]*b[37]-b[3]*b[24]*b[31]-b[15]*b[6]*b[37]-b[15]*b[7]*b[36]+b[15]*b[31]*b[12]+b[16]*b[32]*b[10]+b[16]*b[33]*b[9]+b[13]*b[33]*b[12]-b[13]*b[7]*b[38]+b[14]*b[32]*b[12]+b[14]*b[33]*b[11]-b[16]*b[6]*b[36]-b[16]*b[7]*b[35]+b[16]*b[31]*b[11]+b[16]*b[30]*b[12]+b[15]*b[32]*b[11]+b[15]*b[33]*b[10]-b[15]*b[5]*b[38]+b[29]*b[5]*b[24]+b[29]*b[6]*b[23]-b[26]*b[20]*b[12]+b[26]*b[7]*b[25]-b[27]*b[19]*b[12]-b[27]*b[20]*b[11]+b[27]*b[6]*b[25]+b[27]*b[7]*b[24]-b[28]*b[20]*b[10]-b[16]*b[4]*b[38]-b[16]*b[5]*b[37]+b[29]*b[7]*b[22]-b[29]*b[17]*b[12]-b[29]*b[18]*b[11]-b[29]*b[19]*b[10]+b[28]*b[5]*b[25]+b[28]*b[6]*b[24]+b[28]*b[7]*b[23]-b[28]*b[18]*b[12]-b[28]*b[19]*b[11]-b[29]*b[20]*b[9]+b[29]*b[4]*b[25]-b[2]*b[24]*b[32]+b[0]*b[20]*b[38]-b[0]*b[25]*b[33]+b[1]*b[19]*b[38]-b[1]*b[24]*b[33]+b[1]*b[20]*b[37]-b[2]*b[25]*b[31]+b[2]*b[20]*b[36]-b[1]*b[25]*b[32]+b[2]*b[19]*b[37]+b[2]*b[18]*b[38]-b[2]*b[23]*b[33]); - c[2] = (b[3]*b[18]*b[38]-b[3]*b[24]*b[32]+b[3]*b[19]*b[37]+b[3]*b[20]*b[36]-b[3]*b[25]*b[31]-b[3]*b[23]*b[33]-b[15]*b[6]*b[38]-b[15]*b[7]*b[37]+b[16]*b[32]*b[11]+b[16]*b[33]*b[10]-b[16]*b[5]*b[38]-b[16]*b[6]*b[37]-b[16]*b[7]*b[36]+b[16]*b[31]*b[12]+b[14]*b[33]*b[12]-b[14]*b[7]*b[38]+b[15]*b[32]*b[12]+b[15]*b[33]*b[11]+b[29]*b[5]*b[25]+b[29]*b[6]*b[24]-b[27]*b[20]*b[12]+b[27]*b[7]*b[25]-b[28]*b[19]*b[12]-b[28]*b[20]*b[11]+b[29]*b[7]*b[23]-b[29]*b[18]*b[12]-b[29]*b[19]*b[11]+b[28]*b[6]*b[25]+b[28]*b[7]*b[24]-b[29]*b[20]*b[10]+b[2]*b[19]*b[38]-b[1]*b[25]*b[33]+b[2]*b[20]*b[37]-b[2]*b[24]*b[33]-b[2]*b[25]*b[32]+b[1]*b[20]*b[38]); - c[1] = (b[29]*b[7]*b[24]-b[29]*b[20]*b[11]+b[2]*b[20]*b[38]-b[2]*b[25]*b[33]-b[28]*b[20]*b[12]+b[28]*b[7]*b[25]-b[29]*b[19]*b[12]-b[3]*b[24]*b[33]+b[15]*b[33]*b[12]+b[3]*b[19]*b[38]-b[16]*b[6]*b[38]+b[3]*b[20]*b[37]+b[16]*b[32]*b[12]+b[29]*b[6]*b[25]-b[16]*b[7]*b[37]-b[3]*b[25]*b[32]-b[15]*b[7]*b[38]+b[16]*b[33]*b[11]); - c[0] = -b[29]*b[20]*b[12]+b[29]*b[7]*b[25]+b[16]*b[33]*b[12]-b[16]*b[7]*b[38]+b[3]*b[20]*b[38]-b[3]*b[25]*b[33]; - - std::vector > roots; - solvePoly(coeffs, roots); + double c[11]; + Mat coeffs(1, 11, CV_64F, c); + c[10] = (b[0]*b[17]*b[34]+b[26]*b[4]*b[21]-b[26]*b[17]*b[8]-b[13]*b[4]*b[34]-b[0]*b[21]*b[30]+b[13]*b[30]*b[8]); + c[9] = (b[26]*b[4]*b[22]+b[14]*b[30]*b[8]+b[13]*b[31]*b[8]+b[1]*b[17]*b[34]-b[13]*b[5]*b[34]+b[26]*b[5]*b[21]-b[0]*b[21]*b[31]-b[26]*b[17]*b[9]-b[1]*b[21]*b[30]+b[27]*b[4]*b[21]+b[0]*b[17]*b[35]-b[0]*b[22]*b[30]+b[13]*b[30]*b[9]+b[0]*b[18]*b[34]-b[27]*b[17]*b[8]-b[14]*b[4]*b[34]-b[13]*b[4]*b[35]-b[26]*b[18]*b[8]); + c[8] = (b[14]*b[30]*b[9]+b[14]*b[31]*b[8]+b[13]*b[31]*b[9]-b[13]*b[4]*b[36]-b[13]*b[5]*b[35]+b[15]*b[30]*b[8]-b[13]*b[6]*b[34]+b[13]*b[30]*b[10]+b[13]*b[32]*b[8]-b[14]*b[4]*b[35]-b[14]*b[5]*b[34]+b[26]*b[4]*b[23]+b[26]*b[5]*b[22]+b[26]*b[6]*b[21]-b[26]*b[17]*b[10]-b[15]*b[4]*b[34]-b[26]*b[18]*b[9]-b[26]*b[19]*b[8]+b[27]*b[4]*b[22]+b[27]*b[5]*b[21]-b[27]*b[17]*b[9]-b[27]*b[18]*b[8]-b[1]*b[21]*b[31]-b[0]*b[23]*b[30]-b[0]*b[21]*b[32]+b[28]*b[4]*b[21]-b[28]*b[17]*b[8]+b[2]*b[17]*b[34]+b[0]*b[18]*b[35]-b[0]*b[22]*b[31]+b[0]*b[17]*b[36]+b[0]*b[19]*b[34]-b[1]*b[22]*b[30]+b[1]*b[18]*b[34]+b[1]*b[17]*b[35]-b[2]*b[21]*b[30]); + c[7] = (b[14]*b[30]*b[10]+b[14]*b[32]*b[8]-b[3]*b[21]*b[30]+b[3]*b[17]*b[34]+b[13]*b[32]*b[9]+b[13]*b[33]*b[8]-b[13]*b[4]*b[37]-b[13]*b[5]*b[36]+b[15]*b[30]*b[9]+b[15]*b[31]*b[8]-b[16]*b[4]*b[34]-b[13]*b[6]*b[35]-b[13]*b[7]*b[34]+b[13]*b[30]*b[11]+b[13]*b[31]*b[10]+b[14]*b[31]*b[9]-b[14]*b[4]*b[36]-b[14]*b[5]*b[35]-b[14]*b[6]*b[34]+b[16]*b[30]*b[8]-b[26]*b[20]*b[8]+b[26]*b[4]*b[24]+b[26]*b[5]*b[23]+b[26]*b[6]*b[22]+b[26]*b[7]*b[21]-b[26]*b[17]*b[11]-b[15]*b[4]*b[35]-b[15]*b[5]*b[34]-b[26]*b[18]*b[10]-b[26]*b[19]*b[9]+b[27]*b[4]*b[23]+b[27]*b[5]*b[22]+b[27]*b[6]*b[21]-b[27]*b[17]*b[10]-b[27]*b[18]*b[9]-b[27]*b[19]*b[8]+b[0]*b[17]*b[37]-b[0]*b[23]*b[31]-b[0]*b[24]*b[30]-b[0]*b[21]*b[33]-b[29]*b[17]*b[8]+b[28]*b[4]*b[22]+b[28]*b[5]*b[21]-b[28]*b[17]*b[9]-b[28]*b[18]*b[8]+b[29]*b[4]*b[21]+b[1]*b[19]*b[34]-b[2]*b[21]*b[31]+b[0]*b[20]*b[34]+b[0]*b[19]*b[35]+b[0]*b[18]*b[36]-b[0]*b[22]*b[32]-b[1]*b[23]*b[30]-b[1]*b[21]*b[32]+b[1]*b[18]*b[35]-b[1]*b[22]*b[31]-b[2]*b[22]*b[30]+b[2]*b[17]*b[35]+b[1]*b[17]*b[36]+b[2]*b[18]*b[34]); + c[6] = (-b[14]*b[6]*b[35]-b[14]*b[7]*b[34]-b[3]*b[22]*b[30]-b[3]*b[21]*b[31]+b[3]*b[17]*b[35]+b[3]*b[18]*b[34]+b[13]*b[32]*b[10]+b[13]*b[33]*b[9]-b[13]*b[4]*b[38]-b[13]*b[5]*b[37]-b[15]*b[6]*b[34]+b[15]*b[30]*b[10]+b[15]*b[32]*b[8]-b[16]*b[4]*b[35]-b[13]*b[6]*b[36]-b[13]*b[7]*b[35]+b[13]*b[31]*b[11]+b[13]*b[30]*b[12]+b[14]*b[32]*b[9]+b[14]*b[33]*b[8]-b[14]*b[4]*b[37]-b[14]*b[5]*b[36]+b[16]*b[30]*b[9]+b[16]*b[31]*b[8]-b[26]*b[20]*b[9]+b[26]*b[4]*b[25]+b[26]*b[5]*b[24]+b[26]*b[6]*b[23]+b[26]*b[7]*b[22]-b[26]*b[17]*b[12]+b[14]*b[30]*b[11]+b[14]*b[31]*b[10]+b[15]*b[31]*b[9]-b[15]*b[4]*b[36]-b[15]*b[5]*b[35]-b[26]*b[18]*b[11]-b[26]*b[19]*b[10]-b[27]*b[20]*b[8]+b[27]*b[4]*b[24]+b[27]*b[5]*b[23]+b[27]*b[6]*b[22]+b[27]*b[7]*b[21]-b[27]*b[17]*b[11]-b[27]*b[18]*b[10]-b[27]*b[19]*b[9]-b[16]*b[5]*b[34]-b[29]*b[17]*b[9]-b[29]*b[18]*b[8]+b[28]*b[4]*b[23]+b[28]*b[5]*b[22]+b[28]*b[6]*b[21]-b[28]*b[17]*b[10]-b[28]*b[18]*b[9]-b[28]*b[19]*b[8]+b[29]*b[4]*b[22]+b[29]*b[5]*b[21]-b[2]*b[23]*b[30]+b[2]*b[18]*b[35]-b[1]*b[22]*b[32]-b[2]*b[21]*b[32]+b[2]*b[19]*b[34]+b[0]*b[19]*b[36]-b[0]*b[22]*b[33]+b[0]*b[20]*b[35]-b[0]*b[23]*b[32]-b[0]*b[25]*b[30]+b[0]*b[17]*b[38]+b[0]*b[18]*b[37]-b[0]*b[24]*b[31]+b[1]*b[17]*b[37]-b[1]*b[23]*b[31]-b[1]*b[24]*b[30]-b[1]*b[21]*b[33]+b[1]*b[20]*b[34]+b[1]*b[19]*b[35]+b[1]*b[18]*b[36]+b[2]*b[17]*b[36]-b[2]*b[22]*b[31]); + c[5] = (-b[14]*b[6]*b[36]-b[14]*b[7]*b[35]+b[14]*b[31]*b[11]-b[3]*b[23]*b[30]-b[3]*b[21]*b[32]+b[3]*b[18]*b[35]-b[3]*b[22]*b[31]+b[3]*b[17]*b[36]+b[3]*b[19]*b[34]+b[13]*b[32]*b[11]+b[13]*b[33]*b[10]-b[13]*b[5]*b[38]-b[15]*b[6]*b[35]-b[15]*b[7]*b[34]+b[15]*b[30]*b[11]+b[15]*b[31]*b[10]+b[16]*b[31]*b[9]-b[13]*b[6]*b[37]-b[13]*b[7]*b[36]+b[13]*b[31]*b[12]+b[14]*b[32]*b[10]+b[14]*b[33]*b[9]-b[14]*b[4]*b[38]-b[14]*b[5]*b[37]-b[16]*b[6]*b[34]+b[16]*b[30]*b[10]+b[16]*b[32]*b[8]-b[26]*b[20]*b[10]+b[26]*b[5]*b[25]+b[26]*b[6]*b[24]+b[26]*b[7]*b[23]+b[14]*b[30]*b[12]+b[15]*b[32]*b[9]+b[15]*b[33]*b[8]-b[15]*b[4]*b[37]-b[15]*b[5]*b[36]+b[29]*b[5]*b[22]+b[29]*b[6]*b[21]-b[26]*b[18]*b[12]-b[26]*b[19]*b[11]-b[27]*b[20]*b[9]+b[27]*b[4]*b[25]+b[27]*b[5]*b[24]+b[27]*b[6]*b[23]+b[27]*b[7]*b[22]-b[27]*b[17]*b[12]-b[27]*b[18]*b[11]-b[27]*b[19]*b[10]-b[28]*b[20]*b[8]-b[16]*b[4]*b[36]-b[16]*b[5]*b[35]-b[29]*b[17]*b[10]-b[29]*b[18]*b[9]-b[29]*b[19]*b[8]+b[28]*b[4]*b[24]+b[28]*b[5]*b[23]+b[28]*b[6]*b[22]+b[28]*b[7]*b[21]-b[28]*b[17]*b[11]-b[28]*b[18]*b[10]-b[28]*b[19]*b[9]+b[29]*b[4]*b[23]-b[2]*b[22]*b[32]-b[2]*b[21]*b[33]-b[1]*b[24]*b[31]+b[0]*b[18]*b[38]-b[0]*b[24]*b[32]+b[0]*b[19]*b[37]+b[0]*b[20]*b[36]-b[0]*b[25]*b[31]-b[0]*b[23]*b[33]+b[1]*b[19]*b[36]-b[1]*b[22]*b[33]+b[1]*b[20]*b[35]+b[2]*b[19]*b[35]-b[2]*b[24]*b[30]-b[2]*b[23]*b[31]+b[2]*b[20]*b[34]+b[2]*b[17]*b[37]-b[1]*b[25]*b[30]+b[1]*b[18]*b[37]+b[1]*b[17]*b[38]-b[1]*b[23]*b[32]+b[2]*b[18]*b[36]); + c[4] = (-b[14]*b[6]*b[37]-b[14]*b[7]*b[36]+b[14]*b[31]*b[12]+b[3]*b[17]*b[37]-b[3]*b[23]*b[31]-b[3]*b[24]*b[30]-b[3]*b[21]*b[33]+b[3]*b[20]*b[34]+b[3]*b[19]*b[35]+b[3]*b[18]*b[36]-b[3]*b[22]*b[32]+b[13]*b[32]*b[12]+b[13]*b[33]*b[11]-b[15]*b[6]*b[36]-b[15]*b[7]*b[35]+b[15]*b[31]*b[11]+b[15]*b[30]*b[12]+b[16]*b[32]*b[9]+b[16]*b[33]*b[8]-b[13]*b[6]*b[38]-b[13]*b[7]*b[37]+b[14]*b[32]*b[11]+b[14]*b[33]*b[10]-b[14]*b[5]*b[38]-b[16]*b[6]*b[35]-b[16]*b[7]*b[34]+b[16]*b[30]*b[11]+b[16]*b[31]*b[10]-b[26]*b[19]*b[12]-b[26]*b[20]*b[11]+b[26]*b[6]*b[25]+b[26]*b[7]*b[24]+b[15]*b[32]*b[10]+b[15]*b[33]*b[9]-b[15]*b[4]*b[38]-b[15]*b[5]*b[37]+b[29]*b[5]*b[23]+b[29]*b[6]*b[22]+b[29]*b[7]*b[21]-b[27]*b[20]*b[10]+b[27]*b[5]*b[25]+b[27]*b[6]*b[24]+b[27]*b[7]*b[23]-b[27]*b[18]*b[12]-b[27]*b[19]*b[11]-b[28]*b[20]*b[9]-b[16]*b[4]*b[37]-b[16]*b[5]*b[36]+b[0]*b[19]*b[38]-b[0]*b[24]*b[33]+b[0]*b[20]*b[37]-b[29]*b[17]*b[11]-b[29]*b[18]*b[10]-b[29]*b[19]*b[9]+b[28]*b[4]*b[25]+b[28]*b[5]*b[24]+b[28]*b[6]*b[23]+b[28]*b[7]*b[22]-b[28]*b[17]*b[12]-b[28]*b[18]*b[11]-b[28]*b[19]*b[10]-b[29]*b[20]*b[8]+b[29]*b[4]*b[24]+b[2]*b[18]*b[37]-b[0]*b[25]*b[32]+b[1]*b[18]*b[38]-b[1]*b[24]*b[32]+b[1]*b[19]*b[37]+b[1]*b[20]*b[36]-b[1]*b[25]*b[31]+b[2]*b[17]*b[38]+b[2]*b[19]*b[36]-b[2]*b[24]*b[31]-b[2]*b[22]*b[33]-b[2]*b[23]*b[32]+b[2]*b[20]*b[35]-b[1]*b[23]*b[33]-b[2]*b[25]*b[30]); + c[3] = (-b[14]*b[6]*b[38]-b[14]*b[7]*b[37]+b[3]*b[19]*b[36]-b[3]*b[22]*b[33]+b[3]*b[20]*b[35]-b[3]*b[23]*b[32]-b[3]*b[25]*b[30]+b[3]*b[17]*b[38]+b[3]*b[18]*b[37]-b[3]*b[24]*b[31]-b[15]*b[6]*b[37]-b[15]*b[7]*b[36]+b[15]*b[31]*b[12]+b[16]*b[32]*b[10]+b[16]*b[33]*b[9]+b[13]*b[33]*b[12]-b[13]*b[7]*b[38]+b[14]*b[32]*b[12]+b[14]*b[33]*b[11]-b[16]*b[6]*b[36]-b[16]*b[7]*b[35]+b[16]*b[31]*b[11]+b[16]*b[30]*b[12]+b[15]*b[32]*b[11]+b[15]*b[33]*b[10]-b[15]*b[5]*b[38]+b[29]*b[5]*b[24]+b[29]*b[6]*b[23]-b[26]*b[20]*b[12]+b[26]*b[7]*b[25]-b[27]*b[19]*b[12]-b[27]*b[20]*b[11]+b[27]*b[6]*b[25]+b[27]*b[7]*b[24]-b[28]*b[20]*b[10]-b[16]*b[4]*b[38]-b[16]*b[5]*b[37]+b[29]*b[7]*b[22]-b[29]*b[17]*b[12]-b[29]*b[18]*b[11]-b[29]*b[19]*b[10]+b[28]*b[5]*b[25]+b[28]*b[6]*b[24]+b[28]*b[7]*b[23]-b[28]*b[18]*b[12]-b[28]*b[19]*b[11]-b[29]*b[20]*b[9]+b[29]*b[4]*b[25]-b[2]*b[24]*b[32]+b[0]*b[20]*b[38]-b[0]*b[25]*b[33]+b[1]*b[19]*b[38]-b[1]*b[24]*b[33]+b[1]*b[20]*b[37]-b[2]*b[25]*b[31]+b[2]*b[20]*b[36]-b[1]*b[25]*b[32]+b[2]*b[19]*b[37]+b[2]*b[18]*b[38]-b[2]*b[23]*b[33]); + c[2] = (b[3]*b[18]*b[38]-b[3]*b[24]*b[32]+b[3]*b[19]*b[37]+b[3]*b[20]*b[36]-b[3]*b[25]*b[31]-b[3]*b[23]*b[33]-b[15]*b[6]*b[38]-b[15]*b[7]*b[37]+b[16]*b[32]*b[11]+b[16]*b[33]*b[10]-b[16]*b[5]*b[38]-b[16]*b[6]*b[37]-b[16]*b[7]*b[36]+b[16]*b[31]*b[12]+b[14]*b[33]*b[12]-b[14]*b[7]*b[38]+b[15]*b[32]*b[12]+b[15]*b[33]*b[11]+b[29]*b[5]*b[25]+b[29]*b[6]*b[24]-b[27]*b[20]*b[12]+b[27]*b[7]*b[25]-b[28]*b[19]*b[12]-b[28]*b[20]*b[11]+b[29]*b[7]*b[23]-b[29]*b[18]*b[12]-b[29]*b[19]*b[11]+b[28]*b[6]*b[25]+b[28]*b[7]*b[24]-b[29]*b[20]*b[10]+b[2]*b[19]*b[38]-b[1]*b[25]*b[33]+b[2]*b[20]*b[37]-b[2]*b[24]*b[33]-b[2]*b[25]*b[32]+b[1]*b[20]*b[38]); + c[1] = (b[29]*b[7]*b[24]-b[29]*b[20]*b[11]+b[2]*b[20]*b[38]-b[2]*b[25]*b[33]-b[28]*b[20]*b[12]+b[28]*b[7]*b[25]-b[29]*b[19]*b[12]-b[3]*b[24]*b[33]+b[15]*b[33]*b[12]+b[3]*b[19]*b[38]-b[16]*b[6]*b[38]+b[3]*b[20]*b[37]+b[16]*b[32]*b[12]+b[29]*b[6]*b[25]-b[16]*b[7]*b[37]-b[3]*b[25]*b[32]-b[15]*b[7]*b[38]+b[16]*b[33]*b[11]); + c[0] = -b[29]*b[20]*b[12]+b[29]*b[7]*b[25]+b[16]*b[33]*b[12]-b[16]*b[7]*b[38]+b[3]*b[20]*b[38]-b[3]*b[25]*b[33]; - std::vector xs, ys, zs; - int count = 0; - double * e = ematrix->data.db; + std::vector > roots; + solvePoly(coeffs, roots); + + std::vector xs, ys, zs; + int count = 0; + double * e = ematrix->data.db; for (size_t i = 0; i < roots.size(); i++) { - if (fabs(roots[i].imag()) > 1e-10) continue; - double z1 = roots[i].real(); - double z2 = z1 * z1; - double z3 = z2 * z1; - double z4 = z3 * z1; - - double bz[3][3]; + if (fabs(roots[i].imag()) > 1e-10) continue; + double z1 = roots[i].real(); + double z2 = z1 * z1; + double z3 = z2 * z1; + double z4 = z3 * z1; + + double bz[3][3]; for (int j = 0; j < 3; j++) { - const double * br = b + j * 13; - bz[j][0] = br[0] * z3 + br[1] * z2 + br[2] * z1 + br[3]; - bz[j][1] = br[4] * z3 + br[5] * z2 + br[6] * z1 + br[7]; - bz[j][2] = br[8] * z4 + br[9] * z3 + br[10] * z2 + br[11] * z1 + br[12]; + const double * br = b + j * 13; + bz[j][0] = br[0] * z3 + br[1] * z2 + br[2] * z1 + br[3]; + bz[j][1] = br[4] * z3 + br[5] * z2 + br[6] * z1 + br[7]; + bz[j][2] = br[8] * z4 + br[9] * z3 + br[10] * z2 + br[11] * z1 + br[12]; } - Mat Bz(3, 3, CV_64F, bz); - cv::Mat xy1; - SVD::solveZ(Bz, xy1); + Mat Bz(3, 3, CV_64F, bz); + cv::Mat xy1; + SVD::solveZ(Bz, xy1); - if (fabs(xy1.at(2)) < 1e-10) continue; - xs.push_back(xy1.at(0) / xy1.at(2)); - ys.push_back(xy1.at(1) / xy1.at(2)); - zs.push_back(z1); + if (fabs(xy1.at(2)) < 1e-10) continue; + xs.push_back(xy1.at(0) / xy1.at(2)); + ys.push_back(xy1.at(1) / xy1.at(2)); + zs.push_back(z1); - cv::Mat Evec = EE.col(0) * xs.back() + EE.col(1) * ys.back() + EE.col(2) * zs.back() + EE.col(3); - Evec /= norm(Evec); - - memcpy(e + count * 9, Evec.data, 9 * sizeof(double)); - count++; + cv::Mat Evec = EE.col(0) * xs.back() + EE.col(1) * ys.back() + EE.col(2) * zs.back() + EE.col(3); + Evec /= norm(Evec); + + memcpy(e + count * 9, Evec.data, 9 * sizeof(double)); + count++; } - return count; + return count; } // Same as the runKernel (run5Point), m1 and m2 should be -// 1 row x n col x 2 channels. -// And also, error has to be of CV_32FC1. +// 1 row x n col x 2 channels. +// And also, error has to be of CV_32FC1. void CvEMEstimator::computeReprojError( const CvMat* m1, const CvMat* m2, const CvMat* model, CvMat* error ) { - Mat X1(m1), X2(m2); - int n = X1.cols; - X1 = X1.reshape(1, n); - X2 = X2.reshape(1, n); + Mat X1(m1), X2(m2); + int n = X1.cols; + X1 = X1.reshape(1, n); + X2 = X2.reshape(1, n); - X1.convertTo(X1, CV_64F); - X2.convertTo(X2, CV_64F); + X1.convertTo(X1, CV_64F); + X2.convertTo(X2, CV_64F); - Mat E(model); + Mat E(model); for (int i = 0; i < n; i++) { - Mat x1 = (Mat_(3, 1) << X1.at(i, 0), X1.at(i, 1), 1.0); - Mat x2 = (Mat_(3, 1) << X2.at(i, 0), X2.at(i, 1), 1.0); - double x2tEx1 = x2.dot(E * x1); - Mat Ex1 = E * x1; - Mat Etx2 = E * x2; - double a = Ex1.at(0) * Ex1.at(0); - double b = Ex1.at(1) * Ex1.at(1); - double c = Etx2.at(0) * Etx2.at(0); - double d = Etx2.at(0) * Etx2.at(0); + Mat x1 = (Mat_(3, 1) << X1.at(i, 0), X1.at(i, 1), 1.0); + Mat x2 = (Mat_(3, 1) << X2.at(i, 0), X2.at(i, 1), 1.0); + double x2tEx1 = x2.dot(E * x1); + Mat Ex1 = E * x1; + Mat Etx2 = E * x2; + double a = Ex1.at(0) * Ex1.at(0); + double b = Ex1.at(1) * Ex1.at(1); + double c = Etx2.at(0) * Etx2.at(0); + double d = Etx2.at(0) * Etx2.at(0); - error->data.fl[i] = (float)(x2tEx1 * x2tEx1 / (a + b + c + d)); + error->data.fl[i] = (float)(x2tEx1 * x2tEx1 / (a + b + c + d)); } } @@ -434,7 +433,7 @@ void CvEMEstimator::calibrated_fivepoint_helper( double *EE, double* A ) double e003,e013,e023,e033,e043,e053,e063,e073,e083; double e103,e113,e123,e133,e143,e153,e163,e173,e183; double e203,e213,e223,e233,e243,e253,e263,e273,e283; - double e303,e313,e323,e333,e343,e353,e363,e373,e383; + double e303,e313,e323,e333,e343,e353,e363,e373,e383; e00 = EE[0*9 + 0 ]; e10 = EE[1*9 + 0 ]; e20 = EE[2*9 + 0 ]; @@ -471,8 +470,8 @@ void CvEMEstimator::calibrated_fivepoint_helper( double *EE, double* A ) e18 = EE[1*9 + 8 ]; e28 = EE[2*9 + 8 ]; e38 = EE[3*9 + 8 ]; - - + + e002 =e00*e00; e102 =e10*e10; e202 =e20*e20; @@ -509,7 +508,7 @@ void CvEMEstimator::calibrated_fivepoint_helper( double *EE, double* A ) e182 =e18*e18; e282 =e28*e28; e382 =e38*e38; - + e003 =e00*e00*e00; e103 =e10*e10*e10; e203 =e20*e20*e20; @@ -546,8 +545,8 @@ void CvEMEstimator::calibrated_fivepoint_helper( double *EE, double* A ) e183 =e18*e18*e18; e283 =e28*e28*e28; e383 =e38*e38*e38; - - + + A[0 + 10*0]=0.5*e003+0.5*e00*e012+0.5*e00*e022+0.5*e00*e032+e03*e01*e04+e03*e02*e05+0.5*e00*e062+e06*e01*e07+e06*e02*e08-0.5*e00*e042-0.5*e00*e052-0.5*e00*e072-0.5*e00*e082; A[0 + 10*1]=e00*e11*e01+e00*e12*e02+e03*e00*e13+e03*e11*e04+e03*e01*e14+e03*e12*e05+e03*e02*e15+e13*e01*e04+e13*e02*e05+e06*e00*e16+1.5*e10*e002+0.5*e10*e012+0.5*e10*e022+0.5*e10*e062-0.5*e10*e042-0.5*e10*e052-0.5*e10*e072+0.5*e10*e032+e06*e11*e07+e06*e01*e17+e06*e12*e08+e06*e02*e18+e16*e01*e07+e16*e02*e08-e00*e14*e04-e00*e17*e07-e00*e15*e05-e00*e18*e08-0.5*e10*e082; A[0 + 10*2]=e16*e02*e18+e03*e12*e15+e10*e11*e01+e10*e12*e02+e03*e10*e13+e03*e11*e14+e13*e11*e04+e13*e01*e14+e13*e12*e05+e13*e02*e15+e06*e10*e16+e06*e12*e18+e06*e11*e17+e16*e11*e07+e16*e01*e17+e16*e12*e08-e10*e14*e04-e10*e17*e07-e10*e15*e05-e10*e18*e08+1.5*e00*e102+0.5*e00*e122+0.5*e00*e112+0.5*e00*e132+0.5*e00*e162-0.5*e00*e152-0.5*e00*e172-0.5*e00*e182-0.5*e00*e142; diff --git a/modules/calib3d/src/modelest.cpp b/modules/calib3d/src/modelest.cpp index d49524b6b..3c54c218b 100644 --- a/modules/calib3d/src/modelest.cpp +++ b/modules/calib3d/src/modelest.cpp @@ -45,9 +45,6 @@ #include #include -using namespace std; - - CvModelEstimator2::CvModelEstimator2(int _modelPoints, CvSize _modelSize, int _maxBasicSolutions) { modelPoints = _modelPoints; @@ -272,7 +269,7 @@ bool CvModelEstimator2::runLMeDS( const CvMat* m1, const CvMat* m2, CvMat* model if( minMedian < DBL_MAX ) { - sigma = 2.5*1.4826*(1 + 5./(count - modelPoints))*sqrt(minMedian); + sigma = 2.5*1.4826*(1 + 5./(count - modelPoints))*std::sqrt(minMedian); sigma = MAX( sigma, 0.001 ); count = findInliers( m1, m2, model, err, mask, sigma ); @@ -433,7 +430,7 @@ void cv::Affine3DEstimator::computeReprojError( const CvMat* m1, const CvMat* m2 double b = F[4]*f.x + F[5]*f.y + F[ 6]*f.z + F[ 7] - t.y; double c = F[8]*f.x + F[9]*f.y + F[10]*f.z + F[11] - t.z; - err[i] = (float)sqrt(a*a + b*b + c*c); + err[i] = (float)std::sqrt(a*a + b*b + c*c); } } @@ -493,7 +490,7 @@ int cv::estimateAffine3D(InputArray _from, InputArray _to, CvMat m1 = dFrom; CvMat m2 = dTo; - const double epsilon = numeric_limits::epsilon(); + const double epsilon = std::numeric_limits::epsilon(); param1 = param1 <= 0 ? 3 : param1; param2 = (param2 < epsilon) ? 0.99 : (param2 > 1 - epsilon) ? 0.99 : param2; diff --git a/modules/calib3d/src/p3p.cpp b/modules/calib3d/src/p3p.cpp index a02da3ecb..92e795472 100644 --- a/modules/calib3d/src/p3p.cpp +++ b/modules/calib3d/src/p3p.cpp @@ -5,8 +5,6 @@ #include "polynom_solver.h" #include "p3p.h" -using namespace std; - void p3p::init_inverse_parameters() { inv_fx = 1. / fx; diff --git a/modules/calib3d/src/polynom_solver.cpp b/modules/calib3d/src/polynom_solver.cpp index 1813340af..ea43b69c7 100644 --- a/modules/calib3d/src/polynom_solver.cpp +++ b/modules/calib3d/src/polynom_solver.cpp @@ -1,9 +1,8 @@ +#include "precomp.hpp" +#include "polynom_solver.h" + #include #include -using namespace std; -#include "precomp.hpp" - -#include "polynom_solver.h" int solve_deg2(double a, double b, double c, double & x1, double & x2) { diff --git a/modules/calib3d/src/quadsubpix.cpp b/modules/calib3d/src/quadsubpix.cpp index 2f2dae3a4..26f26b580 100644 --- a/modules/calib3d/src/quadsubpix.cpp +++ b/modules/calib3d/src/quadsubpix.cpp @@ -54,7 +54,7 @@ namespace cv { -// static void drawCircles(Mat& img, const vector& corners, const vector& radius) +// static void drawCircles(Mat& img, const std::vector& corners, const std::vector& radius) // { // for(size_t i = 0; i < corners.size(); i++) // { @@ -86,7 +86,7 @@ inline bool is_smaller(const std::pair& p1, const std::pair >& contours, Point2f point, vector >& order) +static void orderContours(const std::vector >& contours, Point2f point, std::vector >& order) { order.clear(); size_t i, j, n = contours.size(); @@ -106,12 +106,12 @@ static void orderContours(const vector >& contours, Point2f point, } // fit second order curve to a set of 2D points -inline void fitCurve2Order(const vector& /*points*/, vector& /*curve*/) +inline void fitCurve2Order(const std::vector& /*points*/, std::vector& /*curve*/) { // TBD } -inline void findCurvesCross(const vector& /*curve1*/, const vector& /*curve2*/, Point2f& /*cross_point*/) +inline void findCurvesCross(const std::vector& /*curve1*/, const std::vector& /*curve2*/, Point2f& /*cross_point*/) { } @@ -124,7 +124,7 @@ static void findLinesCrossPoint(Point2f origin1, Point2f dir1, Point2f origin2, cross_point = origin1 + dir1*alpha; } -// static void findCorner(const vector& contour, Point2f point, Point2f& corner) +// static void findCorner(const std::vector& contour, Point2f point, Point2f& corner) // { // // find the nearest point // double min_dist = std::numeric_limits::max(); @@ -147,7 +147,7 @@ static void findLinesCrossPoint(Point2f origin1, Point2f dir1, Point2f origin2, // return; // } -static void findCorner(const vector& contour, Point2f point, Point2f& corner) +static void findCorner(const std::vector& contour, Point2f point, Point2f& corner) { // find the nearest point double min_dist = std::numeric_limits::max(); @@ -234,7 +234,7 @@ bool cv::find4QuadCornerSubpix(InputArray _img, InputOutputArray _corners, Size Mat hist; #if defined(_SUBPIX_VERBOSE) - vector radius; + std::vector radius; radius.assign(corners.size(), 0.0f); #endif //_SUBPIX_VERBOSE @@ -277,15 +277,15 @@ bool cv::find4QuadCornerSubpix(InputArray _img, InputOutputArray _corners, Size #endif - vector > white_contours, black_contours; - vector white_hierarchy, black_hierarchy; + std::vector > white_contours, black_contours; + std::vector white_hierarchy, black_hierarchy; findContours(black_comp, black_contours, black_hierarchy, CV_RETR_LIST, CV_CHAIN_APPROX_SIMPLE); findContours(white_comp, white_contours, white_hierarchy, CV_RETR_LIST, CV_CHAIN_APPROX_SIMPLE); if(black_contours.size() < 5 || white_contours.size() < 5) continue; // find two white and black blobs that are close to the input point - vector > white_order, black_order; + std::vector > white_order, black_order; orderContours(black_contours, corners[i], black_order); orderContours(white_contours, corners[i], white_order); @@ -296,14 +296,14 @@ bool cv::find4QuadCornerSubpix(InputArray _img, InputOutputArray _corners, Size continue; // there will be no improvement in this corner position } - const vector* quads[4] = {&black_contours[black_order[0].first], &black_contours[black_order[1].first], + const std::vector* quads[4] = {&black_contours[black_order[0].first], &black_contours[black_order[1].first], &white_contours[white_order[0].first], &white_contours[white_order[1].first]}; - vector quads_approx[4]; + std::vector quads_approx[4]; Point2f quad_corners[4]; for(int k = 0; k < 4; k++) { #if 1 - vector temp; + std::vector temp; for(size_t j = 0; j < quads[k]->size(); j++) temp.push_back((*quads[k])[j]); approxPolyDP(Mat(temp), quads_approx[k], 0.5, true); @@ -332,14 +332,14 @@ bool cv::find4QuadCornerSubpix(InputArray _img, InputOutputArray _corners, Size cvtColor(img, test, CV_GRAY2RGB); // line(test, quad_corners[0] - corners[i] + Point2f(30, 30), quad_corners[1] - corners[i] + Point2f(30, 30), cvScalar(0, 255, 0)); // line(test, quad_corners[2] - corners[i] + Point2f(30, 30), quad_corners[3] - corners[i] + Point2f(30, 30), cvScalar(0, 255, 0)); - vector > contrs; + std::vector > contrs; contrs.resize(1); for(int k = 0; k < 4; k++) { //contrs[0] = quads_approx[k]; contrs[0].clear(); for(size_t j = 0; j < quads_approx[k].size(); j++) contrs[0].push_back(quads_approx[k][j]); - drawContours(test, contrs, 0, CV_RGB(0, 0, 255), 1, 1, vector(), 2); + drawContours(test, contrs, 0, CV_RGB(0, 0, 255), 1, 1, std::vector(), 2); circle(test, quad_corners[k], 0.5, CV_RGB(255, 0, 0)); } Mat test1 = test(Rect(corners[i].x - 30, corners[i].y - 30, 60, 60)); diff --git a/modules/calib3d/src/solvepnp.cpp b/modules/calib3d/src/solvepnp.cpp index 25988be48..5bcffb316 100644 --- a/modules/calib3d/src/solvepnp.cpp +++ b/modules/calib3d/src/solvepnp.cpp @@ -162,8 +162,8 @@ namespace cv CameraParameters camera; }; - static void pnpTask(const vector& pointsMask, const Mat& objectPoints, const Mat& imagePoints, - const Parameters& params, vector& inliers, Mat& rvec, Mat& tvec, + static void pnpTask(const std::vector& pointsMask, const Mat& objectPoints, const Mat& imagePoints, + const Parameters& params, std::vector& inliers, Mat& rvec, Mat& tvec, const Mat& rvecInit, const Mat& tvecInit, Mutex& resultsMutex) { Mat modelObjectPoints(1, MIN_POINTS_COUNT, CV_32FC3), modelImagePoints(1, MIN_POINTS_COUNT, CV_32FC2); @@ -199,14 +199,14 @@ namespace cv params.useExtrinsicGuess, params.flags); - vector projected_points; + std::vector projected_points; projected_points.resize(objectPoints.cols); projectPoints(objectPoints, localRvec, localTvec, params.camera.intrinsics, params.camera.distortion, projected_points); Mat rotatedPoints; project3dPoints(objectPoints, localRvec, localTvec, rotatedPoints); - vector localInliers; + std::vector localInliers; for (int i = 0; i < objectPoints.cols; i++) { Point2f p(imagePoints.at(0, i)[0], imagePoints.at(0, i)[1]); @@ -236,7 +236,7 @@ namespace cv public: void operator()( const BlockedRange& r ) const { - vector pointsMask(objectPoints.cols, 0); + std::vector pointsMask(objectPoints.cols, 0); memset(&pointsMask[0], 1, MIN_POINTS_COUNT ); for( int i=r.begin(); i!=r.end(); ++i ) { @@ -254,7 +254,7 @@ namespace cv } } PnPSolver(const Mat& _objectPoints, const Mat& _imagePoints, const Parameters& _parameters, - Mat& _rvec, Mat& _tvec, vector& _inliers): + Mat& _rvec, Mat& _tvec, std::vector& _inliers): objectPoints(_objectPoints), imagePoints(_imagePoints), parameters(_parameters), rvec(_rvec), tvec(_tvec), inliers(_inliers) { @@ -270,13 +270,13 @@ namespace cv const Mat& imagePoints; const Parameters& parameters; Mat &rvec, &tvec; - vector& inliers; + std::vector& inliers; Mat initRvec, initTvec; static RNG generator; static Mutex syncMutex; - void generateVar(vector& mask) const + void generateVar(std::vector& mask) const { int size = (int)mask.size(); for (int i = 0; i < size; i++) @@ -329,7 +329,7 @@ void cv::solvePnPRansac(InputArray _opoints, InputArray _ipoints, params.camera.init(cameraMatrix, distCoeffs); params.flags = flags; - vector localInliers; + std::vector localInliers; Mat localRvec, localTvec; rvec.copyTo(localRvec); tvec.copyTo(localTvec); diff --git a/modules/calib3d/src/stereobm.cpp b/modules/calib3d/src/stereobm.cpp index b69fa2374..fcf8f13a1 100644 --- a/modules/calib3d/src/stereobm.cpp +++ b/modules/calib3d/src/stereobm.cpp @@ -716,8 +716,8 @@ struct FindStereoCorrespInvoker void operator()( const BlockedRange& range ) const { int cols = left->cols, rows = left->rows; - int _row0 = min(cvRound(range.begin() * rows / nstripes), rows); - int _row1 = min(cvRound(range.end() * rows / nstripes), rows); + int _row0 = std::min(cvRound(range.begin() * rows / nstripes), rows); + int _row1 = std::min(cvRound(range.end() * rows / nstripes), rows); uchar *ptr = state->slidingSumBuf->data.ptr + range.begin() * stripeBufSize; int FILTERED = (state->minDisparity - 1)*16; @@ -801,7 +801,7 @@ static void findStereoCorrespondenceBM( const Mat& left0, const Mat& right0, Mat CV_Error( CV_StsOutOfRange, "preFilterCap must be within 1..63" ); if( state->SADWindowSize < 5 || state->SADWindowSize > 255 || state->SADWindowSize % 2 == 0 || - state->SADWindowSize >= min(left0.cols, left0.rows) ) + state->SADWindowSize >= std::min(left0.cols, left0.rows) ) CV_Error( CV_StsOutOfRange, "SADWindowSize must be odd, be within 5..255 and be not larger than image width or height" ); if( state->numberOfDisparities <= 0 || state->numberOfDisparities % 16 != 0 ) @@ -831,8 +831,8 @@ static void findStereoCorrespondenceBM( const Mat& left0, const Mat& right0, Mat int width = left0.cols; int height = left0.rows; - int lofs = max(ndisp - 1 + mindisp, 0); - int rofs = -min(ndisp - 1 + mindisp, 0); + int lofs = std::max(ndisp - 1 + mindisp, 0); + int rofs = -std::min(ndisp - 1 + mindisp, 0); int width1 = width - rofs - ndisp + 1; int FILTERED = (state->minDisparity - 1) << DISPARITY_SHIFT; @@ -874,13 +874,13 @@ static void findStereoCorrespondenceBM( const Mat& left0, const Mat& right0, Mat #ifdef HAVE_TBB const double SAD_overhead_coeff = 10.0; double N0 = 8000000 / (useShorts ? 1 : 4); // approx tbb's min number instructions reasonable for one thread - double maxStripeSize = min(max(N0 / (width * ndisp), (wsz-1) * SAD_overhead_coeff), (double)height); + double maxStripeSize = std::min(std::max(N0 / (width * ndisp), (wsz-1) * SAD_overhead_coeff), (double)height); int nstripes = cvCeil(height / maxStripeSize); #else const int nstripes = 1; #endif - int bufSize = max(bufSize0 * nstripes, max(bufSize1 * 2, bufSize2)); + int bufSize = std::max(bufSize0 * nstripes, std::max(bufSize1 * 2, bufSize2)); if( !state->slidingSumBuf || state->slidingSumBuf->cols < bufSize ) { diff --git a/modules/calib3d/src/stereosgbm.cpp b/modules/calib3d/src/stereosgbm.cpp index 8caab41b8..4028004cd 100644 --- a/modules/calib3d/src/stereosgbm.cpp +++ b/modules/calib3d/src/stereosgbm.cpp @@ -114,8 +114,8 @@ static void calcPixelCostBT( const Mat& img1, const Mat& img2, int y, int tabOfs, int ) { int x, c, width = img1.cols, cn = img1.channels(); - int minX1 = max(maxD, 0), maxX1 = width + min(minD, 0); - int minX2 = max(minX1 - maxD, 0), maxX2 = min(maxX1 - minD, width); + int minX1 = std::max(maxD, 0), maxX1 = width + std::min(minD, 0); + int minX2 = std::max(minX1 - maxD, 0), maxX2 = std::min(maxX1 - minD, width); int D = maxD - minD, width1 = maxX1 - minX1, width2 = maxX2 - minX2; const PixType *row1 = img1.ptr(y), *row2 = img2.ptr(y); PixType *prow1 = buffer + width2*2, *prow2 = prow1 + width*cn*2; @@ -186,8 +186,8 @@ static void calcPixelCostBT( const Mat& img1, const Mat& img2, int y, int v = prow2[x]; int vl = x > 0 ? (v + prow2[x-1])/2 : v; int vr = x < width-1 ? (v + prow2[x+1])/2 : v; - int v0 = min(vl, vr); v0 = min(v0, v); - int v1 = max(vl, vr); v1 = max(v1, v); + int v0 = std::min(vl, vr); v0 = std::min(v0, v); + int v1 = std::max(vl, vr); v1 = std::max(v1, v); buffer[x] = (PixType)v0; buffer[x + width2] = (PixType)v1; } @@ -197,8 +197,8 @@ static void calcPixelCostBT( const Mat& img1, const Mat& img2, int y, int u = prow1[x]; int ul = x > 0 ? (u + prow1[x-1])/2 : u; int ur = x < width-1 ? (u + prow1[x+1])/2 : u; - int u0 = min(ul, ur); u0 = min(u0, u); - int u1 = max(ul, ur); u1 = max(u1, u); + int u0 = std::min(ul, ur); u0 = std::min(u0, u); + int u1 = std::max(ul, ur); u1 = std::max(u1, u); #if CV_SSE2 if( useSIMD ) @@ -231,10 +231,10 @@ static void calcPixelCostBT( const Mat& img1, const Mat& img2, int y, int v = prow2[width-x-1 + d]; int v0 = buffer[width-x-1 + d]; int v1 = buffer[width-x-1 + d + width2]; - int c0 = max(0, u - v1); c0 = max(c0, v0 - u); - int c1 = max(0, v - u1); c1 = max(c1, u0 - v); + int c0 = std::max(0, u - v1); c0 = std::max(c0, v0 - u); + int c1 = std::max(0, v - u1); c1 = std::max(c1, u0 - v); - cost[x*D + d] = (CostType)(cost[x*D+d] + (min(c0, c1) >> diff_scale)); + cost[x*D + d] = (CostType)(cost[x*D+d] + (std::min(c0, c1) >> diff_scale)); } } } @@ -324,12 +324,12 @@ static void computeDisparitySGBM( const Mat& img1, const Mat& img2, int minD = params.minDisparity, maxD = minD + params.numberOfDisparities; Size SADWindowSize; SADWindowSize.width = SADWindowSize.height = params.SADWindowSize > 0 ? params.SADWindowSize : 5; - int ftzero = max(params.preFilterCap, 15) | 1; + int ftzero = std::max(params.preFilterCap, 15) | 1; int uniquenessRatio = params.uniquenessRatio >= 0 ? params.uniquenessRatio : 10; int disp12MaxDiff = params.disp12MaxDiff > 0 ? params.disp12MaxDiff : 1; - int P1 = params.P1 > 0 ? params.P1 : 2, P2 = max(params.P2 > 0 ? params.P2 : 5, P1+1); + int P1 = params.P1 > 0 ? params.P1 : 2, P2 = std::max(params.P2 > 0 ? params.P2 : 5, P1+1); int k, width = disp1.cols, height = disp1.rows; - int minX1 = max(maxD, 0), maxX1 = width + min(minD, 0); + int minX1 = std::max(maxD, 0), maxX1 = width + std::min(minD, 0); int D = maxD - minD, width1 = maxX1 - minX1; int INVALID_DISP = minD - 1, INVALID_DISP_SCALED = INVALID_DISP*DISP_SCALE; int SW2 = SADWindowSize.width/2, SH2 = SADWindowSize.height/2; @@ -338,7 +338,7 @@ static void computeDisparitySGBM( const Mat& img1, const Mat& img2, PixType clipTab[TAB_SIZE]; for( k = 0; k < TAB_SIZE; k++ ) - clipTab[k] = (PixType)(min(max(k - TAB_OFS, -ftzero), ftzero) + ftzero); + clipTab[k] = (PixType)(std::min(std::max(k - TAB_OFS, -ftzero), ftzero) + ftzero); if( minX1 >= maxX1 ) { @@ -432,7 +432,7 @@ static void computeDisparitySGBM( const Mat& img1, const Mat& img2, for( k = dy1; k <= dy2; k++ ) { - CostType* hsumAdd = hsumBuf + (min(k, height-1) % hsumBufNRows)*costBufSize; + CostType* hsumAdd = hsumBuf + (std::min(k, height-1) % hsumBufNRows)*costBufSize; if( k < height ) { @@ -448,13 +448,13 @@ static void computeDisparitySGBM( const Mat& img1, const Mat& img2, if( y > 0 ) { - const CostType* hsumSub = hsumBuf + (max(y - SH2 - 1, 0) % hsumBufNRows)*costBufSize; + const CostType* hsumSub = hsumBuf + (std::max(y - SH2 - 1, 0) % hsumBufNRows)*costBufSize; const CostType* Cprev = !params.fullDP || y == 0 ? C : C - costBufSize; for( x = D; x < width1*D; x += D ) { - const CostType* pixAdd = pixDiff + min(x + SW2*D, (width1-1)*D); - const CostType* pixSub = pixDiff + max(x - (SW2+1)*D, 0); + const CostType* pixAdd = pixDiff + std::min(x + SW2*D, (width1-1)*D); + const CostType* pixSub = pixDiff + std::max(x - (SW2+1)*D, 0); #if CV_SSE2 if( useSIMD ) @@ -488,8 +488,8 @@ static void computeDisparitySGBM( const Mat& img1, const Mat& img2, { for( x = D; x < width1*D; x += D ) { - const CostType* pixAdd = pixDiff + min(x + SW2*D, (width1-1)*D); - const CostType* pixSub = pixDiff + max(x - (SW2+1)*D, 0); + const CostType* pixAdd = pixDiff + std::min(x + SW2*D, (width1-1)*D); + const CostType* pixSub = pixDiff + std::max(x - (SW2+1)*D, 0); for( d = 0; d < D; d++ ) hsumAdd[x + d] = (CostType)(hsumAdd[x - D + d] + pixAdd[d] - pixSub[d]); @@ -630,22 +630,22 @@ static void computeDisparitySGBM( const Mat& img1, const Mat& img2, { int Cpd = Cp[d], L0, L1, L2, L3; - L0 = Cpd + min((int)Lr_p0[d], min(Lr_p0[d-1] + P1, min(Lr_p0[d+1] + P1, delta0))) - delta0; - L1 = Cpd + min((int)Lr_p1[d], min(Lr_p1[d-1] + P1, min(Lr_p1[d+1] + P1, delta1))) - delta1; - L2 = Cpd + min((int)Lr_p2[d], min(Lr_p2[d-1] + P1, min(Lr_p2[d+1] + P1, delta2))) - delta2; - L3 = Cpd + min((int)Lr_p3[d], min(Lr_p3[d-1] + P1, min(Lr_p3[d+1] + P1, delta3))) - delta3; + L0 = Cpd + std::min((int)Lr_p0[d], std::min(Lr_p0[d-1] + P1, std::min(Lr_p0[d+1] + P1, delta0))) - delta0; + L1 = Cpd + std::min((int)Lr_p1[d], std::min(Lr_p1[d-1] + P1, std::min(Lr_p1[d+1] + P1, delta1))) - delta1; + L2 = Cpd + std::min((int)Lr_p2[d], std::min(Lr_p2[d-1] + P1, std::min(Lr_p2[d+1] + P1, delta2))) - delta2; + L3 = Cpd + std::min((int)Lr_p3[d], std::min(Lr_p3[d-1] + P1, std::min(Lr_p3[d+1] + P1, delta3))) - delta3; Lr_p[d] = (CostType)L0; - minL0 = min(minL0, L0); + minL0 = std::min(minL0, L0); Lr_p[d + D2] = (CostType)L1; - minL1 = min(minL1, L1); + minL1 = std::min(minL1, L1); Lr_p[d + D2*2] = (CostType)L2; - minL2 = min(minL2, L2); + minL2 = std::min(minL2, L2); Lr_p[d + D2*3] = (CostType)L3; - minL3 = min(minL3, L3); + minL3 = std::min(minL3, L3); Sp[d] = saturate_cast(Sp[d] + L0 + L1 + L2 + L3); } @@ -737,10 +737,10 @@ static void computeDisparitySGBM( const Mat& img1, const Mat& img2, { for( d = 0; d < D; d++ ) { - int L0 = Cp[d] + min((int)Lr_p0[d], min(Lr_p0[d-1] + P1, min(Lr_p0[d+1] + P1, delta0))) - delta0; + int L0 = Cp[d] + std::min((int)Lr_p0[d], std::min(Lr_p0[d-1] + P1, std::min(Lr_p0[d+1] + P1, delta0))) - delta0; Lr_p[d] = (CostType)L0; - minL0 = min(minL0, L0); + minL0 = std::min(minL0, L0); int Sval = Sp[d] = saturate_cast(Sp[d] + L0); if( Sval < minS ) @@ -785,7 +785,7 @@ static void computeDisparitySGBM( const Mat& img1, const Mat& img2, // do subpixel quadratic interpolation: // fit parabola into (x1=d-1, y1=Sp[d-1]), (x2=d, y2=Sp[d]), (x3=d+1, y3=Sp[d+1]) // then find minimum of the parabola. - int denom2 = max(Sp[d-1] + Sp[d+1] - 2*Sp[d], 1); + int denom2 = std::max(Sp[d-1] + Sp[d+1] - 2*Sp[d], 1); d = d*DISP_SCALE + ((Sp[d-1] - Sp[d+1])*DISP_SCALE + denom2)/(denom2*2); } else @@ -845,10 +845,10 @@ Rect getValidDisparityROI( Rect roi1, Rect roi2, int SW2 = SADWindowSize/2; int minD = minDisparity, maxD = minDisparity + numberOfDisparities - 1; - int xmin = max(roi1.x, roi2.x + maxD) + SW2; - int xmax = min(roi1.x + roi1.width, roi2.x + roi2.width - minD) - SW2; - int ymin = max(roi1.y, roi2.y) + SW2; - int ymax = min(roi1.y + roi1.height, roi2.y + roi2.height) - SW2; + int xmin = std::max(roi1.x, roi2.x + maxD) + SW2; + int xmax = std::min(roi1.x + roi1.width, roi2.x + roi2.width - minD) - SW2; + int ymin = std::max(roi1.y, roi2.y) + SW2; + int ymax = std::min(roi1.y + roi1.height, roi2.y + roi2.height) - SW2; Rect r(xmin, ymin, xmax - xmin, ymax - ymin); @@ -979,7 +979,7 @@ void cv::validateDisparity( InputOutputArray _disp, InputArray _cost, int minDis Mat disp = _disp.getMat(), cost = _cost.getMat(); int cols = disp.cols, rows = disp.rows; int minD = minDisparity, maxD = minDisparity + numberOfDisparities; - int x, minX1 = max(maxD, 0), maxX1 = cols + min(minD, 0); + int x, minX1 = std::max(maxD, 0), maxX1 = cols + std::min(minD, 0); AutoBuffer _disp2buf(cols*2); int* disp2buf = _disp2buf; int* disp2cost = disp2buf + cols; diff --git a/modules/calib3d/test/test_cameracalibration.cpp b/modules/calib3d/test/test_cameracalibration.cpp index 0b9d794a9..e8b557094 100644 --- a/modules/calib3d/test/test_cameracalibration.cpp +++ b/modules/calib3d/test/test_cameracalibration.cpp @@ -43,6 +43,9 @@ #include +using namespace std; +using namespace cv; + #if 0 class CV_ProjectPointsTest : public cvtest::ArrayTest { @@ -241,8 +244,6 @@ CV_ProjectPointsTest ProjectPoints_test; #endif -using namespace cv; - // --------------------------------- CV_CameraCalibrationTest -------------------------------------------- class CV_CameraCalibrationTest : public cvtest::BaseTest diff --git a/modules/calib3d/test/test_chessboardgenerator.cpp b/modules/calib3d/test/test_chessboardgenerator.cpp index d8ec943a4..7c761fc57 100644 --- a/modules/calib3d/test/test_chessboardgenerator.cpp +++ b/modules/calib3d/test/test_chessboardgenerator.cpp @@ -51,7 +51,7 @@ using namespace cv; using namespace std; ChessBoardGenerator::ChessBoardGenerator(const Size& _patternSize) : sensorWidth(32), sensorHeight(24), - squareEdgePointsNum(200), min_cos(sqrt(2.f)*0.5f), cov(0.5), + squareEdgePointsNum(200), min_cos(std::sqrt(2.f)*0.5f), cov(0.5), patternSize(_patternSize), rendererResolutionMultiplier(4), tvec(Mat::zeros(1, 3, CV_32F)) { Rodrigues(Mat::eye(3, 3, CV_32F), rvec); @@ -178,7 +178,7 @@ Mat cv::ChessBoardGenerator::generateChessBoard(const Mat& bg, const Mat& camMat Mat cv::ChessBoardGenerator::operator ()(const Mat& bg, const Mat& camMat, const Mat& distCoeffs, vector& corners) const { - cov = min(cov, 0.8); + cov = std::min(cov, 0.8); double fovx, fovy, focalLen; Point2d principalPoint; double aspect; @@ -199,7 +199,7 @@ Mat cv::ChessBoardGenerator::operator ()(const Mat& bg, const Mat& camMat, const Point3f pb1, pb2; generateBasis(pb1, pb2); - float cbHalfWidth = static_cast(norm(p) * sin( min(fovx, fovy) * 0.5 * CV_PI / 180)); + float cbHalfWidth = static_cast(norm(p) * sin( std::min(fovx, fovy) * 0.5 * CV_PI / 180)); float cbHalfHeight = cbHalfWidth * patternSize.height / patternSize.width; float cbHalfWidthEx = cbHalfWidth * ( patternSize.width + 1) / patternSize.width; @@ -243,7 +243,7 @@ Mat cv::ChessBoardGenerator::operator ()(const Mat& bg, const Mat& camMat, const Mat cv::ChessBoardGenerator::operator ()(const Mat& bg, const Mat& camMat, const Mat& distCoeffs, const Size2f& squareSize, vector& corners) const { - cov = min(cov, 0.8); + cov = std::min(cov, 0.8); double fovx, fovy, focalLen; Point2d principalPoint; double aspect; @@ -302,7 +302,7 @@ Mat cv::ChessBoardGenerator::operator ()(const Mat& bg, const Mat& camMat, const Mat cv::ChessBoardGenerator::operator ()(const Mat& bg, const Mat& camMat, const Mat& distCoeffs, const Size2f& squareSize, const Point3f& pos, vector& corners) const { - cov = min(cov, 0.8); + cov = std::min(cov, 0.8); Point3f p = pos; Point3f pb1, pb2; generateBasis(pb1, pb2); diff --git a/modules/calib3d/test/test_chessboardgenerator.hpp b/modules/calib3d/test/test_chessboardgenerator.hpp index 48b3f3a24..dbd921325 100644 --- a/modules/calib3d/test/test_chessboardgenerator.hpp +++ b/modules/calib3d/test/test_chessboardgenerator.hpp @@ -18,17 +18,17 @@ public: int rendererResolutionMultiplier; ChessBoardGenerator(const Size& patternSize = Size(8, 6)); - Mat operator()(const Mat& bg, const Mat& camMat, const Mat& distCoeffs, vector& corners) const; - Mat operator()(const Mat& bg, const Mat& camMat, const Mat& distCoeffs, const Size2f& squareSize, vector& corners) const; - Mat operator()(const Mat& bg, const Mat& camMat, const Mat& distCoeffs, const Size2f& squareSize, const Point3f& pos, vector& corners) const; + Mat operator()(const Mat& bg, const Mat& camMat, const Mat& distCoeffs, std::vector& corners) const; + Mat operator()(const Mat& bg, const Mat& camMat, const Mat& distCoeffs, const Size2f& squareSize, std::vector& corners) const; + Mat operator()(const Mat& bg, const Mat& camMat, const Mat& distCoeffs, const Size2f& squareSize, const Point3f& pos, std::vector& corners) const; Size cornersSize() const; - mutable vector corners3d; + mutable std::vector corners3d; private: - void generateEdge(const Point3f& p1, const Point3f& p2, vector& out) const; + void generateEdge(const Point3f& p1, const Point3f& p2, std::vector& out) const; Mat generateChessBoard(const Mat& bg, const Mat& camMat, const Mat& distCoeffs, const Point3f& zero, const Point3f& pb1, const Point3f& pb2, - float sqWidth, float sqHeight, const vector& whole, vector& corners) const; + float sqWidth, float sqHeight, const std::vector& whole, std::vector& corners) const; void generateBasis(Point3f& pb1, Point3f& pb2) const; Mat rvec, tvec; diff --git a/modules/calib3d/test/test_cornerssubpix.cpp b/modules/calib3d/test/test_cornerssubpix.cpp index eb07b47cb..88f7deee0 100644 --- a/modules/calib3d/test/test_cornerssubpix.cpp +++ b/modules/calib3d/test/test_cornerssubpix.cpp @@ -43,6 +43,7 @@ #include #include "test_chessboardgenerator.hpp" +using namespace std; using namespace cv; class CV_ChessboardSubpixelTest : public cvtest::BaseTest diff --git a/modules/calib3d/test/test_modelest.cpp b/modules/calib3d/test/test_modelest.cpp index e27c12d49..b3254c8be 100644 --- a/modules/calib3d/test/test_modelest.cpp +++ b/modules/calib3d/test/test_modelest.cpp @@ -42,6 +42,7 @@ #include "test_precomp.hpp" #include "_modelest.h" +using namespace std; using namespace cv; class BareModelEstimator : public CvModelEstimator2 diff --git a/modules/contrib/include/opencv2/contrib/contrib.hpp b/modules/contrib/include/opencv2/contrib/contrib.hpp index 3bf8e7aa8..c303586cf 100644 --- a/modules/contrib/include/opencv2/contrib/contrib.hpp +++ b/modules/contrib/include/opencv2/contrib/contrib.hpp @@ -270,17 +270,17 @@ namespace cv }; Octree(); - Octree( const vector& points, int maxLevels = 10, int minPoints = 20 ); + Octree( const std::vector& points, int maxLevels = 10, int minPoints = 20 ); virtual ~Octree(); - virtual void buildTree( const vector& points, int maxLevels = 10, int minPoints = 20 ); + virtual void buildTree( const std::vector& points, int maxLevels = 10, int minPoints = 20 ); virtual void getPointsWithinSphere( const Point3f& center, float radius, - vector& points ) const; - const vector& getNodes() const { return nodes; } + std::vector& points ) const; + const std::vector& getNodes() const { return nodes; } private: int minPoints; - vector points; - vector nodes; + std::vector points; + std::vector nodes; virtual void buildNext(size_t node_ind); }; @@ -292,19 +292,19 @@ namespace cv struct EmptyMeshException {}; Mesh3D(); - Mesh3D(const vector& vtx); + Mesh3D(const std::vector& vtx); ~Mesh3D(); void buildOctree(); void clearOctree(); float estimateResolution(float tryRatio = 0.1f); void computeNormals(float normalRadius, int minNeighbors = 20); - void computeNormals(const vector& subset, float normalRadius, int minNeighbors = 20); + void computeNormals(const std::vector& subset, float normalRadius, int minNeighbors = 20); - void writeAsVrml(const String& file, const vector& colors = vector()) const; + void writeAsVrml(const std::string& file, const std::vector& colors = std::vector()) const; - vector vtx; - vector normals; + std::vector vtx; + std::vector normals; float resolution; Octree octree; @@ -335,10 +335,10 @@ namespace cv void setLogger(std::ostream* log); void selectRandomSubset(float ratio); - void setSubset(const vector& subset); + void setSubset(const std::vector& subset); void compute(); - void match(const SpinImageModel& scene, vector< vector >& result); + void match(const SpinImageModel& scene, std::vector< std::vector >& result); Mat packRandomScaledSpins(bool separateScale = false, size_t xCount = 10, size_t yCount = 10) const; @@ -368,12 +368,12 @@ namespace cv protected: void defaultParams(); - void matchSpinToModel(const Mat& spin, vector& indeces, - vector& corrCoeffs, bool useExtremeOutliers = true) const; + void matchSpinToModel(const Mat& spin, std::vector& indeces, + std::vector& corrCoeffs, bool useExtremeOutliers = true) const; - void repackSpinImages(const vector& mask, Mat& spinImages, bool reAlloc = true) const; + void repackSpinImages(const std::vector& mask, Mat& spinImages, bool reAlloc = true) const; - vector subset; + std::vector subset; Mesh3D mesh; Mat spinImages; std::ostream* out; @@ -416,8 +416,8 @@ namespace cv size_t getDescriptorSize() const; Size getGridSize( Size imgsize, Size winStride ) const; - virtual void compute(const Mat& img, vector& descriptors, Size winStride=Size(), - const vector& locations=vector()) const; + virtual void compute(const Mat& img, std::vector& descriptors, Size winStride=Size(), + const std::vector& locations=std::vector()) const; virtual void computeLogPolarMapping(Mat& mappingMask) const; virtual void SSD(const Mat& img, Point pt, Mat& ssd) const; @@ -486,13 +486,13 @@ namespace cv virtual void clear(); // useful function to do simple bundle adjustment tasks - static void bundleAdjust(vector& points, // positions of points in global coordinate system (input and output) - const vector >& imagePoints, // projections of 3d points for every camera - const vector >& visibility, // visibility of 3d points for every camera - vector& cameraMatrix, // intrinsic matrices of all cameras (input and output) - vector& R, // rotation matrices of all cameras (input and output) - vector& T, // translation vector of all cameras (input and output) - vector& distCoeffs, // distortion coefficients of all cameras (input and output) + static void bundleAdjust(std::vector& points, // positions of points in global coordinate system (input and output) + const std::vector >& imagePoints, // projections of 3d points for every camera + const std::vector >& visibility, // visibility of 3d points for every camera + std::vector& cameraMatrix, // intrinsic matrices of all cameras (input and output) + std::vector& R, // rotation matrices of all cameras (input and output) + std::vector& T, // translation vector of all cameras (input and output) + std::vector& distCoeffs, // distortion coefficients of all cameras (input and output) const TermCriteria& criteria= TermCriteria(TermCriteria::COUNT+TermCriteria::EPS, 30, DBL_EPSILON), BundleAdjustCallback cb = 0, void* user_data = 0); @@ -558,7 +558,7 @@ namespace cv }; CV_EXPORTS_W int chamerMatching( Mat& img, Mat& templ, - CV_OUT vector >& results, CV_OUT vector& cost, + CV_OUT std::vector >& results, CV_OUT std::vector& cost, double templScale=1, int maxMatches = 20, double minMatchDistance = 1.0, int padX = 3, int padY = 3, int scales = 5, double minScale = 0.6, double maxScale = 1.6, @@ -757,9 +757,9 @@ namespace cv Mat Rsri; Mat Csri; - vector Rsr; - vector Csr; - vector Wsr; + std::vector Rsr; + std::vector Csr; + std::vector Wsr; int S, R, M, N, ind1; int top, bottom,left,right; @@ -768,13 +768,13 @@ namespace cv struct kernel { kernel() { w = 0; } - vector weights; + std::vector weights; int w; }; Mat ETAyx; Mat CSIyx; - vector w_ker_2D; + std::vector w_ker_2D; void create_map(int M, int N, int R, int S, double ro0); }; @@ -838,8 +838,8 @@ namespace cv int S, R, M, N; int top, bottom,left,right; double ro0, romax, a, q; - vector > L; - vector A; + std::vector > L; + std::vector A; void subdivide_recursively(double x, double y, int i, int j, double length, double smin); bool get_uv(double x, double y, int&u, int&v); @@ -869,10 +869,10 @@ namespace cv } // Serializes this object to a given filename. - void save(const string& filename) const; + void save(const std::string& filename) const; // Deserializes this object from a given filename. - void load(const string& filename); + void load(const std::string& filename); // Serializes this object to a given cv::FileStorage. void save(FileStorage& fs) const; @@ -926,10 +926,10 @@ namespace cv CV_WRAP virtual void predict(InputArray src, CV_OUT int &label, CV_OUT double &confidence) const = 0; // Serializes this object to a given filename. - CV_WRAP virtual void save(const string& filename) const; + CV_WRAP virtual void save(const std::string& filename) const; // Deserializes this object from a given filename. - CV_WRAP virtual void load(const string& filename); + CV_WRAP virtual void load(const std::string& filename); // Serializes this object to a given cv::FileStorage. virtual void save(FileStorage& fs) const = 0; diff --git a/modules/contrib/include/opencv2/contrib/hybridtracker.hpp b/modules/contrib/include/opencv2/contrib/hybridtracker.hpp index 3a1f722d7..cd99b7308 100644 --- a/modules/contrib/include/opencv2/contrib/hybridtracker.hpp +++ b/modules/contrib/include/opencv2/contrib/hybridtracker.hpp @@ -76,9 +76,9 @@ struct CV_EXPORTS CvMeanShiftTrackerParams CvTermCriteria term_crit = CvTermCriteria()); int tracking_type; - vector h_range; - vector s_range; - vector v_range; + std::vector h_range; + std::vector s_range; + std::vector v_range; CvTermCriteria term_crit; }; @@ -145,7 +145,7 @@ class CV_EXPORTS CvFeatureTracker private: Ptr dd; Ptr matcher; - vector matches; + std::vector matches; Mat prev_image; Mat prev_image_bw; @@ -153,7 +153,7 @@ private: Point2d prev_center; int ittr; - vector features[2]; + std::vector features[2]; public: Mat disp_matches; diff --git a/modules/contrib/include/opencv2/contrib/openfabmap.hpp b/modules/contrib/include/opencv2/contrib/openfabmap.hpp index 6b2834edc..e73bbb953 100644 --- a/modules/contrib/include/opencv2/contrib/openfabmap.hpp +++ b/modules/contrib/include/opencv2/contrib/openfabmap.hpp @@ -65,10 +65,6 @@ namespace cv { namespace of2 { -using std::list; -using std::map; -using std::multiset; - /* Return data format of a FABMAP compare call */ @@ -115,50 +111,50 @@ public: //methods to add training data for sampling method virtual void addTraining(const Mat& queryImgDescriptor); - virtual void addTraining(const vector& queryImgDescriptors); + virtual void addTraining(const std::vector& queryImgDescriptors); //methods to add to the test data virtual void add(const Mat& queryImgDescriptor); - virtual void add(const vector& queryImgDescriptors); + virtual void add(const std::vector& queryImgDescriptors); //accessors - const vector& getTrainingImgDescriptors() const; - const vector& getTestImgDescriptors() const; + const std::vector& getTrainingImgDescriptors() const; + const std::vector& getTestImgDescriptors() const; //Main FabMap image comparison void compare(const Mat& queryImgDescriptor, - vector& matches, bool addQuery = false, + std::vector& matches, bool addQuery = false, const Mat& mask = Mat()); void compare(const Mat& queryImgDescriptor, - const Mat& testImgDescriptors, vector& matches, + const Mat& testImgDescriptors, std::vector& matches, const Mat& mask = Mat()); void compare(const Mat& queryImgDescriptor, - const vector& testImgDescriptors, - vector& matches, const Mat& mask = Mat()); - void compare(const vector& queryImgDescriptors, vector< + const std::vector& testImgDescriptors, + std::vector& matches, const Mat& mask = Mat()); + void compare(const std::vector& queryImgDescriptors, std::vector< IMatch>& matches, bool addQuery = false, const Mat& mask = Mat()); - void compare(const vector& queryImgDescriptors, - const vector& testImgDescriptors, - vector& matches, const Mat& mask = Mat()); + void compare(const std::vector& queryImgDescriptors, + const std::vector& testImgDescriptors, + std::vector& matches, const Mat& mask = Mat()); protected: void compareImgDescriptor(const Mat& queryImgDescriptor, - int queryIndex, const vector& testImgDescriptors, - vector& matches); + int queryIndex, const std::vector& testImgDescriptors, + std::vector& matches); void addImgDescriptor(const Mat& queryImgDescriptor); //the getLikelihoods method is overwritten for each different FabMap //method. virtual void getLikelihoods(const Mat& queryImgDescriptor, - const vector& testImgDescriptors, - vector& matches); + const std::vector& testImgDescriptors, + std::vector& matches); virtual double getNewPlaceLikelihood(const Mat& queryImgDescriptor); //turn likelihoods into probabilities (also add in motion model if used) - void normaliseDistribution(vector& matches); + void normaliseDistribution(std::vector& matches); //Chow-Liu Tree int pq(int q); @@ -174,9 +170,9 @@ protected: //data Mat clTree; - vector trainingImgDescriptors; - vector testImgDescriptors; - vector priorMatches; + std::vector trainingImgDescriptors; + std::vector testImgDescriptors; + std::vector priorMatches; //parameters double PzGe; @@ -203,8 +199,8 @@ public: protected: //FabMap1 implementation of likelihood comparison - void getLikelihoods(const Mat& queryImgDescriptor, const vector< - Mat>& testImgDescriptors, vector& matches); + void getLikelihoods(const Mat& queryImgDescriptor, const std::vector< + Mat>& testImgDescriptors, std::vector& matches); }; /* @@ -219,8 +215,8 @@ public: protected: //FabMap look-up-table implementation of the likelihood comparison - void getLikelihoods(const Mat& queryImgDescriptor, const vector< - Mat>& testImgDescriptors, vector& matches); + void getLikelihoods(const Mat& queryImgDescriptor, const std::vector< + Mat>& testImgDescriptors, std::vector& matches); //precomputed data int (*table)[8]; @@ -243,8 +239,8 @@ public: protected: //FabMap Fast Bail-out implementation of the likelihood comparison - void getLikelihoods(const Mat& queryImgDescriptor, const vector< - Mat>& testImgDescriptors, vector& matches); + void getLikelihoods(const Mat& queryImgDescriptor, const std::vector< + Mat>& testImgDescriptors, std::vector& matches); //stucture used to determine word comparison order struct WordStats { @@ -268,7 +264,7 @@ protected: }; //private fast bail-out necessary functions - void setWordStatistics(const Mat& queryImgDescriptor, multiset& wordData); + void setWordStatistics(const Mat& queryImgDescriptor, std::multiset& wordData); double limitbisection(double v, double m); double bennettInequality(double v, double m, double delta); static bool compInfo(const WordStats& first, const WordStats& second); @@ -295,39 +291,39 @@ public: void addTraining(const Mat& queryImgDescriptors) { FabMap::addTraining(queryImgDescriptors); } - void addTraining(const vector& queryImgDescriptors); + void addTraining(const std::vector& queryImgDescriptors); void add(const Mat& queryImgDescriptors) { FabMap::add(queryImgDescriptors); } - void add(const vector& queryImgDescriptors); + void add(const std::vector& queryImgDescriptors); protected: //FabMap2 implementation of the likelihood comparison - void getLikelihoods(const Mat& queryImgDescriptor, const vector< - Mat>& testImgDescriptors, vector& matches); + void getLikelihoods(const Mat& queryImgDescriptor, const std::vector< + Mat>& testImgDescriptors, std::vector& matches); double getNewPlaceLikelihood(const Mat& queryImgDescriptor); //the likelihood function using the inverted index - void getIndexLikelihoods(const Mat& queryImgDescriptor, vector< - double>& defaults, map >& invertedMap, - vector& matches); + void getIndexLikelihoods(const Mat& queryImgDescriptor, std::vector< + double>& defaults, std::map >& invertedMap, + std::vector& matches); void addToIndex(const Mat& queryImgDescriptor, - vector& defaults, - map >& invertedMap); + std::vector& defaults, + std::map >& invertedMap); //data - vector d1, d2, d3, d4; - vector > children; + std::vector d1, d2, d3, d4; + std::vector > children; // TODO: inverted map a vector? - vector trainingDefaults; - map > trainingInvertedMap; + std::vector trainingDefaults; + std::map > trainingInvertedMap; - vector testDefaults; - map > testInvertedMap; + std::vector testDefaults; + std::map > testInvertedMap; }; /* @@ -342,14 +338,14 @@ public: //add data to the chow-liu tree before calling make void add(const Mat& imgDescriptor); - void add(const vector& imgDescriptors); + void add(const std::vector& imgDescriptors); - const vector& getImgDescriptors() const; + const std::vector& getImgDescriptors() const; Mat make(double infoThreshold = 0.0); private: - vector imgDescriptors; + std::vector imgDescriptors; Mat mergedImgDescriptors; typedef struct info { @@ -364,18 +360,18 @@ private: double CP(int a, bool za, int b, bool zb); // a | b //calculating mutual information of all edges - void createBaseEdges(list& edges, double infoThreshold); + void createBaseEdges(std::list& edges, double infoThreshold); double calcMutInfo(int word1, int word2); static bool sortInfoScores(const info& first, const info& second); //selecting minimum spanning egdges with maximum information - bool reduceEdgesToMinSpan(list& edges); + bool reduceEdgesToMinSpan(std::list& edges); //building the tree sctructure - Mat buildTree(int root_word, list &edges); + Mat buildTree(int root_word, std::list &edges); void recAddToTree(Mat &cltree, int q, int pq, - list &remaining_edges); - vector extractChildren(list &remaining_edges, int q); + std::list &remaining_edges); + std::vector extractChildren(std::list &remaining_edges, int q); }; diff --git a/modules/contrib/src/ba.cpp b/modules/contrib/src/ba.cpp index a0f904665..9b64ba4d2 100644 --- a/modules/contrib/src/ba.cpp +++ b/modules/contrib/src/ba.cpp @@ -989,13 +989,13 @@ static void func_new(int i, int j, Mat& point_params, Mat& cam_params, Mat& esti func(i,j,&_point_params,&_cam_params,&_estim,data); }; -void LevMarqSparse::bundleAdjust( vector& points, //positions of points in global coordinate system (input and output) - const vector >& imagePoints, //projections of 3d points for every camera - const vector >& visibility, //visibility of 3d points for every camera - vector& cameraMatrix, //intrinsic matrices of all cameras (input and output) - vector& R, //rotation matrices of all cameras (input and output) - vector& T, //translation vector of all cameras (input and output) - vector& distCoeffs, //distortion coefficients of all cameras (input and output) +void LevMarqSparse::bundleAdjust( std::vector& points, //positions of points in global coordinate system (input and output) + const std::vector >& imagePoints, //projections of 3d points for every camera + const std::vector >& visibility, //visibility of 3d points for every camera + std::vector& cameraMatrix, //intrinsic matrices of all cameras (input and output) + std::vector& R, //rotation matrices of all cameras (input and output) + std::vector& T, //translation vector of all cameras (input and output) + std::vector& distCoeffs, //distortion coefficients of all cameras (input and output) const TermCriteria& criteria, BundleAdjustCallback cb, void* user_data) { //,enum{MOTION_AND_STRUCTURE,MOTION,STRUCTURE}) diff --git a/modules/contrib/src/basicretinafilter.cpp b/modules/contrib/src/basicretinafilter.cpp index 4abe26139..020b8f04e 100644 --- a/modules/contrib/src/basicretinafilter.cpp +++ b/modules/contrib/src/basicretinafilter.cpp @@ -180,7 +180,7 @@ void BasicRetinaFilter::setLPfilterParameters(const float beta, const float tau, } float _temp = (1.0f+_beta)/(2.0f*_mu*_alpha); - float a = _filteringCoeficientsTable[tableOffset] = 1.0f + _temp - (float)sqrt( (1.0f+_temp)*(1.0f+_temp) - 1.0f); + float a = _filteringCoeficientsTable[tableOffset] = 1.0f + _temp - (float)std::sqrt( (1.0f+_temp)*(1.0f+_temp) - 1.0f); _filteringCoeficientsTable[1+tableOffset]=(1.0f-a)*(1.0f-a)*(1.0f-a)*(1.0f-a)/(1.0f+_beta); _filteringCoeficientsTable[2+tableOffset] =tau; @@ -210,17 +210,17 @@ void BasicRetinaFilter::setProgressiveFilterConstants_CentredAccuracy(const floa float _alpha=0.8f; float _temp = (1.0f+_beta)/(2.0f*_mu*_alpha); - float a=_filteringCoeficientsTable[tableOffset] = 1.0f + _temp - (float)sqrt( (1.0f+_temp)*(1.0f+_temp) - 1.0f); + float a=_filteringCoeficientsTable[tableOffset] = 1.0f + _temp - (float)std::sqrt( (1.0f+_temp)*(1.0f+_temp) - 1.0f); _filteringCoeficientsTable[tableOffset+1]=(1.0f-a)*(1.0f-a)*(1.0f-a)*(1.0f-a)/(1.0f+_beta); _filteringCoeficientsTable[tableOffset+2] =tau; - float commonFactor=alpha0/(float)sqrt(_halfNBcolumns*_halfNBcolumns+_halfNBrows*_halfNBrows+1.0f); + float commonFactor=alpha0/(float)std::sqrt(_halfNBcolumns*_halfNBcolumns+_halfNBrows*_halfNBrows+1.0f); //memset(_progressiveSpatialConstant, 255, _filterOutput.getNBpixels()); for (unsigned int idColumn=0;idColumn<_halfNBcolumns; ++idColumn) for (unsigned int idRow=0;idRow<_halfNBrows; ++idRow) { // computing local spatial constant - float localSpatialConstantValue=commonFactor*sqrt((float)(idColumn*idColumn)+(float)(idRow*idRow)); + float localSpatialConstantValue=commonFactor*std::sqrt((float)(idColumn*idColumn)+(float)(idRow*idRow)); if (localSpatialConstantValue>1.0f) localSpatialConstantValue=1.0f; @@ -236,7 +236,7 @@ void BasicRetinaFilter::setProgressiveFilterConstants_CentredAccuracy(const floa _progressiveGain[_halfNBcolumns-1+idColumn+_filterOutput.getNBcolumns()*(_halfNBrows-1-idRow)]=localGain; _progressiveGain[_halfNBcolumns-1-idColumn+_filterOutput.getNBcolumns()*(_halfNBrows-1-idRow)]=localGain; - //std::cout< initialCentres; + std::vector initialCentres; initialCentres.push_back(_descriptors.row(0)); for (int i = 1; i < _descriptors.rows; i++) { double minDist = DBL_MAX; diff --git a/modules/contrib/src/chamfermatching.cpp b/modules/contrib/src/chamfermatching.cpp index 17d06b3b7..a23ca8a8c 100644 --- a/modules/contrib/src/chamfermatching.cpp +++ b/modules/contrib/src/chamfermatching.cpp @@ -54,8 +54,6 @@ namespace cv { -using std::queue; - typedef std::pair coordinate_t; typedef float orientation_t; typedef std::vector template_coords_t; @@ -824,7 +822,7 @@ ChamferMatcher::Template::Template(Mat& edge_image, float scale_) : addr_width(- } -vector& ChamferMatcher::Template::getTemplateAddresses(int width) +std::vector& ChamferMatcher::Template::getTemplateAddresses(int width) { if (addr_width!=width) { addr.resize(coords.size()); diff --git a/modules/contrib/src/chowliutree.cpp b/modules/contrib/src/chowliutree.cpp index ba1ef6561..8c6acabdc 100644 --- a/modules/contrib/src/chowliutree.cpp +++ b/modules/contrib/src/chowliutree.cpp @@ -73,7 +73,7 @@ void ChowLiuTree::add(const Mat& imgDescriptor) { } -void ChowLiuTree::add(const vector& _imgDescriptors) { +void ChowLiuTree::add(const std::vector& _imgDescriptors) { for (size_t i = 0; i < _imgDescriptors.size(); i++) { add(_imgDescriptors[i]); } @@ -164,10 +164,10 @@ cv::Mat ChowLiuTree::buildTree(int root_word, std::list &edges) { //independence from a parent node. //find all children and do the same - vector nextqs = extractChildren(edges, q); + std::vector nextqs = extractChildren(edges, q); int pq = q; - vector::iterator nextq; + std::vector::iterator nextq; for(nextq = nextqs.begin(); nextq != nextqs.end(); nextq++) { recAddToTree(cltree, *nextq, pq, edges); } @@ -186,16 +186,16 @@ void ChowLiuTree::recAddToTree(cv::Mat &cltree, int q, int pq, cltree.at(3, q) = CP(q, true, pq, false); //find all children and do the same - vector nextqs = extractChildren(remaining_edges, q); + std::vector nextqs = extractChildren(remaining_edges, q); pq = q; - vector::iterator nextq; + std::vector::iterator nextq; for(nextq = nextqs.begin(); nextq != nextqs.end(); nextq++) { recAddToTree(cltree, *nextq, pq, remaining_edges); } } -vector ChowLiuTree::extractChildren(std::list &remaining_edges, int q) { +std::vector ChowLiuTree::extractChildren(std::list &remaining_edges, int q) { std::vector children; std::list::iterator edge = remaining_edges.begin(); @@ -225,16 +225,16 @@ double ChowLiuTree::calcMutInfo(int word1, int word2) { double accumulation = 0; double P00 = JP(word1, false, word2, false); - if(P00) accumulation += P00 * log(P00 / (P(word1, false)*P(word2, false))); + if(P00) accumulation += P00 * std::log(P00 / (P(word1, false)*P(word2, false))); double P01 = JP(word1, false, word2, true); - if(P01) accumulation += P01 * log(P01 / (P(word1, false)*P(word2, true))); + if(P01) accumulation += P01 * std::log(P01 / (P(word1, false)*P(word2, true))); double P10 = JP(word1, true, word2, false); - if(P10) accumulation += P10 * log(P10 / (P(word1, true)*P(word2, false))); + if(P10) accumulation += P10 * std::log(P10 / (P(word1, true)*P(word2, false))); double P11 = JP(word1, true, word2, true); - if(P11) accumulation += P11 * log(P11 / (P(word1, true)*P(word2, true))); + if(P11) accumulation += P11 * std::log(P11 / (P(word1, true)*P(word2, true))); return accumulation; } diff --git a/modules/contrib/src/colormap.cpp b/modules/contrib/src/colormap.cpp index bb317f7c4..ca98b3a91 100644 --- a/modules/contrib/src/colormap.cpp +++ b/modules/contrib/src/colormap.cpp @@ -42,7 +42,7 @@ static void sortMatrixRowsByIndices(InputArray _src, InputArray _indices, Output if(_indices.getMat().type() != CV_32SC1) CV_Error(CV_StsUnsupportedFormat, "cv::sortRowsByIndices only works on integer indices!"); Mat src = _src.getMat(); - vector indices = _indices.getMat(); + std::vector indices = _indices.getMat(); _dst.create(src.rows, src.cols, src.type()); Mat dst = _dst.getMat(); for(size_t idx = 0; idx < indices.size(); idx++) { @@ -76,7 +76,7 @@ Mat interp1_(const Mat& X_, const Mat& Y_, const Mat& XI) { int n = XI.rows; // sort input table - vector sort_indices = argsort(X_); + std::vector sort_indices = argsort(X_); Mat X = sortMatrixRowsByIndices(X_,sort_indices); Mat Y = sortMatrixRowsByIndices(Y_,sort_indices); diff --git a/modules/contrib/src/colortracker.cpp b/modules/contrib/src/colortracker.cpp index 03cdf07ae..5a9d9b7c4 100644 --- a/modules/contrib/src/colortracker.cpp +++ b/modules/contrib/src/colortracker.cpp @@ -43,7 +43,6 @@ #include "opencv2/contrib/hybridtracker.hpp" using namespace cv; -using namespace std; CvMeanShiftTracker::CvMeanShiftTracker(CvMeanShiftTrackerParams _params) : params(_params) { diff --git a/modules/contrib/src/detection_based_tracker.cpp b/modules/contrib/src/detection_based_tracker.cpp index 11263a8fc..117a6e916 100644 --- a/modules/contrib/src/detection_based_tracker.cpp +++ b/modules/contrib/src/detection_based_tracker.cpp @@ -43,7 +43,6 @@ using namespace cv; -using namespace std; static inline cv::Point2f centerRect(const cv::Rect& r) { @@ -71,7 +70,7 @@ class cv::DetectionBasedTracker::SeparateDetectionWork public: SeparateDetectionWork(cv::DetectionBasedTracker& _detectionBasedTracker, cv::Ptr _detector); virtual ~SeparateDetectionWork(); - bool communicateWithDetectingThread(const Mat& imageGray, vector& rectsWhereRegions); + bool communicateWithDetectingThread(const Mat& imageGray, std::vector& rectsWhereRegions); bool run(); void stop(); void resetTracking(); @@ -227,7 +226,7 @@ void cv::DetectionBasedTracker::SeparateDetectionWork::workcycleObjectDetector() { static double freq = getTickFrequency(); LOGD("DetectionBasedTracker::SeparateDetectionWork::workcycleObjectDetector() --- start"); - vector objects; + std::vector objects; CV_Assert(stateThread==STATE_THREAD_WORKING_SLEEPING); pthread_mutex_lock(&mutex); @@ -385,7 +384,7 @@ void cv::DetectionBasedTracker::SeparateDetectionWork::resetTracking() } -bool cv::DetectionBasedTracker::SeparateDetectionWork::communicateWithDetectingThread(const Mat& imageGray, vector& rectsWhereRegions) +bool cv::DetectionBasedTracker::SeparateDetectionWork::communicateWithDetectingThread(const Mat& imageGray, std::vector& rectsWhereRegions) { static double freq = getTickFrequency(); @@ -499,7 +498,7 @@ void DetectionBasedTracker::process(const Mat& imageGray) Mat imageDetect=imageGray; - vector rectsWhereRegions; + std::vector rectsWhereRegions; bool shouldHandleResult=false; if (!separateDetectionWork.empty()) { shouldHandleResult = separateDetectionWork->communicateWithDetectingThread(imageGray, rectsWhereRegions); @@ -535,7 +534,7 @@ void DetectionBasedTracker::process(const Mat& imageGray) } LOGI("DetectionBasedTracker::process: tracked objects num==%d", (int)trackedObjects.size()); - vector detectedObjectsInRegions; + std::vector detectedObjectsInRegions; LOGD("DetectionBasedTracker::process: rectsWhereRegions.size()=%d", (int)rectsWhereRegions.size()); for(size_t i=0; i < rectsWhereRegions.size(); i++) { @@ -610,7 +609,7 @@ void cv::DetectionBasedTracker::resetTracking() trackedObjects.clear(); } -void cv::DetectionBasedTracker::updateTrackedObjects(const vector& detectedObjects) +void cv::DetectionBasedTracker::updateTrackedObjects(const std::vector& detectedObjects) { enum { NEW_RECTANGLE=-1, @@ -625,7 +624,7 @@ void cv::DetectionBasedTracker::updateTrackedObjects(const vector& detecte trackedObjects[i].numDetectedFrames++; } - vector correspondence(detectedObjects.size(), NEW_RECTANGLE); + std::vector correspondence(detectedObjects.size(), NEW_RECTANGLE); correspondence.clear(); correspondence.resize(detectedObjects.size(), NEW_RECTANGLE); @@ -831,7 +830,7 @@ Rect cv::DetectionBasedTracker::calcTrackedObjectPositionToShow(int i, ObjectSta return res; } -void cv::DetectionBasedTracker::detectInRegion(const Mat& img, const Rect& r, vector& detectedObjectsInRegions) +void cv::DetectionBasedTracker::detectInRegion(const Mat& img, const Rect& r, std::vector& detectedObjectsInRegions) { Rect r0(Point(), img.size()); Rect r1 = scale_rect(r, innerParameters.coeffTrackingWindowSize); @@ -844,7 +843,7 @@ void cv::DetectionBasedTracker::detectInRegion(const Mat& img, const Rect& r, ve int d = cvRound(std::min(r.width, r.height) * innerParameters.coeffObjectSizeToTrack); - vector tmpobjects; + std::vector tmpobjects; Mat img1(img, r1);//subimage for rectangle -- without data copying LOGD("DetectionBasedTracker::detectInRegion: img1.size()=%d x %d, d=%d", diff --git a/modules/contrib/src/facerec.cpp b/modules/contrib/src/facerec.cpp index bc41a86a0..9ce082819 100644 --- a/modules/contrib/src/facerec.cpp +++ b/modules/contrib/src/facerec.cpp @@ -21,11 +21,9 @@ namespace cv { -using std::set; - // Reads a sequence from a FileNode::SEQ with type _Tp into a result vector. template -inline void readFileNodeList(const FileNode& fn, vector<_Tp>& result) { +inline void readFileNodeList(const FileNode& fn, std::vector<_Tp>& result) { if (fn.type() == FileNode::SEQ) { for (FileNodeIterator it = fn.begin(); it != fn.end();) { _Tp item; @@ -37,10 +35,10 @@ inline void readFileNodeList(const FileNode& fn, vector<_Tp>& result) { // Writes the a list of given items to a cv::FileStorage. template -inline void writeFileNodeList(FileStorage& fs, const string& name, - const vector<_Tp>& items) { +inline void writeFileNodeList(FileStorage& fs, const std::string& name, + const std::vector<_Tp>& items) { // typedefs - typedef typename vector<_Tp>::const_iterator constVecIterator; + typedef typename std::vector<_Tp>::const_iterator constVecIterator; // write the elements in item to fs fs << name << "["; for (constVecIterator it = items.begin(); it != items.end(); ++it) { @@ -52,7 +50,7 @@ inline void writeFileNodeList(FileStorage& fs, const string& name, static Mat asRowMatrix(InputArrayOfArrays src, int rtype, double alpha=1, double beta=0) { // make sure the input data is a vector of matrices or vector of vector if(src.kind() != _InputArray::STD_VECTOR_MAT && src.kind() != _InputArray::STD_VECTOR_VECTOR) { - string error_message = "The data is expected as InputArray::STD_VECTOR_MAT (a std::vector) or _InputArray::STD_VECTOR_VECTOR (a std::vector< vector<...> >)."; + std::string error_message = "The data is expected as InputArray::STD_VECTOR_MAT (a std::vector) or _InputArray::STD_VECTOR_VECTOR (a std::vector< std::vector<...> >)."; CV_Error(CV_StsBadArg, error_message); } // number of samples @@ -68,7 +66,7 @@ static Mat asRowMatrix(InputArrayOfArrays src, int rtype, double alpha=1, double for(unsigned int i = 0; i < n; i++) { // make sure data can be reshaped, throw exception if not! if(src.getMat(i).total() != d) { - string error_message = format("Wrong number of elements in matrix #%d! Expected %d was %d.", i, d, src.getMat(i).total()); + std::string error_message = format("Wrong number of elements in matrix #%d! Expected %d was %d.", i, d, src.getMat(i).total()); CV_Error(CV_StsBadArg, error_message); } // get a hold of the current row @@ -86,13 +84,13 @@ static Mat asRowMatrix(InputArrayOfArrays src, int rtype, double alpha=1, double // Removes duplicate elements in a given vector. template -inline vector<_Tp> remove_dups(const vector<_Tp>& src) { - typedef typename set<_Tp>::const_iterator constSetIterator; - typedef typename vector<_Tp>::const_iterator constVecIterator; - set<_Tp> set_elems; +inline std::vector<_Tp> remove_dups(const std::vector<_Tp>& src) { + typedef typename std::set<_Tp>::const_iterator constSetIterator; + typedef typename std::vector<_Tp>::const_iterator constVecIterator; + std::set<_Tp> set_elems; for (constVecIterator it = src.begin(); it != src.end(); ++it) set_elems.insert(*it); - vector<_Tp> elems; + std::vector<_Tp> elems; for (constSetIterator it = set_elems.begin(); it != set_elems.end(); ++it) elems.push_back(*it); return elems; @@ -106,7 +104,7 @@ class Eigenfaces : public FaceRecognizer private: int _num_components; double _threshold; - vector _projections; + std::vector _projections; Mat _labels; Mat _eigenvectors; Mat _eigenvalues; @@ -162,7 +160,7 @@ private: Mat _eigenvectors; Mat _eigenvalues; Mat _mean; - vector _projections; + std::vector _projections; Mat _labels; public: @@ -220,7 +218,7 @@ private: int _neighbors; double _threshold; - vector _histograms; + std::vector _histograms; Mat _labels; // Computes a LBPH model with images in src and @@ -307,11 +305,11 @@ void FaceRecognizer::update(InputArrayOfArrays src, InputArray labels ) { return; } - string error_msg = format("This FaceRecognizer (%s) does not support updating, you have to use FaceRecognizer::train to update it.", this->name().c_str()); + std::string error_msg = format("This FaceRecognizer (%s) does not support updating, you have to use FaceRecognizer::train to update it.", this->name().c_str()); CV_Error(CV_StsNotImplemented, error_msg); } -void FaceRecognizer::save(const string& filename) const { +void FaceRecognizer::save(const std::string& filename) const { FileStorage fs(filename, FileStorage::WRITE); if (!fs.isOpened()) CV_Error(CV_StsError, "File can't be opened for writing!"); @@ -319,7 +317,7 @@ void FaceRecognizer::save(const string& filename) const { fs.release(); } -void FaceRecognizer::load(const string& filename) { +void FaceRecognizer::load(const std::string& filename) { FileStorage fs(filename, FileStorage::READ); if (!fs.isOpened()) CV_Error(CV_StsError, "File can't be opened for writing!"); @@ -332,17 +330,17 @@ void FaceRecognizer::load(const string& filename) { //------------------------------------------------------------------------------ void Eigenfaces::train(InputArrayOfArrays _src, InputArray _local_labels) { if(_src.total() == 0) { - string error_message = format("Empty training data was given. You'll need more than one sample to learn a model."); + std::string error_message = format("Empty training data was given. You'll need more than one sample to learn a model."); CV_Error(CV_StsBadArg, error_message); } else if(_local_labels.getMat().type() != CV_32SC1) { - string error_message = format("Labels must be given as integer (CV_32SC1). Expected %d, but was %d.", CV_32SC1, _local_labels.type()); + std::string error_message = format("Labels must be given as integer (CV_32SC1). Expected %d, but was %d.", CV_32SC1, _local_labels.type()); CV_Error(CV_StsBadArg, error_message); } // make sure data has correct size if(_src.total() > 1) { for(int i = 1; i < static_cast(_src.total()); i++) { if(_src.getMat(i-1).total() != _src.getMat(i).total()) { - string error_message = format("In the Eigenfaces method all input samples (training images) must be of equal size! Expected %d pixels, but was %d pixels.", _src.getMat(i-1).total(), _src.getMat(i).total()); + std::string error_message = format("In the Eigenfaces method all input samples (training images) must be of equal size! Expected %d pixels, but was %d pixels.", _src.getMat(i-1).total(), _src.getMat(i).total()); CV_Error(CV_StsUnsupportedFormat, error_message); } } @@ -356,7 +354,7 @@ void Eigenfaces::train(InputArrayOfArrays _src, InputArray _local_labels) { int n = data.rows; // assert there are as much samples as labels if(static_cast(labels.total()) != n) { - string error_message = format("The number of samples (src) must equal the number of labels (labels)! len(src)=%d, len(labels)=%d.", n, labels.total()); + std::string error_message = format("The number of samples (src) must equal the number of labels (labels)! len(src)=%d, len(labels)=%d.", n, labels.total()); CV_Error(CV_StsBadArg, error_message); } // clear existing model data @@ -387,11 +385,11 @@ void Eigenfaces::predict(InputArray _src, int &minClass, double &minDist) const // make sure the user is passing correct data if(_projections.empty()) { // throw error if no data (or simply return -1?) - string error_message = "This Eigenfaces model is not computed yet. Did you call Eigenfaces::train?"; + std::string error_message = "This Eigenfaces model is not computed yet. Did you call Eigenfaces::train?"; CV_Error(CV_StsError, error_message); } else if(_eigenvectors.rows != static_cast(src.total())) { // check data alignment just for clearer exception messages - string error_message = format("Wrong input image size. Reason: Training and Test images must be of equal size! Expected an image with %d elements, but got %d.", _eigenvectors.rows, src.total()); + std::string error_message = format("Wrong input image size. Reason: Training and Test images must be of equal size! Expected an image with %d elements, but got %d.", _eigenvectors.rows, src.total()); CV_Error(CV_StsBadArg, error_message); } // project into PCA subspace @@ -441,17 +439,17 @@ void Eigenfaces::save(FileStorage& fs) const { //------------------------------------------------------------------------------ void Fisherfaces::train(InputArrayOfArrays src, InputArray _lbls) { if(src.total() == 0) { - string error_message = format("Empty training data was given. You'll need more than one sample to learn a model."); + std::string error_message = format("Empty training data was given. You'll need more than one sample to learn a model."); CV_Error(CV_StsBadArg, error_message); } else if(_lbls.getMat().type() != CV_32SC1) { - string error_message = format("Labels must be given as integer (CV_32SC1). Expected %d, but was %d.", CV_32SC1, _lbls.type()); + std::string error_message = format("Labels must be given as integer (CV_32SC1). Expected %d, but was %d.", CV_32SC1, _lbls.type()); CV_Error(CV_StsBadArg, error_message); } // make sure data has correct size if(src.total() > 1) { for(int i = 1; i < static_cast(src.total()); i++) { if(src.getMat(i-1).total() != src.getMat(i).total()) { - string error_message = format("In the Fisherfaces method all input samples (training images) must be of equal size! Expected %d pixels, but was %d pixels.", src.getMat(i-1).total(), src.getMat(i).total()); + std::string error_message = format("In the Fisherfaces method all input samples (training images) must be of equal size! Expected %d pixels, but was %d pixels.", src.getMat(i-1).total(), src.getMat(i).total()); CV_Error(CV_StsUnsupportedFormat, error_message); } } @@ -463,17 +461,17 @@ void Fisherfaces::train(InputArrayOfArrays src, InputArray _lbls) { int N = data.rows; // make sure labels are passed in correct shape if(labels.total() != (size_t) N) { - string error_message = format("The number of samples (src) must equal the number of labels (labels)! len(src)=%d, len(labels)=%d.", N, labels.total()); + std::string error_message = format("The number of samples (src) must equal the number of labels (labels)! len(src)=%d, len(labels)=%d.", N, labels.total()); CV_Error(CV_StsBadArg, error_message); } else if(labels.rows != 1 && labels.cols != 1) { - string error_message = format("Expected the labels in a matrix with one row or column! Given dimensions are rows=%s, cols=%d.", labels.rows, labels.cols); + std::string error_message = format("Expected the labels in a matrix with one row or column! Given dimensions are rows=%s, cols=%d.", labels.rows, labels.cols); CV_Error(CV_StsBadArg, error_message); } // clear existing model data _labels.release(); _projections.clear(); // safely copy from cv::Mat to std::vector - vector ll; + std::vector ll; for(unsigned int i = 0; i < labels.total(); i++) { ll.push_back(labels.at(i)); } @@ -507,10 +505,10 @@ void Fisherfaces::predict(InputArray _src, int &minClass, double &minDist) const // check data alignment just for clearer exception messages if(_projections.empty()) { // throw error if no data (or simply return -1?) - string error_message = "This Fisherfaces model is not computed yet. Did you call Fisherfaces::train?"; + std::string error_message = "This Fisherfaces model is not computed yet. Did you call Fisherfaces::train?"; CV_Error(CV_StsBadArg, error_message); } else if(src.total() != (size_t) _eigenvectors.rows) { - string error_message = format("Wrong input image size. Reason: Training and Test images must be of equal size! Expected an image with %d elements, but got %d.", _eigenvectors.rows, src.total()); + std::string error_message = format("Wrong input image size. Reason: Training and Test images must be of equal size! Expected an image with %d elements, but got %d.", _eigenvectors.rows, src.total()); CV_Error(CV_StsBadArg, error_message); } // project into LDA subspace @@ -642,7 +640,7 @@ static void elbp(InputArray src, OutputArray dst, int radius, int neighbors) case CV_32FC1: elbp_(src,dst, radius, neighbors); break; case CV_64FC1: elbp_(src,dst, radius, neighbors); break; default: - string error_msg = format("Using Original Local Binary Patterns for feature extraction only works on single-channel images (given %d). Please pass the image data as a grayscale image!", type); + std::string error_msg = format("Using Original Local Binary Patterns for feature extraction only works on single-channel images (given %d). Please pass the image data as a grayscale image!", type); CV_Error(CV_StsNotImplemented, error_msg); break; } @@ -770,24 +768,24 @@ void LBPH::update(InputArrayOfArrays _in_src, InputArray _in_labels) { void LBPH::train(InputArrayOfArrays _in_src, InputArray _in_labels, bool preserveData) { if(_in_src.kind() != _InputArray::STD_VECTOR_MAT && _in_src.kind() != _InputArray::STD_VECTOR_VECTOR) { - string error_message = "The images are expected as InputArray::STD_VECTOR_MAT (a std::vector) or _InputArray::STD_VECTOR_VECTOR (a std::vector< vector<...> >)."; + std::string error_message = "The images are expected as InputArray::STD_VECTOR_MAT (a std::vector) or _InputArray::STD_VECTOR_VECTOR (a std::vector< std::vector<...> >)."; CV_Error(CV_StsBadArg, error_message); } if(_in_src.total() == 0) { - string error_message = format("Empty training data was given. You'll need more than one sample to learn a model."); + std::string error_message = format("Empty training data was given. You'll need more than one sample to learn a model."); CV_Error(CV_StsUnsupportedFormat, error_message); } else if(_in_labels.getMat().type() != CV_32SC1) { - string error_message = format("Labels must be given as integer (CV_32SC1). Expected %d, but was %d.", CV_32SC1, _in_labels.type()); + std::string error_message = format("Labels must be given as integer (CV_32SC1). Expected %d, but was %d.", CV_32SC1, _in_labels.type()); CV_Error(CV_StsUnsupportedFormat, error_message); } // get the vector of matrices - vector src; + std::vector src; _in_src.getMatVector(src); // get the label matrix Mat labels = _in_labels.getMat(); // check if data is well- aligned if(labels.total() != src.size()) { - string error_message = format("The number of samples (src) must equal the number of labels (labels). Was len(samples)=%d, len(labels)=%d.", src.size(), _labels.total()); + std::string error_message = format("The number of samples (src) must equal the number of labels (labels). Was len(samples)=%d, len(labels)=%d.", src.size(), _labels.total()); CV_Error(CV_StsBadArg, error_message); } // if this model should be trained without preserving old data, delete old model data @@ -818,7 +816,7 @@ void LBPH::train(InputArrayOfArrays _in_src, InputArray _in_labels, bool preserv void LBPH::predict(InputArray _src, int &minClass, double &minDist) const { if(_histograms.empty()) { // throw error if no data (or simply return -1?) - string error_message = "This LBPH model is not computed yet. Did you call the train method?"; + std::string error_message = "This LBPH model is not computed yet. Did you call the train method?"; CV_Error(CV_StsBadArg, error_message); } Mat src = _src.getMat(); diff --git a/modules/contrib/src/featuretracker.cpp b/modules/contrib/src/featuretracker.cpp index 44d561052..712b2d569 100644 --- a/modules/contrib/src/featuretracker.cpp +++ b/modules/contrib/src/featuretracker.cpp @@ -98,8 +98,8 @@ Rect CvFeatureTracker::updateTrackingWindow(Mat image) Rect CvFeatureTracker::updateTrackingWindowWithSIFT(Mat image) { ittr++; - vector prev_keypoints, curr_keypoints; - vector prev_keys, curr_keys; + std::vector prev_keypoints, curr_keypoints; + std::vector prev_keys, curr_keys; Mat prev_desc, curr_desc; Rect window = prev_trackwindow; @@ -149,8 +149,8 @@ Rect CvFeatureTracker::updateTrackingWindowWithFlow(Mat image) Size subPixWinSize(10,10), winSize(31,31); Mat image_bw; TermCriteria termcrit(CV_TERMCRIT_ITER | CV_TERMCRIT_EPS, 20, 0.03); - vector status; - vector err; + std::vector status; + std::vector err; cvtColor(image, image_bw, CV_BGR2GRAY); cvtColor(prev_image, prev_image_bw, CV_BGR2GRAY); diff --git a/modules/contrib/src/hybridtracker.cpp b/modules/contrib/src/hybridtracker.cpp index 362de7c04..23a6ecbba 100644 --- a/modules/contrib/src/hybridtracker.cpp +++ b/modules/contrib/src/hybridtracker.cpp @@ -43,7 +43,6 @@ #include "opencv2/contrib/hybridtracker.hpp" using namespace cv; -using namespace std; CvHybridTrackerParams::CvHybridTrackerParams(float _ft_tracker_weight, float _ms_tracker_weight, CvFeatureTrackerParams _ft_params, @@ -83,7 +82,7 @@ CvHybridTracker::~CvHybridTracker() { inline float CvHybridTracker::getL2Norm(Point2f p1, Point2f p2) { float distance = (p1.x - p2.x) * (p1.x - p2.x) + (p1.y - p2.y) * (p1.y - p2.y); - return sqrt(distance); + return std::sqrt(distance); } Mat CvHybridTracker::getDistanceProjection(Mat image, Point2f center) { diff --git a/modules/contrib/src/imagelogpolprojection.cpp b/modules/contrib/src/imagelogpolprojection.cpp index ed821efa9..22f5214e7 100644 --- a/modules/contrib/src/imagelogpolprojection.cpp +++ b/modules/contrib/src/imagelogpolprojection.cpp @@ -193,7 +193,7 @@ bool ImageLogPolProjection::_initLogRetinaSampling(const double reductionFactor, //double rlim=1.0/reductionFactor*(minDimension/2.0+samplingStrenght); // input frame dimensions INdependent log sampling: - _azero=(1.0+reductionFactor*sqrt(samplingStrenght))/(reductionFactor*reductionFactor*samplingStrenght-1.0); + _azero=(1.0+reductionFactor*std::sqrt(samplingStrenght))/(reductionFactor*reductionFactor*samplingStrenght-1.0); _alim=(1.0+_azero)/reductionFactor; #ifdef IMAGELOGPOLPROJECTION_DEBUG std::cout<<"ImageLogPolProjection::initLogRetinaSampling: rlim= "< input frame dimensions dependent log sampling: - //double scale = samplingStrenght/(rlim-(double)sqrt(idRow*idRow+idColumn*idColumn)); + //double scale = samplingStrenght/(rlim-(double)std::sqrt(idRow*idRow+idColumn*idColumn)); // -> input frame dimensions INdependent log sampling: - double scale=getOriginalRadiusLength((double)sqrt((double)(idRow*idRow+idColumn*idColumn))); + double scale=getOriginalRadiusLength((double)std::sqrt((double)(idRow*idRow+idColumn*idColumn))); #ifdef IMAGELOGPOLPROJECTION_DEBUG std::cout<<"ImageLogPolProjection::initLogRetinaSampling: scale= "< -inline vector<_Tp> remove_dups(const vector<_Tp>& src) { - typedef typename set<_Tp>::const_iterator constSetIterator; - typedef typename vector<_Tp>::const_iterator constVecIterator; - set<_Tp> set_elems; +inline std::vector<_Tp> remove_dups(const std::vector<_Tp>& src) { + typedef typename std::set<_Tp>::const_iterator constSetIterator; + typedef typename std::vector<_Tp>::const_iterator constVecIterator; + std::set<_Tp> set_elems; for (constVecIterator it = src.begin(); it != src.end(); ++it) set_elems.insert(*it); - vector<_Tp> elems; + std::vector<_Tp> elems; for (constSetIterator it = set_elems.begin(); it != set_elems.end(); ++it) elems.push_back(*it); return elems; @@ -47,7 +42,7 @@ static Mat argsort(InputArray _src, bool ascending=true) { Mat src = _src.getMat(); if (src.rows != 1 && src.cols != 1) { - string error_message = "Wrong shape of input matrix! Expected a matrix with one row or column."; + std::string error_message = "Wrong shape of input matrix! Expected a matrix with one row or column."; CV_Error(CV_StsBadArg, error_message); } int flags = CV_SORT_EVERY_ROW+(ascending ? CV_SORT_ASCENDING : CV_SORT_DESCENDING); @@ -59,7 +54,7 @@ static Mat argsort(InputArray _src, bool ascending=true) static Mat asRowMatrix(InputArrayOfArrays src, int rtype, double alpha=1, double beta=0) { // make sure the input data is a vector of matrices or vector of vector if(src.kind() != _InputArray::STD_VECTOR_MAT && src.kind() != _InputArray::STD_VECTOR_VECTOR) { - string error_message = "The data is expected as InputArray::STD_VECTOR_MAT (a std::vector) or _InputArray::STD_VECTOR_VECTOR (a std::vector< vector<...> >)."; + std::string error_message = "The data is expected as InputArray::STD_VECTOR_MAT (a std::vector) or _InputArray::STD_VECTOR_VECTOR (a std::vector< std::vector<...> >)."; CV_Error(CV_StsBadArg, error_message); } // number of samples @@ -75,7 +70,7 @@ static Mat asRowMatrix(InputArrayOfArrays src, int rtype, double alpha=1, double for(int i = 0; i < (int)n; i++) { // make sure data can be reshaped, throw exception if not! if(src.getMat(i).total() != d) { - string error_message = format("Wrong number of elements in matrix #%d! Expected %d was %d.", i, (int)d, (int)src.getMat(i).total()); + std::string error_message = format("Wrong number of elements in matrix #%d! Expected %d was %d.", i, (int)d, (int)src.getMat(i).total()); CV_Error(CV_StsBadArg, error_message); } // get a hold of the current row @@ -95,7 +90,7 @@ static void sortMatrixColumnsByIndices(InputArray _src, InputArray _indices, Out CV_Error(CV_StsUnsupportedFormat, "cv::sortColumnsByIndices only works on integer indices!"); } Mat src = _src.getMat(); - vector indices = _indices.getMat(); + std::vector indices = _indices.getMat(); _dst.create(src.rows, src.cols, src.type()); Mat dst = _dst.getMat(); for(size_t idx = 0; idx < indices.size(); idx++) { @@ -183,12 +178,12 @@ Mat subspaceProject(InputArray _W, InputArray _mean, InputArray _src) { int d = src.cols; // make sure the data has the correct shape if(W.rows != d) { - string error_message = format("Wrong shapes for given matrices. Was size(src) = (%d,%d), size(W) = (%d,%d).", src.rows, src.cols, W.rows, W.cols); + std::string error_message = format("Wrong shapes for given matrices. Was size(src) = (%d,%d), size(W) = (%d,%d).", src.rows, src.cols, W.rows, W.cols); CV_Error(CV_StsBadArg, error_message); } // make sure mean is correct if not empty if(!mean.empty() && (mean.total() != (size_t) d)) { - string error_message = format("Wrong mean shape for the given data matrix. Expected %d, but was %d.", d, mean.total()); + std::string error_message = format("Wrong mean shape for the given data matrix. Expected %d, but was %d.", d, mean.total()); CV_Error(CV_StsBadArg, error_message); } // create temporary matrices @@ -221,12 +216,12 @@ Mat subspaceReconstruct(InputArray _W, InputArray _mean, InputArray _src) int d = src.cols; // make sure the data has the correct shape if(W.cols != d) { - string error_message = format("Wrong shapes for given matrices. Was size(src) = (%d,%d), size(W) = (%d,%d).", src.rows, src.cols, W.rows, W.cols); + std::string error_message = format("Wrong shapes for given matrices. Was size(src) = (%d,%d), size(W) = (%d,%d).", src.rows, src.cols, W.rows, W.cols); CV_Error(CV_StsBadArg, error_message); } // make sure mean is correct if not empty if(!mean.empty() && (mean.total() != (size_t) W.rows)) { - string error_message = format("Wrong mean shape for the given eigenvector matrix. Expected %d, but was %d.", W.cols, mean.total()); + std::string error_message = format("Wrong mean shape for the given eigenvector matrix. Expected %d, but was %d.", W.cols, mean.total()); CV_Error(CV_StsBadArg, error_message); } // initalize temporary matrices @@ -330,7 +325,7 @@ private: int n1 = nn - 1; int low = 0; int high = nn - 1; - double eps = pow(2.0, -52.0); + double eps = std::pow(2.0, -52.0); double exshift = 0.0; double p = 0, q = 0, r = 0, s = 0, z = 0, t, w, x, y; @@ -342,7 +337,7 @@ private: d[i] = H[i][i]; e[i] = 0.0; } - for (int j = max(i - 1, 0); j < nn; j++) { + for (int j = std::max(i - 1, 0); j < nn; j++) { norm = norm + std::abs(H[i][j]); } } @@ -380,7 +375,7 @@ private: w = H[n1][n1 - 1] * H[n1 - 1][n1]; p = (H[n1 - 1][n1 - 1] - H[n1][n1]) / 2.0; q = p * p + w; - z = sqrt(std::abs(q)); + z = std::sqrt(std::abs(q)); H[n1][n1] = H[n1][n1] + exshift; H[n1 - 1][n1 - 1] = H[n1 - 1][n1 - 1] + exshift; x = H[n1][n1]; @@ -404,7 +399,7 @@ private: s = std::abs(x) + std::abs(z); p = x / s; q = z / s; - r = sqrt(p * p + q * q); + r = std::sqrt(p * p + q * q); p = p / r; q = q / r; @@ -475,7 +470,7 @@ private: s = (y - x) / 2.0; s = s * s + w; if (s > 0) { - s = sqrt(s); + s = std::sqrt(s); if (y < x) { s = -s; } @@ -539,7 +534,7 @@ private: if (x == 0.0) { break; } - s = sqrt(p * p + q * q + r * r); + s = std::sqrt(p * p + q * q + r * r); if (p < 0) { s = -s; } @@ -570,7 +565,7 @@ private: // Column modification - for (int i = 0; i <= min(n1, k + 3); i++) { + for (int i = 0; i <= std::min(n1, k + 3); i++) { p = x * H[i][k] + y * H[i][k + 1]; if (notlast) { p = p + z * H[i][k + 2]; @@ -721,7 +716,7 @@ private: // Overflow control - t = max(std::abs(H[i][n1 - 1]), std::abs(H[i][n1])); + t = std::max(std::abs(H[i][n1 - 1]), std::abs(H[i][n1])); if ((eps * t) * t > 1) { for (int j = i; j <= n1; j++) { H[j][n1 - 1] = H[j][n1 - 1] / t; @@ -748,7 +743,7 @@ private: for (int j = nn - 1; j >= low; j--) { for (int i = low; i <= high; i++) { z = 0.0; - for (int k = low; k <= min(j, high); k++) { + for (int k = low; k <= std::min(j, high); k++) { z = z + V[i][k] * H[k][j]; } V[i][j] = z; @@ -782,7 +777,7 @@ private: ort[i] = H[i][m - 1] / scale; h += ort[i] * ort[i]; } - double g = sqrt(h); + double g = std::sqrt(h); if (ort[m] > 0) { g = -g; } @@ -941,7 +936,7 @@ public: //------------------------------------------------------------------------------ // Linear Discriminant Analysis implementation //------------------------------------------------------------------------------ -void LDA::save(const string& filename) const { +void LDA::save(const std::string& filename) const { FileStorage fs(filename, FileStorage::WRITE); if (!fs.isOpened()) { CV_Error(CV_StsError, "File can't be opened for writing!"); @@ -951,7 +946,7 @@ void LDA::save(const string& filename) const { } // Deserializes this object from a given filename. -void LDA::load(const string& filename) { +void LDA::load(const std::string& filename) { FileStorage fs(filename, FileStorage::READ); if (!fs.isOpened()) CV_Error(CV_StsError, "File can't be opened for writing!"); @@ -978,7 +973,7 @@ void LDA::load(const FileStorage& fs) { void LDA::lda(InputArrayOfArrays _src, InputArray _lbls) { // get data Mat src = _src.getMat(); - vector labels; + std::vector labels; // safely copy the labels { Mat tmp = _lbls.getMat(); @@ -991,9 +986,9 @@ void LDA::lda(InputArrayOfArrays _src, InputArray _lbls) { // ensure working matrix is double precision src.convertTo(data, CV_64FC1); // maps the labels, so they're ascending: [0,1,...,C] - vector mapped_labels(labels.size()); - vector num2label = remove_dups(labels); - map label2num; + std::vector mapped_labels(labels.size()); + std::vector num2label = remove_dups(labels); + std::map label2num; for (int i = 0; i < (int)num2label.size(); i++) label2num[num2label[i]] = i; for (size_t i = 0; i < labels.size(); i++) @@ -1006,19 +1001,19 @@ void LDA::lda(InputArrayOfArrays _src, InputArray _lbls) { // we can't do a LDA on one class, what do you // want to separate from each other then? if(C == 1) { - string error_message = "At least two classes are needed to perform a LDA. Reason: Only one class was given!"; + std::string error_message = "At least two classes are needed to perform a LDA. Reason: Only one class was given!"; CV_Error(CV_StsBadArg, error_message); } // throw error if less labels, than samples if (labels.size() != static_cast(N)) { - string error_message = format("The number of samples must equal the number of labels. Given %d labels, %d samples. ", labels.size(), N); + std::string error_message = format("The number of samples must equal the number of labels. Given %d labels, %d samples. ", labels.size(), N); CV_Error(CV_StsBadArg, error_message); } // warn if within-classes scatter matrix becomes singular if (N < D) { - cout << "Warning: Less observations than feature dimension given!" - << "Computation will probably fail." - << endl; + std::cout << "Warning: Less observations than feature dimension given!" + << "Computation will probably fail." + << std::endl; } // clip number of components to be a valid number if ((_num_components <= 0) || (_num_components > (C - 1))) { @@ -1027,8 +1022,8 @@ void LDA::lda(InputArrayOfArrays _src, InputArray _lbls) { // holds the mean over all classes Mat meanTotal = Mat::zeros(1, D, data.type()); // holds the mean for each class - vector meanClass(C); - vector numClass(C); + std::vector meanClass(C); + std::vector numClass(C); // initialize for (int i = 0; i < C; i++) { numClass[i] = 0; @@ -1076,7 +1071,7 @@ void LDA::lda(InputArrayOfArrays _src, InputArray _lbls) { // reshape eigenvalues, so they are stored by column _eigenvalues = _eigenvalues.reshape(1, 1); // get sorted indices descending by their eigenvalue - vector sorted_indices = argsort(_eigenvalues, false); + std::vector sorted_indices = argsort(_eigenvalues, false); // now sort eigenvalues and eigenvectors accordingly _eigenvalues = sortMatrixColumnsByIndices(_eigenvalues, sorted_indices); _eigenvectors = sortMatrixColumnsByIndices(_eigenvectors, sorted_indices); @@ -1094,7 +1089,7 @@ void LDA::compute(InputArrayOfArrays _src, InputArray _lbls) { lda(_src.getMat(), _lbls); break; default: - string error_message= format("InputArray Datatype %d is not supported.", _src.kind()); + std::string error_message= format("InputArray Datatype %d is not supported.", _src.kind()); CV_Error(CV_StsBadArg, error_message); break; } diff --git a/modules/contrib/src/logpolar_bsm.cpp b/modules/contrib/src/logpolar_bsm.cpp index 3de6a6182..70c7437bb 100644 --- a/modules/contrib/src/logpolar_bsm.cpp +++ b/modules/contrib/src/logpolar_bsm.cpp @@ -75,13 +75,13 @@ LogPolar_Interp::LogPolar_Interp(int w, int h, Point2i center, int _R, double _r int rtmp; if (center.x<=w/2 && center.y>=h/2) - rtmp=(int)sqrt((float)center.y*center.y + (float)(w-center.x)*(w-center.x)); + rtmp=(int)std::sqrt((float)center.y*center.y + (float)(w-center.x)*(w-center.x)); else if (center.x>=w/2 && center.y>=h/2) - rtmp=(int)sqrt((float)center.y*center.y + (float)center.x*center.x); + rtmp=(int)std::sqrt((float)center.y*center.y + (float)center.x*center.x); else if (center.x>=w/2 && center.y<=h/2) - rtmp=(int)sqrt((float)(h-center.y)*(h-center.y) + (float)center.x*center.x); + rtmp=(int)std::sqrt((float)(h-center.y)*(h-center.y) + (float)center.x*center.x); else //if (center.x<=w/2 && center.y<=h/2) - rtmp=(int)sqrt((float)(h-center.y)*(h-center.y) + (float)(w-center.x)*(w-center.x)); + rtmp=(int)std::sqrt((float)(h-center.y)*(h-center.y) + (float)(w-center.x)*(w-center.x)); M=2*rtmp; N=2*rtmp; @@ -97,8 +97,8 @@ LogPolar_Interp::LogPolar_Interp(int w, int h, Point2i center, int _R, double _r if (sp){ int jc=M/2-1, ic=N/2-1; - int _romax=min(ic, jc); - double _a=exp(log((double)(_romax/2-1)/(double)ro0)/(double)R); + int _romax=std::min(ic, jc); + double _a=std::exp(std::log((double)(_romax/2-1)/(double)ro0)/(double)R); S=(int) floor(2*CV_PI/(_a-1)+0.5); } @@ -116,8 +116,8 @@ void LogPolar_Interp::create_map(int _M, int _n, int _R, int _s, double _ro0) ro0=_ro0; int jc=N/2-1, ic=M/2-1; - romax=min(ic, jc); - a=exp(log((double)romax/(double)ro0)/(double)R); + romax=std::min(ic, jc); + a=std::exp(std::log((double)romax/(double)ro0)/(double)R); q=((double)S)/(2*CV_PI); Rsri = Mat::zeros(S,R,CV_32FC1); @@ -129,8 +129,8 @@ void LogPolar_Interp::create_map(int _M, int _n, int _R, int _s, double _ro0) { for(int u=0; u(v,u)=(float)(ro0*pow(a,u)*sin(v/q)+jc); - Csri.at(v,u)=(float)(ro0*pow(a,u)*cos(v/q)+ic); + Rsri.at(v,u)=(float)(ro0*std::pow(a,u)*sin(v/q)+jc); + Csri.at(v,u)=(float)(ro0*std::pow(a,u)*cos(v/q)+ic); } } @@ -150,7 +150,7 @@ void LogPolar_Interp::create_map(int _M, int _n, int _R, int _s, double _ro0) ETAyx.at(j,i)=(float)(q*theta); double ro2=(j-jc)*(j-jc)+(i-ic)*(i-ic); - CSIyx.at(j,i)=(float)(0.5*log(ro2/(ro0*ro0))/log(a)); + CSIyx.at(j,i)=(float)(0.5*std::log(ro2/(ro0*ro0))/std::log(a)); } } } @@ -221,13 +221,13 @@ LogPolar_Overlapping::LogPolar_Overlapping(int w, int h, Point2i center, int _R, int rtmp; if (center.x<=w/2 && center.y>=h/2) - rtmp=(int)sqrt((float)center.y*center.y + (float)(w-center.x)*(w-center.x)); + rtmp=(int)std::sqrt((float)center.y*center.y + (float)(w-center.x)*(w-center.x)); else if (center.x>=w/2 && center.y>=h/2) - rtmp=(int)sqrt((float)center.y*center.y + (float)center.x*center.x); + rtmp=(int)std::sqrt((float)center.y*center.y + (float)center.x*center.x); else if (center.x>=w/2 && center.y<=h/2) - rtmp=(int)sqrt((float)(h-center.y)*(h-center.y) + (float)center.x*center.x); + rtmp=(int)std::sqrt((float)(h-center.y)*(h-center.y) + (float)center.x*center.x); else //if (center.x<=w/2 && center.y<=h/2) - rtmp=(int)sqrt((float)(h-center.y)*(h-center.y) + (float)(w-center.x)*(w-center.x)); + rtmp=(int)std::sqrt((float)(h-center.y)*(h-center.y) + (float)(w-center.x)*(w-center.x)); M=2*rtmp; N=2*rtmp; @@ -244,8 +244,8 @@ LogPolar_Overlapping::LogPolar_Overlapping(int w, int h, Point2i center, int _R, if (sp){ int jc=M/2-1, ic=N/2-1; - int _romax=min(ic, jc); - double _a=exp(log((double)(_romax/2-1)/(double)ro0)/(double)R); + int _romax=std::min(ic, jc); + double _a=std::exp(std::log((double)(_romax/2-1)/(double)ro0)/(double)R); S=(int) floor(2*CV_PI/(_a-1)+0.5); } @@ -261,8 +261,8 @@ void LogPolar_Overlapping::create_map(int _M, int _n, int _R, int _s, double _ro ro0=_ro0; int jc=N/2-1, ic=M/2-1; - romax=min(ic, jc); - a=exp(log((double)romax/(double)ro0)/(double)R); + romax=std::min(ic, jc); + a=std::exp(std::log((double)romax/(double)ro0)/(double)R); q=((double)S)/(2*CV_PI); ind1=0; @@ -279,8 +279,8 @@ void LogPolar_Overlapping::create_map(int _M, int _n, int _R, int _s, double _ro { for(int u=0; u(v,u)=(float)(ro0*pow(a,u)*sin(v/q)+jc); - Csri.at(v,u)=(float)(ro0*pow(a,u)*cos(v/q)+ic); + Rsri.at(v,u)=(float)(ro0*std::pow(a,u)*sin(v/q)+jc); + Csri.at(v,u)=(float)(ro0*std::pow(a,u)*cos(v/q)+ic); Rsr[v*R+u]=(int)floor(Rsri.at(v,u)); Csr[v*R+u]=(int)floor(Csri.at(v,u)); } @@ -290,7 +290,7 @@ void LogPolar_Overlapping::create_map(int _M, int _n, int _R, int _s, double _ro for(int i=0; i1)&&(done==false)) { ind1=i; @@ -314,7 +314,7 @@ void LogPolar_Overlapping::create_map(int _M, int _n, int _R, int _s, double _ro ETAyx.at(j,i)=(float)(q*theta); double ro2=(j-jc)*(j-jc)+(i-ic)*(i-ic); - CSIyx.at(j,i)=(float)(0.5*log(ro2/(ro0*ro0))/log(a)); + CSIyx.at(j,i)=(float)(0.5*std::log(ro2/(ro0*ro0))/std::log(a)); } } @@ -332,7 +332,7 @@ void LogPolar_Overlapping::create_map(int _M, int _n, int _R, int _s, double _ro for(int j=0; j<2*w+1; j++) for(int i=0; i<2*w+1; i++) { - (w_ker_2D[v*R+u].weights)[j*(2*w+1)+i]=exp(-(pow(i-w-dx, 2)+pow(j-w-dy, 2))/(2*sigma*sigma)); + (w_ker_2D[v*R+u].weights)[j*(2*w+1)+i]=std::exp(-(std::pow(i-w-dx, 2)+std::pow(j-w-dy, 2))/(2*sigma*sigma)); tot+=(w_ker_2D[v*R+u].weights)[j*(2*w+1)+i]; } for(int j=0; j<(2*w+1); j++) @@ -351,7 +351,7 @@ const Mat LogPolar_Overlapping::to_cortical(const Mat &source) remap(source_border,out,Csri,Rsri,INTER_LINEAR); int wm=w_ker_2D[R-1].w; - vector IMG((M+2*wm+1)*(N+2*wm+1), 0); + std::vector IMG((M+2*wm+1)*(N+2*wm+1), 0); for(int j=0; j IMG((N+2*wm+1)*(M+2*wm+1), 0.); - vector NOR((N+2*wm+1)*(M+2*wm+1), 0.); + std::vector IMG((N+2*wm+1)*(M+2*wm+1), 0.); + std::vector NOR((N+2*wm+1)*(M+2*wm+1), 0.); for(int v=0; v0) ret[M*(j-wm)+i-wm]=(int) floor(IMG[(M+2*wm+1)*j+i]+0.5);*/ - //int ro=(int)floor(sqrt((double)((j-wm-yc)*(j-wm-yc)+(i-wm-xc)*(i-wm-xc)))); + //int ro=(int)floor(std::sqrt((double)((j-wm-yc)*(j-wm-yc)+(i-wm-xc)*(i-wm-xc)))); int csi=(int) floor(CSIyx.at(j-wm,i-wm)); if((csi>=(ind1-(w_ker_2D[ind1]).w))&&(csi=h/2) - rtmp=(int)sqrt((float)center.y*center.y + (float)(w-center.x)*(w-center.x)); + rtmp=(int)std::sqrt((float)center.y*center.y + (float)(w-center.x)*(w-center.x)); else if (center.x>=w/2 && center.y>=h/2) - rtmp=(int)sqrt((float)center.y*center.y + (float)center.x*center.x); + rtmp=(int)std::sqrt((float)center.y*center.y + (float)center.x*center.x); else if (center.x>=w/2 && center.y<=h/2) - rtmp=(int)sqrt((float)(h-center.y)*(h-center.y) + (float)center.x*center.x); + rtmp=(int)std::sqrt((float)(h-center.y)*(h-center.y) + (float)center.x*center.x); else //if (center.x<=w/2 && center.y<=h/2) - rtmp=(int)sqrt((float)(h-center.y)*(h-center.y) + (float)(w-center.x)*(w-center.x)); + rtmp=(int)std::sqrt((float)(h-center.y)*(h-center.y) + (float)(w-center.x)*(w-center.x)); M=2*rtmp; N=2*rtmp; @@ -468,8 +468,8 @@ LogPolar_Adjacent::LogPolar_Adjacent(int w, int h, Point2i center, int _R, doubl if (sp){ int jc=M/2-1, ic=N/2-1; - int _romax=min(ic, jc); - double _a=exp(log((double)(_romax/2-1)/(double)ro0)/(double)R); + int _romax=std::min(ic, jc); + double _a=std::exp(std::log((double)(_romax/2-1)/(double)ro0)/(double)R); S=(int) floor(2*CV_PI/(_a-1)+0.5); } @@ -484,9 +484,9 @@ void LogPolar_Adjacent::create_map(int _M, int _n, int _R, int _s, double _ro0, R=_R; S=_s; ro0=_ro0; - romax=min(M/2.0, N/2.0); + romax=std::min(M/2.0, N/2.0); - a=exp(log(romax/ro0)/(double)R); + a=std::exp(std::log(romax/ro0)/(double)R); q=S/(2*CV_PI); A.resize(R*S); @@ -572,7 +572,7 @@ const Mat LogPolar_Adjacent::to_cortical(const Mat &source) Mat source_border; copyMakeBorder(source,source_border,top,bottom,left,right,BORDER_CONSTANT,Scalar(0)); - vector map(R*S, 0.); + std::vector map(R*S, 0.); for(int j=0; j map(M*N, 0.); + std::vector map(M*N, 0.); for(int j=0; j0) theta=atan(y/x); else @@ -635,7 +635,7 @@ bool LogPolar_Adjacent::get_uv(double x, double y, int&u, int&v) } else { - u= (int) floor(log(ro/ro0)/log(a)); + u= (int) floor(std::log(ro/ro0)/std::log(a)); if(theta>=0) v= (int) floor(q*theta); else diff --git a/modules/contrib/src/magnoretinafilter.cpp b/modules/contrib/src/magnoretinafilter.cpp index 6f72c5bbe..48e10cf53 100644 --- a/modules/contrib/src/magnoretinafilter.cpp +++ b/modules/contrib/src/magnoretinafilter.cpp @@ -144,7 +144,7 @@ void MagnoRetinaFilter::resize(const unsigned int NBrows, const unsigned int NBc void MagnoRetinaFilter::setCoefficientsTable(const float parasolCells_beta, const float parasolCells_tau, const float parasolCells_k, const float amacrinCellsTemporalCutFrequency, const float localAdaptIntegration_tau, const float localAdaptIntegration_k ) { - _temporalCoefficient=(float)exp(-1.0f/amacrinCellsTemporalCutFrequency); + _temporalCoefficient=(float)std::exp(-1.0f/amacrinCellsTemporalCutFrequency); // the first set of parameters is dedicated to the low pass filtering property of the ganglion cells BasicRetinaFilter::setLPfilterParameters(parasolCells_beta, parasolCells_tau, parasolCells_k, 0); // the second set of parameters is dedicated to the ganglion cells output intergartion for their local adaptation property diff --git a/modules/contrib/src/octree.cpp b/modules/contrib/src/octree.cpp index 0808b12eb..80d256494 100644 --- a/modules/contrib/src/octree.cpp +++ b/modules/contrib/src/octree.cpp @@ -101,7 +101,7 @@ namespace return true; } - void fillMinMax(const vector& points, Octree::Node& node) + void fillMinMax(const std::vector& points, Octree::Node& node) { node.x_max = node.y_max = node.z_max = std::numeric_limits::min(); node.x_min = node.y_min = node.z_min = std::numeric_limits::max(); @@ -171,7 +171,7 @@ namespace cv { } - Octree::Octree(const vector& points3d, int maxLevels, int _minPoints) + Octree::Octree(const std::vector& points3d, int maxLevels, int _minPoints) { buildTree(points3d, maxLevels, _minPoints); } @@ -180,7 +180,7 @@ namespace cv { } - void Octree::getPointsWithinSphere(const Point3f& center, float radius, vector& out) const + void Octree::getPointsWithinSphere(const Point3f& center, float radius, std::vector& out) const { out.clear(); @@ -256,7 +256,7 @@ namespace cv } } - void Octree::buildTree(const vector& points3d, int maxLevels, int _minPoints) + void Octree::buildTree(const std::vector& points3d, int maxLevels, int _minPoints) { assert((size_t)maxLevels * 8 < MAX_STACK_SIZE); points.resize(points3d.size()); @@ -286,9 +286,9 @@ namespace cv { size_t size = nodes[nodeInd].end - nodes[nodeInd].begin; - vector boxBorders(MAX_LEAFS+1, 0); - vector boxIndices(size); - vector tempPoints(size); + std::vector boxBorders(MAX_LEAFS+1, 0); + std::vector boxIndices(size); + std::vector tempPoints(size); for (int i = nodes[nodeInd].begin, j = 0; i < nodes[nodeInd].end; ++i, ++j) { @@ -304,7 +304,7 @@ namespace cv for (size_t i = 1; i < boxBorders.size(); ++i) boxBorders[i] += boxBorders[i-1]; - vector writeInds(boxBorders.begin(), boxBorders.end()); + std::vector writeInds(boxBorders.begin(), boxBorders.end()); for (size_t i = 0; i < size; ++i) { diff --git a/modules/contrib/src/openfabmap.cpp b/modules/contrib/src/openfabmap.cpp index e30080bfc..fbc8aee78 100644 --- a/modules/contrib/src/openfabmap.cpp +++ b/modules/contrib/src/openfabmap.cpp @@ -61,7 +61,7 @@ namespace cv { namespace of2 { static double logsumexp(double a, double b) { - return a > b ? log(1 + exp(b - a)) + a : log(1 + exp(a - b)) + b; + return a > b ? std::log(1 + std::exp(b - a)) + a : std::log(1 + std::exp(a - b)) + b; } FabMap::FabMap(const Mat& _clTree, double _PzGe, @@ -103,14 +103,14 @@ const std::vector& FabMap::getTestImgDescriptors() const { void FabMap::addTraining(const Mat& queryImgDescriptor) { CV_Assert(!queryImgDescriptor.empty()); - vector queryImgDescriptors; + std::vector queryImgDescriptors; for (int i = 0; i < queryImgDescriptor.rows; i++) { queryImgDescriptors.push_back(queryImgDescriptor.row(i)); } addTraining(queryImgDescriptors); } -void FabMap::addTraining(const vector& queryImgDescriptors) { +void FabMap::addTraining(const std::vector& queryImgDescriptors) { for (size_t i = 0; i < queryImgDescriptors.size(); i++) { CV_Assert(!queryImgDescriptors[i].empty()); CV_Assert(queryImgDescriptors[i].rows == 1); @@ -122,7 +122,7 @@ void FabMap::addTraining(const vector& queryImgDescriptors) { void FabMap::add(const cv::Mat& queryImgDescriptor) { CV_Assert(!queryImgDescriptor.empty()); - vector queryImgDescriptors; + std::vector queryImgDescriptors; for (int i = 0; i < queryImgDescriptor.rows; i++) { queryImgDescriptors.push_back(queryImgDescriptor.row(i)); } @@ -140,10 +140,10 @@ void FabMap::add(const std::vector& queryImgDescriptors) { } void FabMap::compare(const Mat& queryImgDescriptor, - vector& matches, bool addQuery, + std::vector& matches, bool addQuery, const Mat& mask) { CV_Assert(!queryImgDescriptor.empty()); - vector queryImgDescriptors; + std::vector queryImgDescriptors; for (int i = 0; i < queryImgDescriptor.rows; i++) { queryImgDescriptors.push_back(queryImgDescriptor.row(i)); } @@ -151,16 +151,16 @@ void FabMap::compare(const Mat& queryImgDescriptor, } void FabMap::compare(const Mat& queryImgDescriptor, - const Mat& testImgDescriptor, vector& matches, + const Mat& testImgDescriptor, std::vector& matches, const Mat& mask) { CV_Assert(!queryImgDescriptor.empty()); - vector queryImgDescriptors; + std::vector queryImgDescriptors; for (int i = 0; i < queryImgDescriptor.rows; i++) { queryImgDescriptors.push_back(queryImgDescriptor.row(i)); } CV_Assert(!testImgDescriptor.empty()); - vector _testImgDescriptors; + std::vector _testImgDescriptors; for (int i = 0; i < testImgDescriptor.rows; i++) { _testImgDescriptors.push_back(testImgDescriptor.row(i)); } @@ -169,18 +169,18 @@ void FabMap::compare(const Mat& queryImgDescriptor, } void FabMap::compare(const Mat& queryImgDescriptor, - const vector& _testImgDescriptors, - vector& matches, const Mat& mask) { + const std::vector& _testImgDescriptors, + std::vector& matches, const Mat& mask) { CV_Assert(!queryImgDescriptor.empty()); - vector queryImgDescriptors; + std::vector queryImgDescriptors; for (int i = 0; i < queryImgDescriptor.rows; i++) { queryImgDescriptors.push_back(queryImgDescriptor.row(i)); } compare(queryImgDescriptors,_testImgDescriptors,matches,mask); } -void FabMap::compare(const vector& queryImgDescriptors, - vector& matches, bool addQuery, const Mat& /*mask*/) { +void FabMap::compare(const std::vector& queryImgDescriptors, + std::vector& matches, bool addQuery, const Mat& /*mask*/) { // TODO: add first query if empty (is this necessary) @@ -199,9 +199,9 @@ void FabMap::compare(const vector& queryImgDescriptors, } } -void FabMap::compare(const vector& queryImgDescriptors, - const vector& _testImgDescriptors, - vector& matches, const Mat& /*mask*/) { +void FabMap::compare(const std::vector& queryImgDescriptors, + const std::vector& _testImgDescriptors, + std::vector& matches, const Mat& /*mask*/) { CV_Assert(!(flags & MOTION_MODEL)); for (size_t i = 0; i < _testImgDescriptors.size(); i++) { @@ -225,10 +225,10 @@ void FabMap::compare(const vector& queryImgDescriptors, } void FabMap::compareImgDescriptor(const Mat& queryImgDescriptor, - int queryIndex, const vector& _testImgDescriptors, - vector& matches) { + int queryIndex, const std::vector& _testImgDescriptors, + std::vector& matches) { - vector queryMatches; + std::vector queryMatches; queryMatches.push_back(IMatch(queryIndex,-1, getNewPlaceLikelihood(queryImgDescriptor),0)); getLikelihoods(queryImgDescriptor,_testImgDescriptors,queryMatches); @@ -240,7 +240,7 @@ void FabMap::compareImgDescriptor(const Mat& queryImgDescriptor, } void FabMap::getLikelihoods(const Mat& /*queryImgDescriptor*/, - const vector& /*testImgDescriptors*/, vector& /*matches*/) { + const std::vector& /*testImgDescriptors*/, std::vector& /*matches*/) { } @@ -252,7 +252,7 @@ double FabMap::getNewPlaceLikelihood(const Mat& queryImgDescriptor) { for (int q = 0; q < clTree.cols; q++) { zq = queryImgDescriptor.at(0,q) > 0; - logP += log(Pzq(q, false) * PzqGeq(zq, false) + + logP += std::log(Pzq(q, false) * PzqGeq(zq, false) + Pzq(q, true) * PzqGeq(zq, true)); } } else { @@ -269,7 +269,7 @@ double FabMap::getNewPlaceLikelihood(const Mat& queryImgDescriptor) { beta = Pzq(q, !zq) * PzqGeq(zq, true) * PzqGzpq(q, zq, zpq); p += Pzq(q, true) * beta / (alpha + beta); - logP += log(p); + logP += std::log(p); } } return logP; @@ -279,7 +279,7 @@ double FabMap::getNewPlaceLikelihood(const Mat& queryImgDescriptor) { CV_Assert(!trainingImgDescriptors.empty()); CV_Assert(numSamples > 0); - vector sampledImgDescriptors; + std::vector sampledImgDescriptors; // TODO: this method can result in the same sample being added // multiple times. Is this desired? @@ -289,7 +289,7 @@ double FabMap::getNewPlaceLikelihood(const Mat& queryImgDescriptor) { sampledImgDescriptors.push_back(trainingImgDescriptors[index]); } - vector matches; + std::vector matches; getLikelihoods(queryImgDescriptor,sampledImgDescriptors,matches); double averageLogLikelihood = -DBL_MAX + matches.front().likelihood + 1; @@ -298,34 +298,34 @@ double FabMap::getNewPlaceLikelihood(const Mat& queryImgDescriptor) { logsumexp(matches[i].likelihood, averageLogLikelihood); } - return averageLogLikelihood - log((double)numSamples); + return averageLogLikelihood - std::log((double)numSamples); } return 0; } -void FabMap::normaliseDistribution(vector& matches) { +void FabMap::normaliseDistribution(std::vector& matches) { CV_Assert(!matches.empty()); if (flags & MOTION_MODEL) { - matches[0].match = matches[0].likelihood + log(Pnew); + matches[0].match = matches[0].likelihood + std::log(Pnew); if (priorMatches.size() > 2) { matches[1].match = matches[1].likelihood; - matches[1].match += log( + matches[1].match += std::log( (2 * (1-mBias) * priorMatches[1].match + priorMatches[1].match + 2 * mBias * priorMatches[2].match) / 3); for (size_t i = 2; i < priorMatches.size()-1; i++) { matches[i].match = matches[i].likelihood; - matches[i].match += log( + matches[i].match += std::log( (2 * (1-mBias) * priorMatches[i-1].match + priorMatches[i].match + 2 * mBias * priorMatches[i+1].match)/3); } matches[priorMatches.size()-1].match = matches[priorMatches.size()-1].likelihood; - matches[priorMatches.size()-1].match += log( + matches[priorMatches.size()-1].match += std::log( (2 * (1-mBias) * priorMatches[priorMatches.size()-2].match + priorMatches[priorMatches.size()-1].match + 2 * mBias * priorMatches[priorMatches.size()-1].match)/3); @@ -348,7 +348,7 @@ void FabMap::normaliseDistribution(vector& matches) { //normalise for (size_t i = 0; i < matches.size(); i++) { - matches[i].match = exp(matches[i].match - logsum); + matches[i].match = std::exp(matches[i].match - logsum); } //smooth final probabilities @@ -368,7 +368,7 @@ void FabMap::normaliseDistribution(vector& matches) { logsum = logsumexp(logsum, matches[i].likelihood); } for (size_t i = 0; i < matches.size(); i++) { - matches[i].match = exp(matches[i].likelihood - logsum); + matches[i].match = std::exp(matches[i].likelihood - logsum); } for (size_t i = 0; i < matches.size(); i++) { matches[i].match = sFactor*matches[i].match + @@ -444,7 +444,7 @@ FabMap1::~FabMap1() { } void FabMap1::getLikelihoods(const Mat& queryImgDescriptor, - const vector& testImageDescriptors, vector& matches) { + const std::vector& testImageDescriptors, std::vector& matches) { for (size_t i = 0; i < testImageDescriptors.size(); i++) { bool zq, zpq, Lzq; @@ -455,7 +455,7 @@ void FabMap1::getLikelihoods(const Mat& queryImgDescriptor, zpq = queryImgDescriptor.at(0,pq(q)) > 0; Lzq = testImageDescriptors[i].at(0,q) > 0; - logP += log((this->*PzGL)(q, zq, zpq, Lzq)); + logP += std::log((this->*PzGL)(q, zq, zpq, Lzq)); } matches.push_back(IMatch(0,(int)i,logP,0)); @@ -467,7 +467,7 @@ FabMapLUT::FabMapLUT(const Mat& _clTree, double _PzGe, double _PzGNe, FabMap(_clTree, _PzGe, _PzGNe, _flags, _numSamples), precision(_precision) { int nWords = clTree.cols; - double precFactor = (double)pow(10.0, precision); + double precFactor = (double)std::pow(10.0, precision); table = new int[nWords][8]; @@ -478,7 +478,7 @@ FabMap(_clTree, _PzGe, _PzGNe, _flags, _numSamples), precision(_precision) { bool zq = (bool) ((i >> 1) & 0x01); bool zpq = (bool) (i & 1); - table[q][i] = -(int)(log((this->*PzGL)(q, zq, zpq, Lzq)) + table[q][i] = -(int)(std::log((this->*PzGL)(q, zq, zpq, Lzq)) * precFactor); } } @@ -489,9 +489,9 @@ FabMapLUT::~FabMapLUT() { } void FabMapLUT::getLikelihoods(const Mat& queryImgDescriptor, - const vector& testImageDescriptors, vector& matches) { + const std::vector& testImageDescriptors, std::vector& matches) { - double precFactor = (double)pow(10.0, -precision); + double precFactor = (double)std::pow(10.0, -precision); for (size_t i = 0; i < testImageDescriptors.size(); i++) { unsigned long long int logP = 0; @@ -517,13 +517,13 @@ FabMapFBO::~FabMapFBO() { } void FabMapFBO::getLikelihoods(const Mat& queryImgDescriptor, - const vector& testImageDescriptors, vector& matches) { + const std::vector& testImageDescriptors, std::vector& matches) { std::multiset wordData; setWordStatistics(queryImgDescriptor, wordData); - vector matchIndices; - vector queryMatches; + std::vector matchIndices; + std::vector queryMatches; for (size_t i = 0; i < testImageDescriptors.size(); i++) { queryMatches.push_back(IMatch(0,(int)i,0,0)); @@ -544,7 +544,7 @@ void FabMapFBO::getLikelihoods(const Mat& queryImgDescriptor, bool Lzq = testImageDescriptors[matchIndices[i]].at(0,wordIter->q) > 0; queryMatches[matchIndices[i]].likelihood += - log((this->*PzGL)(wordIter->q,zq,zpq,Lzq)); + std::log((this->*PzGL)(wordIter->q,zq,zpq,Lzq)); currBest = std::max(queryMatches[matchIndices[i]].likelihood, currBest); } @@ -553,9 +553,9 @@ void FabMapFBO::getLikelihoods(const Mat& queryImgDescriptor, continue; double delta = std::max(limitbisection(wordIter->V, wordIter->M), - -log(rejectionThreshold)); + -std::log(rejectionThreshold)); - vector::iterator matchIter = matchIndices.begin(); + std::vector::iterator matchIter = matchIndices.begin(); while (matchIter != matchIndices.end()) { if (currBest - queryMatches[*matchIter].likelihood > delta) { queryMatches[*matchIter].likelihood = bailedOut; @@ -568,7 +568,7 @@ void FabMapFBO::getLikelihoods(const Mat& queryImgDescriptor, for (size_t i = 0; i < queryMatches.size(); i++) { if (queryMatches[i].likelihood == bailedOut) { - queryMatches[i].likelihood = currBest + log(rejectionThreshold); + queryMatches[i].likelihood = currBest + std::log(rejectionThreshold); } } matches.insert(matches.end(), queryMatches.begin(), queryMatches.end()); @@ -595,11 +595,11 @@ void FabMapFBO::setWordStatistics(const Mat& queryImgDescriptor, zq = queryImgDescriptor.at(0,wordIter->q) > 0; zpq = queryImgDescriptor.at(0,pq(wordIter->q)) > 0; - d = log((this->*PzGL)(wordIter->q, zq, zpq, true)) - - log((this->*PzGL)(wordIter->q, zq, zpq, false)); + d = std::log((this->*PzGL)(wordIter->q, zq, zpq, true)) - + std::log((this->*PzGL)(wordIter->q, zq, zpq, false)); - V += pow(d, 2.0) * 2 * - (Pzq(wordIter->q, true) - pow(Pzq(wordIter->q, true), 2.0)); + V += std::pow(d, 2.0) * 2 * + (Pzq(wordIter->q, true) - std::pow(Pzq(wordIter->q, true), 2.0)); M = std::max(M, fabs(d)); wordIter->V = V; @@ -631,8 +631,8 @@ double FabMapFBO::limitbisection(double v, double m) { double FabMapFBO::bennettInequality(double v, double m, double delta) { double DMonV = delta * m / v; - double f_delta = log(DMonV + sqrt(pow(DMonV, 2.0) + 1)); - return exp((v / pow(m, 2.0))*(cosh(f_delta) - 1 - DMonV * f_delta)); + double f_delta = std::log(DMonV + std::sqrt(std::pow(DMonV, 2.0) + 1)); + return std::exp((v / std::pow(m, 2.0))*(cosh(f_delta) - 1 - DMonV * f_delta)); } bool FabMapFBO::compInfo(const WordStats& first, const WordStats& second) { @@ -647,13 +647,13 @@ FabMap(_clTree, _PzGe, _PzGNe, _flags) { children.resize(clTree.cols); for (int q = 0; q < clTree.cols; q++) { - d1.push_back(log((this->*PzGL)(q, false, false, true) / + d1.push_back(std::log((this->*PzGL)(q, false, false, true) / (this->*PzGL)(q, false, false, false))); - d2.push_back(log((this->*PzGL)(q, false, true, true) / + d2.push_back(std::log((this->*PzGL)(q, false, true, true) / (this->*PzGL)(q, false, true, false)) - d1[q]); - d3.push_back(log((this->*PzGL)(q, true, false, true) / + d3.push_back(std::log((this->*PzGL)(q, true, false, true) / (this->*PzGL)(q, true, false, false))- d1[q]); - d4.push_back(log((this->*PzGL)(q, true, true, true) / + d4.push_back(std::log((this->*PzGL)(q, true, true, true) / (this->*PzGL)(q, true, true, false))- d1[q]); children[pq(q)].push_back(q); } @@ -664,7 +664,7 @@ FabMap2::~FabMap2() { } -void FabMap2::addTraining(const vector& queryImgDescriptors) { +void FabMap2::addTraining(const std::vector& queryImgDescriptors) { for (size_t i = 0; i < queryImgDescriptors.size(); i++) { CV_Assert(!queryImgDescriptors[i].empty()); CV_Assert(queryImgDescriptors[i].rows == 1); @@ -676,7 +676,7 @@ void FabMap2::addTraining(const vector& queryImgDescriptors) { } -void FabMap2::add(const vector& queryImgDescriptors) { +void FabMap2::add(const std::vector& queryImgDescriptors) { for (size_t i = 0; i < queryImgDescriptors.size(); i++) { CV_Assert(!queryImgDescriptors[i].empty()); CV_Assert(queryImgDescriptors[i].rows == 1); @@ -688,15 +688,15 @@ void FabMap2::add(const vector& queryImgDescriptors) { } void FabMap2::getLikelihoods(const Mat& queryImgDescriptor, - const vector& testImageDescriptors, vector& matches) { + const std::vector& testImageDescriptors, std::vector& matches) { if (&testImageDescriptors == &testImgDescriptors) { getIndexLikelihoods(queryImgDescriptor, testDefaults, testInvertedMap, matches); } else { CV_Assert(!(flags & MOTION_MODEL)); - vector defaults; - std::map > invertedMap; + std::vector defaults; + std::map > invertedMap; for (size_t i = 0; i < testImageDescriptors.size(); i++) { addToIndex(testImageDescriptors[i],defaults,invertedMap); } @@ -708,7 +708,7 @@ double FabMap2::getNewPlaceLikelihood(const Mat& queryImgDescriptor) { CV_Assert(!trainingImgDescriptors.empty()); - vector matches; + std::vector matches; getIndexLikelihoods(queryImgDescriptor, trainingDefaults, trainingInvertedMap, matches); @@ -718,13 +718,13 @@ double FabMap2::getNewPlaceLikelihood(const Mat& queryImgDescriptor) { logsumexp(matches[i].likelihood, averageLogLikelihood); } - return averageLogLikelihood - log((double)trainingDefaults.size()); + return averageLogLikelihood - std::log((double)trainingDefaults.size()); } void FabMap2::addToIndex(const Mat& queryImgDescriptor, - vector& defaults, - std::map >& invertedMap) { + std::vector& defaults, + std::map >& invertedMap) { defaults.push_back(0); for (int q = 0; q < clTree.cols; q++) { if (queryImgDescriptor.at(0,q) > 0) { @@ -736,10 +736,10 @@ void FabMap2::addToIndex(const Mat& queryImgDescriptor, void FabMap2::getIndexLikelihoods(const Mat& queryImgDescriptor, std::vector& defaults, - std::map >& invertedMap, + std::map >& invertedMap, std::vector& matches) { - vector::iterator LwithI, child; + std::vector::iterator LwithI, child; std::vector likelihoods = defaults; diff --git a/modules/contrib/src/retinafilter.cpp b/modules/contrib/src/retinafilter.cpp index 2d29dc452..4cf6019f5 100644 --- a/modules/contrib/src/retinafilter.cpp +++ b/modules/contrib/src/retinafilter.cpp @@ -206,7 +206,7 @@ namespace cv { for (j=0;j<(int)_photoreceptorsPrefilter.getNBcolumns();++j) { - float distanceToCenter=sqrt(((float)(i-halfRows)*(i-halfRows)+(j-halfColumns)*(j-halfColumns))); + float distanceToCenter=std::sqrt(((float)(i-halfRows)*(i-halfRows)+(j-halfColumns)*(j-halfColumns))); if (distanceToCenter Scalar log2(Scalar v) { using std::log; return log(v)/log(Scalar(2)); } + template Scalar log2(Scalar v) { return std::log(v)/std::log(Scalar(2)); } # endif # if defined __GNUC__ && defined __APPLE__ # pragma GCC diagnostic ignored "-Wshadow" @@ -172,7 +172,7 @@ static void warpImage( const Mat& image, const Mat& depth, { const Rect rect = Rect(0, 0, image.cols, image.rows); - vector points2d; + std::vector points2d; Mat cloud, transformedCloud; cvtDepth2Cloud( depth, cloud, cameraMatrix ); @@ -310,11 +310,11 @@ static void buildPyramids( const Mat& image0, const Mat& image1, const Mat& depth0, const Mat& depth1, const Mat& cameraMatrix, int sobelSize, double sobelScale, - const vector& minGradMagnitudes, - vector& pyramidImage0, vector& pyramidDepth0, - vector& pyramidImage1, vector& pyramidDepth1, - vector& pyramid_dI_dx1, vector& pyramid_dI_dy1, - vector& pyramidTexturedMask1, vector& pyramidCameraMatrix ) + const std::vector& minGradMagnitudes, + std::vector& pyramidImage0, std::vector& pyramidDepth0, + std::vector& pyramidImage1, std::vector& pyramidDepth1, + std::vector& pyramid_dI_dx1, std::vector& pyramid_dI_dy1, + std::vector& pyramidTexturedMask1, std::vector& pyramidCameraMatrix ) { const int pyramidMaxLevel = (int)minGradMagnitudes.size() - 1; @@ -535,10 +535,10 @@ bool cv::RGBDOdometry( cv::Mat& Rt, const Mat& initRt, minGradientMagnitudes.size() == iterCounts.size() ); CV_Assert( initRt.empty() || (initRt.type()==CV_64FC1 && initRt.size()==Size(4,4) ) ); - vector defaultIterCounts; - vector defaultMinGradMagnitudes; - vector const* iterCountsPtr = &iterCounts; - vector const* minGradientMagnitudesPtr = &minGradientMagnitudes; + std::vector defaultIterCounts; + std::vector defaultMinGradMagnitudes; + std::vector const* iterCountsPtr = &iterCounts; + std::vector const* minGradientMagnitudesPtr = &minGradientMagnitudes; if( iterCounts.empty() || minGradientMagnitudes.empty() ) { @@ -560,7 +560,7 @@ bool cv::RGBDOdometry( cv::Mat& Rt, const Mat& initRt, preprocessDepth( depth0, depth1, validMask0, validMask1, minDepth, maxDepth ); - vector pyramidImage0, pyramidDepth0, + std::vector pyramidImage0, pyramidDepth0, pyramidImage1, pyramidDepth1, pyramid_dI_dx1, pyramid_dI_dy1, pyramidTexturedMask1, pyramidCameraMatrix; buildPyramids( image0, image1, depth0, depth1, cameraMatrix, sobelSize, sobelScale, *minGradientMagnitudesPtr, diff --git a/modules/contrib/src/selfsimilarity.cpp b/modules/contrib/src/selfsimilarity.cpp index 3857e3b1d..ecca87c4b 100644 --- a/modules/contrib/src/selfsimilarity.cpp +++ b/modules/contrib/src/selfsimilarity.cpp @@ -145,8 +145,8 @@ void SelfSimDescriptor::SSD(const Mat& img, Point pt, Mat& ssd) const } -void SelfSimDescriptor::compute(const Mat& img, vector& descriptors, Size winStride, - const vector& locations) const +void SelfSimDescriptor::compute(const Mat& img, std::vector& descriptors, Size winStride, + const std::vector& locations) const { CV_Assert( img.depth() == CV_8U ); @@ -156,7 +156,7 @@ void SelfSimDescriptor::compute(const Mat& img, vector& descriptors, Size int i, nwindows = locations.empty() ? gridSize.width*gridSize.height : (int)locations.size(); int border = largeSize/2 + smallSize/2; int fsize = (int)getDescriptorSize(); - vector tempFeature(fsize+1); + std::vector tempFeature(fsize+1); descriptors.resize(fsize*nwindows + 1); Mat ssd(largeSize, largeSize, CV_32F), mappingMask; computeLogPolarMapping(mappingMask); diff --git a/modules/contrib/src/spinimages.cpp b/modules/contrib/src/spinimages.cpp index 21cbc8b9f..ae7914f61 100644 --- a/modules/contrib/src/spinimages.cpp +++ b/modules/contrib/src/spinimages.cpp @@ -49,17 +49,9 @@ #include using namespace cv; -using namespace std; /********************************* local utility *********************************/ -namespace cv -{ - using std::log; - using std::max; - using std::min; - using std::sqrt; -} namespace { const static Scalar colors[] = @@ -85,13 +77,20 @@ namespace }; size_t colors_mum = sizeof(colors)/sizeof(colors[0]); -#if (defined __cplusplus && __cplusplus > 199711L) || defined _STLPORT_MAJOR -#else -template void iota(FwIt first, FwIt last, T value) { while(first != last) *first++ = value++; } -#endif +namespace { -void computeNormals( const Octree& Octree, const vector& centers, vector& normals, - vector& mask, float normalRadius, int minNeighbors = 20) +template inline void _iota(FwIt first, FwIt last, T value) +{ +#if (defined __cplusplus && __cplusplus > 199711L) || defined _STLPORT_MAJOR + std::iota(first, last, value); +#else + while(first != last) *first++ = value++; +#endif +} +} + +void computeNormals( const Octree& Octree, const std::vector& centers, std::vector& normals, + std::vector& mask, float normalRadius, int minNeighbors = 20) { size_t normals_size = centers.size(); normals.resize(normals_size); @@ -105,7 +104,7 @@ void computeNormals( const Octree& Octree, const vector& centers, vecto mask[m] = 1; } - vector buffer; + std::vector buffer; buffer.reserve(128); SVD svd; @@ -223,8 +222,8 @@ inline __m128i _mm_mullo_epi32_emul(const __m128i& a, __m128i& b) #endif -void computeSpinImages( const Octree& Octree, const vector& points, const vector& normals, - vector& mask, Mat& spinImages, int imageWidth, float binSize) +void computeSpinImages( const Octree& Octree, const std::vector& points, const std::vector& normals, + std::vector& mask, Mat& spinImages, int imageWidth, float binSize) { float pixelsPerMeter = 1.f / binSize; float support = imageWidth * binSize; @@ -243,12 +242,12 @@ void computeSpinImages( const Octree& Octree, const vector& points, con int nthreads = getNumThreads(); int i; - vector< vector > pointsInSpherePool(nthreads); + std::vector< std::vector > pointsInSpherePool(nthreads); for(i = 0; i < nthreads; i++) pointsInSpherePool[i].reserve(2048); float halfSuppport = support / 2; - float searchRad = support * sqrt(5.f) / 2; // sqrt(sup*sup + (sup/2) * (sup/2) ) + float searchRad = support * std::sqrt(5.f) / 2; // std::sqrt(sup*sup + (sup/2) * (sup/2) ) #ifdef _OPENMP #pragma omp parallel for num_threads(nthreads) @@ -259,7 +258,7 @@ void computeSpinImages( const Octree& Octree, const vector& points, con continue; int t = cvGetThreadNum(); - vector& pointsInSphere = pointsInSpherePool[t]; + std::vector& pointsInSphere = pointsInSpherePool[t]; const Point3f& center = points[i]; Octree.getPointsWithinSphere(center, searchRad, pointsInSphere); @@ -398,7 +397,7 @@ void computeSpinImages( const Octree& Octree, const vector& points, con if (beta >= support || beta < 0) continue; - alpha = sqrt( (new_center.x - pt.x) * (new_center.x - pt.x) + + alpha = std::sqrt( (new_center.x - pt.x) * (new_center.x - pt.x) + (new_center.y - pt.y) * (new_center.y - pt.y) ); float n1f = beta * pixelsPerMeter; @@ -432,7 +431,7 @@ void computeSpinImages( const Octree& Octree, const vector& points, con const Point3f cv::Mesh3D::allzero(0.f, 0.f, 0.f); cv::Mesh3D::Mesh3D() { resolution = -1; } -cv::Mesh3D::Mesh3D(const vector& _vtx) +cv::Mesh3D::Mesh3D(const std::vector& _vtx) { resolution = -1; vtx.resize(_vtx.size()); @@ -450,14 +449,14 @@ float cv::Mesh3D::estimateResolution(float /*tryRatio*/) const int minReasonable = 10; int tryNum = static_cast(tryRatio * vtx.size()); - tryNum = min(max(tryNum, minReasonable), (int)vtx.size()); + tryNum = std::min(std::max(tryNum, minReasonable), (int)vtx.size()); CvMat desc = cvMat((int)vtx.size(), 3, CV_32F, &vtx[0]); CvFeatureTree* tr = cvCreateKDTree(&desc); - vector dist(tryNum * neighbors); - vector inds(tryNum * neighbors); - vector query; + std::vector dist(tryNum * neighbors); + std::vector inds(tryNum * neighbors); + std::vector query; RNG& rng = theRNG(); for(int i = 0; i < tryNum; ++i) @@ -476,7 +475,7 @@ float cv::Mesh3D::estimateResolution(float /*tryRatio*/) dist.resize(remove(dist.begin(), dist.end(), invalid_dist) - dist.begin()); - sort(dist, less()); + sort(dist, std::less()); return resolution = (float)dist[ dist.size() / 2 ]; #else @@ -489,49 +488,49 @@ float cv::Mesh3D::estimateResolution(float /*tryRatio*/) void cv::Mesh3D::computeNormals(float normalRadius, int minNeighbors) { buildOctree(); - vector mask; + std::vector mask; ::computeNormals(octree, vtx, normals, mask, normalRadius, minNeighbors); } -void cv::Mesh3D::computeNormals(const vector& subset, float normalRadius, int minNeighbors) +void cv::Mesh3D::computeNormals(const std::vector& subset, float normalRadius, int minNeighbors) { buildOctree(); - vector mask(vtx.size(), 0); + std::vector mask(vtx.size(), 0); for(size_t i = 0; i < subset.size(); ++i) mask[subset[i]] = 1; ::computeNormals(octree, vtx, normals, mask, normalRadius, minNeighbors); } -void cv::Mesh3D::writeAsVrml(const String& file, const vector& _colors) const +void cv::Mesh3D::writeAsVrml(const std::string& file, const std::vector& _colors) const { - ofstream ofs(file.c_str()); + std::ofstream ofs(file.c_str()); - ofs << "#VRML V2.0 utf8" << endl; - ofs << "Shape" << std::endl << "{" << endl; - ofs << "geometry PointSet" << endl << "{" << endl; - ofs << "coord Coordinate" << endl << "{" << endl; - ofs << "point[" << endl; + ofs << "#VRML V2.0 utf8" << std::endl; + ofs << "Shape" << std::endl << "{" << std::endl; + ofs << "geometry PointSet" << std::endl << "{" << std::endl; + ofs << "coord Coordinate" << std::endl << "{" << std::endl; + ofs << "point[" << std::endl; for(size_t i = 0; i < vtx.size(); ++i) - ofs << vtx[i].x << " " << vtx[i].y << " " << vtx[i].z << endl; + ofs << vtx[i].x << " " << vtx[i].y << " " << vtx[i].z << std::endl; - ofs << "]" << endl; //point[ - ofs << "}" << endl; //Coordinate{ + ofs << "]" << std::endl; //point[ + ofs << "}" << std::endl; //Coordinate{ if (vtx.size() == _colors.size()) { - ofs << "color Color" << endl << "{" << endl; - ofs << "color[" << endl; + ofs << "color Color" << std::endl << "{" << std::endl; + ofs << "color[" << std::endl; for(size_t i = 0; i < _colors.size(); ++i) - ofs << (float)_colors[i][2] << " " << (float)_colors[i][1] << " " << (float)_colors[i][0] << endl; + ofs << (float)_colors[i][2] << " " << (float)_colors[i][1] << " " << (float)_colors[i][0] << std::endl; - ofs << "]" << endl; //color[ - ofs << "}" << endl; //color Color{ + ofs << "]" << std::endl; //color[ + ofs << "}" << std::endl; //color Color{ } - ofs << "}" << endl; //PointSet{ - ofs << "}" << endl; //Shape{ + ofs << "}" << std::endl; //PointSet{ + ofs << "}" << std::endl; //Shape{ } @@ -624,7 +623,7 @@ bool cv::SpinImageModel::spinCorrelation(const Mat& spin1, const Mat& spin2, flo if (Nsum11 == sum1sum1 || Nsum22 == sum2sum2) return false; - double corr = (Nsum12 - sum1 * sum2) / sqrt( (Nsum11 - sum1sum1) * (Nsum22 - sum2sum2) ); + double corr = (Nsum12 - sum1 * sum2) / std::sqrt( (Nsum11 - sum1sum1) * (Nsum22 - sum2sum2) ); double atanh = Math::atanh(corr); result = (float)( atanh * atanh - lambda * ( 1.0 / (N - 3) ) ); return true; @@ -636,13 +635,13 @@ inline Point2f cv::SpinImageModel::calcSpinMapCoo(const Point3f& p, const Point3 float normalNorm = (float)norm(n); float beta = PmV.dot(n) / normalNorm; float pmcNorm = (float)norm(PmV); - float alpha = sqrt( pmcNorm * pmcNorm - beta * beta); + float alpha = std::sqrt( pmcNorm * pmcNorm - beta * beta); return Point2f(alpha, beta);*/ float pmv_x = p.x - v.x, pmv_y = p.y - v.y, pmv_z = p.z - v.z; - float beta = (pmv_x * n.x + pmv_y + n.y + pmv_z * n.z) / sqrt(n.x * n.x + n.y * n.y + n.z * n.z); - float alpha = sqrt( pmv_x * pmv_x + pmv_y * pmv_y + pmv_z * pmv_z - beta * beta); + float beta = (pmv_x * n.x + pmv_y + n.y + pmv_z * n.z) / std::sqrt(n.x * n.x + n.y * n.y + n.z * n.z); + float alpha = std::sqrt( pmv_x * pmv_x + pmv_y * pmv_y + pmv_z * pmv_z - beta * beta); return Point2f(alpha, beta); } @@ -664,7 +663,7 @@ inline float cv::SpinImageModel::geometricConsistency(const Point3f& pointScene1 double gc12 = 2 * norm(Sm1_to_m2 - Ss1_to_s2) / (n_Sm1_to_m2 + n_Ss1_to_s2 ) ; - return (float)max(gc12, gc21); + return (float)std::max(gc12, gc21); } inline float cv::SpinImageModel::groupingCreteria(const Point3f& pointScene1, const Point3f& normalScene1, @@ -682,15 +681,15 @@ inline float cv::SpinImageModel::groupingCreteria(const Point3f& pointScene1, co double n_Ss2_to_s1 = norm(Ss2_to_s1 = calcSpinMapCoo(pointScene2, pointScene1, normalScene1)); double gc21 = 2 * norm(Sm2_to_m1 - Ss2_to_s1) / (n_Sm2_to_m1 + n_Ss2_to_s1 ); - double wgc21 = gc21 / (1 - exp( -(n_Sm2_to_m1 + n_Ss2_to_s1) * gamma05_inv ) ); + double wgc21 = gc21 / (1 - std::exp( -(n_Sm2_to_m1 + n_Ss2_to_s1) * gamma05_inv ) ); double n_Sm1_to_m2 = norm(Sm1_to_m2 = calcSpinMapCoo(pointModel1, pointModel2, normalModel2)); double n_Ss1_to_s2 = norm(Ss1_to_s2 = calcSpinMapCoo(pointScene1, pointScene2, normalScene2)); double gc12 = 2 * norm(Sm1_to_m2 - Ss1_to_s2) / (n_Sm1_to_m2 + n_Ss1_to_s2 ); - double wgc12 = gc12 / (1 - exp( -(n_Sm1_to_m2 + n_Ss1_to_s2) * gamma05_inv ) ); + double wgc12 = gc12 / (1 - std::exp( -(n_Sm1_to_m2 + n_Ss1_to_s2) * gamma05_inv ) ); - return (float)max(wgc12, wgc21); + return (float)std::max(wgc12, wgc21); } @@ -703,7 +702,7 @@ cv::SpinImageModel::SpinImageModel(const Mesh3D& _mesh) : mesh(_mesh) , out(0) cv::SpinImageModel::SpinImageModel() : out(0) { defaultParams(); } cv::SpinImageModel::~SpinImageModel() {} -void cv::SpinImageModel::setLogger(ostream* log) { out = log; } +void cv::SpinImageModel::setLogger(std::ostream* log) { out = log; } void cv::SpinImageModel::defaultParams() { @@ -723,14 +722,14 @@ void cv::SpinImageModel::defaultParams() Mat cv::SpinImageModel::packRandomScaledSpins(bool separateScale, size_t xCount, size_t yCount) const { int spinNum = (int)getSpinCount(); - int num = min(spinNum, (int)(xCount * yCount)); + int num = std::min(spinNum, (int)(xCount * yCount)); if (num == 0) return Mat(); RNG& rng = theRNG(); - vector spins; + std::vector spins; for(int i = 0; i < num; ++i) spins.push_back(getSpinImage( rng.next() % spinNum ).reshape(1, imageWidth)); @@ -750,7 +749,7 @@ Mat cv::SpinImageModel::packRandomScaledSpins(bool separateScale, size_t xCount, { double m; minMaxLoc(spins[i], 0, &m); - totalMax = max(m, totalMax); + totalMax = std::max(m, totalMax); } for(int i = 0; i < num; ++i) @@ -787,7 +786,7 @@ Mat cv::SpinImageModel::packRandomScaledSpins(bool separateScale, size_t xCount, void cv::SpinImageModel::selectRandomSubset(float ratio) { - ratio = min(max(ratio, 0.f), 1.f); + ratio = std::min(std::max(ratio, 0.f), 1.f); size_t vtxSize = mesh.vtx.size(); size_t setSize = static_cast(vtxSize * ratio); @@ -799,14 +798,14 @@ void cv::SpinImageModel::selectRandomSubset(float ratio) else if (setSize == vtxSize) { subset.resize(vtxSize); - iota(subset.begin(), subset.end(), 0); + _iota(subset.begin(), subset.end(), 0); } else { RNG& rnd = theRNG(); - vector left(vtxSize); - iota(left.begin(), left.end(), (size_t)0); + std::vector left(vtxSize); + _iota(left.begin(), left.end(), (size_t)0); subset.resize(setSize); for(size_t i = 0; i < setSize; ++i) @@ -817,20 +816,20 @@ void cv::SpinImageModel::selectRandomSubset(float ratio) left[pos] = left.back(); left.resize(left.size() - 1); } - sort(subset, less()); + sort(subset, std::less()); } } -void cv::SpinImageModel::setSubset(const vector& ss) +void cv::SpinImageModel::setSubset(const std::vector& ss) { subset = ss; } -void cv::SpinImageModel::repackSpinImages(const vector& mask, Mat& _spinImages, bool reAlloc) const +void cv::SpinImageModel::repackSpinImages(const std::vector& mask, Mat& _spinImages, bool reAlloc) const { if (reAlloc) { - size_t spinCount = mask.size() - count(mask.begin(), mask.end(), (uchar)0); + size_t spinCount = mask.size() - std::count(mask.begin(), mask.end(), (uchar)0); Mat newImgs((int)spinCount, _spinImages.cols, _spinImages.type()); int pos = 0; @@ -846,7 +845,7 @@ void cv::SpinImageModel::repackSpinImages(const vector& mask, Mat& _spinI { int last = (int)mask.size(); - int dest = (int)(find(mask.begin(), mask.end(), (uchar)0) - mask.begin()); + int dest = (int)(std::find(mask.begin(), mask.end(), (uchar)0) - mask.begin()); if (dest == last) return; @@ -879,21 +878,21 @@ void cv::SpinImageModel::compute() { mesh.computeNormals(normalRadius, minNeighbors); subset.resize(mesh.vtx.size()); - iota(subset.begin(), subset.end(), 0); + _iota(subset.begin(), subset.end(), 0); } else mesh.computeNormals(subset, normalRadius, minNeighbors); - vector mask(mesh.vtx.size(), 0); + std::vector mask(mesh.vtx.size(), 0); for(size_t i = 0; i < subset.size(); ++i) if (mesh.normals[subset[i]] == Mesh3D::allzero) subset[i] = -1; else mask[subset[i]] = 1; - subset.resize( remove(subset.begin(), subset.end(), -1) - subset.begin() ); + subset.resize( std::remove(subset.begin(), subset.end(), -1) - subset.begin() ); - vector vtx; - vector normals; + std::vector vtx; + std::vector normals; for(size_t i = 0; i < mask.size(); ++i) if(mask[i]) { @@ -901,7 +900,7 @@ void cv::SpinImageModel::compute() normals.push_back(mesh.normals[i]); } - vector spinMask(vtx.size(), 1); + std::vector spinMask(vtx.size(), 1); computeSpinImages( mesh.octree, vtx, normals, spinMask, spinImages, imageWidth, binSize); repackSpinImages(spinMask, spinImages); @@ -909,19 +908,19 @@ void cv::SpinImageModel::compute() for(size_t i = 0; i < mask.size(); ++i) if(mask[i]) if (spinMask[mask_pos++] == 0) - subset.resize( remove(subset.begin(), subset.end(), (int)i) - subset.begin() ); + subset.resize( std::remove(subset.begin(), subset.end(), (int)i) - subset.begin() ); } -void cv::SpinImageModel::matchSpinToModel(const Mat& spin, vector& indeces, vector& corrCoeffs, bool useExtremeOutliers) const +void cv::SpinImageModel::matchSpinToModel(const Mat& spin, std::vector& indeces, std::vector& corrCoeffs, bool useExtremeOutliers) const { const SpinImageModel& model = *this; indeces.clear(); corrCoeffs.clear(); - vector corrs(model.spinImages.rows); - vector masks(model.spinImages.rows); - vector cleanCorrs; + std::vector corrs(model.spinImages.rows); + std::vector masks(model.spinImages.rows); + std::vector cleanCorrs; cleanCorrs.reserve(model.spinImages.rows); for(int i = 0; i < model.spinImages.rows; ++i) @@ -936,7 +935,7 @@ void cv::SpinImageModel::matchSpinToModel(const Mat& spin, vector& indeces, if(total < 5) return; - sort(cleanCorrs, less()); + sort(cleanCorrs, std::less()); float lower_fourth = cleanCorrs[(1 * total) / 4 - 1]; float upper_fourth = cleanCorrs[(3 * total) / 4 - 0]; @@ -971,7 +970,7 @@ struct Match operator float() const { return measure; } }; -typedef set group_t; +typedef std::set group_t; typedef group_t::iterator iter; typedef group_t::const_iterator citer; @@ -986,10 +985,10 @@ struct WgcHelper float Wgc(const size_t corespInd, const group_t& group) const { const float* wgcLine = mat.ptr((int)corespInd); - float maximum = numeric_limits::min(); + float maximum = std::numeric_limits::min(); for(citer pos = group.begin(); pos != group.end(); ++pos) - maximum = max(wgcLine[*pos], maximum); + maximum = std::max(wgcLine[*pos], maximum); return maximum; } @@ -999,7 +998,7 @@ private: } - void cv::SpinImageModel::match(const SpinImageModel& scene, vector< vector >& result) + void cv::SpinImageModel::match(const SpinImageModel& scene, std::vector< std::vector >& result) { if (mesh.vtx.empty()) throw Mesh3D::EmptyMeshException(); @@ -1007,8 +1006,8 @@ private: result.clear(); SpinImageModel& model = *this; - const float infinity = numeric_limits::infinity(); - const float float_max = numeric_limits::max(); + const float infinity = std::numeric_limits::infinity(); + const float float_max = std::numeric_limits::max(); /* estimate gamma */ if (model.gamma == 0.f) @@ -1021,40 +1020,40 @@ private: /* estimate lambda */ if (model.lambda == 0.f) { - vector nonzero(model.spinImages.rows); + std::vector nonzero(model.spinImages.rows); for(int i = 0; i < model.spinImages.rows; ++i) nonzero[i] = countNonZero(model.spinImages.row(i)); - sort(nonzero, less()); + sort(nonzero, std::less()); model.lambda = static_cast( nonzero[ nonzero.size()/2 ] ) / 2; } TickMeter corr_timer; corr_timer.start(); - vector allMatches; + std::vector allMatches; for(int i = 0; i < scene.spinImages.rows; ++i) { - vector indeces; - vector coeffs; + std::vector indeces; + std::vector coeffs; matchSpinToModel(scene.spinImages.row(i), indeces, coeffs); for(size_t t = 0; t < indeces.size(); ++t) allMatches.push_back(Match(i, indeces[t], coeffs[t])); - if (out) if (i % 100 == 0) *out << "Comparing scene spinimage " << i << " of " << scene.spinImages.rows << endl; + if (out) if (i % 100 == 0) *out << "Comparing scene spinimage " << i << " of " << scene.spinImages.rows << std::endl; } corr_timer.stop(); - if (out) *out << "Spin correlation time = " << corr_timer << endl; - if (out) *out << "Matches number = " << allMatches.size() << endl; + if (out) *out << "Spin correlation time = " << corr_timer << std::endl; + if (out) *out << "Matches number = " << allMatches.size() << std::endl; if(allMatches.empty()) return; /* filtering by similarity measure */ const float fraction = 0.5f; - float maxMeasure = max_element(allMatches.begin(), allMatches.end(), less())->measure; + float maxMeasure = max_element(allMatches.begin(), allMatches.end(), std::less())->measure; allMatches.erase( - remove_if(allMatches.begin(), allMatches.end(), bind2nd(less(), maxMeasure * fraction)), + remove_if(allMatches.begin(), allMatches.end(), bind2nd(std::less(), maxMeasure * fraction)), allMatches.end()); - if (out) *out << "Matches number [filtered by similarity measure] = " << allMatches.size() << endl; + if (out) *out << "Matches number [filtered by similarity measure] = " << allMatches.size() << std::endl; int matchesSize = (int)allMatches.size(); if(matchesSize == 0) @@ -1101,16 +1100,16 @@ private: allMatches[i].measure = infinity; } allMatches.erase( - remove_if(allMatches.begin(), allMatches.end(), bind2nd(equal_to(), infinity)), + std::remove_if(allMatches.begin(), allMatches.end(), std::bind2nd(std::equal_to(), infinity)), allMatches.end()); - if (out) *out << "Matches number [filtered by geometric consistency] = " << allMatches.size() << endl; + if (out) *out << "Matches number [filtered by geometric consistency] = " << allMatches.size() << std::endl; matchesSize = (int)allMatches.size(); if(matchesSize == 0) return; - if (out) *out << "grouping ..." << endl; + if (out) *out << "grouping ..." << std::endl; Mat groupingMat((int)matchesSize, (int)matchesSize, CV_32F); groupingMat = Scalar(0); @@ -1153,13 +1152,13 @@ private: for(int i = 0; i < matchesSize; ++i) allMatchesInds.insert(i); - vector buf(matchesSize); + std::vector buf(matchesSize); float *buf_beg = &buf[0]; - vector groups; + std::vector groups; for(int g = 0; g < matchesSize; ++g) { - if (out) if (g % 100 == 0) *out << "G = " << g << endl; + if (out) if (g % 100 == 0) *out << "G = " << g << std::endl; group_t left = allMatchesInds; group_t group; @@ -1174,7 +1173,7 @@ private: break; std::transform(left.begin(), left.end(), buf_beg, WgcHelper(group, groupingMat)); - size_t minInd = min_element(buf_beg, buf_beg + left_size) - buf_beg; + size_t minInd = std::min_element(buf_beg, buf_beg + left_size) - buf_beg; if (buf[minInd] < model.T_GroupingCorespondances) /* can add corespondance to group */ { @@ -1197,7 +1196,7 @@ private: { const group_t& group = groups[i]; - vector< Vec2i > outgrp; + std::vector< Vec2i > outgrp; for(citer pos = group.begin(); pos != group.end(); ++pos) { const Match& m = allMatches[*pos]; diff --git a/modules/contrib/src/stereovar.cpp b/modules/contrib/src/stereovar.cpp index 1b542bbf5..a825ad8d8 100644 --- a/modules/contrib/src/stereovar.cpp +++ b/modules/contrib/src/stereovar.cpp @@ -144,11 +144,11 @@ void StereoVar::VariationalSolver(Mat &I1, Mat &I2, Mat &I2x, Mat &u, int level) if (flags & USE_SMART_ID) { - double scale = pow(pyrScale, (double) level) * (1 + pyrScale); + double scale = std::pow(pyrScale, (double) level) * (1 + pyrScale); N = (int) (N / scale); } - double scale = pow(pyrScale, (double) level); + double scale = std::pow(pyrScale, (double) level); Fi /= (float) scale; l *= (float) scale; @@ -284,7 +284,7 @@ void StereoVar::VCycle_MyFAS(Mat &I1, Mat &I2, Mat &I2x, Mat &_u, int level) void StereoVar::FMG(Mat &I1, Mat &I2, Mat &I2x, Mat &u, int level) { - double scale = pow(pyrScale, (double) level); + double scale = std::pow(pyrScale, (double) level); CvSize frmSize = cvSize((int) (u.cols * scale + 0.5), (int) (u.rows * scale + 0.5)); Mat I1_h, I2_h, I2x_h, u_h; @@ -336,7 +336,7 @@ void StereoVar::autoParams() if (maxD) { levels = 0; - while ( pow(pyrScale, levels) * maxD > 1.5) levels ++; + while ( std::pow(pyrScale, levels) * maxD > 1.5) levels ++; levels++; } diff --git a/modules/contrib/src/templatebuffer.hpp b/modules/contrib/src/templatebuffer.hpp index c49e49358..21414b4da 100644 --- a/modules/contrib/src/templatebuffer.hpp +++ b/modules/contrib/src/templatebuffer.hpp @@ -322,7 +322,7 @@ namespace cv double diff=(*(bufferPTR++)-meanValue); standardDeviation+=diff*diff; } - return sqrt(standardDeviation/this->size()); + return std::sqrt(standardDeviation/this->size()); }; /** @@ -513,7 +513,7 @@ namespace cv stdValue+=inputMinusMean*inputMinusMean; } - stdValue=sqrt(stdValue/((type)_NBpixels)); + stdValue=std::sqrt(stdValue/((type)_NBpixels)); // adjust luminance in regard of mean and std value; inputOutputBufferPTR=inputOutputBuffer; for (size_t index=0;index<_NBpixels;++index, ++inputOutputBufferPTR) diff --git a/modules/core/doc/xml_yaml_persistence.rst b/modules/core/doc/xml_yaml_persistence.rst index c7d55d01f..102dafc70 100644 --- a/modules/core/doc/xml_yaml_persistence.rst +++ b/modules/core/doc/xml_yaml_persistence.rst @@ -548,11 +548,11 @@ Returns the node content as double. :returns: The node content as double. -FileNode::operator string -------------------------- +FileNode::operator std::string +------------------------------ Returns the node content as text string. -.. ocv:function:: FileNode::operator string() const +.. ocv:function:: FileNode::operator std::string() const :returns: The node content as a text string. diff --git a/modules/core/include/opencv2/core/core.hpp b/modules/core/include/opencv2/core/core.hpp index aeba6648d..3393e3db6 100644 --- a/modules/core/include/opencv2/core/core.hpp +++ b/modules/core/include/opencv2/core/core.hpp @@ -74,18 +74,12 @@ namespace cv { #undef max #undef Complex -using std::vector; -using std::string; -using std::ptrdiff_t; - template class CV_EXPORTS Size_; template class CV_EXPORTS Point_; template class CV_EXPORTS Rect_; template class CV_EXPORTS Vec; template class CV_EXPORTS Matx; -typedef std::string String; - class Mat; class SparseMat; typedef Mat MatND; @@ -111,8 +105,8 @@ template class CV_EXPORTS MatCommaInitializer_; template class CV_EXPORTS AutoBuffer; -CV_EXPORTS string format( const char* fmt, ... ); -CV_EXPORTS string tempfile( const char* suffix CV_DEFAULT(0)); +CV_EXPORTS std::string format( const char* fmt, ... ); +CV_EXPORTS std::string tempfile( const char* suffix CV_DEFAULT(0)); // matrix decomposition types enum { DECOMP_LU=0, DECOMP_SVD=1, DECOMP_EIG=2, DECOMP_CHOLESKY=3, DECOMP_QR=4, DECOMP_NORMAL=16 }; @@ -138,7 +132,7 @@ public: Full constructor. Normally the constuctor is not called explicitly. Instead, the macros CV_Error(), CV_Error_() and CV_Assert() are used. */ - Exception(int _code, const string& _err, const string& _func, const string& _file, int _line); + Exception(int _code, const std::string& _err, const std::string& _func, const std::string& _file, int _line); virtual ~Exception() throw(); /*! @@ -147,12 +141,12 @@ public: virtual const char *what() const throw(); void formatMessage(); - string msg; ///< the formatted error message + std::string msg; ///< the formatted error message int code; ///< error code @see CVStatus - string err; ///< error description - string func; ///< function name. Available only when the compiler supports __func__ macro - string file; ///< source file name where the error has occured + std::string err; ///< error description + std::string func; ///< function name. Available only when the compiler supports __func__ macro + std::string file; ///< source file name where the error has occured int line; ///< line number in the source file where the error has occured }; @@ -216,7 +210,7 @@ CV_EXPORTS void setNumThreads(int nthreads); CV_EXPORTS int getNumThreads(); CV_EXPORTS int getThreadNum(); -CV_EXPORTS_W const string& getBuildInformation(); +CV_EXPORTS_W const std::string& getBuildInformation(); //! Returns the number of ticks. @@ -1317,10 +1311,10 @@ public: _InputArray(const Mat& m); _InputArray(const MatExpr& expr); template _InputArray(const _Tp* vec, int n); - template _InputArray(const vector<_Tp>& vec); - template _InputArray(const vector >& vec); - _InputArray(const vector& vec); - template _InputArray(const vector >& vec); + template _InputArray(const std::vector<_Tp>& vec); + template _InputArray(const std::vector >& vec); + _InputArray(const std::vector& vec); + template _InputArray(const std::vector >& vec); template _InputArray(const Mat_<_Tp>& m); template _InputArray(const Matx<_Tp, m, n>& matx); _InputArray(const Scalar& s); @@ -1330,7 +1324,7 @@ public: _InputArray(const gpu::GpuMat& d_mat); virtual Mat getMat(int i=-1) const; - virtual void getMatVector(vector& mv) const; + virtual void getMatVector(std::vector& mv) const; virtual GlBuffer getGlBuffer() const; virtual GlTexture2D getGlTexture2D() const; virtual gpu::GpuMat getGpuMat() const; @@ -1375,10 +1369,10 @@ public: _OutputArray(); _OutputArray(Mat& m); - template _OutputArray(vector<_Tp>& vec); - template _OutputArray(vector >& vec); - _OutputArray(vector& vec); - template _OutputArray(vector >& vec); + template _OutputArray(std::vector<_Tp>& vec); + template _OutputArray(std::vector >& vec); + _OutputArray(std::vector& vec); + template _OutputArray(std::vector >& vec); template _OutputArray(Mat_<_Tp>& m); template _OutputArray(Matx<_Tp, m, n>& matx); template _OutputArray(_Tp* vec, int n); @@ -1387,10 +1381,10 @@ public: _OutputArray(GlTexture2D& tex); _OutputArray(const Mat& m); - template _OutputArray(const vector<_Tp>& vec); - template _OutputArray(const vector >& vec); - _OutputArray(const vector& vec); - template _OutputArray(const vector >& vec); + template _OutputArray(const std::vector<_Tp>& vec); + template _OutputArray(const std::vector >& vec); + _OutputArray(const std::vector& vec); + template _OutputArray(const std::vector >& vec); template _OutputArray(const Mat_<_Tp>& m); template _OutputArray(const Matx<_Tp, m, n>& matx); template _OutputArray(const _Tp* vec, int n); @@ -1690,7 +1684,7 @@ public: //! converts old-style IplImage to the new matrix; the data is not copied by default Mat(const IplImage* img, bool copyData=false); //! builds matrix from std::vector with or without copying the data - template explicit Mat(const vector<_Tp>& vec, bool copyData=false); + template explicit Mat(const std::vector<_Tp>& vec, bool copyData=false); //! builds matrix from cv::Vec; the data is copied by default template explicit Mat(const Vec<_Tp, n>& vec, bool copyData=true); //! builds matrix from cv::Matx; the data is copied by default @@ -1821,7 +1815,7 @@ public: //! converts header to IplImage; no data is copied operator IplImage() const; - template operator vector<_Tp>() const; + template operator std::vector<_Tp>() const; template operator Vec<_Tp, n>() const; template operator Matx<_Tp, m, n>() const; @@ -2155,10 +2149,10 @@ CV_EXPORTS_W void split(InputArray m, OutputArrayOfArrays mv); //! copies selected channels from the input arrays to the selected channels of the output arrays CV_EXPORTS void mixChannels(const Mat* src, size_t nsrcs, Mat* dst, size_t ndsts, const int* fromTo, size_t npairs); -CV_EXPORTS void mixChannels(const vector& src, vector& dst, +CV_EXPORTS void mixChannels(const std::vector& src, std::vector& dst, const int* fromTo, size_t npairs); CV_EXPORTS_W void mixChannels(InputArrayOfArrays src, InputArrayOfArrays dst, - const vector& fromTo); + const std::vector& fromTo); //! extracts a single channel from src (coi is 0-based index) CV_EXPORTS_W void extractChannel(InputArray src, OutputArray dst, int coi); @@ -2620,7 +2614,7 @@ public: //! converts elliptic arc to a polygonal curve CV_EXPORTS_W void ellipse2Poly( Point center, Size axes, int angle, int arcStart, int arcEnd, int delta, - CV_OUT vector& pts ); + CV_OUT std::vector& pts ); enum { @@ -2636,13 +2630,13 @@ enum }; //! renders text string in the image -CV_EXPORTS_W void putText( Mat& img, const string& text, Point org, +CV_EXPORTS_W void putText( Mat& img, const std::string& text, Point org, int fontFace, double fontScale, Scalar color, int thickness=1, int lineType=8, bool bottomLeftOrigin=false ); //! returns bounding box of the text string -CV_EXPORTS_W Size getTextSize(const string& text, int fontFace, +CV_EXPORTS_W Size getTextSize(const std::string& text, int fontFace, double fontScale, int thickness, CV_OUT int* baseLine); @@ -2732,7 +2726,7 @@ public: //! from a matrix expression explicit Mat_(const MatExpr& e); //! makes a matrix out of Vec, std::vector, Point_ or Point3_. The matrix will have a single column - explicit Mat_(const vector<_Tp>& vec, bool copyData=false); + explicit Mat_(const std::vector<_Tp>& vec, bool copyData=false); template explicit Mat_(const Vec::channel_type, n>& vec, bool copyData=true); template explicit Mat_(const Matx::channel_type, m, n>& mtx, bool copyData=true); explicit Mat_(const Point_::channel_type>& pt, bool copyData=true); @@ -2825,7 +2819,7 @@ public: const _Tp& operator ()(Point pt) const; //! conversion to vector. - operator vector<_Tp>() const; + operator std::vector<_Tp>() const; //! conversion to Vec template operator Vec::channel_type, n>() const; //! conversion to Matx @@ -3339,8 +3333,8 @@ public: size_t nodeSize; size_t nodeCount; size_t freeList; - vector pool; - vector hashtab; + std::vector pool; + std::vector hashtab; int size[CV_MAX_DIM]; }; @@ -3878,9 +3872,9 @@ public: //! returns the search space dimensionality CV_WRAP int dims() const; - vector nodes; //!< all the tree nodes + std::vector nodes; //!< all the tree nodes CV_PROP Mat points; //!< all the points. It can be a reordered copy of the input vector set or the original vector set. - CV_PROP vector labels; //!< the parallel array of labels. + CV_PROP std::vector labels; //!< the parallel array of labels. CV_PROP int maxDepth; //!< maximum depth of the search tree. Do not modify it CV_PROP_RW int normType; //!< type of the distance (cv::NORM_L1 or cv::NORM_L2) used for search. Initially set to cv::NORM_L2, but you can modify it }; @@ -3954,7 +3948,7 @@ class CV_EXPORTS FileNode; FileStorage fs("test.yml", FileStorage::READ); int test_int = (int)fs["test_int"]; double test_real = (double)fs["test_real"]; - string test_string = (string)fs["test_string"]; + std::string test_string = (std::string)fs["test_string"]; Mat M; fs["test_mat"] >> M; @@ -3965,7 +3959,7 @@ class CV_EXPORTS FileNode; int tl1 = (int)tl[1]; double tl2 = (double)tl[2]; int tl3 = (int)tl[3]; - string tl4 = (string)tl[4]; + std::string tl4 = (std::string)tl[4]; CV_Assert(tl[5].type() == FileNode::MAP && tl[5].size() == 3); int month = (int)tl[5]["month"]; @@ -4011,27 +4005,27 @@ public: //! the default constructor CV_WRAP FileStorage(); //! the full constructor that opens file storage for reading or writing - CV_WRAP FileStorage(const string& source, int flags, const string& encoding=string()); + CV_WRAP FileStorage(const std::string& source, int flags, const std::string& encoding=std::string()); //! the constructor that takes pointer to the C FileStorage structure FileStorage(CvFileStorage* fs); //! the destructor. calls release() virtual ~FileStorage(); //! opens file storage for reading or writing. The previous storage is closed with release() - CV_WRAP virtual bool open(const string& filename, int flags, const string& encoding=string()); + CV_WRAP virtual bool open(const std::string& filename, int flags, const std::string& encoding=std::string()); //! returns true if the object is associated with currently opened file. CV_WRAP virtual bool isOpened() const; //! closes the file and releases all the memory buffers CV_WRAP virtual void release(); //! closes the file, releases all the memory buffers and returns the text string - CV_WRAP virtual string releaseAndGetString(); + CV_WRAP virtual std::string releaseAndGetString(); //! returns the first element of the top-level mapping CV_WRAP FileNode getFirstTopLevelNode() const; //! returns the top-level mapping. YAML supports multiple streams CV_WRAP FileNode root(int streamidx=0) const; //! returns the specified element of the top-level mapping - FileNode operator[](const string& nodename) const; + FileNode operator[](const std::string& nodename) const; //! returns the specified element of the top-level mapping CV_WRAP FileNode operator[](const char* nodename) const; @@ -4040,16 +4034,16 @@ public: //! returns pointer to the underlying C FileStorage structure const CvFileStorage* operator *() const { return fs; } //! writes one or more numbers of the specified format to the currently written structure - void writeRaw( const string& fmt, const uchar* vec, size_t len ); + void writeRaw( const std::string& fmt, const uchar* vec, size_t len ); //! writes the registered C structure (CvMat, CvMatND, CvSeq). See cvWrite() - void writeObj( const string& name, const void* obj ); + void writeObj( const std::string& name, const void* obj ); //! returns the normalized object name for the specified file name - static string getDefaultObjectName(const string& filename); + static std::string getDefaultObjectName(const std::string& filename); Ptr fs; //!< the underlying C FileStorage structure - string elname; //!< the currently written element - vector structs; //!< the stack of written structures + std::string elname; //!< the currently written element + std::vector structs; //!< the stack of written structures int state; //!< the writer state }; @@ -4093,7 +4087,7 @@ public: //! the copy constructor FileNode(const FileNode& node); //! returns element of a mapping node - FileNode operator[](const string& nodename) const; + FileNode operator[](const std::string& nodename) const; //! returns element of a mapping node CV_WRAP FileNode operator[](const char* nodename) const; //! returns element of a sequence node @@ -4118,7 +4112,7 @@ public: //! returns true if the node has a name CV_WRAP bool isNamed() const; //! returns the node name or an empty string if the node is nameless - CV_WRAP string name() const; + CV_WRAP std::string name() const; //! returns the number of elements in the node, if it is a sequence or mapping, or 1 otherwise. CV_WRAP size_t size() const; //! returns the node content as an integer. If the node stores floating-point number, it is rounded. @@ -4128,7 +4122,7 @@ public: //! returns the node content as double operator double() const; //! returns the node content as text string - operator string() const; + operator std::string() const; //! returns pointer to the underlying file node CvFileNode* operator *(); @@ -4141,7 +4135,7 @@ public: FileNodeIterator end() const; //! reads node elements to the buffer with the specified format - void readRaw( const string& fmt, uchar* vec, size_t len ) const; + void readRaw( const std::string& fmt, uchar* vec, size_t len ) const; //! reads the registered object and returns pointer to it void* readObj() const; @@ -4184,7 +4178,7 @@ public: FileNodeIterator& operator -= (int ofs); //! reads the next maxCount elements (or less, if the sequence/mapping last element occurs earlier) to the buffer with the specified format - FileNodeIterator& readRaw( const string& fmt, uchar* vec, + FileNodeIterator& readRaw( const std::string& fmt, uchar* vec, size_t maxCount=(size_t)INT_MAX ); const CvFileStorage* fs; @@ -4281,9 +4275,9 @@ public: void pop_back(_Tp* elems, size_t count); //! copies the whole sequence or the sequence slice to the specified vector - void copyTo(vector<_Tp>& vec, const Range& range=Range::all()) const; + void copyTo(std::vector<_Tp>& vec, const Range& range=Range::all()) const; //! returns the vector containing all the sequence elements - operator vector<_Tp>() const; + operator std::vector<_Tp>() const; CvSeq* seq; }; @@ -4340,59 +4334,59 @@ class CV_EXPORTS_W Algorithm public: Algorithm(); virtual ~Algorithm(); - string name() const; + std::string name() const; - template typename ParamType<_Tp>::member_type get(const string& name) const; + template typename ParamType<_Tp>::member_type get(const std::string& name) const; template typename ParamType<_Tp>::member_type get(const char* name) const; - CV_WRAP int getInt(const string& name) const; - CV_WRAP double getDouble(const string& name) const; - CV_WRAP bool getBool(const string& name) const; - CV_WRAP string getString(const string& name) const; - CV_WRAP Mat getMat(const string& name) const; - CV_WRAP vector getMatVector(const string& name) const; - CV_WRAP Ptr getAlgorithm(const string& name) const; + CV_WRAP int getInt(const std::string& name) const; + CV_WRAP double getDouble(const std::string& name) const; + CV_WRAP bool getBool(const std::string& name) const; + CV_WRAP std::string getString(const std::string& name) const; + CV_WRAP Mat getMat(const std::string& name) const; + CV_WRAP std::vector getMatVector(const std::string& name) const; + CV_WRAP Ptr getAlgorithm(const std::string& name) const; - void set(const string& name, int value); - void set(const string& name, double value); - void set(const string& name, bool value); - void set(const string& name, const string& value); - void set(const string& name, const Mat& value); - void set(const string& name, const vector& value); - void set(const string& name, const Ptr& value); - template void set(const string& name, const Ptr<_Tp>& value); + void set(const std::string& name, int value); + void set(const std::string& name, double value); + void set(const std::string& name, bool value); + void set(const std::string& name, const std::string& value); + void set(const std::string& name, const Mat& value); + void set(const std::string& name, const std::vector& value); + void set(const std::string& name, const Ptr& value); + template void set(const std::string& name, const Ptr<_Tp>& value); - CV_WRAP void setInt(const string& name, int value); - CV_WRAP void setDouble(const string& name, double value); - CV_WRAP void setBool(const string& name, bool value); - CV_WRAP void setString(const string& name, const string& value); - CV_WRAP void setMat(const string& name, const Mat& value); - CV_WRAP void setMatVector(const string& name, const vector& value); - CV_WRAP void setAlgorithm(const string& name, const Ptr& value); - template void setAlgorithm(const string& name, const Ptr<_Tp>& value); + CV_WRAP void setInt(const std::string& name, int value); + CV_WRAP void setDouble(const std::string& name, double value); + CV_WRAP void setBool(const std::string& name, bool value); + CV_WRAP void setString(const std::string& name, const std::string& value); + CV_WRAP void setMat(const std::string& name, const Mat& value); + CV_WRAP void setMatVector(const std::string& name, const std::vector& value); + CV_WRAP void setAlgorithm(const std::string& name, const Ptr& value); + template void setAlgorithm(const std::string& name, const Ptr<_Tp>& value); void set(const char* name, int value); void set(const char* name, double value); void set(const char* name, bool value); - void set(const char* name, const string& value); + void set(const char* name, const std::string& value); void set(const char* name, const Mat& value); - void set(const char* name, const vector& value); + void set(const char* name, const std::vector& value); void set(const char* name, const Ptr& value); template void set(const char* name, const Ptr<_Tp>& value); void setInt(const char* name, int value); void setDouble(const char* name, double value); void setBool(const char* name, bool value); - void setString(const char* name, const string& value); + void setString(const char* name, const std::string& value); void setMat(const char* name, const Mat& value); - void setMatVector(const char* name, const vector& value); + void setMatVector(const char* name, const std::vector& value); void setAlgorithm(const char* name, const Ptr& value); template void setAlgorithm(const char* name, const Ptr<_Tp>& value); - CV_WRAP string paramHelp(const string& name) const; + CV_WRAP std::string paramHelp(const std::string& name) const; int paramType(const char* name) const; - CV_WRAP int paramType(const string& name) const; - CV_WRAP void getParams(CV_OUT vector& names) const; + CV_WRAP int paramType(const std::string& name) const; + CV_WRAP void getParams(CV_OUT std::vector& names) const; virtual void write(FileStorage& fs) const; @@ -4402,9 +4396,9 @@ public: typedef int (Algorithm::*Getter)() const; typedef void (Algorithm::*Setter)(int); - CV_WRAP static void getList(CV_OUT vector& algorithms); - CV_WRAP static Ptr _create(const string& name); - template static Ptr<_Tp> create(const string& name); + CV_WRAP static void getList(CV_OUT std::vector& algorithms); + CV_WRAP static Ptr _create(const std::string& name); + template static Ptr<_Tp> create(const std::string& name); virtual AlgorithmInfo* info() const /* TODO: make it = 0;*/ { return 0; } }; @@ -4414,66 +4408,66 @@ class CV_EXPORTS AlgorithmInfo { public: friend class Algorithm; - AlgorithmInfo(const string& name, Algorithm::Constructor create); + AlgorithmInfo(const std::string& name, Algorithm::Constructor create); ~AlgorithmInfo(); void get(const Algorithm* algo, const char* name, int argType, void* value) const; void addParam_(Algorithm& algo, const char* name, int argType, void* value, bool readOnly, Algorithm::Getter getter, Algorithm::Setter setter, - const string& help=string()); - string paramHelp(const char* name) const; + const std::string& help=std::string()); + std::string paramHelp(const char* name) const; int paramType(const char* name) const; - void getParams(vector& names) const; + void getParams(std::vector& names) const; void write(const Algorithm* algo, FileStorage& fs) const; void read(Algorithm* algo, const FileNode& fn) const; - string name() const; + std::string name() const; void addParam(Algorithm& algo, const char* name, int& value, bool readOnly=false, int (Algorithm::*getter)()=0, void (Algorithm::*setter)(int)=0, - const string& help=string()); + const std::string& help=std::string()); void addParam(Algorithm& algo, const char* name, bool& value, bool readOnly=false, int (Algorithm::*getter)()=0, void (Algorithm::*setter)(int)=0, - const string& help=string()); + const std::string& help=std::string()); void addParam(Algorithm& algo, const char* name, double& value, bool readOnly=false, double (Algorithm::*getter)()=0, void (Algorithm::*setter)(double)=0, - const string& help=string()); + const std::string& help=std::string()); void addParam(Algorithm& algo, const char* name, - string& value, bool readOnly=false, - string (Algorithm::*getter)()=0, - void (Algorithm::*setter)(const string&)=0, - const string& help=string()); + std::string& value, bool readOnly=false, + std::string (Algorithm::*getter)()=0, + void (Algorithm::*setter)(const std::string&)=0, + const std::string& help=std::string()); void addParam(Algorithm& algo, const char* name, Mat& value, bool readOnly=false, Mat (Algorithm::*getter)()=0, void (Algorithm::*setter)(const Mat&)=0, - const string& help=string()); + const std::string& help=std::string()); void addParam(Algorithm& algo, const char* name, - vector& value, bool readOnly=false, - vector (Algorithm::*getter)()=0, - void (Algorithm::*setter)(const vector&)=0, - const string& help=string()); + std::vector& value, bool readOnly=false, + std::vector (Algorithm::*getter)()=0, + void (Algorithm::*setter)(const std::vector&)=0, + const std::string& help=std::string()); void addParam(Algorithm& algo, const char* name, Ptr& value, bool readOnly=false, Ptr (Algorithm::*getter)()=0, void (Algorithm::*setter)(const Ptr&)=0, - const string& help=string()); + const std::string& help=std::string()); template void addParam(Algorithm& algo, const char* name, Ptr<_Tp>& value, bool readOnly=false, Ptr<_Tp> (Algorithm::*getter)()=0, void (Algorithm::*setter)(const Ptr<_Tp>&)=0, - const string& help=string()); + const std::string& help=std::string()); template void addParam(Algorithm& algo, const char* name, Ptr<_Tp>& value, bool readOnly=false, Ptr<_Tp> (Algorithm::*getter)()=0, void (Algorithm::*setter)(const Ptr<_Tp>&)=0, - const string& help=string()); + const std::string& help=std::string()); protected: AlgorithmInfoData* data; void set(Algorithm* algo, const char* name, int argType, @@ -4489,13 +4483,13 @@ struct CV_EXPORTS Param Param(int _type, bool _readonly, int _offset, Algorithm::Getter _getter=0, Algorithm::Setter _setter=0, - const string& _help=string()); + const std::string& _help=std::string()); int type; int offset; bool readonly; Algorithm::Getter getter; Algorithm::Setter setter; - string help; + std::string help; }; template<> struct ParamType @@ -4522,10 +4516,10 @@ template<> struct ParamType enum { type = Param::REAL }; }; -template<> struct ParamType +template<> struct ParamType { - typedef const string& const_param_type; - typedef string member_type; + typedef const std::string& const_param_type; + typedef std::string member_type; enum { type = Param::STRING }; }; @@ -4538,10 +4532,10 @@ template<> struct ParamType enum { type = Param::MAT }; }; -template<> struct ParamType > +template<> struct ParamType > { - typedef const vector& const_param_type; - typedef vector member_type; + typedef const std::vector& const_param_type; + typedef std::vector member_type; enum { type = Param::MAT_VECTOR }; }; @@ -4584,14 +4578,14 @@ template<> struct ParamType class CV_EXPORTS CommandLineParser { public: - CommandLineParser(int argc, const char* const argv[], const string& keys); + CommandLineParser(int argc, const char* const argv[], const std::string& keys); CommandLineParser(const CommandLineParser& parser); CommandLineParser& operator = (const CommandLineParser& parser); - string getPathToApplication() const; + std::string getPathToApplication() const; template - T get(const string& name, bool space_delete = true) const + T get(const std::string& name, bool space_delete = true) const { T val = T(); getByName(name, space_delete, ParamType::type, (void*)&val); @@ -4606,17 +4600,17 @@ public: return val; } - bool has(const string& name) const; + bool has(const std::string& name) const; bool check() const; - void about(const string& message); + void about(const std::string& message); void printMessage() const; void printErrors() const; protected: - void getByName(const string& name, bool space_delete, int type, void* dst) const; + void getByName(const std::string& name, bool space_delete, int type, void* dst) const; void getByIndex(int index, bool space_delete, int type, void* dst) const; struct Impl; diff --git a/modules/core/include/opencv2/core/mat.hpp b/modules/core/include/opencv2/core/mat.hpp index 92301cf3b..8e7890568 100644 --- a/modules/core/include/opencv2/core/mat.hpp +++ b/modules/core/include/opencv2/core/mat.hpp @@ -171,7 +171,7 @@ inline Mat::Mat(Size _sz, int _type, void* _data, size_t _step) } -template inline Mat::Mat(const vector<_Tp>& vec, bool copyData) +template inline Mat::Mat(const std::vector<_Tp>& vec, bool copyData) : flags(MAGIC_VAL | DataType<_Tp>::type | CV_MAT_CONT_FLAG), dims(2), rows((int)vec.size()), cols(1), data(0), refcount(0), datastart(0), dataend(0), allocator(0), size(&rows) @@ -648,9 +648,9 @@ template inline MatIterator_<_Tp> Mat::end() return it; } -template inline Mat::operator vector<_Tp>() const +template inline Mat::operator std::vector<_Tp>() const { - vector<_Tp> v; + std::vector<_Tp> v; copyTo(v); return v; } @@ -873,7 +873,7 @@ template inline Mat_<_Tp>::Mat_(const Point3_ inline Mat_<_Tp>::Mat_(const MatCommaInitializer_<_Tp>& commaInitializer) : Mat(commaInitializer) {} -template inline Mat_<_Tp>::Mat_(const vector<_Tp>& vec, bool copyData) +template inline Mat_<_Tp>::Mat_(const std::vector<_Tp>& vec, bool copyData) : Mat(vec, copyData) {} template inline Mat_<_Tp>& Mat_<_Tp>::operator = (const Mat& m) @@ -1059,9 +1059,9 @@ template inline const _Tp& Mat_<_Tp>::operator ()(int i0, int i1, } -template inline Mat_<_Tp>::operator vector<_Tp>() const +template inline Mat_<_Tp>::operator std::vector<_Tp>() const { - vector<_Tp> v; + std::vector<_Tp> v; copyTo(v); return v; } @@ -1116,13 +1116,13 @@ process( const Mat_& m1, const Mat_& m2, Mat_& m3, Op op ) /////////////////////////////// Input/Output Arrays ///////////////////////////////// -template inline _InputArray::_InputArray(const vector<_Tp>& vec) +template inline _InputArray::_InputArray(const std::vector<_Tp>& vec) : flags(FIXED_TYPE + STD_VECTOR + DataType<_Tp>::type), obj((void*)&vec) {} -template inline _InputArray::_InputArray(const vector >& vec) +template inline _InputArray::_InputArray(const std::vector >& vec) : flags(FIXED_TYPE + STD_VECTOR_VECTOR + DataType<_Tp>::type), obj((void*)&vec) {} -template inline _InputArray::_InputArray(const vector >& vec) +template inline _InputArray::_InputArray(const std::vector >& vec) : flags(FIXED_TYPE + STD_VECTOR_MAT + DataType<_Tp>::type), obj((void*)&vec) {} template inline _InputArray::_InputArray(const Matx<_Tp, m, n>& mtx) @@ -1137,11 +1137,11 @@ inline _InputArray::_InputArray(const Scalar& s) template inline _InputArray::_InputArray(const Mat_<_Tp>& m) : flags(FIXED_TYPE + MAT + DataType<_Tp>::type), obj((void*)&m) {} -template inline _OutputArray::_OutputArray(vector<_Tp>& vec) +template inline _OutputArray::_OutputArray(std::vector<_Tp>& vec) : _InputArray(vec) {} -template inline _OutputArray::_OutputArray(vector >& vec) +template inline _OutputArray::_OutputArray(std::vector >& vec) : _InputArray(vec) {} -template inline _OutputArray::_OutputArray(vector >& vec) +template inline _OutputArray::_OutputArray(std::vector >& vec) : _InputArray(vec) {} template inline _OutputArray::_OutputArray(Mat_<_Tp>& m) : _InputArray(m) {} @@ -1150,11 +1150,11 @@ template inline _OutputArray::_OutputArray(Matx<_Tp, template inline _OutputArray::_OutputArray(_Tp* vec, int n) : _InputArray(vec, n) {} -template inline _OutputArray::_OutputArray(const vector<_Tp>& vec) +template inline _OutputArray::_OutputArray(const std::vector<_Tp>& vec) : _InputArray(vec) {flags |= FIXED_SIZE;} -template inline _OutputArray::_OutputArray(const vector >& vec) +template inline _OutputArray::_OutputArray(const std::vector >& vec) : _InputArray(vec) {flags |= FIXED_SIZE;} -template inline _OutputArray::_OutputArray(const vector >& vec) +template inline _OutputArray::_OutputArray(const std::vector >& vec) : _InputArray(vec) {flags |= FIXED_SIZE;} template inline _OutputArray::_OutputArray(const Mat_<_Tp>& m) @@ -1667,8 +1667,8 @@ operator ^= (const Mat_<_Tp>& a, const Scalar& s) /////////////////////////////// Miscellaneous operations ////////////////////////////// -template void split(const Mat& src, vector >& mv) -{ split(src, (vector&)mv ); } +template void split(const Mat& src, std::vector >& mv) +{ split(src, (std::vector&)mv ); } ////////////////////////////////////////////////////////////// diff --git a/modules/core/include/opencv2/core/operations.hpp b/modules/core/include/opencv2/core/operations.hpp index 0d0f7c732..518077091 100644 --- a/modules/core/include/opencv2/core/operations.hpp +++ b/modules/core/include/opencv2/core/operations.hpp @@ -101,16 +101,6 @@ namespace cv { -using std::cos; -using std::sin; -using std::max; -using std::min; -using std::exp; -using std::log; -using std::pow; -using std::sqrt; - - /////////////// saturate_cast (used in image & signal processing) /////////////////// template static inline _Tp saturate_cast(uchar v) { return _Tp(v); } @@ -2769,18 +2759,18 @@ template<> CV_EXPORTS void Ptr::delete_obj(); //////////////////////////////////////// XML & YAML I/O //////////////////////////////////// -CV_EXPORTS_W void write( FileStorage& fs, const string& name, int value ); -CV_EXPORTS_W void write( FileStorage& fs, const string& name, float value ); -CV_EXPORTS_W void write( FileStorage& fs, const string& name, double value ); -CV_EXPORTS_W void write( FileStorage& fs, const string& name, const string& value ); +CV_EXPORTS_W void write( FileStorage& fs, const std::string& name, int value ); +CV_EXPORTS_W void write( FileStorage& fs, const std::string& name, float value ); +CV_EXPORTS_W void write( FileStorage& fs, const std::string& name, double value ); +CV_EXPORTS_W void write( FileStorage& fs, const std::string& name, const std::string& value ); template inline void write(FileStorage& fs, const _Tp& value) -{ write(fs, string(), value); } +{ write(fs, std::string(), value); } CV_EXPORTS void writeScalar( FileStorage& fs, int value ); CV_EXPORTS void writeScalar( FileStorage& fs, float value ); CV_EXPORTS void writeScalar( FileStorage& fs, double value ); -CV_EXPORTS void writeScalar( FileStorage& fs, const string& value ); +CV_EXPORTS void writeScalar( FileStorage& fs, const std::string& value ); template<> inline void write( FileStorage& fs, const int& value ) { @@ -2797,7 +2787,7 @@ template<> inline void write( FileStorage& fs, const double& value ) writeScalar(fs, value); } -template<> inline void write( FileStorage& fs, const string& value ) +template<> inline void write( FileStorage& fs, const std::string& value ) { writeScalar(fs, value); } @@ -2858,20 +2848,20 @@ inline void write(FileStorage& fs, const Range& r ) class CV_EXPORTS WriteStructContext { public: - WriteStructContext(FileStorage& _fs, const string& name, - int flags, const string& typeName=string()); + WriteStructContext(FileStorage& _fs, const std::string& name, + int flags, const std::string& typeName=std::string()); ~WriteStructContext(); FileStorage* fs; }; -template inline void write(FileStorage& fs, const string& name, const Point_<_Tp>& pt ) +template inline void write(FileStorage& fs, const std::string& name, const Point_<_Tp>& pt ) { WriteStructContext ws(fs, name, CV_NODE_SEQ+CV_NODE_FLOW); write(fs, pt.x); write(fs, pt.y); } -template inline void write(FileStorage& fs, const string& name, const Point3_<_Tp>& pt ) +template inline void write(FileStorage& fs, const std::string& name, const Point3_<_Tp>& pt ) { WriteStructContext ws(fs, name, CV_NODE_SEQ+CV_NODE_FLOW); write(fs, pt.x); @@ -2879,21 +2869,21 @@ template inline void write(FileStorage& fs, const string& name, co write(fs, pt.z); } -template inline void write(FileStorage& fs, const string& name, const Size_<_Tp>& sz ) +template inline void write(FileStorage& fs, const std::string& name, const Size_<_Tp>& sz ) { WriteStructContext ws(fs, name, CV_NODE_SEQ+CV_NODE_FLOW); write(fs, sz.width); write(fs, sz.height); } -template inline void write(FileStorage& fs, const string& name, const Complex<_Tp>& c ) +template inline void write(FileStorage& fs, const std::string& name, const Complex<_Tp>& c ) { WriteStructContext ws(fs, name, CV_NODE_SEQ+CV_NODE_FLOW); write(fs, c.re); write(fs, c.im); } -template inline void write(FileStorage& fs, const string& name, const Rect_<_Tp>& r ) +template inline void write(FileStorage& fs, const std::string& name, const Rect_<_Tp>& r ) { WriteStructContext ws(fs, name, CV_NODE_SEQ+CV_NODE_FLOW); write(fs, r.x); @@ -2902,14 +2892,14 @@ template inline void write(FileStorage& fs, const string& name, co write(fs, r.height); } -template inline void write(FileStorage& fs, const string& name, const Vec<_Tp, cn>& v ) +template inline void write(FileStorage& fs, const std::string& name, const Vec<_Tp, cn>& v ) { WriteStructContext ws(fs, name, CV_NODE_SEQ+CV_NODE_FLOW); for(int i = 0; i < cn; i++) write(fs, v.val[i]); } -template inline void write(FileStorage& fs, const string& name, const Scalar_<_Tp>& s ) +template inline void write(FileStorage& fs, const std::string& name, const Scalar_<_Tp>& s ) { WriteStructContext ws(fs, name, CV_NODE_SEQ+CV_NODE_FLOW); write(fs, s.val[0]); @@ -2918,7 +2908,7 @@ template inline void write(FileStorage& fs, const string& name, co write(fs, s.val[3]); } -inline void write(FileStorage& fs, const string& name, const Range& r ) +inline void write(FileStorage& fs, const std::string& name, const Range& r ) { WriteStructContext ws(fs, name, CV_NODE_SEQ+CV_NODE_FLOW); write(fs, r.start); @@ -2929,7 +2919,7 @@ template class CV_EXPORTS VecWriterProxy { public: VecWriterProxy( FileStorage* _fs ) : fs(_fs) {} - void operator()(const vector<_Tp>& vec) const + void operator()(const std::vector<_Tp>& vec) const { size_t i, count = vec.size(); for( i = 0; i < count; i++ ) @@ -2942,30 +2932,30 @@ template class CV_EXPORTS VecWriterProxy<_Tp,1> { public: VecWriterProxy( FileStorage* _fs ) : fs(_fs) {} - void operator()(const vector<_Tp>& vec) const + void operator()(const std::vector<_Tp>& vec) const { int _fmt = DataType<_Tp>::fmt; char fmt[] = { (char)((_fmt>>8)+'1'), (char)_fmt, '\0' }; - fs->writeRaw( string(fmt), !vec.empty() ? (uchar*)&vec[0] : 0, vec.size()*sizeof(_Tp) ); + fs->writeRaw( std::string(fmt), !vec.empty() ? (uchar*)&vec[0] : 0, vec.size()*sizeof(_Tp) ); } FileStorage* fs; }; -template static inline void write( FileStorage& fs, const vector<_Tp>& vec ) +template static inline void write( FileStorage& fs, const std::vector<_Tp>& vec ) { VecWriterProxy<_Tp, DataType<_Tp>::fmt != 0> w(&fs); w(vec); } -template static inline void write( FileStorage& fs, const string& name, - const vector<_Tp>& vec ) +template static inline void write( FileStorage& fs, const std::string& name, + const std::vector<_Tp>& vec ) { WriteStructContext ws(fs, name, CV_NODE_SEQ+(DataType<_Tp>::fmt != 0 ? CV_NODE_FLOW : 0)); write(fs, vec); } -CV_EXPORTS_W void write( FileStorage& fs, const string& name, const Mat& value ); -CV_EXPORTS void write( FileStorage& fs, const string& name, const SparseMat& value ); +CV_EXPORTS_W void write( FileStorage& fs, const std::string& name, const Mat& value ); +CV_EXPORTS void write( FileStorage& fs, const std::string& name, const SparseMat& value ); template static inline FileStorage& operator << (FileStorage& fs, const _Tp& value) { @@ -2979,10 +2969,10 @@ template static inline FileStorage& operator << (FileStorage& fs, return fs; } -CV_EXPORTS FileStorage& operator << (FileStorage& fs, const string& str); +CV_EXPORTS FileStorage& operator << (FileStorage& fs, const std::string& str); static inline FileStorage& operator << (FileStorage& fs, const char* str) -{ return (fs << string(str)); } +{ return (fs << std::string(str)); } inline FileNode::FileNode() : fs(0), node(0) {} inline FileNode::FileNode(const CvFileStorage* _fs, const CvFileNode* _node) @@ -3060,9 +3050,9 @@ static inline void read(const FileNode& node, double& value, double default_valu CV_NODE_IS_REAL(node.node->tag) ? node.node->data.f : 1e300; } -static inline void read(const FileNode& node, string& value, const string& default_value) +static inline void read(const FileNode& node, std::string& value, const std::string& default_value) { - value = !node.node ? default_value : CV_NODE_IS_STRING(node.node->tag) ? string(node.node->data.str.ptr) : string(""); + value = !node.node ? default_value : CV_NODE_IS_STRING(node.node->tag) ? std::string(node.node->data.str.ptr) : std::string(""); } CV_EXPORTS_W void read(const FileNode& node, Mat& mat, const Mat& default_mat=Mat() ); @@ -3086,14 +3076,14 @@ inline FileNode::operator double() const read(*this, value, 0.); return value; } -inline FileNode::operator string() const +inline FileNode::operator std::string() const { - string value; + std::string value; read(*this, value, value); return value; } -inline void FileNode::readRaw( const string& fmt, uchar* vec, size_t len ) const +inline void FileNode::readRaw( const std::string& fmt, uchar* vec, size_t len ) const { begin().readRaw( fmt, vec, len ); } @@ -3102,7 +3092,7 @@ template class CV_EXPORTS VecReaderProxy { public: VecReaderProxy( FileNodeIterator* _it ) : it(_it) {} - void operator()(vector<_Tp>& vec, size_t count) const + void operator()(std::vector<_Tp>& vec, size_t count) const { count = std::min(count, it->remaining); vec.resize(count); @@ -3116,7 +3106,7 @@ template class CV_EXPORTS VecReaderProxy<_Tp,1> { public: VecReaderProxy( FileNodeIterator* _it ) : it(_it) {} - void operator()(vector<_Tp>& vec, size_t count) const + void operator()(std::vector<_Tp>& vec, size_t count) const { size_t remaining = it->remaining, cn = DataType<_Tp>::channels; int _fmt = DataType<_Tp>::fmt; @@ -3124,20 +3114,20 @@ public: size_t remaining1 = remaining/cn; count = count < remaining1 ? count : remaining1; vec.resize(count); - it->readRaw( string(fmt), !vec.empty() ? (uchar*)&vec[0] : 0, count*sizeof(_Tp) ); + it->readRaw( std::string(fmt), !vec.empty() ? (uchar*)&vec[0] : 0, count*sizeof(_Tp) ); } FileNodeIterator* it; }; template static inline void -read( FileNodeIterator& it, vector<_Tp>& vec, size_t maxCount=(size_t)INT_MAX ) +read( FileNodeIterator& it, std::vector<_Tp>& vec, size_t maxCount=(size_t)INT_MAX ) { VecReaderProxy<_Tp, DataType<_Tp>::fmt != 0> r(&it); r(vec, maxCount); } template static inline void -read( const FileNode& node, vector<_Tp>& vec, const vector<_Tp>& default_value=vector<_Tp>() ) +read( const FileNode& node, std::vector<_Tp>& vec, const std::vector<_Tp>& default_value=std::vector<_Tp>() ) { if(!node.node) vec = default_value; @@ -3168,7 +3158,7 @@ template static inline FileNodeIterator& operator >> (FileNodeIter { read( *it, value, _Tp()); return ++it; } template static inline -FileNodeIterator& operator >> (FileNodeIterator& it, vector<_Tp>& vec) +FileNodeIterator& operator >> (FileNodeIterator& it, std::vector<_Tp>& vec) { VecReaderProxy<_Tp, DataType<_Tp>::fmt != 0> r(&it); r(vec, (size_t)INT_MAX); @@ -3178,7 +3168,7 @@ FileNodeIterator& operator >> (FileNodeIterator& it, vector<_Tp>& vec) template static inline void operator >> (const FileNode& n, _Tp& value) { read( n, value, _Tp()); } -template static inline void operator >> (const FileNode& n, vector<_Tp>& vec) +template static inline void operator >> (const FileNode& n, std::vector<_Tp>& vec) { FileNodeIterator it = n.begin(); it >> vec; } static inline bool operator == (const FileNodeIterator& it1, const FileNodeIterator& it2) @@ -3264,7 +3254,7 @@ template static inline _Tp gcd(_Tp a, _Tp b) \****************************************************************************************/ -template void sort( vector<_Tp>& vec, _LT LT=_LT() ) +template void sort( std::vector<_Tp>& vec, _LT LT=_LT() ) { int isort_thresh = 7; int sp = 0; @@ -3462,7 +3452,7 @@ public: // The algorithm is described in "Introduction to Algorithms" // by Cormen, Leiserson and Rivest, the chapter "Data structures for disjoint sets" template int -partition( const vector<_Tp>& _vec, vector& labels, +partition( const std::vector<_Tp>& _vec, std::vector& labels, _EqPredicate predicate=_EqPredicate()) { int i, j, N = (int)_vec.size(); @@ -3471,7 +3461,7 @@ partition( const vector<_Tp>& _vec, vector& labels, const int PARENT=0; const int RANK=1; - vector _nodes(N*2); + std::vector _nodes(N*2); int (*nodes)[2] = (int(*)[2])&_nodes[0]; // The first O(N) pass: create N single-vertex trees @@ -3667,7 +3657,7 @@ template inline void Seq<_Tp>::remove(int idx) template inline void Seq<_Tp>::remove(const Range& r) { seqRemoveSlice(seq, r); } -template inline void Seq<_Tp>::copyTo(vector<_Tp>& vec, const Range& range) const +template inline void Seq<_Tp>::copyTo(std::vector<_Tp>& vec, const Range& range) const { size_t len = !seq ? 0 : range == Range::all() ? seq->total : range.end - range.start; vec.resize(len); @@ -3675,9 +3665,9 @@ template inline void Seq<_Tp>::copyTo(vector<_Tp>& vec, const Rang cvCvtSeqToArray(seq, &vec[0], range); } -template inline Seq<_Tp>::operator vector<_Tp>() const +template inline Seq<_Tp>::operator std::vector<_Tp>() const { - vector<_Tp> vec; + std::vector<_Tp> vec; copyTo(vec); return vec; } @@ -3815,7 +3805,7 @@ public: { FileStorage fs(_fs); fs.fs.addref(); - ((const _ClsName*)ptr)->write(fs, string(name)); + ((const _ClsName*)ptr)->write(fs, std::string(name)); } } @@ -3843,28 +3833,28 @@ public: struct CV_EXPORTS Formatted { Formatted(const Mat& m, const Formatter* fmt, - const vector& params); + const std::vector& params); Formatted(const Mat& m, const Formatter* fmt, const int* params=0); Mat mtx; const Formatter* fmt; - vector params; + std::vector params; }; static inline Formatted format(const Mat& mtx, const char* fmt, - const vector& params=vector()) + const std::vector& params=std::vector()) { return Formatted(mtx, Formatter::get(fmt), params); } -template static inline Formatted format(const vector >& vec, - const char* fmt, const vector& params=vector()) +template static inline Formatted format(const std::vector >& vec, + const char* fmt, const std::vector& params=std::vector()) { return Formatted(Mat(vec), Formatter::get(fmt), params); } -template static inline Formatted format(const vector >& vec, - const char* fmt, const vector& params=vector()) +template static inline Formatted format(const std::vector >& vec, + const char* fmt, const std::vector& params=std::vector()) { return Formatted(Mat(vec), Formatter::get(fmt), params); } @@ -3897,7 +3887,7 @@ static inline std::ostream& operator << (std::ostream& out, const Formatted& fmt template static inline std::ostream& operator << (std::ostream& out, - const vector >& vec) + const std::vector >& vec) { Formatter::get()->write(out, Mat(vec)); return out; @@ -3905,7 +3895,7 @@ template static inline std::ostream& operator << (std::ostream& ou template static inline std::ostream& operator << (std::ostream& out, - const vector >& vec) + const std::vector >& vec) { Formatter::get()->write(out, Mat(vec)); return out; @@ -3977,7 +3967,7 @@ template inline std::ostream& operator<<(std::ostream& out, const } -template inline Ptr<_Tp> Algorithm::create(const string& name) +template inline Ptr<_Tp> Algorithm::create(const std::string& name) { return _create(name).ptr<_Tp>(); } @@ -3993,7 +3983,7 @@ inline void Algorithm::set(const char* _name, const Ptr<_Tp>& value) } template -inline void Algorithm::set(const string& _name, const Ptr<_Tp>& value) +inline void Algorithm::set(const std::string& _name, const Ptr<_Tp>& value) { this->set<_Tp>(_name.c_str(), value); } @@ -4009,12 +3999,12 @@ inline void Algorithm::setAlgorithm(const char* _name, const Ptr<_Tp>& value) } template -inline void Algorithm::setAlgorithm(const string& _name, const Ptr<_Tp>& value) +inline void Algorithm::setAlgorithm(const std::string& _name, const Ptr<_Tp>& value) { this->set<_Tp>(_name.c_str(), value); } -template inline typename ParamType<_Tp>::member_type Algorithm::get(const string& _name) const +template inline typename ParamType<_Tp>::member_type Algorithm::get(const std::string& _name) const { typename ParamType<_Tp>::member_type value; info()->get(this, _name.c_str(), ParamType<_Tp>::type, &value); @@ -4030,7 +4020,7 @@ template inline typename ParamType<_Tp>::member_type Algorithm::ge template inline void AlgorithmInfo::addParam(Algorithm& algo, const char* parameter, Ptr<_Tp>& value, bool readOnly, Ptr<_Tp> (Algorithm::*getter)(), void (Algorithm::*setter)(const Ptr<_Tp>&), - const string& help) + const std::string& help) { //TODO: static assert: _Tp inherits from _Base addParam_(algo, parameter, ParamType<_Base>::type, &value, readOnly, @@ -4039,7 +4029,7 @@ template inline void AlgorithmInfo::addParam(Algor template inline void AlgorithmInfo::addParam(Algorithm& algo, const char* parameter, Ptr<_Tp>& value, bool readOnly, Ptr<_Tp> (Algorithm::*getter)(), void (Algorithm::*setter)(const Ptr<_Tp>&), - const string& help) + const std::string& help) { //TODO: static assert: _Tp inherits from Algorithm addParam_(algo, parameter, ParamType::type, &value, readOnly, diff --git a/modules/core/src/algorithm.cpp b/modules/core/src/algorithm.cpp index 9001fcd12..d99bd129b 100644 --- a/modules/core/src/algorithm.cpp +++ b/modules/core/src/algorithm.cpp @@ -45,8 +45,6 @@ namespace cv { -using std::pair; - template struct sorted_vector { sorted_vector() {} @@ -57,7 +55,7 @@ template struct sorted_vector void add(const _KeyTp& k, const _ValueTp& val) { - pair<_KeyTp, _ValueTp> p(k, val); + std::pair<_KeyTp, _ValueTp> p(k, val); vec.push_back(p); size_t i = vec.size()-1; for( ; i > 0 && vec[i].first < vec[i-1].first; i-- ) @@ -85,7 +83,7 @@ template struct sorted_vector return false; } - void get_keys(vector<_KeyTp>& keys) const + void get_keys(std::vector<_KeyTp>& keys) const { size_t i = 0, n = vec.size(); keys.resize(n); @@ -94,11 +92,11 @@ template struct sorted_vector keys[i] = vec[i].first; } - vector > vec; + std::vector > vec; }; -template inline const _ValueTp* findstr(const sorted_vector& vec, +template inline const _ValueTp* findstr(const sorted_vector& vec, const char* key) { if( !key ) @@ -132,7 +130,7 @@ Param::Param() Param::Param(int _type, bool _readonly, int _offset, Algorithm::Getter _getter, Algorithm::Setter _setter, - const string& _help) + const std::string& _help) { type = _type; readonly = _readonly; @@ -144,23 +142,23 @@ Param::Param(int _type, bool _readonly, int _offset, struct CV_EXPORTS AlgorithmInfoData { - sorted_vector params; - string _name; + sorted_vector params; + std::string _name; }; -static sorted_vector& alglist() +static sorted_vector& alglist() { - static sorted_vector alglist_var; + static sorted_vector alglist_var; return alglist_var; } -void Algorithm::getList(vector& algorithms) +void Algorithm::getList(std::vector& algorithms) { alglist().get_keys(algorithms); } -Ptr Algorithm::_create(const string& name) +Ptr Algorithm::_create(const std::string& name) { Algorithm::Constructor c = 0; if( !alglist().find(name, c) ) @@ -176,42 +174,42 @@ Algorithm::~Algorithm() { } -string Algorithm::name() const +std::string Algorithm::name() const { return info()->name(); } -void Algorithm::set(const string& parameter, int value) +void Algorithm::set(const std::string& parameter, int value) { info()->set(this, parameter.c_str(), ParamType::type, &value); } -void Algorithm::set(const string& parameter, double value) +void Algorithm::set(const std::string& parameter, double value) { info()->set(this, parameter.c_str(), ParamType::type, &value); } -void Algorithm::set(const string& parameter, bool value) +void Algorithm::set(const std::string& parameter, bool value) { info()->set(this, parameter.c_str(), ParamType::type, &value); } -void Algorithm::set(const string& parameter, const string& value) +void Algorithm::set(const std::string& parameter, const std::string& value) { - info()->set(this, parameter.c_str(), ParamType::type, &value); + info()->set(this, parameter.c_str(), ParamType::type, &value); } -void Algorithm::set(const string& parameter, const Mat& value) +void Algorithm::set(const std::string& parameter, const Mat& value) { info()->set(this, parameter.c_str(), ParamType::type, &value); } -void Algorithm::set(const string& parameter, const vector& value) +void Algorithm::set(const std::string& parameter, const std::vector& value) { - info()->set(this, parameter.c_str(), ParamType >::type, &value); + info()->set(this, parameter.c_str(), ParamType >::type, &value); } -void Algorithm::set(const string& parameter, const Ptr& value) +void Algorithm::set(const std::string& parameter, const Ptr& value) { info()->set(this, parameter.c_str(), ParamType::type, &value); } @@ -231,9 +229,9 @@ void Algorithm::set(const char* parameter, bool value) info()->set(this, parameter, ParamType::type, &value); } -void Algorithm::set(const char* parameter, const string& value) +void Algorithm::set(const char* parameter, const std::string& value) { - info()->set(this, parameter, ParamType::type, &value); + info()->set(this, parameter, ParamType::type, &value); } void Algorithm::set(const char* parameter, const Mat& value) @@ -241,9 +239,9 @@ void Algorithm::set(const char* parameter, const Mat& value) info()->set(this, parameter, ParamType::type, &value); } -void Algorithm::set(const char* parameter, const vector& value) +void Algorithm::set(const char* parameter, const std::vector& value) { - info()->set(this, parameter, ParamType >::type, &value); + info()->set(this, parameter, ParamType >::type, &value); } void Algorithm::set(const char* parameter, const Ptr& value) @@ -252,37 +250,37 @@ void Algorithm::set(const char* parameter, const Ptr& value) } -void Algorithm::setInt(const string& parameter, int value) +void Algorithm::setInt(const std::string& parameter, int value) { info()->set(this, parameter.c_str(), ParamType::type, &value); } -void Algorithm::setDouble(const string& parameter, double value) +void Algorithm::setDouble(const std::string& parameter, double value) { info()->set(this, parameter.c_str(), ParamType::type, &value); } -void Algorithm::setBool(const string& parameter, bool value) +void Algorithm::setBool(const std::string& parameter, bool value) { info()->set(this, parameter.c_str(), ParamType::type, &value); } -void Algorithm::setString(const string& parameter, const string& value) +void Algorithm::setString(const std::string& parameter, const std::string& value) { - info()->set(this, parameter.c_str(), ParamType::type, &value); + info()->set(this, parameter.c_str(), ParamType::type, &value); } -void Algorithm::setMat(const string& parameter, const Mat& value) +void Algorithm::setMat(const std::string& parameter, const Mat& value) { info()->set(this, parameter.c_str(), ParamType::type, &value); } -void Algorithm::setMatVector(const string& parameter, const vector& value) +void Algorithm::setMatVector(const std::string& parameter, const std::vector& value) { - info()->set(this, parameter.c_str(), ParamType >::type, &value); + info()->set(this, parameter.c_str(), ParamType >::type, &value); } -void Algorithm::setAlgorithm(const string& parameter, const Ptr& value) +void Algorithm::setAlgorithm(const std::string& parameter, const Ptr& value) { info()->set(this, parameter.c_str(), ParamType::type, &value); } @@ -302,9 +300,9 @@ void Algorithm::setBool(const char* parameter, bool value) info()->set(this, parameter, ParamType::type, &value); } -void Algorithm::setString(const char* parameter, const string& value) +void Algorithm::setString(const char* parameter, const std::string& value) { - info()->set(this, parameter, ParamType::type, &value); + info()->set(this, parameter, ParamType::type, &value); } void Algorithm::setMat(const char* parameter, const Mat& value) @@ -312,9 +310,9 @@ void Algorithm::setMat(const char* parameter, const Mat& value) info()->set(this, parameter, ParamType::type, &value); } -void Algorithm::setMatVector(const char* parameter, const vector& value) +void Algorithm::setMatVector(const char* parameter, const std::vector& value) { - info()->set(this, parameter, ParamType >::type, &value); + info()->set(this, parameter, ParamType >::type, &value); } void Algorithm::setAlgorithm(const char* parameter, const Ptr& value) @@ -324,47 +322,47 @@ void Algorithm::setAlgorithm(const char* parameter, const Ptr& value) -int Algorithm::getInt(const string& parameter) const +int Algorithm::getInt(const std::string& parameter) const { return get(parameter); } -double Algorithm::getDouble(const string& parameter) const +double Algorithm::getDouble(const std::string& parameter) const { return get(parameter); } -bool Algorithm::getBool(const string& parameter) const +bool Algorithm::getBool(const std::string& parameter) const { return get(parameter); } -string Algorithm::getString(const string& parameter) const +std::string Algorithm::getString(const std::string& parameter) const { - return get(parameter); + return get(parameter); } -Mat Algorithm::getMat(const string& parameter) const +Mat Algorithm::getMat(const std::string& parameter) const { return get(parameter); } -vector Algorithm::getMatVector(const string& parameter) const +std::vector Algorithm::getMatVector(const std::string& parameter) const { - return get >(parameter); + return get >(parameter); } -Ptr Algorithm::getAlgorithm(const string& parameter) const +Ptr Algorithm::getAlgorithm(const std::string& parameter) const { return get(parameter); } -string Algorithm::paramHelp(const string& parameter) const +std::string Algorithm::paramHelp(const std::string& parameter) const { return info()->paramHelp(parameter.c_str()); } -int Algorithm::paramType(const string& parameter) const +int Algorithm::paramType(const std::string& parameter) const { return info()->paramType(parameter.c_str()); } @@ -374,7 +372,7 @@ int Algorithm::paramType(const char* parameter) const return info()->paramType(parameter); } -void Algorithm::getParams(vector& names) const +void Algorithm::getParams(std::vector& names) const { info()->getParams(names); } @@ -390,7 +388,7 @@ void Algorithm::read(const FileNode& fn) } -AlgorithmInfo::AlgorithmInfo(const string& _name, Algorithm::Constructor create) +AlgorithmInfo::AlgorithmInfo(const std::string& _name, Algorithm::Constructor create) { data = new AlgorithmInfoData; data->_name = _name; @@ -410,7 +408,7 @@ void AlgorithmInfo::write(const Algorithm* algo, FileStorage& fs) const for( i = 0; i < nparams; i++ ) { const Param& p = data->params.vec[i].second; - const string& pname = data->params.vec[i].first; + const std::string& pname = data->params.vec[i].first; if( p.type == Param::INT ) cv::write(fs, pname, algo->get(pname)); else if( p.type == Param::BOOLEAN ) @@ -418,11 +416,11 @@ void AlgorithmInfo::write(const Algorithm* algo, FileStorage& fs) const else if( p.type == Param::REAL ) cv::write(fs, pname, algo->get(pname)); else if( p.type == Param::STRING ) - cv::write(fs, pname, algo->get(pname)); + cv::write(fs, pname, algo->get(pname)); else if( p.type == Param::MAT ) cv::write(fs, pname, algo->get(pname)); else if( p.type == Param::MAT_VECTOR ) - cv::write(fs, pname, algo->get >(pname)); + cv::write(fs, pname, algo->get >(pname)); else if( p.type == Param::ALGORITHM ) { WriteStructContext ws(fs, pname, CV_NODE_MAP); @@ -431,7 +429,7 @@ void AlgorithmInfo::write(const Algorithm* algo, FileStorage& fs) const } else { - string msg = format("unknown/unsupported type of '%s' parameter == %d", pname.c_str(), p.type); + std::string msg = format("unknown/unsupported type of '%s' parameter == %d", pname.c_str(), p.type); CV_Error( CV_StsUnsupportedFormat, msg.c_str()); } } @@ -445,7 +443,7 @@ void AlgorithmInfo::read(Algorithm* algo, const FileNode& fn) const for( i = 0; i < nparams; i++ ) { const Param& p = data->params.vec[i].second; - const string& pname = data->params.vec[i].first; + const std::string& pname = data->params.vec[i].first; const FileNode n = fn[pname]; if( n.empty() ) continue; @@ -466,7 +464,7 @@ void AlgorithmInfo::read(Algorithm* algo, const FileNode& fn) const } else if( p.type == Param::STRING ) { - string val = (string)n; + std::string val = (std::string)n; info->set(algo, pname.c_str(), p.type, &val, true); } else if( p.type == Param::MAT ) @@ -477,26 +475,26 @@ void AlgorithmInfo::read(Algorithm* algo, const FileNode& fn) const } else if( p.type == Param::MAT_VECTOR ) { - vector mv; + std::vector mv; cv::read(n, mv); info->set(algo, pname.c_str(), p.type, &mv, true); } else if( p.type == Param::ALGORITHM ) { - Ptr nestedAlgo = Algorithm::_create((string)n["name"]); + Ptr nestedAlgo = Algorithm::_create((std::string)n["name"]); CV_Assert( !nestedAlgo.empty() ); nestedAlgo->read(n); info->set(algo, pname.c_str(), p.type, &nestedAlgo, true); } else { - string msg = format("unknown/unsupported type of '%s' parameter == %d", pname.c_str(), p.type); + std::string msg = format("unknown/unsupported type of '%s' parameter == %d", pname.c_str(), p.type); CV_Error( CV_StsUnsupportedFormat, msg.c_str()); } } } -string AlgorithmInfo::name() const +std::string AlgorithmInfo::name() const { return data->_name; } @@ -506,23 +504,23 @@ union GetSetParam int (Algorithm::*get_int)() const; bool (Algorithm::*get_bool)() const; double (Algorithm::*get_double)() const; - string (Algorithm::*get_string)() const; + std::string (Algorithm::*get_string)() const; Mat (Algorithm::*get_mat)() const; - vector (Algorithm::*get_mat_vector)() const; + std::vector (Algorithm::*get_mat_vector)() const; Ptr (Algorithm::*get_algo)() const; void (Algorithm::*set_int)(int); void (Algorithm::*set_bool)(bool); void (Algorithm::*set_double)(double); - void (Algorithm::*set_string)(const string&); + void (Algorithm::*set_string)(const std::string&); void (Algorithm::*set_mat)(const Mat&); - void (Algorithm::*set_mat_vector)(const vector&); + void (Algorithm::*set_mat_vector)(const std::vector&); void (Algorithm::*set_algo)(const Ptr&); }; -static string getNameOfType(int argType); +static std::string getNameOfType(int argType); -static string getNameOfType(int argType) +static std::string getNameOfType(int argType) { switch(argType) { @@ -537,10 +535,10 @@ static string getNameOfType(int argType) } return ""; } -static string getErrorMessageForWrongArgumentInSetter(string algoName, string paramName, int paramType, int argType); -static string getErrorMessageForWrongArgumentInSetter(string algoName, string paramName, int paramType, int argType) + +static std::string getErrorMessageForWrongArgumentInSetter(std::string algoName, std::string paramName, int paramType, int argType) { - string message = string("Argument error: the setter") + std::string message = std::string("Argument error: the setter") + " method was called for the parameter '" + paramName + "' of the algorithm '" + algoName +"', the parameter has " + getNameOfType(paramType) + " type, "; @@ -553,10 +551,9 @@ static string getErrorMessageForWrongArgumentInSetter(string algoName, string pa return message; } -static string getErrorMessageForWrongArgumentInGetter(string algoName, string paramName, int paramType, int argType); -static string getErrorMessageForWrongArgumentInGetter(string algoName, string paramName, int paramType, int argType) +static std::string getErrorMessageForWrongArgumentInGetter(std::string algoName, std::string paramName, int paramType, int argType) { - string message = string("Argument error: the getter") + std::string message = std::string("Argument error: the getter") + " method was called for the parameter '" + paramName + "' of the algorithm '" + algoName +"', the parameter has " + getNameOfType(paramType) + " type, "; @@ -590,7 +587,7 @@ void AlgorithmInfo::set(Algorithm* algo, const char* parameter, int argType, con { if ( !( p->type == Param::INT || p->type == Param::REAL || p->type == Param::BOOLEAN) ) { - string message = getErrorMessageForWrongArgumentInSetter(algo->name(), parameter, p->type, argType); + std::string message = getErrorMessageForWrongArgumentInSetter(algo->name(), parameter, p->type, argType); CV_Error(CV_StsBadArg, message); } @@ -629,21 +626,21 @@ void AlgorithmInfo::set(Algorithm* algo, const char* parameter, int argType, con { if( p->type != Param::STRING ) { - string message = getErrorMessageForWrongArgumentInSetter(algo->name(), parameter, p->type, argType); + std::string message = getErrorMessageForWrongArgumentInSetter(algo->name(), parameter, p->type, argType); CV_Error(CV_StsBadArg, message); } - const string& val = *(const string*)value; + const std::string& val = *(const std::string*)value; if( p->setter ) (algo->*f.set_string)(val); else - *(string*)((uchar*)algo + p->offset) = val; + *(std::string*)((uchar*)algo + p->offset) = val; } else if( argType == Param::MAT ) { if( p->type != Param::MAT ) { - string message = getErrorMessageForWrongArgumentInSetter(algo->name(), parameter, p->type, argType); + std::string message = getErrorMessageForWrongArgumentInSetter(algo->name(), parameter, p->type, argType); CV_Error(CV_StsBadArg, message); } @@ -657,21 +654,21 @@ void AlgorithmInfo::set(Algorithm* algo, const char* parameter, int argType, con { if( p->type != Param::MAT_VECTOR ) { - string message = getErrorMessageForWrongArgumentInSetter(algo->name(), parameter, p->type, argType); + std::string message = getErrorMessageForWrongArgumentInSetter(algo->name(), parameter, p->type, argType); CV_Error(CV_StsBadArg, message); } - const vector& val = *(const vector*)value; + const std::vector& val = *(const std::vector*)value; if( p->setter ) (algo->*f.set_mat_vector)(val); else - *(vector*)((uchar*)algo + p->offset) = val; + *(std::vector*)((uchar*)algo + p->offset) = val; } else if( argType == Param::ALGORITHM ) { if( p->type != Param::ALGORITHM ) { - string message = getErrorMessageForWrongArgumentInSetter(algo->name(), parameter, p->type, argType); + std::string message = getErrorMessageForWrongArgumentInSetter(algo->name(), parameter, p->type, argType); CV_Error(CV_StsBadArg, message); } @@ -700,7 +697,7 @@ void AlgorithmInfo::get(const Algorithm* algo, const char* parameter, int argTyp { if (!( argType == Param::INT || argType == Param::REAL )) { - string message = getErrorMessageForWrongArgumentInGetter(algo->name(), parameter, p->type, argType); + std::string message = getErrorMessageForWrongArgumentInGetter(algo->name(), parameter, p->type, argType); CV_Error(CV_StsBadArg, message); } int val = p->getter ? (algo->*f.get_int)() : *(int*)((uchar*)algo + p->offset); @@ -714,7 +711,7 @@ void AlgorithmInfo::get(const Algorithm* algo, const char* parameter, int argTyp { if (!( argType == Param::INT || argType == Param::BOOLEAN || argType == Param::REAL )) { - string message = getErrorMessageForWrongArgumentInGetter(algo->name(), parameter, p->type, argType); + std::string message = getErrorMessageForWrongArgumentInGetter(algo->name(), parameter, p->type, argType); CV_Error(CV_StsBadArg, message); } bool val = p->getter ? (algo->*f.get_bool)() : *(bool*)((uchar*)algo + p->offset); @@ -730,7 +727,7 @@ void AlgorithmInfo::get(const Algorithm* algo, const char* parameter, int argTyp { if( argType != Param::REAL ) { - string message = getErrorMessageForWrongArgumentInGetter(algo->name(), parameter, p->type, argType); + std::string message = getErrorMessageForWrongArgumentInGetter(algo->name(), parameter, p->type, argType); CV_Error(CV_StsBadArg, message); } double val = p->getter ? (algo->*f.get_double)() : *(double*)((uchar*)algo + p->offset); @@ -742,18 +739,18 @@ void AlgorithmInfo::get(const Algorithm* algo, const char* parameter, int argTyp { if( p->type != Param::STRING ) { - string message = getErrorMessageForWrongArgumentInGetter(algo->name(), parameter, p->type, argType); + std::string message = getErrorMessageForWrongArgumentInGetter(algo->name(), parameter, p->type, argType); CV_Error(CV_StsBadArg, message); } - *(string*)value = p->getter ? (algo->*f.get_string)() : - *(string*)((uchar*)algo + p->offset); + *(std::string*)value = p->getter ? (algo->*f.get_string)() : + *(std::string*)((uchar*)algo + p->offset); } else if( argType == Param::MAT ) { if( p->type != Param::MAT ) { - string message = getErrorMessageForWrongArgumentInGetter(algo->name(), parameter, p->type, argType); + std::string message = getErrorMessageForWrongArgumentInGetter(algo->name(), parameter, p->type, argType); CV_Error(CV_StsBadArg, message); } @@ -764,18 +761,18 @@ void AlgorithmInfo::get(const Algorithm* algo, const char* parameter, int argTyp { if( p->type != Param::MAT_VECTOR ) { - string message = getErrorMessageForWrongArgumentInGetter(algo->name(), parameter, p->type, argType); + std::string message = getErrorMessageForWrongArgumentInGetter(algo->name(), parameter, p->type, argType); CV_Error(CV_StsBadArg, message); } - *(vector*)value = p->getter ? (algo->*f.get_mat_vector)() : - *(vector*)((uchar*)algo + p->offset); + *(std::vector*)value = p->getter ? (algo->*f.get_mat_vector)() : + *(std::vector*)((uchar*)algo + p->offset); } else if( argType == Param::ALGORITHM ) { if( p->type != Param::ALGORITHM ) { - string message = getErrorMessageForWrongArgumentInGetter(algo->name(), parameter, p->type, argType); + std::string message = getErrorMessageForWrongArgumentInGetter(algo->name(), parameter, p->type, argType); CV_Error(CV_StsBadArg, message); } @@ -784,7 +781,7 @@ void AlgorithmInfo::get(const Algorithm* algo, const char* parameter, int argTyp } else { - string message = getErrorMessageForWrongArgumentInGetter(algo->name(), parameter, p->type, argType); + std::string message = getErrorMessageForWrongArgumentInGetter(algo->name(), parameter, p->type, argType); CV_Error(CV_StsBadArg, message); } } @@ -799,7 +796,7 @@ int AlgorithmInfo::paramType(const char* parameter) const } -string AlgorithmInfo::paramHelp(const char* parameter) const +std::string AlgorithmInfo::paramHelp(const char* parameter) const { const Param* p = findstr(data->params, parameter); if( !p ) @@ -808,7 +805,7 @@ string AlgorithmInfo::paramHelp(const char* parameter) const } -void AlgorithmInfo::getParams(vector& names) const +void AlgorithmInfo::getParams(std::vector& names) const { data->params.get_keys(names); } @@ -817,13 +814,13 @@ void AlgorithmInfo::getParams(vector& names) const void AlgorithmInfo::addParam_(Algorithm& algo, const char* parameter, int argType, void* value, bool readOnly, Algorithm::Getter getter, Algorithm::Setter setter, - const string& help) + const std::string& help) { CV_Assert( argType == Param::INT || argType == Param::BOOLEAN || argType == Param::REAL || argType == Param::STRING || argType == Param::MAT || argType == Param::MAT_VECTOR || argType == Param::ALGORITHM ); - data->params.add(string(parameter), Param(argType, readOnly, + data->params.add(std::string(parameter), Param(argType, readOnly, (int)((size_t)value - (size_t)(void*)&algo), getter, setter, help)); } @@ -833,7 +830,7 @@ void AlgorithmInfo::addParam(Algorithm& algo, const char* parameter, int& value, bool readOnly, int (Algorithm::*getter)(), void (Algorithm::*setter)(int), - const string& help) + const std::string& help) { addParam_(algo, parameter, ParamType::type, &value, readOnly, (Algorithm::Getter)getter, (Algorithm::Setter)setter, help); @@ -843,7 +840,7 @@ void AlgorithmInfo::addParam(Algorithm& algo, const char* parameter, bool& value, bool readOnly, int (Algorithm::*getter)(), void (Algorithm::*setter)(int), - const string& help) + const std::string& help) { addParam_(algo, parameter, ParamType::type, &value, readOnly, (Algorithm::Getter)getter, (Algorithm::Setter)setter, help); @@ -853,19 +850,19 @@ void AlgorithmInfo::addParam(Algorithm& algo, const char* parameter, double& value, bool readOnly, double (Algorithm::*getter)(), void (Algorithm::*setter)(double), - const string& help) + const std::string& help) { addParam_(algo, parameter, ParamType::type, &value, readOnly, (Algorithm::Getter)getter, (Algorithm::Setter)setter, help); } void AlgorithmInfo::addParam(Algorithm& algo, const char* parameter, - string& value, bool readOnly, - string (Algorithm::*getter)(), - void (Algorithm::*setter)(const string&), - const string& help) + std::string& value, bool readOnly, + std::string (Algorithm::*getter)(), + void (Algorithm::*setter)(const std::string&), + const std::string& help) { - addParam_(algo, parameter, ParamType::type, &value, readOnly, + addParam_(algo, parameter, ParamType::type, &value, readOnly, (Algorithm::Getter)getter, (Algorithm::Setter)setter, help); } @@ -873,19 +870,19 @@ void AlgorithmInfo::addParam(Algorithm& algo, const char* parameter, Mat& value, bool readOnly, Mat (Algorithm::*getter)(), void (Algorithm::*setter)(const Mat&), - const string& help) + const std::string& help) { addParam_(algo, parameter, ParamType::type, &value, readOnly, (Algorithm::Getter)getter, (Algorithm::Setter)setter, help); } void AlgorithmInfo::addParam(Algorithm& algo, const char* parameter, - vector& value, bool readOnly, - vector (Algorithm::*getter)(), - void (Algorithm::*setter)(const vector&), - const string& help) + std::vector& value, bool readOnly, + std::vector (Algorithm::*getter)(), + void (Algorithm::*setter)(const std::vector&), + const std::string& help) { - addParam_(algo, parameter, ParamType >::type, &value, readOnly, + addParam_(algo, parameter, ParamType >::type, &value, readOnly, (Algorithm::Getter)getter, (Algorithm::Setter)setter, help); } @@ -893,7 +890,7 @@ void AlgorithmInfo::addParam(Algorithm& algo, const char* parameter, Ptr& value, bool readOnly, Ptr (Algorithm::*getter)(), void (Algorithm::*setter)(const Ptr&), - const string& help) + const std::string& help) { addParam_(algo, parameter, ParamType::type, &value, readOnly, (Algorithm::Getter)getter, (Algorithm::Setter)setter, help); diff --git a/modules/core/src/command_line_parser.cpp b/modules/core/src/command_line_parser.cpp index 5218419e2..1bffe5af7 100644 --- a/modules/core/src/command_line_parser.cpp +++ b/modules/core/src/command_line_parser.cpp @@ -9,9 +9,9 @@ namespace cv struct CommandLineParserParams { public: - string help_message; - string def_value; - vector keys; + std::string help_message; + std::string def_value; + std::vector keys; int number; }; @@ -19,27 +19,27 @@ public: struct CommandLineParser::Impl { bool error; - string error_message; - string about_message; + std::string error_message; + std::string about_message; - string path_to_app; - string app_name; + std::string path_to_app; + std::string app_name; - vector data; + std::vector data; - vector split_range_string(const string& str, char fs, char ss) const; - vector split_string(const string& str, char symbol = ' ', bool create_empty_item = false) const; - string cat_string(const string& str) const; + std::vector split_range_string(const std::string& str, char fs, char ss) const; + std::vector split_string(const std::string& str, char symbol = ' ', bool create_empty_item = false) const; + std::string cat_string(const std::string& str) const; - void apply_params(const string& key, const string& value); - void apply_params(int i, string value); + void apply_params(const std::string& key, const std::string& value); + void apply_params(int i, std::string value); void sort_params(); int refcount; }; -static string get_type_name(int type) +static std::string get_type_name(int type) { if( type == Param::INT ) return "int"; @@ -56,7 +56,7 @@ static string get_type_name(int type) return "unknown"; } -static void from_str(const string& str, int type, void* dst) +static void from_str(const std::string& str, int type, void* dst) { std::stringstream ss(str); if( type == Param::INT ) @@ -70,20 +70,20 @@ static void from_str(const string& str, int type, void* dst) else if( type == Param::REAL ) ss >> *(double*)dst; else if( type == Param::STRING ) - *(string*)dst = str; + *(std::string*)dst = str; else throw cv::Exception(CV_StsBadArg, "unknown/unsupported parameter type", "", __FILE__, __LINE__); if (ss.fail()) { - string err_msg = "can not convert: [" + str + + std::string err_msg = "can not convert: [" + str + + "] to [" + get_type_name(type) + "]"; throw cv::Exception(CV_StsBadArg, err_msg, "", __FILE__, __LINE__); } } -void CommandLineParser::getByName(const string& name, bool space_delete, int type, void* dst) const +void CommandLineParser::getByName(const std::string& name, bool space_delete, int type, void* dst) const { try { @@ -93,7 +93,7 @@ void CommandLineParser::getByName(const string& name, bool space_delete, int typ { if (name.compare(impl->data[i].keys[j]) == 0) { - string v = impl->data[i].def_value; + std::string v = impl->data[i].def_value; if (space_delete) v = impl->cat_string(v); from_str(v, type, dst); @@ -107,7 +107,7 @@ void CommandLineParser::getByName(const string& name, bool space_delete, int typ catch (std::exception& e) { impl->error = true; - impl->error_message += "Exception: " + string(e.what()) + "\n"; + impl->error_message += "Exception: " + std::string(e.what()) + "\n"; } } @@ -120,7 +120,7 @@ void CommandLineParser::getByIndex(int index, bool space_delete, int type, void* { if (impl->data[i].number == index) { - string v = impl->data[i].def_value; + std::string v = impl->data[i].def_value; if (space_delete == true) v = impl->cat_string(v); from_str(v, type, dst); return; @@ -132,7 +132,7 @@ void CommandLineParser::getByIndex(int index, bool space_delete, int type, void* catch(std::exception & e) { impl->error = true; - impl->error_message += "Exception: " + string(e.what()) + "\n"; + impl->error_message += "Exception: " + std::string(e.what()) + "\n"; } } @@ -152,34 +152,34 @@ static bool cmp_params(const CommandLineParserParams & p1, const CommandLinePars return true; } -CommandLineParser::CommandLineParser(int argc, const char* const argv[], const string& keys) +CommandLineParser::CommandLineParser(int argc, const char* const argv[], const std::string& keys) { impl = new Impl; impl->refcount = 1; // path to application - size_t pos_s = string(argv[0]).find_last_of("/\\"); - if (pos_s == string::npos) + size_t pos_s = std::string(argv[0]).find_last_of("/\\"); + if (pos_s == std::string::npos) { impl->path_to_app = ""; - impl->app_name = string(argv[0]); + impl->app_name = std::string(argv[0]); } else { - impl->path_to_app = string(argv[0]).substr(0, pos_s); - impl->app_name = string(argv[0]).substr(pos_s + 1, string(argv[0]).length() - pos_s); + impl->path_to_app = std::string(argv[0]).substr(0, pos_s); + impl->app_name = std::string(argv[0]).substr(pos_s + 1, std::string(argv[0]).length() - pos_s); } impl->error = false; impl->error_message = ""; // parse keys - vector k = impl->split_range_string(keys, '{', '}'); + std::vector k = impl->split_range_string(keys, '{', '}'); int jj = 0; for (size_t i = 0; i < k.size(); i++) { - vector l = impl->split_string(k[i], '|', true); + std::vector l = impl->split_string(k[i], '|', true); CommandLineParserParams p; p.keys = impl->split_string(l[0]); p.def_value = l[1]; @@ -206,11 +206,11 @@ CommandLineParser::CommandLineParser(int argc, const char* const argv[], const s jj = 0; for (int i = 1; i < argc; i++) { - string s = string(argv[i]); + std::string s = std::string(argv[i]); - if (s.find('=') != string::npos && s.find('=') < s.length()) + if (s.find('=') != std::string::npos && s.find('=') < s.length()) { - vector k_v = impl->split_string(s, '=', true); + std::vector k_v = impl->split_string(s, '=', true); for (int h = 0; h < 2; h++) { if (k_v[0][0] == '-') @@ -256,12 +256,12 @@ CommandLineParser& CommandLineParser::operator = (const CommandLineParser& parse return *this; } -void CommandLineParser::about(const string& message) +void CommandLineParser::about(const std::string& message) { impl->about_message = message; } -void CommandLineParser::Impl::apply_params(const string& key, const string& value) +void CommandLineParser::Impl::apply_params(const std::string& key, const std::string& value) { for (size_t i = 0; i < data.size(); i++) { @@ -276,7 +276,7 @@ void CommandLineParser::Impl::apply_params(const string& key, const string& valu } } -void CommandLineParser::Impl::apply_params(int i, string value) +void CommandLineParser::Impl::apply_params(int i, std::string value) { for (size_t j = 0; j < data.size(); j++) { @@ -298,28 +298,28 @@ void CommandLineParser::Impl::sort_params() std::sort (data.begin(), data.end(), cmp_params); } -string CommandLineParser::Impl::cat_string(const string& str) const +std::string CommandLineParser::Impl::cat_string(const std::string& str) const { int left = 0, right = (int)str.length(); while( left <= right && str[left] == ' ' ) left++; while( right > left && str[right-1] == ' ' ) right--; - return left >= right ? string("") : str.substr(left, right-left); + return left >= right ? std::string("") : str.substr(left, right-left); } -string CommandLineParser::getPathToApplication() const +std::string CommandLineParser::getPathToApplication() const { return impl->path_to_app; } -bool CommandLineParser::has(const string& name) const +bool CommandLineParser::has(const std::string& name) const { for (size_t i = 0; i < impl->data.size(); i++) { for (size_t j = 0; j < impl->data[i].keys.size(); j++) { - if (name.compare(impl->data[i].keys[j]) == 0 && string("true").compare(impl->data[i].def_value) == 0) + if (name.compare(impl->data[i].keys[j]) == 0 && std::string("true").compare(impl->data[i].def_value) == 0) { return true; } @@ -352,7 +352,7 @@ void CommandLineParser::printMessage() const { if (impl->data[i].number > -1) { - string name = impl->data[i].keys[0].substr(1, impl->data[i].keys[0].length() - 1); + std::string name = impl->data[i].keys[0].substr(1, impl->data[i].keys[0].length() - 1); std::cout << name << " "; } } @@ -366,7 +366,7 @@ void CommandLineParser::printMessage() const std::cout << "\t"; for (size_t j = 0; j < impl->data[i].keys.size(); j++) { - string k = impl->data[i].keys[j]; + std::string k = impl->data[i].keys[j]; if (k.length() > 1) { std::cout << "--"; @@ -382,7 +382,7 @@ void CommandLineParser::printMessage() const std::cout << ", "; } } - string dv = impl->cat_string(impl->data[i].def_value); + std::string dv = impl->cat_string(impl->data[i].def_value); if (dv.compare("") != 0) { std::cout << " (value:" << dv << ")"; @@ -397,12 +397,12 @@ void CommandLineParser::printMessage() const if (impl->data[i].number != -1) { std::cout << "\t"; - string k = impl->data[i].keys[0]; + std::string k = impl->data[i].keys[0]; k = k.substr(1, k.length() - 1); std::cout << k; - string dv = impl->cat_string(impl->data[i].def_value); + std::string dv = impl->cat_string(impl->data[i].def_value); if (dv.compare("") != 0) { std::cout << " (value:" << dv << ")"; @@ -412,11 +412,11 @@ void CommandLineParser::printMessage() const } } -vector CommandLineParser::Impl::split_range_string(const string& _str, char fs, char ss) const +std::vector CommandLineParser::Impl::split_range_string(const std::string& _str, char fs, char ss) const { - string str = _str; - vector vec; - string word = ""; + std::string str = _str; + std::vector vec; + std::string word = ""; bool begin = false; while (!str.empty()) @@ -426,13 +426,13 @@ vector CommandLineParser::Impl::split_range_string(const string& _str, c if (begin == true) { throw cv::Exception(CV_StsParseError, - string("error in split_range_string(") + std::string("error in split_range_string(") + str - + string(", ") - + string(1, fs) - + string(", ") - + string(1, ss) - + string(")"), + + std::string(", ") + + std::string(1, fs) + + std::string(", ") + + std::string(1, ss) + + std::string(")"), "", __FILE__, __LINE__ ); } @@ -446,13 +446,13 @@ vector CommandLineParser::Impl::split_range_string(const string& _str, c if (begin == false) { throw cv::Exception(CV_StsParseError, - string("error in split_range_string(") + std::string("error in split_range_string(") + str - + string(", ") - + string(1, fs) - + string(", ") - + string(1, ss) - + string(")"), + + std::string(", ") + + std::string(1, fs) + + std::string(", ") + + std::string(1, ss) + + std::string(")"), "", __FILE__, __LINE__ ); } @@ -470,13 +470,13 @@ vector CommandLineParser::Impl::split_range_string(const string& _str, c if (begin == true) { throw cv::Exception(CV_StsParseError, - string("error in split_range_string(") + std::string("error in split_range_string(") + str - + string(", ") - + string(1, fs) - + string(", ") - + string(1, ss) - + string(")"), + + std::string(", ") + + std::string(1, fs) + + std::string(", ") + + std::string(1, ss) + + std::string(")"), "", __FILE__, __LINE__ ); } @@ -484,11 +484,11 @@ vector CommandLineParser::Impl::split_range_string(const string& _str, c return vec; } -vector CommandLineParser::Impl::split_string(const string& _str, char symbol, bool create_empty_item) const +std::vector CommandLineParser::Impl::split_string(const std::string& _str, char symbol, bool create_empty_item) const { - string str = _str; - vector vec; - string word = ""; + std::string str = _str; + std::vector vec; + std::string word = ""; while (!str.empty()) { diff --git a/modules/core/src/convert.cpp b/modules/core/src/convert.cpp index 439d4c1a9..d8ef88151 100644 --- a/modules/core/src/convert.cpp +++ b/modules/core/src/convert.cpp @@ -344,7 +344,7 @@ void cv::merge(const Mat* mv, size_t n, OutputArray _dst) void cv::merge(InputArrayOfArrays _mv, OutputArray _dst) { - vector mv; + std::vector mv; _mv.getMatVector(mv); merge(!mv.empty() ? &mv[0] : 0, mv.size(), _dst); } @@ -505,7 +505,7 @@ void cv::mixChannels( const Mat* src, size_t nsrcs, Mat* dst, size_t ndsts, cons } -void cv::mixChannels(const vector& src, vector& dst, +void cv::mixChannels(const std::vector& src, std::vector& dst, const int* fromTo, size_t npairs) { mixChannels(!src.empty() ? &src[0] : 0, src.size(), @@ -513,7 +513,7 @@ void cv::mixChannels(const vector& src, vector& dst, } void cv::mixChannels(InputArrayOfArrays src, InputArrayOfArrays dst, - const vector& fromTo) + const std::vector& fromTo) { if(fromTo.empty()) return; @@ -1247,8 +1247,8 @@ cvSplit( const void* srcarr, void* dstarr0, void* dstarr1, void* dstarr2, void* for( i = 0; i < 4; i++ ) nz += dptrs[i] != 0; CV_Assert( nz > 0 ); - cv::vector dvec(nz); - cv::vector pairs(nz*2); + std::vector dvec(nz); + std::vector pairs(nz*2); for( i = j = 0; i < 4; i++ ) { @@ -1283,8 +1283,8 @@ cvMerge( const void* srcarr0, const void* srcarr1, const void* srcarr2, for( i = 0; i < 4; i++ ) nz += sptrs[i] != 0; CV_Assert( nz > 0 ); - cv::vector svec(nz); - cv::vector pairs(nz*2); + std::vector svec(nz); + std::vector pairs(nz*2); for( i = j = 0; i < 4; i++ ) { diff --git a/modules/core/src/datastructs.cpp b/modules/core/src/datastructs.cpp index 9438fa276..c927c9e22 100644 --- a/modules/core/src/datastructs.cpp +++ b/modules/core/src/datastructs.cpp @@ -3643,7 +3643,7 @@ void KDTree::build(InputArray __points, InputArray __labels, bool _copyData) { Mat _points = __points.getMat(), _labels = __labels.getMat(); CV_Assert(_points.type() == CV_32F && !_points.empty()); - vector().swap(nodes); + std::vector().swap(nodes); if( !_copyData ) points = _points; @@ -3672,7 +3672,7 @@ void KDTree::build(InputArray __points, InputArray __labels, bool _copyData) Mat sumstack(MAX_TREE_DEPTH*2, ptdims*2, CV_64F); SubTree stack[MAX_TREE_DEPTH*2]; - vector _ptofs(n); + std::vector _ptofs(n); size_t* ptofs = &_ptofs[0]; for( i = 0; i < n; i++ ) @@ -3909,7 +3909,7 @@ void KDTree::findOrthoRange(InputArray _lowerBound, const float* L = lowerBound.ptr(); const float* R = upperBound.ptr(); - vector idx; + std::vector idx; AutoBuffer _stack(MAX_TREE_DEPTH*2 + 1); int* stack = _stack; int top = 0; diff --git a/modules/core/src/drawing.cpp b/modules/core/src/drawing.cpp index 50e51fb33..8850c6ec4 100644 --- a/modules/core/src/drawing.cpp +++ b/modules/core/src/drawing.cpp @@ -57,11 +57,11 @@ struct PolyEdge static void CollectPolyEdges( Mat& img, const Point* v, int npts, - vector& edges, const void* color, int line_type, + std::vector& edges, const void* color, int line_type, int shift, Point offset=Point() ); static void -FillEdgeCollection( Mat& img, vector& edges, const void* color ); +FillEdgeCollection( Mat& img, std::vector& edges, const void* color ); static void PolyLine( Mat& img, const Point* v, int npts, bool closed, @@ -835,7 +835,7 @@ sincos( int angle, float& cosval, float& sinval ) */ void ellipse2Poly( Point center, Size axes, int angle, int arc_start, int arc_end, - int delta, vector& pts ) + int delta, std::vector& pts ) { float alpha, beta; double size_a = axes.width, size_b = axes.height; @@ -904,7 +904,7 @@ EllipseEx( Mat& img, Point center, Size axes, int delta = (std::max(axes.width,axes.height)+(XY_ONE>>1))>>XY_SHIFT; delta = delta < 3 ? 90 : delta < 10 ? 30 : delta < 15 ? 18 : 5; - vector v; + std::vector v; ellipse2Poly( center, axes, angle, arc_start, arc_end, delta, v ); if( thickness >= 0 ) @@ -914,7 +914,7 @@ EllipseEx( Mat& img, Point center, Size axes, else { v.push_back(center); - vector edges; + std::vector edges; CollectPolyEdges( img, &v[0], (int)v.size(), edges, color, line_type, XY_SHIFT ); FillEdgeCollection( img, edges, color ); } @@ -1104,7 +1104,7 @@ FillConvexPoly( Mat& img, const Point* v, int npts, const void* color, int line_ /******** Arbitrary polygon **********/ static void -CollectPolyEdges( Mat& img, const Point* v, int count, vector& edges, +CollectPolyEdges( Mat& img, const Point* v, int count, std::vector& edges, const void* color, int line_type, int shift, Point offset ) { int i, delta = offset.y + (shift ? 1 << (shift - 1) : 0); @@ -1170,7 +1170,7 @@ struct CmpEdges /**************** helper macros and functions for sequence/contour processing ***********/ static void -FillEdgeCollection( Mat& img, vector& edges, const void* color ) +FillEdgeCollection( Mat& img, std::vector& edges, const void* color ) { PolyEdge tmp; int i, y, total = (int)edges.size(); @@ -1716,7 +1716,7 @@ void fillPoly( Mat& img, const Point** pts, const int* npts, int ncontours, double buf[4]; scalarToRawData(color, buf, img.type(), 0); - vector edges; + std::vector edges; int i, total = 0; for( i = 0; i < ncontours; i++ ) @@ -1914,7 +1914,7 @@ static const int* getFontData(int fontFace) } -void putText( Mat& img, const string& text, Point org, +void putText( Mat& img, const std::string& text, Point org, int fontFace, double fontScale, Scalar color, int thickness, int line_type, bool bottomLeftOrigin ) @@ -1935,7 +1935,7 @@ void putText( Mat& img, const string& text, Point org, int view_x = org.x << XY_SHIFT; int view_y = (org.y << XY_SHIFT) + base_line*vscale; - vector pts; + std::vector pts; pts.reserve(1 << 10); const char **faces = cv::g_HersheyGlyphs; @@ -1976,7 +1976,7 @@ void putText( Mat& img, const string& text, Point org, } } -Size getTextSize( const string& text, int fontFace, double fontScale, int thickness, int* _base_line) +Size getTextSize( const std::string& text, int fontFace, double fontScale, int thickness, int* _base_line) { Size size; double view_x = 0; @@ -2076,8 +2076,8 @@ using namespace cv; static void addChildContour(InputArrayOfArrays contours, size_t ncontours, const Vec4i* hierarchy, - int i, vector& seq, - vector& block) + int i, std::vector& seq, + std::vector& block) { for( ; i >= 0; i = hierarchy[i][0] ) { @@ -2109,8 +2109,8 @@ void cv::drawContours( InputOutputArray _image, InputArrayOfArrays _contours, size_t ncontours = _contours.total(); size_t i = 0, first = 0, last = ncontours; - vector seq; - vector block; + std::vector seq; + std::vector block; if( !last ) return; @@ -2194,8 +2194,8 @@ cvDrawContours( void* _img, CvSeq* contour, { CvSeq *contour0 = contour, *h_next = 0; CvTreeNodeIterator iterator; - cv::vector edges; - cv::vector pts; + std::vector edges; + std::vector pts; cv::Scalar externalColor = _externalColor, holeColor = _holeColor; cv::Mat img = cv::cvarrToMat(_img); cv::Point offset = _offset; @@ -2318,7 +2318,7 @@ CV_IMPL int cvEllipse2Poly( CvPoint center, CvSize axes, int angle, int arc_start, int arc_end, CvPoint* _pts, int delta ) { - cv::vector pts; + std::vector pts; cv::ellipse2Poly( center, axes, angle, arc_start, arc_end, delta, pts ); memcpy( _pts, &pts[0], pts.size()*sizeof(_pts[0]) ); return (int)pts.size(); diff --git a/modules/core/src/gpumat.cpp b/modules/core/src/gpumat.cpp index a199381b4..899871785 100644 --- a/modules/core/src/gpumat.cpp +++ b/modules/core/src/gpumat.cpp @@ -60,10 +60,6 @@ #endif #endif -using namespace std; -using namespace cv; -using namespace cv::gpu; - //////////////////////////////// Initialization & Info //////////////////////// namespace @@ -73,7 +69,7 @@ namespace public: CudaArch(); - bool builtWith(FeatureSet feature_set) const; + bool builtWith(cv::gpu::FeatureSet feature_set) const; bool hasPtx(int major, int minor) const; bool hasBin(int major, int minor) const; bool hasEqualOrLessPtx(int major, int minor) const; @@ -81,11 +77,11 @@ namespace bool hasEqualOrGreaterBin(int major, int minor) const; private: - static void fromStr(const string& set_as_str, vector& arr); + static void fromStr(const std::string& set_as_str, std::vector& arr); - vector bin; - vector ptx; - vector features; + std::vector bin; + std::vector ptx; + std::vector features; }; const CudaArch cudaArch; @@ -99,19 +95,19 @@ namespace #endif } - bool CudaArch::builtWith(FeatureSet feature_set) const + bool CudaArch::builtWith(cv::gpu::FeatureSet feature_set) const { return !features.empty() && (features.back() >= feature_set); } bool CudaArch::hasPtx(int major, int minor) const { - return find(ptx.begin(), ptx.end(), major * 10 + minor) != ptx.end(); + return std::find(ptx.begin(), ptx.end(), major * 10 + minor) != ptx.end(); } bool CudaArch::hasBin(int major, int minor) const { - return find(bin.begin(), bin.end(), major * 10 + minor) != bin.end(); + return std::find(bin.begin(), bin.end(), major * 10 + minor) != bin.end(); } bool CudaArch::hasEqualOrLessPtx(int major, int minor) const @@ -129,12 +125,12 @@ namespace return !bin.empty() && (bin.back() >= major * 10 + minor); } - void CudaArch::fromStr(const string& set_as_str, vector& arr) + void CudaArch::fromStr(const std::string& set_as_str, std::vector& arr) { - if (set_as_str.find_first_not_of(" ") == string::npos) + if (set_as_str.find_first_not_of(" ") == std::string::npos) return; - istringstream stream(set_as_str); + std::istringstream stream(set_as_str); int cur_value; while (!stream.eof()) @@ -143,7 +139,7 @@ namespace arr.push_back(cur_value); } - sort(arr.begin(), arr.end()); + std::sort(arr.begin(), arr.end()); } } @@ -646,7 +642,7 @@ cv::gpu::GpuMat::GpuMat(const Mat& m) : upload(m); } -GpuMat& cv::gpu::GpuMat::operator = (const GpuMat& m) +cv::gpu::GpuMat& cv::gpu::GpuMat::operator = (const cv::gpu::GpuMat& m) { if (this != &m) { @@ -693,7 +689,7 @@ void cv::gpu::GpuMat::locateROI(Size& wholeSize, Point& ofs) const wholeSize.width = std::max(static_cast((delta2 - step * (wholeSize.height - 1)) / esz), ofs.x + cols); } -GpuMat& cv::gpu::GpuMat::adjustROI(int dtop, int dbottom, int dleft, int dright) +cv::gpu::GpuMat& cv::gpu::GpuMat::adjustROI(int dtop, int dbottom, int dleft, int dright) { Size wholeSize; Point ofs; @@ -719,7 +715,7 @@ GpuMat& cv::gpu::GpuMat::adjustROI(int dtop, int dbottom, int dleft, int dright) return *this; } -GpuMat cv::gpu::GpuMat::reshape(int new_cn, int new_rows) const +cv::gpu::GpuMat cv::gpu::GpuMat::reshape(int new_cn, int new_rows) const { GpuMat hdr = *this; @@ -762,7 +758,7 @@ GpuMat cv::gpu::GpuMat::reshape(int new_cn, int new_rows) const return hdr; } -cv::Mat::Mat(const GpuMat& m) : flags(0), dims(0), rows(0), cols(0), data(0), refcount(0), datastart(0), dataend(0), datalimit(0), allocator(0), size(&rows) +cv::Mat::Mat(const cv::gpu::GpuMat& m) : flags(0), dims(0), rows(0), cols(0), data(0), refcount(0), datastart(0), dataend(0), datalimit(0), allocator(0), size(&rows) { m.download(*this); } @@ -804,7 +800,7 @@ void cv::gpu::ensureSizeIsEnough(int rows, int cols, int type, GpuMat& m) } } -GpuMat cv::gpu::allocMatFromBuf(int rows, int cols, int type, GpuMat &mat) +cv::gpu::GpuMat cv::gpu::allocMatFromBuf(int rows, int cols, int type, GpuMat &mat) { if (!mat.empty() && mat.type() == type && mat.rows >= rows && mat.cols >= cols) return mat(Rect(0, 0, cols, rows)); @@ -818,16 +814,16 @@ namespace public: virtual ~GpuFuncTable() {} - virtual void copy(const Mat& src, GpuMat& dst) const = 0; - virtual void copy(const GpuMat& src, Mat& dst) const = 0; - virtual void copy(const GpuMat& src, GpuMat& dst) const = 0; + virtual void copy(const cv::Mat& src, cv::gpu::GpuMat& dst) const = 0; + virtual void copy(const cv::gpu::GpuMat& src, cv::Mat& dst) const = 0; + virtual void copy(const cv::gpu::GpuMat& src, cv::gpu::GpuMat& dst) const = 0; - virtual void copyWithMask(const GpuMat& src, GpuMat& dst, const GpuMat& mask) const = 0; + virtual void copyWithMask(const cv::gpu::GpuMat& src, cv::gpu::GpuMat& dst, const cv::gpu::GpuMat& mask) const = 0; - virtual void convert(const GpuMat& src, GpuMat& dst) const = 0; - virtual void convert(const GpuMat& src, GpuMat& dst, double alpha, double beta) const = 0; + virtual void convert(const cv::gpu::GpuMat& src, cv::gpu::GpuMat& dst) const = 0; + virtual void convert(const cv::gpu::GpuMat& src, cv::gpu::GpuMat& dst, double alpha, double beta) const = 0; - virtual void setTo(GpuMat& m, Scalar s, const GpuMat& mask) const = 0; + virtual void setTo(cv::gpu::GpuMat& m, cv::Scalar s, const cv::gpu::GpuMat& mask) const = 0; virtual void mallocPitch(void** devPtr, size_t* step, size_t width, size_t height) const = 0; virtual void free(void* devPtr) const = 0; @@ -841,16 +837,16 @@ namespace class EmptyFuncTable : public GpuFuncTable { public: - void copy(const Mat&, GpuMat&) const { CV_Error(CV_GpuNotSupported, "The library is compiled without CUDA support"); } - void copy(const GpuMat&, Mat&) const { CV_Error(CV_GpuNotSupported, "The library is compiled without CUDA support"); } - void copy(const GpuMat&, GpuMat&) const { CV_Error(CV_GpuNotSupported, "The library is compiled without CUDA support"); } + void copy(const cv::Mat&, cv::gpu::GpuMat&) const { CV_Error(CV_GpuNotSupported, "The library is compiled without CUDA support"); } + void copy(const cv::gpu::GpuMat&, cv::Mat&) const { CV_Error(CV_GpuNotSupported, "The library is compiled without CUDA support"); } + void copy(const cv::gpu::GpuMat&, cv::gpu::GpuMat&) const { CV_Error(CV_GpuNotSupported, "The library is compiled without CUDA support"); } - void copyWithMask(const GpuMat&, GpuMat&, const GpuMat&) const { CV_Error(CV_GpuNotSupported, "The library is compiled without CUDA support"); } + void copyWithMask(const cv::gpu::GpuMat&, cv::gpu::GpuMat&, const cv::gpu::GpuMat&) const { CV_Error(CV_GpuNotSupported, "The library is compiled without CUDA support"); } - void convert(const GpuMat&, GpuMat&) const { CV_Error(CV_GpuNotSupported, "The library is compiled without CUDA support"); } - void convert(const GpuMat&, GpuMat&, double, double) const { CV_Error(CV_GpuNotSupported, "The library is compiled without CUDA support"); } + void convert(const cv::gpu::GpuMat&, cv::gpu::GpuMat&) const { CV_Error(CV_GpuNotSupported, "The library is compiled without CUDA support"); } + void convert(const cv::gpu::GpuMat&, cv::gpu::GpuMat&, double, double) const { CV_Error(CV_GpuNotSupported, "The library is compiled without CUDA support"); } - void setTo(GpuMat&, Scalar, const GpuMat&) const { CV_Error(CV_GpuNotSupported, "The library is compiled without CUDA support"); } + void setTo(cv::gpu::GpuMat&, cv::Scalar, const cv::gpu::GpuMat&) const { CV_Error(CV_GpuNotSupported, "The library is compiled without CUDA support"); } void mallocPitch(void**, size_t*, size_t, size_t) const { CV_Error(CV_GpuNotSupported, "The library is compiled without CUDA support"); } void free(void*) const {} @@ -880,15 +876,15 @@ namespace cv { namespace gpu { namespace device namespace { - template void kernelSetCaller(GpuMat& src, Scalar s, cudaStream_t stream) + template void kernelSetCaller(cv::gpu::GpuMat& src, cv::Scalar s, cudaStream_t stream) { - Scalar_ sf = s; + cv::Scalar_ sf = s; cv::gpu::device::set_to_gpu(src, sf.val, src.channels(), stream); } - template void kernelSetCaller(GpuMat& src, Scalar s, const GpuMat& mask, cudaStream_t stream) + template void kernelSetCaller(cv::gpu::GpuMat& src, cv::Scalar s, const cv::gpu::GpuMat& mask, cudaStream_t stream) { - Scalar_ sf = s; + cv::Scalar_ sf = s; cv::gpu::device::set_to_gpu(src, sf.val, mask, src.channels(), stream); } } @@ -996,7 +992,7 @@ namespace typedef typename NPPTypeTraits::npp_type src_t; typedef typename NPPTypeTraits::npp_type dst_t; - static void call(const GpuMat& src, GpuMat& dst) + static void call(const cv::gpu::GpuMat& src, cv::gpu::GpuMat& dst) { NppiSize sz; sz.width = src.cols; @@ -1011,7 +1007,7 @@ namespace { typedef typename NPPTypeTraits::npp_type dst_t; - static void call(const GpuMat& src, GpuMat& dst) + static void call(const cv::gpu::GpuMat& src, cv::gpu::GpuMat& dst) { NppiSize sz; sz.width = src.cols; @@ -1051,13 +1047,13 @@ namespace { typedef typename NPPTypeTraits::npp_type src_t; - static void call(GpuMat& src, Scalar s) + static void call(cv::gpu::GpuMat& src, cv::Scalar s) { NppiSize sz; sz.width = src.cols; sz.height = src.rows; - Scalar_ nppS = s; + cv::Scalar_ nppS = s; nppSafeCall( func(nppS.val, src.ptr(), static_cast(src.step), sz) ); @@ -1068,13 +1064,13 @@ namespace { typedef typename NPPTypeTraits::npp_type src_t; - static void call(GpuMat& src, Scalar s) + static void call(cv::gpu::GpuMat& src, cv::Scalar s) { NppiSize sz; sz.width = src.cols; sz.height = src.rows; - Scalar_ nppS = s; + cv::Scalar_ nppS = s; nppSafeCall( func(nppS[0], src.ptr(), static_cast(src.step), sz) ); @@ -1099,13 +1095,13 @@ namespace { typedef typename NPPTypeTraits::npp_type src_t; - static void call(GpuMat& src, Scalar s, const GpuMat& mask) + static void call(cv::gpu::GpuMat& src, cv::Scalar s, const cv::gpu::GpuMat& mask) { NppiSize sz; sz.width = src.cols; sz.height = src.rows; - Scalar_ nppS = s; + cv::Scalar_ nppS = s; nppSafeCall( func(nppS.val, src.ptr(), static_cast(src.step), sz, mask.ptr(), static_cast(mask.step)) ); @@ -1116,13 +1112,13 @@ namespace { typedef typename NPPTypeTraits::npp_type src_t; - static void call(GpuMat& src, Scalar s, const GpuMat& mask) + static void call(cv::gpu::GpuMat& src, cv::Scalar s, const cv::gpu::GpuMat& mask) { NppiSize sz; sz.width = src.cols; sz.height = src.rows; - Scalar_ nppS = s; + cv::Scalar_ nppS = s; nppSafeCall( func(nppS[0], src.ptr(), static_cast(src.step), sz, mask.ptr(), static_cast(mask.step)) ); @@ -1144,7 +1140,7 @@ namespace { typedef typename NPPTypeTraits::npp_type src_t; - static void call(const GpuMat& src, GpuMat& dst, const GpuMat& mask, cudaStream_t /*stream*/) + static void call(const cv::gpu::GpuMat& src, cv::gpu::GpuMat& dst, const cv::gpu::GpuMat& mask, cudaStream_t /*stream*/) { NppiSize sz; sz.width = src.cols; @@ -1167,20 +1163,20 @@ namespace class CudaFuncTable : public GpuFuncTable { public: - void copy(const Mat& src, GpuMat& dst) const + void copy(const cv::Mat& src, cv::gpu::GpuMat& dst) const { cudaSafeCall( cudaMemcpy2D(dst.data, dst.step, src.data, src.step, src.cols * src.elemSize(), src.rows, cudaMemcpyHostToDevice) ); } - void copy(const GpuMat& src, Mat& dst) const + void copy(const cv::gpu::GpuMat& src, cv::Mat& dst) const { cudaSafeCall( cudaMemcpy2D(dst.data, dst.step, src.data, src.step, src.cols * src.elemSize(), src.rows, cudaMemcpyDeviceToHost) ); } - void copy(const GpuMat& src, GpuMat& dst) const + void copy(const cv::gpu::GpuMat& src, cv::gpu::GpuMat& dst) const { cudaSafeCall( cudaMemcpy2D(dst.data, dst.step, src.data, src.step, src.cols * src.elemSize(), src.rows, cudaMemcpyDeviceToDevice) ); } - void copyWithMask(const GpuMat& src, GpuMat& dst, const GpuMat& mask) const + void copyWithMask(const cv::gpu::GpuMat& src, cv::gpu::GpuMat& dst, const cv::gpu::GpuMat& mask) const { CV_Assert(src.depth() <= CV_64F && src.channels() <= 4); CV_Assert(src.size() == dst.size() && src.type() == dst.type()); @@ -1188,11 +1184,11 @@ namespace if (src.depth() == CV_64F) { - if (!TargetArchs::builtWith(NATIVE_DOUBLE) || !DeviceInfo().supports(NATIVE_DOUBLE)) + if (!cv::gpu::TargetArchs::builtWith(cv::gpu::NATIVE_DOUBLE) || !cv::gpu::DeviceInfo().supports(cv::gpu::NATIVE_DOUBLE)) CV_Error(CV_StsUnsupportedFormat, "The device doesn't support double"); } - typedef void (*func_t)(const GpuMat& src, GpuMat& dst, const GpuMat& mask, cudaStream_t stream); + typedef void (*func_t)(const cv::gpu::GpuMat& src, cv::gpu::GpuMat& dst, const cv::gpu::GpuMat& mask, cudaStream_t stream); static const func_t funcs[7][4] = { /* 8U */ {NppCopyMasked::call, cv::gpu::copyWithMask, NppCopyMasked::call, NppCopyMasked::call}, @@ -1209,9 +1205,9 @@ namespace func(src, dst, mask, 0); } - void convert(const GpuMat& src, GpuMat& dst) const + void convert(const cv::gpu::GpuMat& src, cv::gpu::GpuMat& dst) const { - typedef void (*func_t)(const GpuMat& src, GpuMat& dst); + typedef void (*func_t)(const cv::gpu::GpuMat& src, cv::gpu::GpuMat& dst); static const func_t funcs[7][7][4] = { { @@ -1285,7 +1281,7 @@ namespace if (src.depth() == CV_64F || dst.depth() == CV_64F) { - if (!TargetArchs::builtWith(NATIVE_DOUBLE) || !DeviceInfo().supports(NATIVE_DOUBLE)) + if (!cv::gpu::TargetArchs::builtWith(cv::gpu::NATIVE_DOUBLE) || !cv::gpu::DeviceInfo().supports(cv::gpu::NATIVE_DOUBLE)) CV_Error(CV_StsUnsupportedFormat, "The device doesn't support double"); } @@ -1302,21 +1298,21 @@ namespace func(src, dst); } - void convert(const GpuMat& src, GpuMat& dst, double alpha, double beta) const + void convert(const cv::gpu::GpuMat& src, cv::gpu::GpuMat& dst, double alpha, double beta) const { CV_Assert(src.depth() <= CV_64F && src.channels() <= 4); CV_Assert(dst.depth() <= CV_64F); if (src.depth() == CV_64F || dst.depth() == CV_64F) { - if (!TargetArchs::builtWith(NATIVE_DOUBLE) || !DeviceInfo().supports(NATIVE_DOUBLE)) + if (!cv::gpu::TargetArchs::builtWith(cv::gpu::NATIVE_DOUBLE) || !cv::gpu::DeviceInfo().supports(cv::gpu::NATIVE_DOUBLE)) CV_Error(CV_StsUnsupportedFormat, "The device doesn't support double"); } cv::gpu::convertTo(src, dst, alpha, beta); } - void setTo(GpuMat& m, Scalar s, const GpuMat& mask) const + void setTo(cv::gpu::GpuMat& m, cv::Scalar s, const cv::gpu::GpuMat& mask) const { if (mask.empty()) { @@ -1332,13 +1328,13 @@ namespace if (cn == 1 || (cn == 2 && s[0] == s[1]) || (cn == 3 && s[0] == s[1] && s[0] == s[2]) || (cn == 4 && s[0] == s[1] && s[0] == s[2] && s[0] == s[3])) { - int val = saturate_cast(s[0]); + int val = cv::saturate_cast(s[0]); cudaSafeCall( cudaMemset2D(m.data, m.step, val, m.cols * m.elemSize(), m.rows) ); return; } } - typedef void (*func_t)(GpuMat& src, Scalar s); + typedef void (*func_t)(cv::gpu::GpuMat& src, cv::Scalar s); static const func_t funcs[7][4] = { {NppSet::call, cv::gpu::setTo , cv::gpu::setTo , NppSet::call}, @@ -1354,7 +1350,7 @@ namespace if (m.depth() == CV_64F) { - if (!TargetArchs::builtWith(NATIVE_DOUBLE) || !DeviceInfo().supports(NATIVE_DOUBLE)) + if (!cv::gpu::TargetArchs::builtWith(cv::gpu::NATIVE_DOUBLE) || !cv::gpu::DeviceInfo().supports(cv::gpu::NATIVE_DOUBLE)) CV_Error(CV_StsUnsupportedFormat, "The device doesn't support double"); } @@ -1362,7 +1358,7 @@ namespace } else { - typedef void (*func_t)(GpuMat& src, Scalar s, const GpuMat& mask); + typedef void (*func_t)(cv::gpu::GpuMat& src, cv::Scalar s, const cv::gpu::GpuMat& mask); static const func_t funcs[7][4] = { {NppSetMask::call, cv::gpu::setTo, cv::gpu::setTo, NppSetMask::call}, @@ -1378,7 +1374,7 @@ namespace if (m.depth() == CV_64F) { - if (!TargetArchs::builtWith(NATIVE_DOUBLE) || !DeviceInfo().supports(NATIVE_DOUBLE)) + if (!cv::gpu::TargetArchs::builtWith(cv::gpu::NATIVE_DOUBLE) || !cv::gpu::DeviceInfo().supports(cv::gpu::NATIVE_DOUBLE)) CV_Error(CV_StsUnsupportedFormat, "The device doesn't support double"); } @@ -1406,7 +1402,7 @@ namespace #endif // HAVE_CUDA -void cv::gpu::GpuMat::upload(const Mat& m) +void cv::gpu::GpuMat::upload(const cv::Mat& m) { CV_DbgAssert(!m.empty()); @@ -1415,7 +1411,7 @@ void cv::gpu::GpuMat::upload(const Mat& m) gpuFuncTable()->copy(m, *this); } -void cv::gpu::GpuMat::download(Mat& m) const +void cv::gpu::GpuMat::download(cv::Mat& m) const { CV_DbgAssert(!empty()); @@ -1424,7 +1420,7 @@ void cv::gpu::GpuMat::download(Mat& m) const gpuFuncTable()->copy(*this, m); } -void cv::gpu::GpuMat::copyTo(GpuMat& m) const +void cv::gpu::GpuMat::copyTo(cv::gpu::GpuMat& m) const { CV_DbgAssert(!empty()); @@ -1433,7 +1429,7 @@ void cv::gpu::GpuMat::copyTo(GpuMat& m) const gpuFuncTable()->copy(*this, m); } -void cv::gpu::GpuMat::copyTo(GpuMat& mat, const GpuMat& mask) const +void cv::gpu::GpuMat::copyTo(cv::gpu::GpuMat& mat, const cv::gpu::GpuMat& mask) const { if (mask.empty()) copyTo(mat); @@ -1445,9 +1441,9 @@ void cv::gpu::GpuMat::copyTo(GpuMat& mat, const GpuMat& mask) const } } -void cv::gpu::GpuMat::convertTo(GpuMat& dst, int rtype, double alpha, double beta) const +void cv::gpu::GpuMat::convertTo(cv::gpu::GpuMat& dst, int rtype, double alpha, double beta) const { - bool noScale = fabs(alpha - 1) < numeric_limits::epsilon() && fabs(beta) < numeric_limits::epsilon(); + bool noScale = fabs(alpha - 1) < std::numeric_limits::epsilon() && fabs(beta) < std::numeric_limits::epsilon(); if (rtype < 0) rtype = type(); @@ -1462,8 +1458,8 @@ void cv::gpu::GpuMat::convertTo(GpuMat& dst, int rtype, double alpha, double bet return; } - GpuMat temp; - const GpuMat* psrc = this; + cv::gpu::GpuMat temp; + const cv::gpu::GpuMat* psrc = this; if (sdepth != ddepth && psrc == &dst) { temp = *this; @@ -1478,7 +1474,7 @@ void cv::gpu::GpuMat::convertTo(GpuMat& dst, int rtype, double alpha, double bet gpuFuncTable()->convert(*psrc, dst, alpha, beta); } -GpuMat& cv::gpu::GpuMat::setTo(Scalar s, const GpuMat& mask) +cv::gpu::GpuMat& cv::gpu::GpuMat::setTo(cv::Scalar s, const cv::gpu::GpuMat& mask) { CV_Assert(mask.empty() || mask.type() == CV_8UC1); CV_DbgAssert(!empty()); @@ -1502,7 +1498,7 @@ void cv::gpu::GpuMat::create(int _rows, int _cols, int _type) if (_rows > 0 && _cols > 0) { - flags = Mat::MAGIC_VAL + _type; + flags = cv::Mat::MAGIC_VAL + _type; rows = _rows; cols = _cols; @@ -1516,7 +1512,7 @@ void cv::gpu::GpuMat::create(int _rows, int _cols, int _type) step = esz * cols; if (esz * cols == step) - flags |= Mat::CONTINUOUS_FLAG; + flags |= cv::Mat::CONTINUOUS_FLAG; int64 _nettosize = static_cast(step) * rows; size_t nettosize = static_cast(_nettosize); @@ -1550,13 +1546,13 @@ void cv::gpu::error(const char *error_string, const char *file, const int line, { int code = CV_GpuApiCallError; - if (uncaught_exception()) + if (std::uncaught_exception()) { const char* errorStr = cvErrorStr(code); const char* function = func ? func : "unknown function"; - cerr << "OpenCV Error: " << errorStr << "(" << error_string << ") in " << function << ", file " << file << ", line " << line; - cerr.flush(); + std::cerr << "OpenCV Error: " << errorStr << "(" << error_string << ") in " << function << ", file " << file << ", line " << line; + std::cerr.flush(); } else cv::error( cv::Exception(code, error_string, func, file, line) ); diff --git a/modules/core/src/mathfuncs.cpp b/modules/core/src/mathfuncs.cpp index 42b76a5f5..8e76d7235 100644 --- a/modules/core/src/mathfuncs.cpp +++ b/modules/core/src/mathfuncs.cpp @@ -1991,7 +1991,7 @@ void pow( InputArray _src, double power, OutputArray _dst ) void sqrt(InputArray a, OutputArray b) { - pow(a, 0.5, b); + cv::pow(a, 0.5, b); } /************************** CheckArray for NaN's, Inf's *********************************/ @@ -2396,7 +2396,7 @@ int cv::solveCubic( InputArray _coeffs, OutputArray _roots ) double d = a2*a2 - 4*a1*a3; if( d >= 0 ) { - d = sqrt(d); + d = std::sqrt(d); double q1 = (-a2 + d) * 0.5; double q2 = (a2 + d) * -0.5; if( fabs(q1) > fabs(q2) ) @@ -2427,8 +2427,8 @@ int cv::solveCubic( InputArray _coeffs, OutputArray _roots ) if( d >= 0 ) { - double theta = acos(R / sqrt(Qcubed)); - double sqrtQ = sqrt(Q); + double theta = acos(R / std::sqrt(Qcubed)); + double sqrtQ = std::sqrt(Q); double t0 = -2 * sqrtQ; double t1 = theta * (1./3); double t2 = a1 * (1./3); @@ -2440,8 +2440,8 @@ int cv::solveCubic( InputArray _coeffs, OutputArray _roots ) else { double e; - d = sqrt(-d); - e = pow(d + fabs(R), 0.333333333333); + d = std::sqrt(-d); + e = std::pow(d + fabs(R), 0.333333333333); if( R > 0 ) e = -e; x0 = (e + Q / e) - a1 * (1./3); @@ -2519,7 +2519,7 @@ double cv::solvePoly( InputArray _coeffs0, OutputArray _roots0, int maxIters ) } num /= denom; roots[i] = p - num; - maxDiff = max(maxDiff, abs(num)); + maxDiff = std::max(maxDiff, cv::abs(num)); } if( maxDiff <= 0 ) break; diff --git a/modules/core/src/matmul.cpp b/modules/core/src/matmul.cpp index 00bf0826d..6b075a5b8 100644 --- a/modules/core/src/matmul.cpp +++ b/modules/core/src/matmul.cpp @@ -2151,7 +2151,7 @@ void cv::calcCovarMatrix( InputArray _src, OutputArray _covar, InputOutputArray Mat _data(static_cast(src.size()), size.area(), type); int i = 0; - for(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/core/src/matrix.cpp b/modules/core/src/matrix.cpp index 86b68ef4c..0528ce212 100644 --- a/modules/core/src/matrix.cpp +++ b/modules/core/src/matrix.cpp @@ -931,7 +931,7 @@ void scalarToRawData(const Scalar& s, void* _buf, int type, int unroll_to) _InputArray::_InputArray() : flags(0), obj(0) {} _InputArray::~_InputArray() {} _InputArray::_InputArray(const Mat& m) : flags(MAT), obj((void*)&m) {} -_InputArray::_InputArray(const vector& vec) : flags(STD_VECTOR_MAT), obj((void*)&vec) {} +_InputArray::_InputArray(const std::vector& vec) : flags(STD_VECTOR_MAT), obj((void*)&vec) {} _InputArray::_InputArray(const double& val) : flags(FIXED_TYPE + FIXED_SIZE + MATX + CV_64F), obj((void*)&val), sz(Size(1,1)) {} _InputArray::_InputArray(const MatExpr& expr) : flags(FIXED_TYPE + FIXED_SIZE + EXPR), obj((void*)&expr) {} _InputArray::_InputArray(const GlBuffer& buf) : flags(OPENGL_BUFFER), obj((void*)&buf) {} @@ -966,7 +966,7 @@ Mat _InputArray::getMat(int i) const { CV_Assert( i < 0 ); int t = CV_MAT_TYPE(flags); - const vector& v = *(const vector*)obj; + const std::vector& v = *(const std::vector*)obj; return !v.empty() ? Mat(size(), t, (void*)&v[0]) : Mat(); } @@ -977,9 +977,9 @@ Mat _InputArray::getMat(int i) const if( k == STD_VECTOR_VECTOR ) { int t = type(i); - const vector >& vv = *(const vector >*)obj; + const std::vector >& vv = *(const std::vector >*)obj; CV_Assert( 0 <= i && i < (int)vv.size() ); - const vector& v = vv[i]; + const std::vector& v = vv[i]; return !v.empty() ? Mat(size(i), t, (void*)&v[0]) : Mat(); } @@ -987,7 +987,7 @@ Mat _InputArray::getMat(int i) const CV_Assert( k == STD_VECTOR_MAT ); //if( k == STD_VECTOR_MAT ) { - const vector& v = *(const vector*)obj; + const std::vector& v = *(const std::vector*)obj; CV_Assert( 0 <= i && i < (int)v.size() ); return v[i]; @@ -995,7 +995,7 @@ Mat _InputArray::getMat(int i) const } -void _InputArray::getMatVector(vector& mv) const +void _InputArray::getMatVector(std::vector& mv) const { int k = kind(); @@ -1034,7 +1034,7 @@ void _InputArray::getMatVector(vector& mv) const if( k == STD_VECTOR ) { - const vector& v = *(const vector*)obj; + const std::vector& v = *(const std::vector*)obj; size_t i, n = v.size(), esz = CV_ELEM_SIZE(flags); int t = CV_MAT_DEPTH(flags), cn = CV_MAT_CN(flags); @@ -1053,14 +1053,14 @@ void _InputArray::getMatVector(vector& mv) const if( k == STD_VECTOR_VECTOR ) { - const vector >& vv = *(const vector >*)obj; + const std::vector >& vv = *(const std::vector >*)obj; int i, n = (int)vv.size(); int t = CV_MAT_TYPE(flags); mv.resize(n); for( i = 0; i < n; i++ ) { - const vector& v = vv[i]; + const std::vector& v = vv[i]; mv[i] = Mat(size(i), t, (void*)&v[0]); } return; @@ -1069,7 +1069,7 @@ void _InputArray::getMatVector(vector& mv) const CV_Assert( k == STD_VECTOR_MAT ); //if( k == STD_VECTOR_MAT ) { - const vector& v = *(const vector*)obj; + const std::vector& v = *(const std::vector*)obj; mv.resize(v.size()); std::copy(v.begin(), v.end(), mv.begin()); return; @@ -1142,8 +1142,8 @@ Size _InputArray::size(int i) const if( k == STD_VECTOR ) { CV_Assert( i < 0 ); - const vector& v = *(const vector*)obj; - const vector& iv = *(const vector*)obj; + const std::vector& v = *(const std::vector*)obj; + const std::vector& iv = *(const std::vector*)obj; size_t szb = v.size(), szi = iv.size(); return szb == szi ? Size((int)szb, 1) : Size((int)(szb/CV_ELEM_SIZE(flags)), 1); } @@ -1153,11 +1153,11 @@ Size _InputArray::size(int i) const if( k == STD_VECTOR_VECTOR ) { - const vector >& vv = *(const vector >*)obj; + const std::vector >& vv = *(const std::vector >*)obj; if( i < 0 ) return vv.empty() ? Size() : Size((int)vv.size(), 1); CV_Assert( i < (int)vv.size() ); - const vector >& ivv = *(const vector >*)obj; + const std::vector >& ivv = *(const std::vector >*)obj; size_t szb = vv[i].size(), szi = ivv[i].size(); return szb == szi ? Size((int)szb, 1) : Size((int)(szb/CV_ELEM_SIZE(flags)), 1); @@ -1165,7 +1165,7 @@ Size _InputArray::size(int i) const if( k == STD_VECTOR_MAT ) { - const vector& vv = *(const vector*)obj; + const std::vector& vv = *(const std::vector*)obj; if( i < 0 ) return vv.empty() ? Size() : Size((int)vv.size(), 1); CV_Assert( i < (int)vv.size() ); @@ -1208,7 +1208,7 @@ size_t _InputArray::total(int i) const if( k == STD_VECTOR_MAT ) { - const vector& vv = *(const vector*)obj; + const std::vector& vv = *(const std::vector*)obj; if( i < 0 ) return vv.size(); @@ -1237,7 +1237,7 @@ int _InputArray::type(int i) const if( k == STD_VECTOR_MAT ) { - const vector& vv = *(const vector*)obj; + const std::vector& vv = *(const std::vector*)obj; CV_Assert( i < (int)vv.size() ); return vv[i >= 0 ? i : 0].type(); @@ -1276,7 +1276,7 @@ bool _InputArray::empty() const if( k == STD_VECTOR ) { - const vector& v = *(const vector*)obj; + const std::vector& v = *(const std::vector*)obj; return v.empty(); } @@ -1285,13 +1285,13 @@ bool _InputArray::empty() const if( k == STD_VECTOR_VECTOR ) { - const vector >& vv = *(const vector >*)obj; + const std::vector >& vv = *(const std::vector >*)obj; return vv.empty(); } if( k == STD_VECTOR_MAT ) { - const vector& vv = *(const vector*)obj; + const std::vector& vv = *(const std::vector*)obj; return vv.empty(); } @@ -1310,13 +1310,13 @@ bool _InputArray::empty() const _OutputArray::_OutputArray() {} _OutputArray::~_OutputArray() {} _OutputArray::_OutputArray(Mat& m) : _InputArray(m) {} -_OutputArray::_OutputArray(vector& vec) : _InputArray(vec) {} +_OutputArray::_OutputArray(std::vector& vec) : _InputArray(vec) {} _OutputArray::_OutputArray(gpu::GpuMat& d_mat) : _InputArray(d_mat) {} _OutputArray::_OutputArray(GlBuffer& buf) : _InputArray(buf) {} _OutputArray::_OutputArray(GlTexture2D& tex) : _InputArray(tex) {} _OutputArray::_OutputArray(const Mat& m) : _InputArray(m) {flags |= FIXED_SIZE|FIXED_TYPE;} -_OutputArray::_OutputArray(const vector& vec) : _InputArray(vec) {flags |= FIXED_SIZE;} +_OutputArray::_OutputArray(const std::vector& vec) : _InputArray(vec) {flags |= FIXED_SIZE;} _OutputArray::_OutputArray(const gpu::GpuMat& d_mat) : _InputArray(d_mat) {flags |= FIXED_SIZE|FIXED_TYPE;} _OutputArray::_OutputArray(const GlBuffer& buf) : _InputArray(buf) {flags |= FIXED_SIZE|FIXED_TYPE;} _OutputArray::_OutputArray(const GlTexture2D& tex) : _InputArray(tex) {flags |= FIXED_SIZE|FIXED_TYPE;} @@ -1441,11 +1441,11 @@ void _OutputArray::create(int dims, const int* sizes, int mtype, int i, bool all { CV_Assert( dims == 2 && (sizes[0] == 1 || sizes[1] == 1 || sizes[0]*sizes[1] == 0) ); size_t len = sizes[0]*sizes[1] > 0 ? sizes[0] + sizes[1] - 1 : 0; - vector* v = (vector*)obj; + std::vector* v = (std::vector*)obj; if( k == STD_VECTOR_VECTOR ) { - vector >& vv = *(vector >*)obj; + std::vector >& vv = *(std::vector >*)obj; if( i < 0 ) { CV_Assert(!fixedSize() || len == vv.size()); @@ -1462,56 +1462,56 @@ void _OutputArray::create(int dims, const int* sizes, int mtype, int i, bool all CV_Assert( mtype == type0 || (CV_MAT_CN(mtype) == CV_MAT_CN(type0) && ((1 << type0) & fixedDepthMask) != 0) ); int esz = CV_ELEM_SIZE(type0); - CV_Assert(!fixedSize() || len == ((vector*)v)->size() / esz); + CV_Assert(!fixedSize() || len == ((std::vector*)v)->size() / esz); switch( esz ) { case 1: - ((vector*)v)->resize(len); + ((std::vector*)v)->resize(len); break; case 2: - ((vector*)v)->resize(len); + ((std::vector*)v)->resize(len); break; case 3: - ((vector*)v)->resize(len); + ((std::vector*)v)->resize(len); break; case 4: - ((vector*)v)->resize(len); + ((std::vector*)v)->resize(len); break; case 6: - ((vector*)v)->resize(len); + ((std::vector*)v)->resize(len); break; case 8: - ((vector*)v)->resize(len); + ((std::vector*)v)->resize(len); break; case 12: - ((vector*)v)->resize(len); + ((std::vector*)v)->resize(len); break; case 16: - ((vector*)v)->resize(len); + ((std::vector*)v)->resize(len); break; case 24: - ((vector*)v)->resize(len); + ((std::vector*)v)->resize(len); break; case 32: - ((vector*)v)->resize(len); + ((std::vector*)v)->resize(len); break; case 36: - ((vector >*)v)->resize(len); + ((std::vector >*)v)->resize(len); break; case 48: - ((vector >*)v)->resize(len); + ((std::vector >*)v)->resize(len); break; case 64: - ((vector >*)v)->resize(len); + ((std::vector >*)v)->resize(len); break; case 128: - ((vector >*)v)->resize(len); + ((std::vector >*)v)->resize(len); break; case 256: - ((vector >*)v)->resize(len); + ((std::vector >*)v)->resize(len); break; case 512: - ((vector >*)v)->resize(len); + ((std::vector >*)v)->resize(len); break; default: CV_Error_(CV_StsBadArg, ("Vectors with element size %d are not supported. Please, modify OutputArray::create()\n", esz)); @@ -1528,7 +1528,7 @@ void _OutputArray::create(int dims, const int* sizes, int mtype, int i, bool all CV_Assert( k == STD_VECTOR_MAT ); //if( k == STD_VECTOR_MAT ) { - vector& v = *(vector*)obj; + std::vector& v = *(std::vector*)obj; if( i < 0 ) { @@ -1626,14 +1626,14 @@ void _OutputArray::release() const if( k == STD_VECTOR_VECTOR ) { - ((vector >*)obj)->clear(); + ((std::vector >*)obj)->clear(); return; } CV_Assert( k == STD_VECTOR_MAT ); //if( k == STD_VECTOR_MAT ) { - ((vector*)obj)->clear(); + ((std::vector*)obj)->clear(); } } @@ -1667,7 +1667,7 @@ Mat& _OutputArray::getMatRef(int i) const else { CV_Assert( k == STD_VECTOR_MAT ); - vector& v = *(vector*)obj; + std::vector& v = *(std::vector*)obj; CV_Assert( i < (int)v.size() ); return v[i]; } @@ -1738,7 +1738,7 @@ void cv::hconcat(InputArray src1, InputArray src2, OutputArray dst) void cv::hconcat(InputArray _src, OutputArray dst) { - vector src; + std::vector src; _src.getMatVector(src); hconcat(!src.empty() ? &src[0] : 0, src.size(), dst); } @@ -1778,7 +1778,7 @@ void cv::vconcat(InputArray src1, InputArray src2, OutputArray dst) void cv::vconcat(InputArray _src, OutputArray dst) { - vector src; + std::vector src; _src.getMatVector(src); vconcat(!src.empty() ? &src[0] : 0, src.size(), dst); } @@ -2504,7 +2504,7 @@ void cv::sortIdx( InputArray _src, OutputArray _dst, int flags ) namespace cv { -static void generateRandomCenter(const vector& box, float* center, RNG& rng) +static void generateRandomCenter(const std::vector& box, float* center, RNG& rng) { size_t j, dims = box.size(); float margin = 1.f/dims; @@ -2560,9 +2560,9 @@ static void generateCentersPP(const Mat& _data, Mat& _out_centers, int i, j, k, dims = _data.cols, N = _data.rows; const float* data = _data.ptr(0); size_t step = _data.step/sizeof(data[0]); - vector _centers(K); + std::vector _centers(K); int* centers = &_centers[0]; - vector _dist(N*3); + std::vector _dist(N*3); float* dist = &_dist[0], *tdist = dist + N, *tdist2 = tdist + N; double sum0 = 0; @@ -2710,8 +2710,8 @@ double cv::kmeans( InputArray _data, int K, int* labels = _labels.ptr(); Mat centers(K, dims, type), old_centers(K, dims, type), temp(1, dims, type); - vector counters(K); - vector _box(dims); + std::vector counters(K); + std::vector _box(dims); Vec2f* box = &_box[0]; double best_compactness = DBL_MAX, compactness = 0; RNG& rng = theRNG(); @@ -3973,7 +3973,7 @@ void SparseMat::resizeHashTab(size_t newsize) newsize = (size_t)1 << cvCeil(std::log((double)newsize)/CV_LOG2); size_t i, hsize = hdr->hashtab.size(); - vector _newh(newsize); + std::vector _newh(newsize); size_t* newh = &_newh[0]; for( i = 0; i < newsize; i++ ) newh[i] = 0; @@ -4062,7 +4062,7 @@ SparseMatConstIterator::SparseMatConstIterator(const SparseMat* _m) if(!_m || !_m->hdr) return; SparseMat::Hdr& hdr = *m->hdr; - const vector& htab = hdr.hashtab; + const std::vector& htab = hdr.hashtab; size_t i, hsize = htab.size(); for( i = 0; i < hsize; i++ ) { @@ -4252,10 +4252,10 @@ Rect RotatedRect::boundingRect() const { Point2f pt[4]; points(pt); - Rect r(cvFloor(min(min(min(pt[0].x, pt[1].x), pt[2].x), pt[3].x)), - cvFloor(min(min(min(pt[0].y, pt[1].y), pt[2].y), pt[3].y)), - cvCeil(max(max(max(pt[0].x, pt[1].x), pt[2].x), pt[3].x)), - cvCeil(max(max(max(pt[0].y, pt[1].y), pt[2].y), pt[3].y))); + Rect r(cvFloor(std::min(std::min(std::min(pt[0].x, pt[1].x), pt[2].x), pt[3].x)), + cvFloor(std::min(std::min(std::min(pt[0].y, pt[1].y), pt[2].y), pt[3].y)), + cvCeil(std::max(std::max(std::max(pt[0].x, pt[1].x), pt[2].x), pt[3].x)), + cvCeil(std::max(std::max(std::max(pt[0].y, pt[1].y), pt[2].y), pt[3].y))); r.width -= r.x - 1; r.height -= r.y - 1; return r; diff --git a/modules/core/src/opengl_interop.cpp b/modules/core/src/opengl_interop.cpp index befc63f3f..ae2387093 100644 --- a/modules/core/src/opengl_interop.cpp +++ b/modules/core/src/opengl_interop.cpp @@ -53,10 +53,6 @@ #endif #endif -using namespace std; -using namespace cv; -using namespace cv::gpu; - namespace { #ifndef HAVE_OPENGL @@ -363,7 +359,7 @@ private: #endif }; -const Ptr& cv::GlBuffer::Impl::empty() +const cv::Ptr& cv::GlBuffer::Impl::empty() { static Ptr p(new Impl); return p; @@ -720,7 +716,7 @@ void cv::GlBuffer::copyTo(OutputArray arr, Target target, bool autoRelease) cons #endif } -GlBuffer cv::GlBuffer::clone(Target target, bool autoRelease) const +cv::GlBuffer cv::GlBuffer::clone(Target target, bool autoRelease) const { #ifndef HAVE_OPENGL (void) target; @@ -755,14 +751,14 @@ void cv::GlBuffer::unbind(Target target) #endif } -Mat cv::GlBuffer::mapHost(Access access) +cv::Mat cv::GlBuffer::mapHost(Access access) { #ifndef HAVE_OPENGL (void) access; throw_nogl(); - return Mat(); + return cv::Mat(); #else - return Mat(rows_, cols_, type_, impl_->mapHost(access)); + return cv::Mat(rows_, cols_, type_, impl_->mapHost(access)); #endif } @@ -775,17 +771,17 @@ void cv::GlBuffer::unmapHost() #endif } -GpuMat cv::GlBuffer::mapDevice() +cv::gpu::GpuMat cv::GlBuffer::mapDevice() { #ifndef HAVE_OPENGL throw_nogl(); - return GpuMat(); + return cv::gpu::GpuMat(); #else #if !defined HAVE_CUDA || defined(CUDA_DISABLER) throw_nocuda(); - return GpuMat(); + return cv::gpu::GpuMat(); #else - return GpuMat(rows_, cols_, type_, impl_->mapDevice()); + return cv::gpu::GpuMat(rows_, cols_, type_, impl_->mapDevice()); #endif #endif } @@ -854,7 +850,7 @@ private: bool autoRelease_; }; -const Ptr cv::GlTexture2D::Impl::empty() +const cv::Ptr cv::GlTexture2D::Impl::empty() { static Ptr p(new Impl); return p; diff --git a/modules/core/src/out.cpp b/modules/core/src/out.cpp index 6817fca61..5ceee6162 100644 --- a/modules/core/src/out.cpp +++ b/modules/core/src/out.cpp @@ -282,7 +282,7 @@ const Formatter* Formatter::setDefault(const Formatter* fmt) } Formatted::Formatted(const Mat& _m, const Formatter* _fmt, - const vector& _params) + const std::vector& _params) { mtx = _m; fmt = _fmt ? _fmt : Formatter::get(); diff --git a/modules/core/src/persistence.cpp b/modules/core/src/persistence.cpp index 01129d551..1ee511910 100644 --- a/modules/core/src/persistence.cpp +++ b/modules/core/src/persistence.cpp @@ -116,7 +116,7 @@ static char* icv_itoa( int _val, char* buffer, int /*radix*/ ) return ptr; } -cv::string cv::FileStorage::getDefaultObjectName(const string& _filename) +std::string cv::FileStorage::getDefaultObjectName(const std::string& _filename) { static const char* stubname = "unnamed"; const char* filename = _filename.c_str(); @@ -152,7 +152,7 @@ cv::string cv::FileStorage::getDefaultObjectName(const string& _filename) name = name_buf; if( strcmp( name, "_" ) == 0 ) strcpy( name, stubname ); - return cv::string(name); + return std::string(name); } typedef struct CvGenericHash @@ -5011,7 +5011,7 @@ cvSave( const char* filename, const void* struct_ptr, if( !fs ) CV_Error( CV_StsError, "Could not open the file storage. Check the path and permissions" ); - cv::string name = _name ? cv::string(_name) : cv::FileStorage::getDefaultObjectName(filename); + std::string name = _name ? std::string(_name) : cv::FileStorage::getDefaultObjectName(filename); if( comment ) cvWriteComment( fs, comment, 0 ); @@ -5105,7 +5105,7 @@ stop_search: namespace cv { -static void getElemSize( const string& fmt, size_t& elemSize, size_t& cn ) +static void getElemSize( const std::string& fmt, size_t& elemSize, size_t& cn ) { const char* dt = fmt.c_str(); cn = 1; @@ -5125,7 +5125,7 @@ FileStorage::FileStorage() state = UNDEFINED; } -FileStorage::FileStorage(const string& filename, int flags, const string& encoding) +FileStorage::FileStorage(const std::string& filename, int flags, const std::string& encoding) { state = UNDEFINED; open( filename, flags, encoding ); @@ -5146,7 +5146,7 @@ FileStorage::~FileStorage() } } -bool FileStorage::open(const string& filename, int flags, const string& encoding) +bool FileStorage::open(const std::string& filename, int flags, const std::string& encoding) { release(); fs = Ptr(cvOpenFileStorage( filename.c_str(), 0, flags, @@ -5168,9 +5168,9 @@ void FileStorage::release() state = UNDEFINED; } -string FileStorage::releaseAndGetString() +std::string FileStorage::releaseAndGetString() { - string buf; + std::string buf; buf.reserve(16); // HACK: Work around for compiler bug if( fs.obj && fs.obj->outbuf ) icvClose(fs.obj, &buf); @@ -5184,7 +5184,7 @@ FileNode FileStorage::root(int streamidx) const return isOpened() ? FileNode(fs, cvGetRootFileNode(fs, streamidx)) : FileNode(); } -FileStorage& operator << (FileStorage& fs, const string& str) +FileStorage& operator << (FileStorage& fs, const std::string& str) { enum { NAME_EXPECTED = FileStorage::NAME_EXPECTED, VALUE_EXPECTED = FileStorage::VALUE_EXPECTED, @@ -5203,7 +5203,7 @@ FileStorage& operator << (FileStorage& fs, const string& str) fs.state = fs.structs.empty() || fs.structs.back() == '{' ? INSIDE_MAP + NAME_EXPECTED : VALUE_EXPECTED; cvEndWriteStruct( *fs ); - fs.elname = string(); + fs.elname = std::string(); } else if( fs.state == NAME_EXPECTED + INSIDE_MAP ) { @@ -5227,12 +5227,12 @@ FileStorage& operator << (FileStorage& fs, const string& str) } cvStartWriteStruct( *fs, fs.elname.size() > 0 ? fs.elname.c_str() : 0, flags, *_str ? _str : 0 ); - fs.elname = string(); + fs.elname = std::string(); } else { write( fs, fs.elname, (_str[0] == '\\' && (_str[1] == '{' || _str[1] == '}' || - _str[1] == '[' || _str[1] == ']')) ? string(_str+1) : str ); + _str[1] == '[' || _str[1] == ']')) ? std::string(_str+1) : str ); if( fs.state == INSIDE_MAP + VALUE_EXPECTED ) fs.state = INSIDE_MAP + NAME_EXPECTED; } @@ -5243,7 +5243,7 @@ FileStorage& operator << (FileStorage& fs, const string& str) } -void FileStorage::writeRaw( const string& fmt, const uchar* vec, size_t len ) +void FileStorage::writeRaw( const std::string& fmt, const uchar* vec, size_t len ) { if( !isOpened() ) return; @@ -5254,7 +5254,7 @@ void FileStorage::writeRaw( const string& fmt, const uchar* vec, size_t len ) } -void FileStorage::writeObj( const string& name, const void* obj ) +void FileStorage::writeObj( const std::string& name, const void* obj ) { if( !isOpened() ) return; @@ -5262,7 +5262,7 @@ void FileStorage::writeObj( const string& name, const void* obj ) } -FileNode FileStorage::operator[](const string& nodename) const +FileNode FileStorage::operator[](const std::string& nodename) const { return FileNode(fs, cvGetFileNodeByName(fs, 0, nodename.c_str())); } @@ -5272,7 +5272,7 @@ FileNode FileStorage::operator[](const char* nodename) const return FileNode(fs, cvGetFileNodeByName(fs, 0, nodename)); } -FileNode FileNode::operator[](const string& nodename) const +FileNode FileNode::operator[](const std::string& nodename) const { return FileNode(fs, cvGetFileNodeByName(fs, node, nodename.c_str())); } @@ -5288,10 +5288,10 @@ FileNode FileNode::operator[](int i) const i == 0 ? *this : FileNode(); } -string FileNode::name() const +std::string FileNode::name() const { const char* str; - return !node || (str = cvGetFileNodeName(node)) == 0 ? string() : string(str); + return !node || (str = cvGetFileNodeName(node)) == 0 ? std::string() : std::string(str); } void* FileNode::readObj() const @@ -5406,7 +5406,7 @@ FileNodeIterator& FileNodeIterator::operator -= (int ofs) } -FileNodeIterator& FileNodeIterator::readRaw( const string& fmt, uchar* vec, size_t maxCount ) +FileNodeIterator& FileNodeIterator::readRaw( const std::string& fmt, uchar* vec, size_t maxCount ) { if( fs && container && remaining > 0 ) { @@ -5430,16 +5430,16 @@ FileNodeIterator& FileNodeIterator::readRaw( const string& fmt, uchar* vec, size } -void write( FileStorage& fs, const string& name, int value ) +void write( FileStorage& fs, const std::string& name, int value ) { cvWriteInt( *fs, name.size() ? name.c_str() : 0, value ); } -void write( FileStorage& fs, const string& name, float value ) +void write( FileStorage& fs, const std::string& name, float value ) { cvWriteReal( *fs, name.size() ? name.c_str() : 0, value ); } -void write( FileStorage& fs, const string& name, double value ) +void write( FileStorage& fs, const std::string& name, double value ) { cvWriteReal( *fs, name.size() ? name.c_str() : 0, value ); } -void write( FileStorage& fs, const string& name, const string& value ) +void write( FileStorage& fs, const std::string& name, const std::string& value ) { cvWriteString( *fs, name.size() ? name.c_str() : 0, value.c_str() ); } void writeScalar(FileStorage& fs, int value ) @@ -5451,11 +5451,11 @@ void writeScalar(FileStorage& fs, float value ) void writeScalar(FileStorage& fs, double value ) { cvWriteReal( *fs, 0, value ); } -void writeScalar(FileStorage& fs, const string& value ) +void writeScalar(FileStorage& fs, const std::string& value ) { cvWriteString( *fs, 0, value.c_str() ); } -void write( FileStorage& fs, const string& name, const Mat& value ) +void write( FileStorage& fs, const std::string& name, const Mat& value ) { if( value.dims <= 2 ) { @@ -5470,15 +5470,15 @@ void write( FileStorage& fs, const string& name, const Mat& value ) } // TODO: the 4 functions below need to be implemented more efficiently -void write( FileStorage& fs, const string& name, const SparseMat& value ) +void write( FileStorage& fs, const std::string& name, const SparseMat& value ) { Ptr mat = (CvSparseMat*)value; cvWrite( *fs, name.size() ? name.c_str() : 0, mat ); } -WriteStructContext::WriteStructContext(FileStorage& _fs, const string& name, - int flags, const string& typeName) : fs(&_fs) +WriteStructContext::WriteStructContext(FileStorage& _fs, const std::string& name, + int flags, const std::string& typeName) : fs(&_fs) { cvStartWriteStruct(**fs, !name.empty() ? name.c_str() : 0, flags, !typeName.empty() ? typeName.c_str() : 0); diff --git a/modules/core/src/rand.cpp b/modules/core/src/rand.cpp index bae8eae89..7244d1ee2 100644 --- a/modules/core/src/rand.cpp +++ b/modules/core/src/rand.cpp @@ -537,13 +537,13 @@ void RNG::fill( InputOutputArray _mat, int disttype, ip = (Vec2i*)(parambuf + cn*2); for( j = 0, fast_int_mode = 1; j < cn; j++ ) { - double a = min(p1[j], p2[j]); - double b = max(p1[j], p2[j]); + double a = std::min(p1[j], p2[j]); + double b = std::max(p1[j], p2[j]); if( saturateRange ) { - a = max(a, depth == CV_8U || depth == CV_16U ? 0. : + a = std::max(a, depth == CV_8U || depth == CV_16U ? 0. : depth == CV_8S ? -128. : depth == CV_16S ? -32768. : (double)INT_MIN); - b = min(b, depth == CV_8U ? 256. : depth == CV_16U ? 65536. : + b = std::min(b, depth == CV_8U ? 256. : depth == CV_16U ? 65536. : depth == CV_8S ? 128. : depth == CV_16S ? 32768. : (double)INT_MAX); } ip[j][1] = cvCeil(a); @@ -573,8 +573,8 @@ void RNG::fill( InputOutputArray _mat, int disttype, while(((uint64)1 << l) < d) l++; ds[j].M = (unsigned)(((uint64)1 << 32)*(((uint64)1 << l) - d)/d) + 1; - ds[j].sh1 = min(l, 1); - ds[j].sh2 = max(l - 1, 0); + ds[j].sh1 = std::min(l, 1); + ds[j].sh2 = std::max(l - 1, 0); } } diff --git a/modules/core/src/system.cpp b/modules/core/src/system.cpp index a891e94cc..2efaa2074 100644 --- a/modules/core/src/system.cpp +++ b/modules/core/src/system.cpp @@ -113,7 +113,7 @@ namespace cv Exception::Exception() { code = 0; line = 0; } -Exception::Exception(int _code, const string& _err, const string& _func, const string& _file, int _line) +Exception::Exception(int _code, const std::string& _err, const std::string& _func, const std::string& _file, int _line) : code(_code), err(_err), func(_func), file(_file), line(_line) { formatMessage(); @@ -348,19 +348,19 @@ const std::string& getBuildInformation() return build_info; } -string format( const char* fmt, ... ) +std::string format( const char* fmt, ... ) { char buf[1 << 16]; va_list args; va_start( args, fmt ); vsprintf( buf, fmt, args ); - return string(buf); + return std::string(buf); } -string tempfile( const char* suffix ) +std::string tempfile( const char* suffix ) { const char *temp_dir = getenv("OPENCV_TEMP_PATH"); - string fname; + std::string fname; #if defined WIN32 || defined _WIN32 char temp_dir2[MAX_PATH + 1] = { 0 }; @@ -372,7 +372,7 @@ string tempfile( const char* suffix ) temp_dir = temp_dir2; } if(0 == ::GetTempFileNameA(temp_dir, "ocv", 0, temp_file)) - return string(); + return std::string(); DeleteFileA(temp_file); @@ -397,7 +397,7 @@ string tempfile( const char* suffix ) } const int fd = mkstemp((char*)fname.c_str()); - if (fd == -1) return string(); + if (fd == -1) return std::string(); close(fd); remove(fname.c_str()); diff --git a/modules/features2d/include/opencv2/features2d/features2d.hpp b/modules/features2d/include/opencv2/features2d/features2d.hpp index 01ef28d06..59820154d 100644 --- a/modules/features2d/include/opencv2/features2d/features2d.hpp +++ b/modules/features2d/include/opencv2/features2d/features2d.hpp @@ -85,12 +85,12 @@ public: size_t hash() const; //! converts vector of keypoints to vector of points - static void convert(const vector& keypoints, - CV_OUT vector& points2f, - const vector& keypointIndexes=vector()); + static void convert(const std::vector& keypoints, + CV_OUT std::vector& points2f, + const std::vector& keypointIndexes=std::vector()); //! converts vector of points to the vector of keypoints, where each keypoint is assigned the same size and the same orientation - static void convert(const vector& points2f, - CV_OUT vector& keypoints, + static void convert(const std::vector& points2f, + CV_OUT std::vector& keypoints, float size=1, float response=1, int octave=0, int class_id=-1); //! computes overlap for pair of keypoints; @@ -109,9 +109,9 @@ public: }; //! writes vector of keypoints to the file storage -CV_EXPORTS void write(FileStorage& fs, const string& name, const vector& keypoints); +CV_EXPORTS void write(FileStorage& fs, const std::string& name, const std::vector& keypoints); //! reads vector of keypoints from the specified file storage node -CV_EXPORTS void read(const FileNode& node, CV_OUT vector& keypoints); +CV_EXPORTS void read(const FileNode& node, CV_OUT std::vector& keypoints); /* * A class filters a vector of keypoints. @@ -126,25 +126,25 @@ public: /* * Remove keypoints within borderPixels of an image edge. */ - static void runByImageBorder( vector& keypoints, Size imageSize, int borderSize ); + static void runByImageBorder( std::vector& keypoints, Size imageSize, int borderSize ); /* * Remove keypoints of sizes out of range. */ - static void runByKeypointSize( vector& keypoints, float minSize, + static void runByKeypointSize( std::vector& keypoints, float minSize, float maxSize=FLT_MAX ); /* * Remove keypoints from some image by mask for pixels of this image. */ - static void runByPixelsMask( vector& keypoints, const Mat& mask ); + static void runByPixelsMask( std::vector& keypoints, const Mat& mask ); /* * Remove duplicated keypoints. */ - static void removeDuplicated( vector& keypoints ); + static void removeDuplicated( std::vector& keypoints ); /* * Retain the specified number of the best keypoints (according to the response) */ - static void retainBest( vector& keypoints, int npoints ); + static void retainBest( std::vector& keypoints, int npoints ); }; @@ -165,7 +165,7 @@ public: * mask Mask specifying where to look for keypoints (optional). Must be a char * matrix with non-zero values in the region of interest. */ - CV_WRAP void detect( const Mat& image, CV_OUT vector& keypoints, const Mat& mask=Mat() ) const; + CV_WRAP void detect( const Mat& image, CV_OUT std::vector& keypoints, const Mat& mask=Mat() ) const; /* * Detect keypoints in an image set. @@ -173,23 +173,23 @@ public: * keypoints Collection of keypoints detected in an input images. keypoints[i] is a set of keypoints detected in an images[i]. * masks Masks for image set. masks[i] is a mask for images[i]. */ - void detect( const vector& images, vector >& keypoints, const vector& masks=vector() ) const; + void detect( const std::vector& images, std::vector >& keypoints, const std::vector& masks=std::vector() ) const; // Return true if detector object is empty CV_WRAP virtual bool empty() const; // Create feature detector by detector name. - CV_WRAP static Ptr create( const string& detectorType ); + CV_WRAP static Ptr create( const std::string& detectorType ); protected: - virtual void detectImpl( const Mat& image, vector& keypoints, const Mat& mask=Mat() ) const = 0; + virtual void detectImpl( const Mat& image, std::vector& keypoints, const Mat& mask=Mat() ) const = 0; /* * Remove keypoints that are not in the mask. * Helper function, useful when wrapping a library call for keypoint detection that * does not support a mask argument. */ - static void removeInvalidPoints( const Mat& mask, vector& keypoints ); + static void removeInvalidPoints( const Mat& mask, std::vector& keypoints ); }; @@ -213,7 +213,7 @@ public: * keypoints The input keypoints. Keypoints for which a descriptor cannot be computed are removed. * descriptors Copmputed descriptors. Row i is the descriptor for keypoint i. */ - CV_WRAP void compute( const Mat& image, CV_OUT CV_IN_OUT vector& keypoints, CV_OUT Mat& descriptors ) const; + CV_WRAP void compute( const Mat& image, CV_OUT CV_IN_OUT std::vector& keypoints, CV_OUT Mat& descriptors ) const; /* * Compute the descriptors for a keypoints collection detected in image collection. @@ -222,22 +222,22 @@ public: * Keypoints for which a descriptor cannot be computed are removed. * descriptors Descriptor collection. descriptors[i] are descriptors computed for set keypoints[i]. */ - void compute( const vector& images, vector >& keypoints, vector& descriptors ) const; + void compute( const std::vector& images, std::vector >& keypoints, std::vector& descriptors ) const; CV_WRAP virtual int descriptorSize() const = 0; CV_WRAP virtual int descriptorType() const = 0; CV_WRAP virtual bool empty() const; - CV_WRAP static Ptr create( const string& descriptorExtractorType ); + CV_WRAP static Ptr create( const std::string& descriptorExtractorType ); protected: - virtual void computeImpl( const Mat& image, vector& keypoints, Mat& descriptors ) const = 0; + virtual void computeImpl( const Mat& image, std::vector& keypoints, Mat& descriptors ) const = 0; /* * Remove keypoints within borderPixels of an image edge. */ - static void removeBorderKeypoints( vector& keypoints, + static void removeBorderKeypoints( std::vector& keypoints, Size imageSize, int borderSize ); }; @@ -259,12 +259,12 @@ public: * descriptors for the provided keypoints */ CV_WRAP_AS(detectAndCompute) virtual void operator()( InputArray image, InputArray mask, - CV_OUT vector& keypoints, + CV_OUT std::vector& keypoints, OutputArray descriptors, bool useProvidedKeypoints=false ) const = 0; // Create feature detector and descriptor extractor by name. - CV_WRAP static Ptr create( const string& name ); + CV_WRAP static Ptr create( const std::string& name ); }; /*! @@ -283,10 +283,10 @@ public: int descriptorType() const; // Compute the BRISK features on an image - void operator()(InputArray image, InputArray mask, vector& keypoints) const; + void operator()(InputArray image, InputArray mask, std::vector& keypoints) const; // Compute the BRISK features and descriptors on an image - void operator()( InputArray image, InputArray mask, vector& keypoints, + void operator()( InputArray image, InputArray mask, std::vector& keypoints, OutputArray descriptors, bool useProvidedKeypoints=false ) const; AlgorithmInfo* info() const; @@ -304,11 +304,11 @@ public: protected: - void computeImpl( const Mat& image, vector& keypoints, Mat& descriptors ) const; - void detectImpl( const Mat& image, vector& keypoints, const Mat& mask=Mat() ) const; + void computeImpl( const Mat& image, std::vector& keypoints, Mat& descriptors ) const; + void detectImpl( const Mat& image, std::vector& keypoints, const Mat& mask=Mat() ) const; - void computeKeypointsNoOrientation(InputArray image, InputArray mask, vector& keypoints) const; - void computeDescriptorsAndOrOrientation(InputArray image, InputArray mask, vector& keypoints, + void computeKeypointsNoOrientation(InputArray image, InputArray mask, std::vector& keypoints) const; + void computeDescriptorsAndOrOrientation(InputArray image, InputArray mask, std::vector& keypoints, OutputArray descriptors, bool doDescriptors, bool doOrientation, bool useProvidedKeypoints) const; @@ -377,18 +377,18 @@ public: int descriptorType() const; // Compute the ORB features and descriptors on an image - void operator()(InputArray image, InputArray mask, vector& keypoints) const; + void operator()(InputArray image, InputArray mask, std::vector& keypoints) const; // Compute the ORB features and descriptors on an image - void operator()( InputArray image, InputArray mask, vector& keypoints, + void operator()( InputArray image, InputArray mask, std::vector& keypoints, OutputArray descriptors, bool useProvidedKeypoints=false ) const; AlgorithmInfo* info() const; protected: - void computeImpl( const Mat& image, vector& keypoints, Mat& descriptors ) const; - void detectImpl( const Mat& image, vector& keypoints, const Mat& mask=Mat() ) const; + void computeImpl( const Mat& image, std::vector& keypoints, Mat& descriptors ) const; + void detectImpl( const Mat& image, std::vector& keypoints, const Mat& mask=Mat() ) const; CV_PROP_RW int nfeatures; CV_PROP_RW double scaleFactor; @@ -420,7 +420,7 @@ public: bool scaleNormalized = true, float patternScale = 22.0f, int nOctaves = 4, - const vector& selectedPairs = vector()); + const std::vector& selectedPairs = std::vector()); FREAK( const FREAK& rhs ); FREAK& operator=( const FREAK& ); @@ -439,7 +439,7 @@ public: * @param verbose print construction information * @return list of best pair indexes */ - vector selectPairs( const vector& images, vector >& keypoints, + std::vector selectPairs( const std::vector& images, std::vector >& keypoints, const double corrThresh = 0.7, bool verbose = true ); AlgorithmInfo* info() const; @@ -450,7 +450,7 @@ public: }; protected: - virtual void computeImpl( const Mat& image, vector& keypoints, Mat& descriptors ) const; + virtual void computeImpl( const Mat& image, std::vector& keypoints, Mat& descriptors ) const; void buildPattern(); uchar meanIntensity( const Mat& image, const Mat& integral, const float kp_x, const float kp_y, const unsigned int scale, const unsigned int rot, const unsigned int point ) const; @@ -463,7 +463,7 @@ protected: double patternScale0; int nOctaves0; - vector selectedPairs0; + std::vector selectedPairs0; struct PatternPoint { @@ -486,7 +486,7 @@ protected: int weight_dy; // dy/(norm_sq))*4096 }; - vector patternLookup; // look-up table for the pattern points (position+sigma of all points at all scales and orientation) + std::vector patternLookup; // look-up table for the pattern points (position+sigma of all points at all scales and orientation) int patternSizes[NB_SCALES]; // size of the pattern at a specific scale (used to check if a point is within image boundaries) DescriptionPair descriptionPairs[NB_PAIRS]; OrientationPair orientationPairs[NB_ORIENPAIRS]; @@ -512,12 +512,12 @@ public: double _min_margin=0.003, int _edge_blur_size=5 ); //! the operator that extracts the MSERs from the image or the specific part of it - CV_WRAP_AS(detect) void operator()( const Mat& image, CV_OUT vector >& msers, + CV_WRAP_AS(detect) void operator()( const Mat& image, CV_OUT std::vector >& msers, const Mat& mask=Mat() ) const; AlgorithmInfo* info() const; protected: - void detectImpl( const Mat& image, vector& keypoints, const Mat& mask=Mat() ) const; + void detectImpl( const Mat& image, std::vector& keypoints, const Mat& mask=Mat() ) const; int delta; int minArea; @@ -548,12 +548,12 @@ public: //! finds the keypoints in the image CV_WRAP_AS(detect) void operator()(const Mat& image, - CV_OUT vector& keypoints) const; + CV_OUT std::vector& keypoints) const; AlgorithmInfo* info() const; protected: - void detectImpl( const Mat& image, vector& keypoints, const Mat& mask=Mat() ) const; + void detectImpl( const Mat& image, std::vector& keypoints, const Mat& mask=Mat() ) const; int maxSize; int responseThreshold; @@ -563,10 +563,10 @@ protected: }; //! detects corners using FAST algorithm by E. Rosten -CV_EXPORTS void FAST( InputArray image, CV_OUT vector& keypoints, +CV_EXPORTS void FAST( InputArray image, CV_OUT std::vector& keypoints, int threshold, bool nonmaxSupression=true ); -CV_EXPORTS void FAST( InputArray image, CV_OUT vector& keypoints, +CV_EXPORTS void FAST( InputArray image, CV_OUT std::vector& keypoints, int threshold, bool nonmaxSupression, int type ); class CV_EXPORTS_W FastFeatureDetector : public FeatureDetector @@ -582,7 +582,7 @@ public: AlgorithmInfo* info() const; protected: - virtual void detectImpl( const Mat& image, vector& keypoints, const Mat& mask=Mat() ) const; + virtual void detectImpl( const Mat& image, std::vector& keypoints, const Mat& mask=Mat() ) const; int threshold; bool nonmaxSuppression; @@ -598,7 +598,7 @@ public: AlgorithmInfo* info() const; protected: - virtual void detectImpl( const Mat& image, vector& keypoints, const Mat& mask=Mat() ) const; + virtual void detectImpl( const Mat& image, std::vector& keypoints, const Mat& mask=Mat() ) const; int nfeatures; double qualityLevel; @@ -655,8 +655,8 @@ protected: double confidence; }; - virtual void detectImpl( const Mat& image, vector& keypoints, const Mat& mask=Mat() ) const; - virtual void findBlobs(const Mat &image, const Mat &binaryImage, vector
¢ers) const; + virtual void detectImpl( const Mat& image, std::vector& keypoints, const Mat& mask=Mat() ) const; + virtual void findBlobs(const Mat &image, const Mat &binaryImage, std::vector
¢ers) const; Params params; }; @@ -673,7 +673,7 @@ public: AlgorithmInfo* info() const; protected: - virtual void detectImpl( const Mat& image, vector& keypoints, const Mat& mask=Mat() ) const; + virtual void detectImpl( const Mat& image, std::vector& keypoints, const Mat& mask=Mat() ) const; double initFeatureScale; int featureScaleLevels; @@ -710,7 +710,7 @@ public: AlgorithmInfo* info() const; protected: - virtual void detectImpl( const Mat& image, vector& keypoints, const Mat& mask=Mat() ) const; + virtual void detectImpl( const Mat& image, std::vector& keypoints, const Mat& mask=Mat() ) const; Ptr detector; int maxTotalKeypoints; @@ -732,7 +732,7 @@ public: virtual bool empty() const; protected: - virtual void detectImpl( const Mat& image, vector& keypoints, const Mat& mask=Mat() ) const; + virtual void detectImpl( const Mat& image, std::vector& keypoints, const Mat& mask=Mat() ) const; Ptr detector; int maxLevel; @@ -764,7 +764,7 @@ public: virtual Ptr clone() const = 0; - static Ptr create( const string& detectorType ); + static Ptr create( const std::string& detectorType ); }; /** \brief an adaptively adjusting detector that iteratively detects until the desired number * of features are detected. @@ -793,7 +793,7 @@ public: virtual bool empty() const; protected: - virtual void detectImpl( const Mat& image, vector& keypoints, const Mat& mask=Mat() ) const; + virtual void detectImpl( const Mat& image, std::vector& keypoints, const Mat& mask=Mat() ) const; private: DynamicAdaptedFeatureDetector& operator=(const DynamicAdaptedFeatureDetector&); @@ -822,7 +822,7 @@ public: virtual Ptr clone() const; protected: - virtual void detectImpl( const Mat& image, vector& keypoints, const Mat& mask=Mat() ) const; + virtual void detectImpl( const Mat& image, std::vector& keypoints, const Mat& mask=Mat() ) const; int thresh_; bool nonmax_; @@ -845,7 +845,7 @@ public: virtual Ptr clone() const; protected: - virtual void detectImpl( const Mat& image, vector& keypoints, const Mat& mask=Mat() ) const; + virtual void detectImpl( const Mat& image, std::vector& keypoints, const Mat& mask=Mat() ) const; double thresh_, init_thresh_, min_thresh_, max_thresh_; }; @@ -862,12 +862,12 @@ public: virtual Ptr clone() const; protected: - virtual void detectImpl( const Mat& image, vector& keypoints, const Mat& mask=Mat() ) const; + virtual void detectImpl( const Mat& image, std::vector& keypoints, const Mat& mask=Mat() ) const; double thresh_, init_thresh_, min_thresh_, max_thresh_; }; -CV_EXPORTS Mat windowedMatchingMask( const vector& keypoints1, const vector& keypoints2, +CV_EXPORTS Mat windowedMatchingMask( const std::vector& keypoints1, const std::vector& keypoints2, float maxDeltaX, float maxDeltaY ); @@ -895,7 +895,7 @@ public: virtual bool empty() const; protected: - virtual void computeImpl( const Mat& image, vector& keypoints, Mat& descriptors ) const; + virtual void computeImpl( const Mat& image, std::vector& keypoints, Mat& descriptors ) const; Ptr descriptorExtractor; }; @@ -923,9 +923,9 @@ public: AlgorithmInfo* info() const; protected: - virtual void computeImpl(const Mat& image, vector& keypoints, Mat& descriptors) const; + virtual void computeImpl(const Mat& image, std::vector& keypoints, Mat& descriptors) const; - typedef void(*PixelTestFn)(const Mat&, const vector&, Mat&); + typedef void(*PixelTestFn)(const Mat&, const std::vector&, Mat&); int bytes_; PixelTestFn test_fn_; @@ -975,7 +975,7 @@ struct CV_EXPORTS L2 ResultType operator()( const T* a, const T* b, int size ) const { - return (ResultType)sqrt((double)normL2Sqr(a, b, size)); + return (ResultType)std::sqrt((double)normL2Sqr(a, b, size)); } }; @@ -1069,11 +1069,11 @@ public: * Add descriptors to train descriptor collection. * descriptors Descriptors to add. Each descriptors[i] is a descriptors set from one image. */ - CV_WRAP virtual void add( const vector& descriptors ); + CV_WRAP virtual void add( const std::vector& descriptors ); /* * Get train descriptors collection. */ - CV_WRAP const vector& getTrainDescriptors() const; + CV_WRAP const std::vector& getTrainDescriptors() const; /* * Clear train descriptors collection. */ @@ -1106,29 +1106,29 @@ public: */ // Find one best match for each query descriptor (if mask is empty). CV_WRAP void match( const Mat& queryDescriptors, const Mat& trainDescriptors, - CV_OUT vector& matches, const Mat& mask=Mat() ) const; + CV_OUT std::vector& matches, const Mat& mask=Mat() ) const; // Find k best matches for each query descriptor (in increasing order of distances). // compactResult is used when mask is not empty. If compactResult is false matches // vector will have the same size as queryDescriptors rows. If compactResult is true // matches vector will not contain matches for fully masked out query descriptors. CV_WRAP void knnMatch( const Mat& queryDescriptors, const Mat& trainDescriptors, - CV_OUT vector >& matches, int k, + CV_OUT std::vector >& matches, int k, const Mat& mask=Mat(), bool compactResult=false ) const; // Find best matches for each query descriptor which have distance less than // maxDistance (in increasing order of distances). void radiusMatch( const Mat& queryDescriptors, const Mat& trainDescriptors, - vector >& matches, float maxDistance, + std::vector >& matches, float maxDistance, const Mat& mask=Mat(), bool compactResult=false ) const; /* * Group of methods to match descriptors from one image to image set. * See description of similar methods for matching image pair above. */ - CV_WRAP void match( const Mat& queryDescriptors, CV_OUT vector& matches, - const vector& masks=vector() ); - CV_WRAP void knnMatch( const Mat& queryDescriptors, CV_OUT vector >& matches, int k, - const vector& masks=vector(), bool compactResult=false ); - void radiusMatch( const Mat& queryDescriptors, vector >& matches, float maxDistance, - const vector& masks=vector(), bool compactResult=false ); + CV_WRAP void match( const Mat& queryDescriptors, CV_OUT std::vector& matches, + const std::vector& masks=std::vector() ); + CV_WRAP void knnMatch( const Mat& queryDescriptors, CV_OUT std::vector >& matches, int k, + const std::vector& masks=std::vector(), bool compactResult=false ); + void radiusMatch( const Mat& queryDescriptors, std::vector >& matches, float maxDistance, + const std::vector& masks=std::vector(), bool compactResult=false ); // Reads matcher object from a file node virtual void read( const FileNode& ); @@ -1140,7 +1140,7 @@ public: // but with empty train data. virtual Ptr clone( bool emptyTrainData=false ) const = 0; - CV_WRAP static Ptr create( const string& descriptorMatcherType ); + CV_WRAP static Ptr create( const std::string& descriptorMatcherType ); protected: /* * Class to work with descriptors from several images as with one merged matrix. @@ -1154,7 +1154,7 @@ protected: virtual ~DescriptorCollection(); // Vector of matrices "descriptors" will be merged to one matrix "mergedDescriptors" here. - void set( const vector& descriptors ); + void set( const std::vector& descriptors ); virtual void clear(); const Mat& getDescriptors() const; @@ -1166,25 +1166,25 @@ protected: protected: Mat mergedDescriptors; - vector startIdxs; + std::vector startIdxs; }; // In fact the matching is implemented only by the following two methods. These methods suppose // that the class object has been trained already. Public match methods call these methods // after calling train(). - virtual void knnMatchImpl( const Mat& queryDescriptors, vector >& matches, int k, - const vector& masks=vector(), bool compactResult=false ) = 0; - virtual void radiusMatchImpl( const Mat& queryDescriptors, vector >& matches, float maxDistance, - const vector& masks=vector(), bool compactResult=false ) = 0; + virtual void knnMatchImpl( const Mat& queryDescriptors, std::vector >& matches, int k, + const std::vector& masks=std::vector(), bool compactResult=false ) = 0; + virtual void radiusMatchImpl( const Mat& queryDescriptors, std::vector >& matches, float maxDistance, + const std::vector& masks=std::vector(), bool compactResult=false ) = 0; static bool isPossibleMatch( const Mat& mask, int queryIdx, int trainIdx ); - static bool isMaskedOut( const vector& masks, int queryIdx ); + static bool isMaskedOut( const std::vector& masks, int queryIdx ); static Mat clone_op( Mat m ) { return m.clone(); } - void checkMasks( const vector& masks, int queryDescriptorsCount ) const; + void checkMasks( const std::vector& masks, int queryDescriptorsCount ) const; // Collection of descriptors from train images. - vector trainDescCollection; + std::vector trainDescCollection; }; /* @@ -1208,10 +1208,10 @@ public: AlgorithmInfo* info() const; protected: - virtual void knnMatchImpl( const Mat& queryDescriptors, vector >& matches, int k, - const vector& masks=vector(), bool compactResult=false ); - virtual void radiusMatchImpl( const Mat& queryDescriptors, vector >& matches, float maxDistance, - const vector& masks=vector(), bool compactResult=false ); + virtual void knnMatchImpl( const Mat& queryDescriptors, std::vector >& matches, int k, + const std::vector& masks=std::vector(), bool compactResult=false ); + virtual void radiusMatchImpl( const Mat& queryDescriptors, std::vector >& matches, float maxDistance, + const std::vector& masks=std::vector(), bool compactResult=false ); int normType; bool crossCheck; @@ -1227,7 +1227,7 @@ public: CV_WRAP FlannBasedMatcher( const Ptr& indexParams=new flann::KDTreeIndexParams(), const Ptr& searchParams=new flann::SearchParams() ); - virtual void add( const vector& descriptors ); + virtual void add( const std::vector& descriptors ); virtual void clear(); // Reads matcher object from a file node @@ -1244,12 +1244,12 @@ public: protected: static void convertToDMatches( const DescriptorCollection& descriptors, const Mat& indices, const Mat& distances, - vector >& matches ); + std::vector >& matches ); - virtual void knnMatchImpl( const Mat& queryDescriptors, vector >& matches, int k, - const vector& masks=vector(), bool compactResult=false ); - virtual void radiusMatchImpl( const Mat& queryDescriptors, vector >& matches, float maxDistance, - const vector& masks=vector(), bool compactResult=false ); + virtual void knnMatchImpl( const Mat& queryDescriptors, std::vector >& matches, int k, + const std::vector& masks=std::vector(), bool compactResult=false ); + virtual void radiusMatchImpl( const Mat& queryDescriptors, std::vector >& matches, float maxDistance, + const std::vector& masks=std::vector(), bool compactResult=false ); Ptr indexParams; Ptr searchParams; @@ -1284,11 +1284,11 @@ public: * If inheritor class need perform such prefiltering the method add() must be overloaded. * In the other class methods programmer has access to the train keypoints by a constant link. */ - virtual void add( const vector& images, - vector >& keypoints ); + virtual void add( const std::vector& images, + std::vector >& keypoints ); - const vector& getTrainImages() const; - const vector >& getTrainKeypoints() const; + const std::vector& getTrainImages() const; + const std::vector >& getTrainKeypoints() const; /* * Clear images and keypoints storing in train collection. @@ -1313,10 +1313,10 @@ public: * trainKeypoints Keypoints from the train image */ // Classify keypoints from query image under one train image. - void classify( const Mat& queryImage, vector& queryKeypoints, - const Mat& trainImage, vector& trainKeypoints ) const; + void classify( const Mat& queryImage, std::vector& queryKeypoints, + const Mat& trainImage, std::vector& trainKeypoints ) const; // Classify keypoints from query image under train image collection. - void classify( const Mat& queryImage, vector& queryKeypoints ); + void classify( const Mat& queryImage, std::vector& queryKeypoints ); /* * Group of methods to match keypoints from image pair. @@ -1324,34 +1324,34 @@ public: * train() method is called here. */ // Find one best match for each query descriptor (if mask is empty). - void match( const Mat& queryImage, vector& queryKeypoints, - const Mat& trainImage, vector& trainKeypoints, - vector& matches, const Mat& mask=Mat() ) const; + void match( const Mat& queryImage, std::vector& queryKeypoints, + const Mat& trainImage, std::vector& trainKeypoints, + std::vector& matches, const Mat& mask=Mat() ) const; // Find k best matches for each query keypoint (in increasing order of distances). // compactResult is used when mask is not empty. If compactResult is false matches // vector will have the same size as queryDescriptors rows. // If compactResult is true matches vector will not contain matches for fully masked out query descriptors. - void knnMatch( const Mat& queryImage, vector& queryKeypoints, - const Mat& trainImage, vector& trainKeypoints, - vector >& matches, int k, + void knnMatch( const Mat& queryImage, std::vector& queryKeypoints, + const Mat& trainImage, std::vector& trainKeypoints, + std::vector >& matches, int k, const Mat& mask=Mat(), bool compactResult=false ) const; // Find best matches for each query descriptor which have distance less than maxDistance (in increasing order of distances). - void radiusMatch( const Mat& queryImage, vector& queryKeypoints, - const Mat& trainImage, vector& trainKeypoints, - vector >& matches, float maxDistance, + void radiusMatch( const Mat& queryImage, std::vector& queryKeypoints, + const Mat& trainImage, std::vector& trainKeypoints, + std::vector >& matches, float maxDistance, const Mat& mask=Mat(), bool compactResult=false ) const; /* * Group of methods to match keypoints from one image to image set. * See description of similar methods for matching image pair above. */ - void match( const Mat& queryImage, vector& queryKeypoints, - vector& matches, const vector& masks=vector() ); - void knnMatch( const Mat& queryImage, vector& queryKeypoints, - vector >& matches, int k, - const vector& masks=vector(), bool compactResult=false ); - void radiusMatch( const Mat& queryImage, vector& queryKeypoints, - vector >& matches, float maxDistance, - const vector& masks=vector(), bool compactResult=false ); + void match( const Mat& queryImage, std::vector& queryKeypoints, + std::vector& matches, const std::vector& masks=std::vector() ); + void knnMatch( const Mat& queryImage, std::vector& queryKeypoints, + std::vector >& matches, int k, + const std::vector& masks=std::vector(), bool compactResult=false ); + void radiusMatch( const Mat& queryImage, std::vector& queryKeypoints, + std::vector >& matches, float maxDistance, + const std::vector& masks=std::vector(), bool compactResult=false ); // Reads matcher object from a file node virtual void read( const FileNode& fn ); @@ -1366,19 +1366,19 @@ public: // but with empty train data. virtual Ptr clone( bool emptyTrainData=false ) const = 0; - static Ptr create( const string& genericDescritptorMatcherType, - const string ¶msFilename=string() ); + static Ptr create( const std::string& genericDescritptorMatcherType, + const std::string ¶msFilename=std::string() ); protected: // In fact the matching is implemented only by the following two methods. These methods suppose // that the class object has been trained already. Public match methods call these methods // after calling train(). - virtual void knnMatchImpl( const Mat& queryImage, vector& queryKeypoints, - vector >& matches, int k, - const vector& masks, bool compactResult ) = 0; - virtual void radiusMatchImpl( const Mat& queryImage, vector& queryKeypoints, - vector >& matches, float maxDistance, - const vector& masks, bool compactResult ) = 0; + virtual void knnMatchImpl( const Mat& queryImage, std::vector& queryKeypoints, + std::vector >& matches, int k, + const std::vector& masks, bool compactResult ) = 0; + virtual void radiusMatchImpl( const Mat& queryImage, std::vector& queryKeypoints, + std::vector >& matches, float maxDistance, + const std::vector& masks, bool compactResult ) = 0; /* * A storage for sets of keypoints together with corresponding images and class IDs */ @@ -1387,29 +1387,29 @@ protected: public: KeyPointCollection(); KeyPointCollection( const KeyPointCollection& collection ); - void add( const vector& images, const vector >& keypoints ); + void add( const std::vector& images, const std::vector >& keypoints ); void clear(); // Returns the total number of keypoints in the collection size_t keypointCount() const; size_t imageCount() const; - const vector >& getKeypoints() const; - const vector& getKeypoints( int imgIdx ) const; + const std::vector >& getKeypoints() const; + const std::vector& getKeypoints( int imgIdx ) const; const KeyPoint& getKeyPoint( int imgIdx, int localPointIdx ) const; const KeyPoint& getKeyPoint( int globalPointIdx ) const; void getLocalIdx( int globalPointIdx, int& imgIdx, int& localPointIdx ) const; - const vector& getImages() const; + const std::vector& getImages() const; const Mat& getImage( int imgIdx ) const; protected: int pointCount; - vector images; - vector > keypoints; + std::vector images; + std::vector > keypoints; // global indices of the first points in each image, startIndices.size() = keypoints.size() - vector startIndices; + std::vector startIndices; private: static Mat clone_op( Mat m ) { return m.clone(); } @@ -1435,8 +1435,8 @@ public: VectorDescriptorMatcher( const Ptr& extractor, const Ptr& matcher ); virtual ~VectorDescriptorMatcher(); - virtual void add( const vector& imgCollection, - vector >& pointCollection ); + virtual void add( const std::vector& imgCollection, + std::vector >& pointCollection ); virtual void clear(); @@ -1451,12 +1451,12 @@ public: virtual Ptr clone( bool emptyTrainData=false ) const; protected: - virtual void knnMatchImpl( const Mat& queryImage, vector& queryKeypoints, - vector >& matches, int k, - const vector& masks, bool compactResult ); - virtual void radiusMatchImpl( const Mat& queryImage, vector& queryKeypoints, - vector >& matches, float maxDistance, - const vector& masks, bool compactResult ); + virtual void knnMatchImpl( const Mat& queryImage, std::vector& queryKeypoints, + std::vector >& matches, int k, + const std::vector& masks, bool compactResult ); + virtual void radiusMatchImpl( const Mat& queryImage, std::vector& queryKeypoints, + std::vector >& matches, float maxDistance, + const std::vector& masks, bool compactResult ); Ptr extractor; Ptr matcher; @@ -1481,42 +1481,42 @@ struct CV_EXPORTS DrawMatchesFlags }; // Draw keypoints. -CV_EXPORTS_W void drawKeypoints( const Mat& image, const vector& keypoints, CV_OUT Mat& outImage, +CV_EXPORTS_W void drawKeypoints( const Mat& image, const std::vector& keypoints, CV_OUT Mat& outImage, const Scalar& color=Scalar::all(-1), int flags=DrawMatchesFlags::DEFAULT ); // Draws matches of keypints from two images on output image. -CV_EXPORTS void drawMatches( const Mat& img1, const vector& keypoints1, - const Mat& img2, const vector& keypoints2, - const vector& matches1to2, Mat& outImg, +CV_EXPORTS void drawMatches( const Mat& img1, const std::vector& keypoints1, + const Mat& img2, const std::vector& keypoints2, + const std::vector& matches1to2, Mat& outImg, const Scalar& matchColor=Scalar::all(-1), const Scalar& singlePointColor=Scalar::all(-1), - const vector& matchesMask=vector(), int flags=DrawMatchesFlags::DEFAULT ); + const std::vector& matchesMask=std::vector(), int flags=DrawMatchesFlags::DEFAULT ); -CV_EXPORTS void drawMatches( const Mat& img1, const vector& keypoints1, - const Mat& img2, const vector& keypoints2, - const vector >& matches1to2, Mat& outImg, +CV_EXPORTS void drawMatches( const Mat& img1, const std::vector& keypoints1, + const Mat& img2, const std::vector& keypoints2, + const std::vector >& matches1to2, Mat& outImg, const Scalar& matchColor=Scalar::all(-1), const Scalar& singlePointColor=Scalar::all(-1), - const vector >& matchesMask=vector >(), int flags=DrawMatchesFlags::DEFAULT ); + const std::vector >& matchesMask=std::vector >(), int flags=DrawMatchesFlags::DEFAULT ); /****************************************************************************************\ * Functions to evaluate the feature detectors and [generic] descriptor extractors * \****************************************************************************************/ CV_EXPORTS void evaluateFeatureDetector( const Mat& img1, const Mat& img2, const Mat& H1to2, - vector* keypoints1, vector* keypoints2, + std::vector* keypoints1, std::vector* keypoints2, float& repeatability, int& correspCount, const Ptr& fdetector=Ptr() ); -CV_EXPORTS void computeRecallPrecisionCurve( const vector >& matches1to2, - const vector >& correctMatches1to2Mask, - vector& recallPrecisionCurve ); +CV_EXPORTS void computeRecallPrecisionCurve( const std::vector >& matches1to2, + const std::vector >& correctMatches1to2Mask, + std::vector& recallPrecisionCurve ); -CV_EXPORTS float getRecall( const vector& recallPrecisionCurve, float l_precision ); -CV_EXPORTS int getNearestPoint( const vector& recallPrecisionCurve, float l_precision ); +CV_EXPORTS float getRecall( const std::vector& recallPrecisionCurve, float l_precision ); +CV_EXPORTS int getNearestPoint( const std::vector& recallPrecisionCurve, float l_precision ); CV_EXPORTS void evaluateGenericDescriptorMatcher( const Mat& img1, const Mat& img2, const Mat& H1to2, - vector& keypoints1, vector& keypoints2, - vector >* matches1to2, vector >* correctMatches1to2Mask, - vector& recallPrecisionCurve, + std::vector& keypoints1, std::vector& keypoints2, + std::vector >* matches1to2, std::vector >* correctMatches1to2Mask, + std::vector& recallPrecisionCurve, const Ptr& dmatch=Ptr() ); @@ -1533,7 +1533,7 @@ public: virtual ~BOWTrainer(); void add( const Mat& descriptors ); - const vector& getDescriptors() const; + const std::vector& getDescriptors() const; int descripotorsCount() const; virtual void clear(); @@ -1549,7 +1549,7 @@ public: virtual Mat cluster( const Mat& descriptors ) const = 0; protected: - vector descriptors; + std::vector descriptors; int size; }; @@ -1587,8 +1587,8 @@ public: void setVocabulary( const Mat& vocabulary ); const Mat& getVocabulary() const; - void compute( const Mat& image, vector& keypoints, Mat& imgDescriptor, - vector >* pointIdxsOfClusters=0, Mat* descriptors=0 ); + void compute( const Mat& image, std::vector& keypoints, Mat& imgDescriptor, + std::vector >* pointIdxsOfClusters=0, Mat* descriptors=0 ); // compute() is not constant because DescriptorMatcher::match is not constant int descriptorSize() const; diff --git a/modules/features2d/perf/perf_fast.cpp b/modules/features2d/perf/perf_fast.cpp index d7bcb41e0..465bef768 100644 --- a/modules/features2d/perf/perf_fast.cpp +++ b/modules/features2d/perf/perf_fast.cpp @@ -9,7 +9,7 @@ using std::tr1::get; enum { TYPE_5_8 =FastFeatureDetector::TYPE_5_8, TYPE_7_12 = FastFeatureDetector::TYPE_7_12, TYPE_9_16 = FastFeatureDetector::TYPE_9_16 }; CV_ENUM(FastType, TYPE_5_8, TYPE_7_12, TYPE_9_16) -typedef std::tr1::tuple File_Type_t; +typedef std::tr1::tuple File_Type_t; typedef perf::TestBaseWithParam fast; #define FAST_IMAGES \ @@ -21,7 +21,7 @@ PERF_TEST_P(fast, detect, testing::Combine( testing::ValuesIn(FastType::all()) )) { - String filename = getDataPath(get<0>(GetParam())); + string filename = getDataPath(get<0>(GetParam())); int type = get<1>(GetParam()); Mat frame = imread(filename, IMREAD_GRAYSCALE); diff --git a/modules/features2d/perf/perf_orb.cpp b/modules/features2d/perf/perf_orb.cpp index 4c799ff7b..63de12e25 100644 --- a/modules/features2d/perf/perf_orb.cpp +++ b/modules/features2d/perf/perf_orb.cpp @@ -14,7 +14,7 @@ typedef perf::TestBaseWithParam orb; PERF_TEST_P(orb, detect, testing::Values(ORB_IMAGES)) { - String filename = getDataPath(GetParam()); + string filename = getDataPath(GetParam()); Mat frame = imread(filename, IMREAD_GRAYSCALE); if (frame.empty()) @@ -33,7 +33,7 @@ PERF_TEST_P(orb, detect, testing::Values(ORB_IMAGES)) PERF_TEST_P(orb, extract, testing::Values(ORB_IMAGES)) { - String filename = getDataPath(GetParam()); + string filename = getDataPath(GetParam()); Mat frame = imread(filename, IMREAD_GRAYSCALE); if (frame.empty()) @@ -56,7 +56,7 @@ PERF_TEST_P(orb, extract, testing::Values(ORB_IMAGES)) PERF_TEST_P(orb, full, testing::Values(ORB_IMAGES)) { - String filename = getDataPath(GetParam()); + string filename = getDataPath(GetParam()); Mat frame = imread(filename, IMREAD_GRAYSCALE); if (frame.empty()) diff --git a/modules/features2d/src/bagofwords.cpp b/modules/features2d/src/bagofwords.cpp index 9770064c9..b27b85123 100644 --- a/modules/features2d/src/bagofwords.cpp +++ b/modules/features2d/src/bagofwords.cpp @@ -41,8 +41,6 @@ #include "precomp.hpp" -using namespace std; - namespace cv { @@ -69,7 +67,7 @@ void BOWTrainer::add( const Mat& _descriptors ) descriptors.push_back(_descriptors); } -const vector& BOWTrainer::getDescriptors() const +const std::vector& BOWTrainer::getDescriptors() const { return descriptors; } @@ -130,7 +128,7 @@ void BOWImgDescriptorExtractor::setVocabulary( const Mat& _vocabulary ) { dmatcher->clear(); vocabulary = _vocabulary; - dmatcher->add( vector(1, vocabulary) ); + dmatcher->add( std::vector(1, vocabulary) ); } const Mat& BOWImgDescriptorExtractor::getVocabulary() const @@ -138,8 +136,8 @@ const Mat& BOWImgDescriptorExtractor::getVocabulary() const return vocabulary; } -void BOWImgDescriptorExtractor::compute( const Mat& image, vector& keypoints, Mat& imgDescriptor, - vector >* pointIdxsOfClusters, Mat* _descriptors ) +void BOWImgDescriptorExtractor::compute( const Mat& image, std::vector& keypoints, Mat& imgDescriptor, + std::vector >* pointIdxsOfClusters, Mat* _descriptors ) { imgDescriptor.release(); @@ -153,7 +151,7 @@ void BOWImgDescriptorExtractor::compute( const Mat& image, vector& key dextractor->compute( image, keypoints, descriptors ); // Match keypoint descriptors to cluster center (to vocabulary) - vector matches; + std::vector matches; dmatcher->match( descriptors, matches ); // Compute image descriptor diff --git a/modules/features2d/src/blobdetector.cpp b/modules/features2d/src/blobdetector.cpp index dcc8946c1..735fe6e78 100644 --- a/modules/features2d/src/blobdetector.cpp +++ b/modules/features2d/src/blobdetector.cpp @@ -162,12 +162,12 @@ void SimpleBlobDetector::write( cv::FileStorage& fs ) const params.write(fs); } -void SimpleBlobDetector::findBlobs(const cv::Mat &image, const cv::Mat &binaryImage, vector
¢ers) const +void SimpleBlobDetector::findBlobs(const cv::Mat &image, const cv::Mat &binaryImage, std::vector
¢ers) const { (void)image; centers.clear(); - vector < vector > contours; + std::vector < std::vector > contours; Mat tmpBinaryImage = binaryImage.clone(); findContours(tmpBinaryImage, contours, CV_RETR_LIST, CV_CHAIN_APPROX_NONE); @@ -204,7 +204,7 @@ void SimpleBlobDetector::findBlobs(const cv::Mat &image, const cv::Mat &binaryIm if (params.filterByInertia) { - double denominator = sqrt(pow(2 * moms.mu11, 2) + pow(moms.mu20 - moms.mu02, 2)); + double denominator = std::sqrt(std::pow(2 * moms.mu11, 2) + std::pow(moms.mu20 - moms.mu02, 2)); const double eps = 1e-2; double ratio; if (denominator > eps) @@ -231,7 +231,7 @@ void SimpleBlobDetector::findBlobs(const cv::Mat &image, const cv::Mat &binaryIm if (params.filterByConvexity) { - vector < Point > hull; + std::vector < Point > hull; convexHull(Mat(contours[contourIdx]), hull); double area = contourArea(Mat(contours[contourIdx])); double hullArea = contourArea(Mat(hull)); @@ -250,7 +250,7 @@ void SimpleBlobDetector::findBlobs(const cv::Mat &image, const cv::Mat &binaryIm //compute blob radius { - vector dists; + std::vector dists; for (size_t pointIdx = 0; pointIdx < contours[contourIdx].size(); pointIdx++) { Point2d pt = contours[contourIdx][pointIdx]; @@ -282,7 +282,7 @@ void SimpleBlobDetector::detectImpl(const cv::Mat& image, std::vector > centers; + std::vector < std::vector
> centers; for (double thresh = params.minThreshold; thresh < params.maxThreshold; thresh += params.thresholdStep) { Mat binarizedImage; @@ -293,9 +293,9 @@ void SimpleBlobDetector::detectImpl(const cv::Mat& image, std::vector curCenters; + std::vector < Center > curCenters; findBlobs(grayscaleImage, binarizedImage, curCenters); - vector < vector
> newCenters; + std::vector < std::vector
> newCenters; for (size_t i = 0; i < curCenters.size(); i++) { #ifdef DEBUG_BLOB_DETECTOR @@ -324,8 +324,8 @@ void SimpleBlobDetector::detectImpl(const cv::Mat& image, std::vector (1, curCenters[i])); - //centers.push_back(vector
(1, curCenters[i])); + newCenters.push_back(std::vector
(1, curCenters[i])); + //centers.push_back(std::vector
(1, curCenters[i])); } } std::copy(newCenters.begin(), newCenters.end(), std::back_inserter(centers)); diff --git a/modules/features2d/src/brisk.cpp b/modules/features2d/src/brisk.cpp index 87a1f8b42..0e67e4d0f 100644 --- a/modules/features2d/src/brisk.cpp +++ b/modules/features2d/src/brisk.cpp @@ -247,7 +247,7 @@ BRISK::generateKernel(std::vector &radiusList, std::vector &numberLi BriskPatternPoint* patternIterator = patternPoints_; // define the scale discretization: - static const float lb_scale = (float)(log(scalerange_) / log(2.0)); + static const float lb_scale = (float)(std::log(scalerange_) / std::log(2.0)); static const float lb_scale_step = lb_scale / (scales_); scaleList_ = new float[scales_]; @@ -257,7 +257,7 @@ BRISK::generateKernel(std::vector &radiusList, std::vector &numberLi for (unsigned int scale = 0; scale < scales_; ++scale) { - scaleList_[scale] = (float)pow((double) 2.0, (double) (scale * lb_scale_step)); + scaleList_[scale] = (float)std::pow((double) 2.0, (double) (scale * lb_scale_step)); sizeList_[scale] = 0; // generate the pattern points look-up @@ -519,7 +519,7 @@ RoiPredicate(const float minX, const float minY, const float maxX, const float m // computes the descriptor void -BRISK::operator()( InputArray _image, InputArray _mask, vector& keypoints, +BRISK::operator()( InputArray _image, InputArray _mask, std::vector& keypoints, OutputArray _descriptors, bool useProvidedKeypoints) const { bool doOrientation=true; @@ -530,7 +530,7 @@ BRISK::operator()( InputArray _image, InputArray _mask, vector& keypoi } void -BRISK::computeDescriptorsAndOrOrientation(InputArray _image, InputArray _mask, vector& keypoints, +BRISK::computeDescriptorsAndOrOrientation(InputArray _image, InputArray _mask, std::vector& keypoints, OutputArray _descriptors, bool doDescriptors, bool doOrientation, bool useProvidedKeypoints) const { @@ -549,14 +549,14 @@ BRISK::computeDescriptorsAndOrOrientation(InputArray _image, InputArray _mask, v std::vector kscales; // remember the scale per keypoint kscales.resize(ksize); static const float log2 = 0.693147180559945f; - static const float lb_scalerange = (float)(log(scalerange_) / (log2)); + static const float lb_scalerange = (float)(std::log(scalerange_) / (log2)); std::vector::iterator beginning = keypoints.begin(); std::vector::iterator beginningkscales = kscales.begin(); static const float basicSize06 = basicSize_ * 0.6f; for (size_t k = 0; k < ksize; k++) { unsigned int scale; - scale = std::max((int) (scales_ / lb_scalerange * (log(keypoints[k].size / (basicSize06)) / log2) + 0.5), 0); + scale = std::max((int) (scales_ / lb_scalerange * (std::log(keypoints[k].size / (basicSize06)) / log2) + 0.5), 0); // saturate if (scale >= scales_) scale = scales_ - 1; @@ -718,14 +718,14 @@ BRISK::~BRISK() } void -BRISK::operator()(InputArray image, InputArray mask, vector& keypoints) const +BRISK::operator()(InputArray image, InputArray mask, std::vector& keypoints) const { computeKeypointsNoOrientation(image, mask, keypoints); computeDescriptorsAndOrOrientation(image, mask, keypoints, cv::noArray(), false, true, true); } void -BRISK::computeKeypointsNoOrientation(InputArray _image, InputArray _mask, vector& keypoints) const +BRISK::computeKeypointsNoOrientation(InputArray _image, InputArray _mask, std::vector& keypoints) const { Mat image = _image.getMat(), mask = _mask.getMat(); if( image.type() != CV_8UC1 ) @@ -741,13 +741,13 @@ BRISK::computeKeypointsNoOrientation(InputArray _image, InputArray _mask, vector void -BRISK::detectImpl( const Mat& image, vector& keypoints, const Mat& mask) const +BRISK::detectImpl( const Mat& image, std::vector& keypoints, const Mat& mask) const { (*this)(image, mask, keypoints); } void -BRISK::computeImpl( const Mat& image, vector& keypoints, Mat& descriptors) const +BRISK::computeImpl( const Mat& image, std::vector& keypoints, Mat& descriptors) const { (*this)(image, Mat(), keypoints, descriptors, true); } diff --git a/modules/features2d/src/descriptors.cpp b/modules/features2d/src/descriptors.cpp index 06efe9791..7f87bd5eb 100644 --- a/modules/features2d/src/descriptors.cpp +++ b/modules/features2d/src/descriptors.cpp @@ -41,8 +41,6 @@ #include "precomp.hpp" -using namespace std; - namespace cv { @@ -55,7 +53,7 @@ namespace cv DescriptorExtractor::~DescriptorExtractor() {} -void DescriptorExtractor::compute( const Mat& image, vector& keypoints, Mat& descriptors ) const +void DescriptorExtractor::compute( const Mat& image, std::vector& keypoints, Mat& descriptors ) const { if( image.empty() || keypoints.empty() ) { @@ -69,7 +67,7 @@ void DescriptorExtractor::compute( const Mat& image, vector& keypoints computeImpl( image, keypoints, descriptors ); } -void DescriptorExtractor::compute( const vector& imageCollection, vector >& pointCollection, vector& descCollection ) const +void DescriptorExtractor::compute( const std::vector& imageCollection, std::vector >& pointCollection, std::vector& descCollection ) const { CV_Assert( imageCollection.size() == pointCollection.size() ); descCollection.resize( imageCollection.size() ); @@ -88,18 +86,18 @@ bool DescriptorExtractor::empty() const return false; } -void DescriptorExtractor::removeBorderKeypoints( vector& keypoints, +void DescriptorExtractor::removeBorderKeypoints( std::vector& keypoints, Size imageSize, int borderSize ) { KeyPointsFilter::runByImageBorder( keypoints, imageSize, borderSize ); } -Ptr DescriptorExtractor::create(const string& descriptorExtractorType) +Ptr DescriptorExtractor::create(const std::string& descriptorExtractorType) { if( descriptorExtractorType.find("Opponent") == 0 ) { - size_t pos = string("Opponent").size(); - string type = descriptorExtractorType.substr(pos); + size_t pos = std::string("Opponent").size(); + std::string type = descriptorExtractorType.substr(pos); return new OpponentColorDescriptorExtractor(DescriptorExtractor::create(type)); } @@ -117,7 +115,7 @@ OpponentColorDescriptorExtractor::OpponentColorDescriptorExtractor( const Ptr& opponentChannels ) +static void convertBGRImageToOpponentColorSpace( const Mat& bgrImage, std::vector& opponentChannels ) { if( bgrImage.type() != CV_8UC3 ) CV_Error( CV_StsBadArg, "input image must be an BGR image of type CV_8UC3" ); @@ -144,23 +142,23 @@ static void convertBGRImageToOpponentColorSpace( const Mat& bgrImage, vector& _kp) : kp(&_kp) {} + KP_LessThan(const std::vector& _kp) : kp(&_kp) {} bool operator()(int i, int j) const { return (*kp)[i].class_id < (*kp)[j].class_id; } - const vector* kp; + const std::vector* kp; }; -void OpponentColorDescriptorExtractor::computeImpl( const Mat& bgrImage, vector& keypoints, Mat& descriptors ) const +void OpponentColorDescriptorExtractor::computeImpl( const Mat& bgrImage, std::vector& keypoints, Mat& descriptors ) const { - vector opponentChannels; + std::vector opponentChannels; convertBGRImageToOpponentColorSpace( bgrImage, opponentChannels ); const int N = 3; // channels count - vector channelKeypoints[N]; + std::vector channelKeypoints[N]; Mat channelDescriptors[N]; - vector idxs[N]; + std::vector idxs[N]; // Compute descriptors three times, once for each Opponent channel to concatenate into a single color descriptor int maxKeypointsCount = 0; @@ -181,7 +179,7 @@ void OpponentColorDescriptorExtractor::computeImpl( const Mat& bgrImage, vector< maxKeypointsCount = std::max( maxKeypointsCount, (int)channelKeypoints[ci].size()); } - vector outKeypoints; + std::vector outKeypoints; outKeypoints.reserve( keypoints.size() ); int dSize = descriptorExtractor->descriptorSize(); diff --git a/modules/features2d/src/detectors.cpp b/modules/features2d/src/detectors.cpp index 2efd5a652..19175f1b6 100644 --- a/modules/features2d/src/detectors.cpp +++ b/modules/features2d/src/detectors.cpp @@ -41,8 +41,6 @@ #include "precomp.hpp" -using namespace std; - namespace cv { @@ -53,7 +51,7 @@ namespace cv FeatureDetector::~FeatureDetector() {} -void FeatureDetector::detect( const Mat& image, vector& keypoints, const Mat& mask ) const +void FeatureDetector::detect( const Mat& image, std::vector& keypoints, const Mat& mask ) const { keypoints.clear(); @@ -65,7 +63,7 @@ void FeatureDetector::detect( const Mat& image, vector& keypoints, con detectImpl( image, keypoints, mask ); } -void FeatureDetector::detect(const vector& imageCollection, vector >& pointCollection, const vector& masks ) const +void FeatureDetector::detect(const std::vector& imageCollection, std::vector >& pointCollection, const std::vector& masks ) const { pointCollection.resize( imageCollection.size() ); for( size_t i = 0; i < imageCollection.size(); i++ ) @@ -83,12 +81,12 @@ bool FeatureDetector::empty() const return false; } -void FeatureDetector::removeInvalidPoints( const Mat& mask, vector& keypoints ) +void FeatureDetector::removeInvalidPoints( const Mat& mask, std::vector& keypoints ) { KeyPointsFilter::runByPixelsMask( keypoints, mask ); } -Ptr FeatureDetector::create( const string& detectorType ) +Ptr FeatureDetector::create( const std::string& detectorType ) { if( detectorType.find("Grid") == 0 ) { @@ -127,17 +125,17 @@ GFTTDetector::GFTTDetector( int _nfeatures, double _qualityLevel, { } -void GFTTDetector::detectImpl( const Mat& image, vector& keypoints, const Mat& mask) const +void GFTTDetector::detectImpl( const Mat& image, std::vector& keypoints, const Mat& mask) const { Mat grayImage = image; if( image.type() != CV_8U ) cvtColor( image, grayImage, CV_BGR2GRAY ); - vector corners; + std::vector corners; goodFeaturesToTrack( grayImage, corners, nfeatures, qualityLevel, minDistance, mask, blockSize, useHarrisDetector, k ); keypoints.resize(corners.size()); - vector::const_iterator corner_it = corners.begin(); - vector::iterator keypoint_it = keypoints.begin(); + std::vector::const_iterator corner_it = corners.begin(); + std::vector::iterator keypoint_it = keypoints.begin(); for( ; corner_it != corners.end(); ++corner_it, ++keypoint_it ) { *keypoint_it = KeyPoint( *corner_it, (float)blockSize ); @@ -159,7 +157,7 @@ DenseFeatureDetector::DenseFeatureDetector( float _initFeatureScale, int _featur {} -void DenseFeatureDetector::detectImpl( const Mat& image, vector& keypoints, const Mat& mask ) const +void DenseFeatureDetector::detectImpl( const Mat& image, std::vector& keypoints, const Mat& mask ) const { float curScale = static_cast(initFeatureScale); int curStep = initXyStep; @@ -203,11 +201,11 @@ struct ResponseComparator } }; -static void keepStrongest( int N, vector& keypoints ) +static void keepStrongest( int N, std::vector& keypoints ) { if( (int)keypoints.size() > N ) { - vector::iterator nth = keypoints.begin() + N; + std::vector::iterator nth = keypoints.begin() + N; std::nth_element( keypoints.begin(), nth, keypoints.end(), ResponseComparator() ); keypoints.erase( nth, keypoints.end() ); } @@ -219,7 +217,7 @@ class GridAdaptedFeatureDetectorInvoker private: int gridRows_, gridCols_; int maxPerCell_; - vector& keypoints_; + std::vector& keypoints_; const Mat& image_; const Mat& mask_; const Ptr& detector_; @@ -231,7 +229,7 @@ private: public: - GridAdaptedFeatureDetectorInvoker(const Ptr& detector, const Mat& image, const Mat& mask, vector& keypoints, int maxPerCell, int gridRows, int gridCols + GridAdaptedFeatureDetectorInvoker(const Ptr& detector, const Mat& image, const Mat& mask, std::vector& keypoints, int maxPerCell, int gridRows, int gridCols #ifdef HAVE_TBB , tbb::mutex* kptLock #endif @@ -257,7 +255,7 @@ public: Mat sub_mask; if (!mask_.empty()) sub_mask = mask_(row_range, col_range); - vector sub_keypoints; + std::vector sub_keypoints; sub_keypoints.reserve(maxPerCell_); detector_->detect( sub_image, sub_keypoints, sub_mask ); @@ -279,7 +277,7 @@ public: }; } // namepace -void GridAdaptedFeatureDetector::detectImpl( const Mat& image, vector& keypoints, const Mat& mask ) const +void GridAdaptedFeatureDetector::detectImpl( const Mat& image, std::vector& keypoints, const Mat& mask ) const { if (image.empty() || maxTotalKeypoints < gridRows * gridCols) { @@ -310,7 +308,7 @@ bool PyramidAdaptedFeatureDetector::empty() const return detector.empty() || (FeatureDetector*)detector->empty(); } -void PyramidAdaptedFeatureDetector::detectImpl( const Mat& image, vector& keypoints, const Mat& mask ) const +void PyramidAdaptedFeatureDetector::detectImpl( const Mat& image, std::vector& keypoints, const Mat& mask ) const { Mat src = image; Mat src_mask = mask; @@ -327,9 +325,9 @@ void PyramidAdaptedFeatureDetector::detectImpl( const Mat& image, vector new_pts; + std::vector new_pts; detector->detect( src, new_pts, src_mask ); - vector::iterator it = new_pts.begin(), + std::vector::iterator it = new_pts.begin(), end = new_pts.end(); for( ; it != end; ++it) { diff --git a/modules/features2d/src/draw.cpp b/modules/features2d/src/draw.cpp index 144f71a26..16466577f 100644 --- a/modules/features2d/src/draw.cpp +++ b/modules/features2d/src/draw.cpp @@ -41,8 +41,6 @@ #include "precomp.hpp" -using namespace std; - const int draw_shift_bits = 4; const int draw_multiplier = 1 << draw_shift_bits; @@ -90,7 +88,7 @@ static inline void _drawKeypoint( Mat& img, const KeyPoint& p, const Scalar& col } } -void drawKeypoints( const Mat& image, const vector& keypoints, Mat& outImage, +void drawKeypoints( const Mat& image, const std::vector& keypoints, Mat& outImage, const Scalar& _color, int flags ) { if( !(flags & DrawMatchesFlags::DRAW_OVER_OUTIMG) ) @@ -113,7 +111,7 @@ void drawKeypoints( const Mat& image, const vector& keypoints, Mat& ou bool isRandColor = _color == Scalar::all(-1); CV_Assert( !outImage.empty() ); - vector::const_iterator it = keypoints.begin(), + std::vector::const_iterator it = keypoints.begin(), end = keypoints.end(); for( ; it != end; ++it ) { @@ -122,8 +120,8 @@ void drawKeypoints( const Mat& image, const vector& keypoints, Mat& ou } } -static void _prepareImgAndDrawKeypoints( const Mat& img1, const vector& keypoints1, - const Mat& img2, const vector& keypoints2, +static void _prepareImgAndDrawKeypoints( const Mat& img1, const std::vector& keypoints1, + const Mat& img2, const std::vector& keypoints2, Mat& outImg, Mat& outImg1, Mat& outImg2, const Scalar& singlePointColor, int flags ) { @@ -184,11 +182,11 @@ static inline void _drawMatch( Mat& outImg, Mat& outImg1, Mat& outImg2 , color, 1, CV_AA, draw_shift_bits ); } -void drawMatches( const Mat& img1, const vector& keypoints1, - const Mat& img2, const vector& keypoints2, - const vector& matches1to2, Mat& outImg, +void drawMatches( const Mat& img1, const std::vector& keypoints1, + const Mat& img2, const std::vector& keypoints2, + const std::vector& matches1to2, Mat& outImg, const Scalar& matchColor, const Scalar& singlePointColor, - const vector& matchesMask, int flags ) + const std::vector& matchesMask, int flags ) { if( !matchesMask.empty() && matchesMask.size() != matches1to2.size() ) CV_Error( CV_StsBadSize, "matchesMask must have the same size as matches1to2" ); @@ -213,11 +211,11 @@ void drawMatches( const Mat& img1, const vector& keypoints1, } } -void drawMatches( const Mat& img1, const vector& keypoints1, - const Mat& img2, const vector& keypoints2, - const vector >& matches1to2, Mat& outImg, +void drawMatches( const Mat& img1, const std::vector& keypoints1, + const Mat& img2, const std::vector& keypoints2, + const std::vector >& matches1to2, Mat& outImg, const Scalar& matchColor, const Scalar& singlePointColor, - const vector >& matchesMask, int flags ) + const std::vector >& matchesMask, int flags ) { if( !matchesMask.empty() && matchesMask.size() != matches1to2.size() ) CV_Error( CV_StsBadSize, "matchesMask must have the same size as matches1to2" ); diff --git a/modules/features2d/src/dynamic.cpp b/modules/features2d/src/dynamic.cpp index 3503cad5b..523a3e1f8 100644 --- a/modules/features2d/src/dynamic.cpp +++ b/modules/features2d/src/dynamic.cpp @@ -54,7 +54,7 @@ bool DynamicAdaptedFeatureDetector::empty() const return adjuster_.empty() || adjuster_->empty(); } -void DynamicAdaptedFeatureDetector::detectImpl(const Mat& image, vector& keypoints, const Mat& mask) const +void DynamicAdaptedFeatureDetector::detectImpl(const Mat& image, std::vector& keypoints, const Mat& mask) const { //for oscillation testing bool down = false; @@ -98,7 +98,7 @@ FastAdjuster::FastAdjuster( int init_thresh, bool nonmax, int min_thresh, int ma min_thresh_(min_thresh), max_thresh_(max_thresh) {} -void FastAdjuster::detectImpl(const Mat& image, vector& keypoints, const Mat& mask) const +void FastAdjuster::detectImpl(const Mat& image, std::vector& keypoints, const Mat& mask) const { FastFeatureDetector(thresh_, nonmax_).detect(image, keypoints, mask); } @@ -133,7 +133,7 @@ StarAdjuster::StarAdjuster(double initial_thresh, double min_thresh, double max_ min_thresh_(min_thresh), max_thresh_(max_thresh) {} -void StarAdjuster::detectImpl(const Mat& image, vector& keypoints, const Mat& mask) const +void StarAdjuster::detectImpl(const Mat& image, std::vector& keypoints, const Mat& mask) const { StarFeatureDetector detector_tmp(16, cvRound(thresh_), 10, 8, 3); detector_tmp.detect(image, keypoints, mask); @@ -167,7 +167,7 @@ SurfAdjuster::SurfAdjuster( double initial_thresh, double min_thresh, double max min_thresh_(min_thresh), max_thresh_(max_thresh) {} -void SurfAdjuster::detectImpl(const Mat& image, vector& keypoints, const cv::Mat& mask) const +void SurfAdjuster::detectImpl(const Mat& image, std::vector& keypoints, const cv::Mat& mask) const { Ptr surf = FeatureDetector::create("SURF"); surf->set("hessianThreshold", thresh_); @@ -199,7 +199,7 @@ Ptr SurfAdjuster::clone() const return cloned_obj; } -Ptr AdjusterAdapter::create( const string& detectorType ) +Ptr AdjusterAdapter::create( const std::string& detectorType ) { Ptr adapter; diff --git a/modules/features2d/src/evaluation.cpp b/modules/features2d/src/evaluation.cpp index 1724b0176..591e1c20b 100644 --- a/modules/features2d/src/evaluation.cpp +++ b/modules/features2d/src/evaluation.cpp @@ -44,7 +44,6 @@ #include using namespace cv; -using namespace std; template static int solveQuadratic(_Tp a, _Tp b, _Tp c, _Tp& x1, _Tp& x2) { @@ -89,7 +88,7 @@ static inline Point2f applyHomography( const Mat_& H, const Point2f& pt double w = 1./z; return Point2f( (float)((H(0,0)*pt.x + H(0,1)*pt.y + H(0,2))*w), (float)((H(1,0)*pt.x + H(1,1)*pt.y + H(1,2))*w) ); } - return Point2f( numeric_limits::max(), numeric_limits::max() ); + return Point2f( std::numeric_limits::max(), std::numeric_limits::max() ); } static inline void linearizeHomographyAt( const Mat_& H, const Point2f& pt, Mat_& A ) @@ -108,7 +107,7 @@ static inline void linearizeHomographyAt( const Mat_& H, const Point2f& A(1,1) = H(1,1)/p3 - p2*H(2,1)/p3_2; // fydx } else - A.setTo(Scalar::all(numeric_limits::max())); + A.setTo(Scalar::all(std::numeric_limits::max())); } class EllipticKeyPoint @@ -117,14 +116,14 @@ public: EllipticKeyPoint(); EllipticKeyPoint( const Point2f& _center, const Scalar& _ellipse ); - static void convert( const vector& src, vector& dst ); - static void convert( const vector& src, vector& dst ); + static void convert( const std::vector& src, std::vector& dst ); + static void convert( const std::vector& src, std::vector& dst ); static Mat_ getSecondMomentsMatrix( const Scalar& _ellipse ); Mat_ getSecondMomentsMatrix() const; void calcProjection( const Mat_& H, EllipticKeyPoint& projection ) const; - static void calcProjection( const vector& src, const Mat_& H, vector& dst ); + static void calcProjection( const std::vector& src, const Mat_& H, std::vector& dst ); Point2f center; Scalar ellipse; // 3 elements a, b, c: ax^2+2bxy+cy^2=1 @@ -178,7 +177,7 @@ void EllipticKeyPoint::calcProjection( const Mat_& H, EllipticKeyPoint& projection = EllipticKeyPoint( dstCenter, Scalar(dstM(0,0), dstM(0,1), dstM(1,1)) ); } -void EllipticKeyPoint::convert( const vector& src, vector& dst ) +void EllipticKeyPoint::convert( const std::vector& src, std::vector& dst ) { if( !src.empty() ) { @@ -193,7 +192,7 @@ void EllipticKeyPoint::convert( const vector& src, vector& src, vector& dst ) +void EllipticKeyPoint::convert( const std::vector& src, std::vector& dst ) { if( !src.empty() ) { @@ -207,26 +206,26 @@ void EllipticKeyPoint::convert( const vector& src, vector& src, const Mat_& H, vector& dst ) +void EllipticKeyPoint::calcProjection( const std::vector& src, const Mat_& H, std::vector& dst ) { if( !src.empty() ) { assert( !H.empty() && H.cols == 3 && H.rows == 3); dst.resize(src.size()); - vector::const_iterator srcIt = src.begin(); - vector::iterator dstIt = dst.begin(); + std::vector::const_iterator srcIt = src.begin(); + std::vector::iterator dstIt = dst.begin(); for( ; srcIt != src.end(); ++srcIt, ++dstIt ) srcIt->calcProjection(H, *dstIt); } } -static void filterEllipticKeyPointsByImageSize( vector& keypoints, const Size& imgSize ) +static void filterEllipticKeyPointsByImageSize( std::vector& keypoints, const Size& imgSize ) { if( !keypoints.empty() ) { - vector filtered; + std::vector filtered; filtered.reserve(keypoints.size()); - vector::const_iterator it = keypoints.begin(); + std::vector::const_iterator it = keypoints.begin(); for( int i = 0; it != keypoints.end(); ++it, i++ ) { if( it->center.x + it->boundingBox.width < imgSize.width && @@ -315,8 +314,8 @@ struct SIdx }; }; -static void computeOneToOneMatchedOverlaps( const vector& keypoints1, const vector& keypoints2t, - bool commonPart, vector& overlaps, float minOverlap ) +static void computeOneToOneMatchedOverlaps( const std::vector& keypoints1, const std::vector& keypoints2t, + bool commonPart, std::vector& overlaps, float minOverlap ) { CV_Assert( minOverlap >= 0.f ); overlaps.clear(); @@ -374,9 +373,9 @@ static void computeOneToOneMatchedOverlaps( const vector& keyp } } - sort( overlaps.begin(), overlaps.end() ); + std::sort( overlaps.begin(), overlaps.end() ); - typedef vector::iterator It; + typedef std::vector::iterator It; It pos = overlaps.begin(); It end = overlaps.end(); @@ -390,11 +389,11 @@ static void computeOneToOneMatchedOverlaps( const vector& keyp } static void calculateRepeatability( const Mat& img1, const Mat& img2, const Mat& H1to2, - const vector& _keypoints1, const vector& _keypoints2, + const std::vector& _keypoints1, const std::vector& _keypoints2, float& repeatability, int& correspondencesCount, Mat* thresholdedOverlapMask=0 ) { - vector keypoints1, keypoints2, keypoints1t, keypoints2t; + std::vector keypoints1, keypoints2, keypoints1t, keypoints2t; EllipticKeyPoint::convert( _keypoints1, keypoints1 ); EllipticKeyPoint::convert( _keypoints2, keypoints2 ); @@ -427,7 +426,7 @@ static void calculateRepeatability( const Mat& img1, const Mat& img2, const Mat& size_t minCount = MIN( size1, size2 ); // calculate overlap errors - vector overlaps; + std::vector overlaps; computeOneToOneMatchedOverlaps( keypoints1, keypoints2t, ifEvaluateDetectors, overlaps, overlapThreshold/*min overlap*/ ); correspondencesCount = -1; @@ -453,12 +452,12 @@ static void calculateRepeatability( const Mat& img1, const Mat& img2, const Mat& } void cv::evaluateFeatureDetector( const Mat& img1, const Mat& img2, const Mat& H1to2, - vector* _keypoints1, vector* _keypoints2, + std::vector* _keypoints1, std::vector* _keypoints2, float& repeatability, int& correspCount, const Ptr& _fdetector ) { Ptr fdetector(_fdetector); - vector *keypoints1, *keypoints2, buf1, buf2; + std::vector *keypoints1, *keypoints2, buf1, buf2; keypoints1 = _keypoints1 != 0 ? _keypoints1 : &buf1; keypoints2 = _keypoints2 != 0 ? _keypoints2 : &buf2; @@ -489,13 +488,13 @@ static inline float precision( int correctMatchCount, int falseMatchCount ) return correctMatchCount + falseMatchCount ? (float)correctMatchCount / (float)(correctMatchCount + falseMatchCount) : -1; } -void cv::computeRecallPrecisionCurve( const vector >& matches1to2, - const vector >& correctMatches1to2Mask, - vector& recallPrecisionCurve ) +void cv::computeRecallPrecisionCurve( const std::vector >& matches1to2, + const std::vector >& correctMatches1to2Mask, + std::vector& recallPrecisionCurve ) { CV_Assert( matches1to2.size() == correctMatches1to2Mask.size() ); - vector allMatches; + std::vector allMatches; int correspondenceCount = 0; for( size_t i = 0; i < matches1to2.size(); i++ ) { @@ -525,7 +524,7 @@ void cv::computeRecallPrecisionCurve( const vector >& matches1to2 } } -float cv::getRecall( const vector& recallPrecisionCurve, float l_precision ) +float cv::getRecall( const std::vector& recallPrecisionCurve, float l_precision ) { int nearestPointIndex = getNearestPoint( recallPrecisionCurve, l_precision ); @@ -537,7 +536,7 @@ float cv::getRecall( const vector& recallPrecisionCurve, float l_precis return recall; } -int cv::getNearestPoint( const vector& recallPrecisionCurve, float l_precision ) +int cv::getNearestPoint( const std::vector& recallPrecisionCurve, float l_precision ) { int nearestPointIndex = -1; @@ -559,18 +558,18 @@ int cv::getNearestPoint( const vector& recallPrecisionCurve, float l_pr } void cv::evaluateGenericDescriptorMatcher( const Mat& img1, const Mat& img2, const Mat& H1to2, - vector& keypoints1, vector& keypoints2, - vector >* _matches1to2, vector >* _correctMatches1to2Mask, - vector& recallPrecisionCurve, + std::vector& keypoints1, std::vector& keypoints2, + std::vector >* _matches1to2, std::vector >* _correctMatches1to2Mask, + std::vector& recallPrecisionCurve, const Ptr& _dmatcher ) { Ptr dmatcher = _dmatcher; dmatcher->clear(); - vector > *matches1to2, buf1; + std::vector > *matches1to2, buf1; matches1to2 = _matches1to2 != 0 ? _matches1to2 : &buf1; - vector > *correctMatches1to2Mask, buf2; + std::vector > *correctMatches1to2Mask, buf2; correctMatches1to2Mask = _correctMatches1to2Mask != 0 ? _correctMatches1to2Mask : &buf2; if( keypoints1.empty() ) diff --git a/modules/features2d/src/fast.cpp b/modules/features2d/src/fast.cpp index c82385627..8306e3eb2 100644 --- a/modules/features2d/src/fast.cpp +++ b/modules/features2d/src/fast.cpp @@ -283,7 +283,7 @@ FastFeatureDetector::FastFeatureDetector( int _threshold, bool _nonmaxSuppressio : threshold(_threshold), nonmaxSuppression(_nonmaxSuppression), type((short)_type) {} -void FastFeatureDetector::detectImpl( const Mat& image, vector& keypoints, const Mat& mask ) const +void FastFeatureDetector::detectImpl( const Mat& image, std::vector& keypoints, const Mat& mask ) const { Mat grayImage = image; if( image.type() != CV_8U ) cvtColor( image, grayImage, CV_BGR2GRAY ); diff --git a/modules/features2d/src/features2d_init.cpp b/modules/features2d/src/features2d_init.cpp index 4bfcd65ad..8dd7a2145 100644 --- a/modules/features2d/src/features2d_init.cpp +++ b/modules/features2d/src/features2d_init.cpp @@ -44,7 +44,7 @@ using namespace cv; -Ptr Feature2D::create( const string& feature2DType ) +Ptr Feature2D::create( const std::string& feature2DType ) { return Algorithm::create("Feature2D." + feature2DType); } diff --git a/modules/features2d/src/freak.cpp b/modules/features2d/src/freak.cpp index 4e1e6411f..6c9093f7c 100644 --- a/modules/features2d/src/freak.cpp +++ b/modules/features2d/src/freak.cpp @@ -114,7 +114,7 @@ void FREAK::buildPattern() patternScale0 = patternScale; patternLookup.resize(FREAK_NB_SCALES*FREAK_NB_ORIENTATION*FREAK_NB_POINTS); - double scaleStep = pow(2.0, (double)(nOctaves)/FREAK_NB_SCALES ); // 2 ^ ( (nOctaves-1) /nbScales) + double scaleStep = std::pow(2.0, (double)(nOctaves)/FREAK_NB_SCALES ); // 2 ^ ( (nOctaves-1) /nbScales) double scalingFactor, alpha, beta, theta = 0; // pattern definition, radius normalized to 1.0 (outer point position+sigma=1.0) @@ -132,7 +132,7 @@ void FREAK::buildPattern() // fill the lookup table for( int scaleIdx=0; scaleIdx < FREAK_NB_SCALES; ++scaleIdx ) { patternSizes[scaleIdx] = 0; // proper initialization - scalingFactor = pow(scaleStep,scaleIdx); //scale of the pattern, scaleStep ^ scaleIdx + scalingFactor = std::pow(scaleStep,scaleIdx); //scale of the pattern, scaleStep ^ scaleIdx for( int orientationIdx = 0; orientationIdx < FREAK_NB_ORIENTATION; ++orientationIdx ) { theta = double(orientationIdx)* 2*CV_PI/double(FREAK_NB_ORIENTATION); // orientation of the pattern @@ -239,7 +239,7 @@ void FREAK::computeImpl( const Mat& image, std::vector& keypoints, Mat if( scaleNormalized ) { for( size_t k = keypoints.size(); k--; ) { //Is k non-zero? If so, decrement it and continue" - kpScaleIdx[k] = max( (int)(log(keypoints[k].size/FREAK_SMALLEST_KP_SIZE)*sizeCst+0.5) ,0); + kpScaleIdx[k] = std::max( (int)(std::log(keypoints[k].size/FREAK_SMALLEST_KP_SIZE)*sizeCst+0.5) ,0); if( kpScaleIdx[k] >= FREAK_NB_SCALES ) kpScaleIdx[k] = FREAK_NB_SCALES-1; @@ -254,7 +254,7 @@ void FREAK::computeImpl( const Mat& image, std::vector& keypoints, Mat } } else { - const int scIdx = max( (int)(1.0986122886681*sizeCst+0.5) ,0); + const int scIdx = std::max( (int)(1.0986122886681*sizeCst+0.5) ,0); for( size_t k = keypoints.size(); k--; ) { kpScaleIdx[k] = scIdx; // equivalent to the formule when the scale is normalized with a constant size of keypoints[k].size=3*SMALLEST_KP_SIZE if( kpScaleIdx[k] >= FREAK_NB_SCALES ) { @@ -495,7 +495,7 @@ uchar FREAK::meanIntensity( const cv::Mat& image, const cv::Mat& integral, } // pair selection algorithm from a set of training images and corresponding keypoints -vector FREAK::selectPairs(const std::vector& images +std::vector FREAK::selectPairs(const std::vector& images , std::vector >& keypoints , const double corrTresh , bool verbose ) diff --git a/modules/features2d/src/keypoint.cpp b/modules/features2d/src/keypoint.cpp index 9b85fd39c..a4b960d1b 100644 --- a/modules/features2d/src/keypoint.cpp +++ b/modules/features2d/src/keypoint.cpp @@ -58,7 +58,7 @@ size_t KeyPoint::hash() const return _Val; } -void write(FileStorage& fs, const string& objname, const vector& keypoints) +void write(FileStorage& fs, const std::string& objname, const std::vector& keypoints) { WriteStructContext ws(fs, objname, CV_NODE_SEQ + CV_NODE_FLOW); @@ -77,7 +77,7 @@ void write(FileStorage& fs, const string& objname, const vector& keypo } -void read(const FileNode& node, vector& keypoints) +void read(const FileNode& node, std::vector& keypoints) { keypoints.resize(0); FileNodeIterator it = node.begin(), it_end = node.end(); @@ -91,7 +91,7 @@ void read(const FileNode& node, vector& keypoints) void KeyPoint::convert(const std::vector& keypoints, std::vector& points2f, - const vector& keypointIndexes) + const std::vector& keypointIndexes) { if( keypointIndexes.empty() ) { @@ -138,8 +138,8 @@ float KeyPoint::overlap( const KeyPoint& kp1, const KeyPoint& kp2 ) float ovrl = 0.f; // one circle is completely encovered by the other => no intersection points! - if( min( a, b ) + c <= max( a, b ) ) - return min( a_2, b_2 ) / max( a_2, b_2 ); + if( std::min( a, b ) + c <= std::max( a, b ) ) + return std::min( a_2, b_2 ) / std::max( a_2, b_2 ); if( c < a + b ) // circles intersect { @@ -189,7 +189,7 @@ struct KeypointResponseGreater }; // takes keypoints and culls them by the response -void KeyPointsFilter::retainBest(vector& keypoints, int n_points) +void KeyPointsFilter::retainBest(std::vector& keypoints, int n_points) { //this is only necessary if the keypoints size is greater than the number of desired points. if( n_points > 0 && keypoints.size() > (size_t)n_points ) @@ -204,7 +204,7 @@ void KeyPointsFilter::retainBest(vector& keypoints, int n_points) //this is the boundary response, and in the case of FAST may be ambigous float ambiguous_response = keypoints[n_points - 1].response; //use std::partition to grab all of the keypoints with the boundary response. - vector::const_iterator new_end = + std::vector::const_iterator new_end = std::partition(keypoints.begin() + n_points, keypoints.end(), KeypointResponseGreaterThanThreshold(ambiguous_response)); //resize the keypoints, given this new end point. nth_element and partition reordered the points inplace @@ -225,7 +225,7 @@ struct RoiPredicate Rect r; }; -void KeyPointsFilter::runByImageBorder( vector& keypoints, Size imageSize, int borderSize ) +void KeyPointsFilter::runByImageBorder( std::vector& keypoints, Size imageSize, int borderSize ) { if( borderSize > 0) { @@ -253,7 +253,7 @@ struct SizePredicate float minSize, maxSize; }; -void KeyPointsFilter::runByKeypointSize( vector& keypoints, float minSize, float maxSize ) +void KeyPointsFilter::runByKeypointSize( std::vector& keypoints, float minSize, float maxSize ) { CV_Assert( minSize >= 0 ); CV_Assert( maxSize >= 0); @@ -277,7 +277,7 @@ private: MaskPredicate& operator=(const MaskPredicate&); }; -void KeyPointsFilter::runByPixelsMask( vector& keypoints, const Mat& mask ) +void KeyPointsFilter::runByPixelsMask( std::vector& keypoints, const Mat& mask ) { if( mask.empty() ) return; @@ -287,7 +287,7 @@ void KeyPointsFilter::runByPixelsMask( vector& keypoints, const Mat& m struct KeyPoint_LessThan { - KeyPoint_LessThan(const vector& _kp) : kp(&_kp) {} + KeyPoint_LessThan(const std::vector& _kp) : kp(&_kp) {} bool operator()(int i, int j) const { const KeyPoint& kp1 = (*kp)[i]; @@ -309,14 +309,14 @@ struct KeyPoint_LessThan return i < j; } - const vector* kp; + const std::vector* kp; }; -void KeyPointsFilter::removeDuplicated( vector& keypoints ) +void KeyPointsFilter::removeDuplicated( std::vector& keypoints ) { int i, j, n = (int)keypoints.size(); - vector kpidx(n); - vector mask(n, (uchar)1); + std::vector kpidx(n); + std::vector mask(n, (uchar)1); for( i = 0; i < n; i++ ) kpidx[i] = i; diff --git a/modules/features2d/src/matchers.cpp b/modules/features2d/src/matchers.cpp index e82b1738b..658c902f9 100644 --- a/modules/features2d/src/matchers.cpp +++ b/modules/features2d/src/matchers.cpp @@ -49,7 +49,7 @@ namespace cv { -Mat windowedMatchingMask( const vector& keypoints1, const vector& keypoints2, +Mat windowedMatchingMask( const std::vector& keypoints1, const std::vector& keypoints2, float maxDeltaX, float maxDeltaY ) { if( keypoints1.empty() || keypoints2.empty() ) @@ -83,7 +83,7 @@ DescriptorMatcher::DescriptorCollection::DescriptorCollection( const DescriptorC DescriptorMatcher::DescriptorCollection::~DescriptorCollection() {} -void DescriptorMatcher::DescriptorCollection::set( const vector& descriptors ) +void DescriptorMatcher::DescriptorCollection::set( const std::vector& descriptors ) { clear(); @@ -175,7 +175,7 @@ int DescriptorMatcher::DescriptorCollection::size() const /* * DescriptorMatcher */ -static void convertMatches( const vector >& knnMatches, vector& matches ) +static void convertMatches( const std::vector >& knnMatches, std::vector& matches ) { matches.clear(); matches.reserve( knnMatches.size() ); @@ -190,12 +190,12 @@ static void convertMatches( const vector >& knnMatches, vector& descriptors ) +void DescriptorMatcher::add( const std::vector& descriptors ) { trainDescCollection.insert( trainDescCollection.end(), descriptors.begin(), descriptors.end() ); } -const vector& DescriptorMatcher::getTrainDescriptors() const +const std::vector& DescriptorMatcher::getTrainDescriptors() const { return trainDescCollection; } @@ -213,37 +213,37 @@ bool DescriptorMatcher::empty() const void DescriptorMatcher::train() {} -void DescriptorMatcher::match( const Mat& queryDescriptors, const Mat& trainDescriptors, vector& matches, const Mat& mask ) const +void DescriptorMatcher::match( const Mat& queryDescriptors, const Mat& trainDescriptors, std::vector& matches, const Mat& mask ) const { Ptr tempMatcher = clone(true); - tempMatcher->add( vector(1, trainDescriptors) ); - tempMatcher->match( queryDescriptors, matches, vector(1, mask) ); + tempMatcher->add( std::vector(1, trainDescriptors) ); + tempMatcher->match( queryDescriptors, matches, std::vector(1, mask) ); } -void DescriptorMatcher::knnMatch( const Mat& queryDescriptors, const Mat& trainDescriptors, vector >& matches, int knn, +void DescriptorMatcher::knnMatch( const Mat& queryDescriptors, const Mat& trainDescriptors, std::vector >& matches, int knn, const Mat& mask, bool compactResult ) const { Ptr tempMatcher = clone(true); - tempMatcher->add( vector(1, trainDescriptors) ); - tempMatcher->knnMatch( queryDescriptors, matches, knn, vector(1, mask), compactResult ); + tempMatcher->add( std::vector(1, trainDescriptors) ); + tempMatcher->knnMatch( queryDescriptors, matches, knn, std::vector(1, mask), compactResult ); } -void DescriptorMatcher::radiusMatch( const Mat& queryDescriptors, const Mat& trainDescriptors, vector >& matches, float maxDistance, +void DescriptorMatcher::radiusMatch( const Mat& queryDescriptors, const Mat& trainDescriptors, std::vector >& matches, float maxDistance, const Mat& mask, bool compactResult ) const { Ptr tempMatcher = clone(true); - tempMatcher->add( vector(1, trainDescriptors) ); - tempMatcher->radiusMatch( queryDescriptors, matches, maxDistance, vector(1, mask), compactResult ); + tempMatcher->add( std::vector(1, trainDescriptors) ); + tempMatcher->radiusMatch( queryDescriptors, matches, maxDistance, std::vector(1, mask), compactResult ); } -void DescriptorMatcher::match( const Mat& queryDescriptors, vector& matches, const vector& masks ) +void DescriptorMatcher::match( const Mat& queryDescriptors, std::vector& matches, const std::vector& masks ) { - vector > knnMatches; + std::vector > knnMatches; knnMatch( queryDescriptors, knnMatches, 1, masks, true /*compactResult*/ ); convertMatches( knnMatches, matches ); } -void DescriptorMatcher::checkMasks( const vector& masks, int queryDescriptorsCount ) const +void DescriptorMatcher::checkMasks( const std::vector& masks, int queryDescriptorsCount ) const { if( isMaskSupported() && !masks.empty() ) { @@ -262,8 +262,8 @@ void DescriptorMatcher::checkMasks( const vector& masks, int queryDescripto } } -void DescriptorMatcher::knnMatch( const Mat& queryDescriptors, vector >& matches, int knn, - const vector& masks, bool compactResult ) +void DescriptorMatcher::knnMatch( const Mat& queryDescriptors, std::vector >& matches, int knn, + const std::vector& masks, bool compactResult ) { matches.clear(); if( empty() || queryDescriptors.empty() ) @@ -277,8 +277,8 @@ void DescriptorMatcher::knnMatch( const Mat& queryDescriptors, vector >& matches, float maxDistance, - const vector& masks, bool compactResult ) +void DescriptorMatcher::radiusMatch( const Mat& queryDescriptors, std::vector >& matches, float maxDistance, + const std::vector& masks, bool compactResult ) { matches.clear(); if( empty() || queryDescriptors.empty() ) @@ -303,7 +303,7 @@ bool DescriptorMatcher::isPossibleMatch( const Mat& mask, int queryIdx, int trai return mask.empty() || mask.at(queryIdx, trainIdx); } -bool DescriptorMatcher::isMaskedOut( const vector& masks, int queryIdx ) +bool DescriptorMatcher::isMaskedOut( const std::vector& masks, int queryIdx ) { size_t outCount = 0; for( size_t i = 0; i < masks.size(); i++ ) @@ -337,8 +337,8 @@ Ptr BFMatcher::clone( bool emptyTrainData ) const } -void BFMatcher::knnMatchImpl( const Mat& queryDescriptors, vector >& matches, int knn, - const vector& masks, bool compactResult ) +void BFMatcher::knnMatchImpl( const Mat& queryDescriptors, std::vector >& matches, int knn, + const std::vector& masks, bool compactResult ) { const int IMGIDX_SHIFT = 18; const int IMGIDX_ONE = (1 << IMGIDX_SHIFT); @@ -380,8 +380,8 @@ void BFMatcher::knnMatchImpl( const Mat& queryDescriptors, vector const float* distptr = dist.ptr(qIdx); const int* nidxptr = nidx.ptr(qIdx); - matches.push_back( vector() ); - vector& mq = matches.back(); + matches.push_back( std::vector() ); + std::vector& mq = matches.back(); mq.reserve(knn); for( int k = 0; k < nidx.cols; k++ ) @@ -398,8 +398,8 @@ void BFMatcher::knnMatchImpl( const Mat& queryDescriptors, vector } -void BFMatcher::radiusMatchImpl( const Mat& queryDescriptors, vector >& matches, - float maxDistance, const vector& masks, bool compactResult ) +void BFMatcher::radiusMatchImpl( const Mat& queryDescriptors, std::vector >& matches, + float maxDistance, const std::vector& masks, bool compactResult ) { if( queryDescriptors.empty() || trainDescCollection.empty() ) { @@ -428,7 +428,7 @@ void BFMatcher::radiusMatchImpl( const Mat& queryDescriptors, vector(qIdx); - vector& mq = matches[qIdx]; + std::vector& mq = matches[qIdx]; for( int k = 0; k < distf.cols; k++ ) { if( distptr[k] <= maxDistance ) @@ -456,7 +456,7 @@ void BFMatcher::radiusMatchImpl( const Mat& queryDescriptors, vector DescriptorMatcher::create( const string& descriptorMatcherType ) +Ptr DescriptorMatcher::create( const std::string& descriptorMatcherType ) { DescriptorMatcher* dm = 0; if( !descriptorMatcherType.compare( "FlannBased" ) ) @@ -501,7 +501,7 @@ FlannBasedMatcher::FlannBasedMatcher( const Ptr& _indexParam CV_Assert( !_searchParams.empty() ); } -void FlannBasedMatcher::add( const vector& descriptors ) +void FlannBasedMatcher::add( const std::vector& descriptors ) { DescriptorMatcher::add( descriptors ); for( size_t i = 0; i < descriptors.size(); i++ ) @@ -740,7 +740,7 @@ Ptr FlannBasedMatcher::clone( bool emptyTrainData ) const } void FlannBasedMatcher::convertToDMatches( const DescriptorCollection& collection, const Mat& indices, const Mat& dists, - vector >& matches ) + std::vector >& matches ) { matches.resize( indices.rows ); for( int i = 0; i < indices.rows; i++ ) @@ -763,8 +763,8 @@ void FlannBasedMatcher::convertToDMatches( const DescriptorCollection& collectio } } -void FlannBasedMatcher::knnMatchImpl( const Mat& queryDescriptors, vector >& matches, int knn, - const vector& /*masks*/, bool /*compactResult*/ ) +void FlannBasedMatcher::knnMatchImpl( const Mat& queryDescriptors, std::vector >& matches, int knn, + const std::vector& /*masks*/, bool /*compactResult*/ ) { Mat indices( queryDescriptors.rows, knn, CV_32SC1 ); Mat dists( queryDescriptors.rows, knn, CV_32FC1); @@ -773,8 +773,8 @@ void FlannBasedMatcher::knnMatchImpl( const Mat& queryDescriptors, vector >& matches, float maxDistance, - const vector& /*masks*/, bool /*compactResult*/ ) +void FlannBasedMatcher::radiusMatchImpl( const Mat& queryDescriptors, std::vector >& matches, float maxDistance, + const std::vector& /*masks*/, bool /*compactResult*/ ) { const int count = mergedDescriptors.size(); // TODO do count as param? Mat indices( queryDescriptors.rows, count, CV_32SC1, Scalar::all(-1) ); @@ -812,8 +812,8 @@ GenericDescriptorMatcher::KeyPointCollection::KeyPointCollection( const KeyPoint std::copy( collection.startIndices.begin(), collection.startIndices.end(), startIndices.begin() ); } -void GenericDescriptorMatcher::KeyPointCollection::add( const vector& _images, - const vector >& _points ) +void GenericDescriptorMatcher::KeyPointCollection::add( const std::vector& _images, + const std::vector >& _points ) { CV_Assert( !_images.empty() ); CV_Assert( _images.size() == _points.size() ); @@ -856,12 +856,12 @@ size_t GenericDescriptorMatcher::KeyPointCollection::imageCount() const return images.size(); } -const vector >& GenericDescriptorMatcher::KeyPointCollection::getKeypoints() const +const std::vector >& GenericDescriptorMatcher::KeyPointCollection::getKeypoints() const { return keypoints; } -const vector& GenericDescriptorMatcher::KeyPointCollection::getKeypoints( int imgIdx ) const +const std::vector& GenericDescriptorMatcher::KeyPointCollection::getKeypoints( int imgIdx ) const { CV_Assert( imgIdx < (int)imageCount() ); return keypoints[imgIdx]; @@ -897,7 +897,7 @@ void GenericDescriptorMatcher::KeyPointCollection::getLocalIdx( int globalPointI localPointIdx = globalPointIdx - startIndices[imgIdx]; } -const vector& GenericDescriptorMatcher::KeyPointCollection::getImages() const +const std::vector& GenericDescriptorMatcher::KeyPointCollection::getImages() const { return images; } @@ -917,8 +917,8 @@ GenericDescriptorMatcher::GenericDescriptorMatcher() GenericDescriptorMatcher::~GenericDescriptorMatcher() {} -void GenericDescriptorMatcher::add( const vector& images, - vector >& keypoints ) +void GenericDescriptorMatcher::add( const std::vector& images, + std::vector >& keypoints ) { CV_Assert( !images.empty() ); CV_Assert( images.size() == keypoints.size() ); @@ -933,12 +933,12 @@ void GenericDescriptorMatcher::add( const vector& images, trainPointCollection.add( images, keypoints ); } -const vector& GenericDescriptorMatcher::getTrainImages() const +const std::vector& GenericDescriptorMatcher::getTrainImages() const { return trainPointCollection.getImages(); } -const vector >& GenericDescriptorMatcher::getTrainKeypoints() const +const std::vector >& GenericDescriptorMatcher::getTrainKeypoints() const { return trainPointCollection.getKeypoints(); } @@ -951,10 +951,10 @@ void GenericDescriptorMatcher::clear() void GenericDescriptorMatcher::train() {} -void GenericDescriptorMatcher::classify( const Mat& queryImage, vector& queryKeypoints, - const Mat& trainImage, vector& trainKeypoints ) const +void GenericDescriptorMatcher::classify( const Mat& queryImage, std::vector& queryKeypoints, + const Mat& trainImage, std::vector& trainKeypoints ) const { - vector matches; + std::vector matches; match( queryImage, queryKeypoints, trainImage, trainKeypoints, matches ); // remap keypoint indices to descriptors @@ -962,9 +962,9 @@ void GenericDescriptorMatcher::classify( const Mat& queryImage, vector queryKeypoints[matches[i].queryIdx].class_id = trainKeypoints[matches[i].trainIdx].class_id; } -void GenericDescriptorMatcher::classify( const Mat& queryImage, vector& queryKeypoints ) +void GenericDescriptorMatcher::classify( const Mat& queryImage, std::vector& queryKeypoints ) { - vector matches; + std::vector matches; match( queryImage, queryKeypoints, matches ); // remap keypoint indices to descriptors @@ -972,51 +972,51 @@ void GenericDescriptorMatcher::classify( const Mat& queryImage, vector queryKeypoints[matches[i].queryIdx].class_id = trainPointCollection.getKeyPoint( matches[i].trainIdx, matches[i].trainIdx ).class_id; } -void GenericDescriptorMatcher::match( const Mat& queryImage, vector& queryKeypoints, - const Mat& trainImage, vector& trainKeypoints, - vector& matches, const Mat& mask ) const +void GenericDescriptorMatcher::match( const Mat& queryImage, std::vector& queryKeypoints, + const Mat& trainImage, std::vector& trainKeypoints, + std::vector& matches, const Mat& mask ) const { Ptr tempMatcher = clone( true ); - vector > vecTrainPoints(1, trainKeypoints); - tempMatcher->add( vector(1, trainImage), vecTrainPoints ); - tempMatcher->match( queryImage, queryKeypoints, matches, vector(1, mask) ); + std::vector > vecTrainPoints(1, trainKeypoints); + tempMatcher->add( std::vector(1, trainImage), vecTrainPoints ); + tempMatcher->match( queryImage, queryKeypoints, matches, std::vector(1, mask) ); vecTrainPoints[0].swap( trainKeypoints ); } -void GenericDescriptorMatcher::knnMatch( const Mat& queryImage, vector& queryKeypoints, - const Mat& trainImage, vector& trainKeypoints, - vector >& matches, int knn, const Mat& mask, bool compactResult ) const +void GenericDescriptorMatcher::knnMatch( const Mat& queryImage, std::vector& queryKeypoints, + const Mat& trainImage, std::vector& trainKeypoints, + std::vector >& matches, int knn, const Mat& mask, bool compactResult ) const { Ptr tempMatcher = clone( true ); - vector > vecTrainPoints(1, trainKeypoints); - tempMatcher->add( vector(1, trainImage), vecTrainPoints ); - tempMatcher->knnMatch( queryImage, queryKeypoints, matches, knn, vector(1, mask), compactResult ); + std::vector > vecTrainPoints(1, trainKeypoints); + tempMatcher->add( std::vector(1, trainImage), vecTrainPoints ); + tempMatcher->knnMatch( queryImage, queryKeypoints, matches, knn, std::vector(1, mask), compactResult ); vecTrainPoints[0].swap( trainKeypoints ); } -void GenericDescriptorMatcher::radiusMatch( const Mat& queryImage, vector& queryKeypoints, - const Mat& trainImage, vector& trainKeypoints, - vector >& matches, float maxDistance, +void GenericDescriptorMatcher::radiusMatch( const Mat& queryImage, std::vector& queryKeypoints, + const Mat& trainImage, std::vector& trainKeypoints, + std::vector >& matches, float maxDistance, const Mat& mask, bool compactResult ) const { Ptr tempMatcher = clone( true ); - vector > vecTrainPoints(1, trainKeypoints); - tempMatcher->add( vector(1, trainImage), vecTrainPoints ); - tempMatcher->radiusMatch( queryImage, queryKeypoints, matches, maxDistance, vector(1, mask), compactResult ); + std::vector > vecTrainPoints(1, trainKeypoints); + tempMatcher->add( std::vector(1, trainImage), vecTrainPoints ); + tempMatcher->radiusMatch( queryImage, queryKeypoints, matches, maxDistance, std::vector(1, mask), compactResult ); vecTrainPoints[0].swap( trainKeypoints ); } -void GenericDescriptorMatcher::match( const Mat& queryImage, vector& queryKeypoints, - vector& matches, const vector& masks ) +void GenericDescriptorMatcher::match( const Mat& queryImage, std::vector& queryKeypoints, + std::vector& matches, const std::vector& masks ) { - vector > knnMatches; + std::vector > knnMatches; knnMatch( queryImage, queryKeypoints, knnMatches, 1, masks, false ); convertMatches( knnMatches, matches ); } -void GenericDescriptorMatcher::knnMatch( const Mat& queryImage, vector& queryKeypoints, - vector >& matches, int knn, - const vector& masks, bool compactResult ) +void GenericDescriptorMatcher::knnMatch( const Mat& queryImage, std::vector& queryKeypoints, + std::vector >& matches, int knn, + const std::vector& masks, bool compactResult ) { matches.clear(); @@ -1030,9 +1030,9 @@ void GenericDescriptorMatcher::knnMatch( const Mat& queryImage, vector knnMatchImpl( queryImage, queryKeypoints, matches, knn, masks, compactResult ); } -void GenericDescriptorMatcher::radiusMatch( const Mat& queryImage, vector& queryKeypoints, - vector >& matches, float maxDistance, - const vector& masks, bool compactResult ) +void GenericDescriptorMatcher::radiusMatch( const Mat& queryImage, std::vector& queryKeypoints, + std::vector >& matches, float maxDistance, + const std::vector& masks, bool compactResult ) { matches.clear(); @@ -1060,8 +1060,8 @@ bool GenericDescriptorMatcher::empty() const /* * Factory function for GenericDescriptorMatch creating */ -Ptr GenericDescriptorMatcher::create( const string& genericDescritptorMatcherType, - const string ¶msFilename ) +Ptr GenericDescriptorMatcher::create( const std::string& genericDescritptorMatcherType, + const std::string ¶msFilename ) { Ptr descriptorMatcher = Algorithm::create("DescriptorMatcher." + genericDescritptorMatcherType); @@ -1092,10 +1092,10 @@ VectorDescriptorMatcher::VectorDescriptorMatcher( const Ptr VectorDescriptorMatcher::~VectorDescriptorMatcher() {} -void VectorDescriptorMatcher::add( const vector& imgCollection, - vector >& pointCollection ) +void VectorDescriptorMatcher::add( const std::vector& imgCollection, + std::vector >& pointCollection ) { - vector descriptors; + std::vector descriptors; extractor->compute( imgCollection, pointCollection, descriptors ); matcher->add( descriptors ); @@ -1120,18 +1120,18 @@ bool VectorDescriptorMatcher::isMaskSupported() return matcher->isMaskSupported(); } -void VectorDescriptorMatcher::knnMatchImpl( const Mat& queryImage, vector& queryKeypoints, - vector >& matches, int knn, - const vector& masks, bool compactResult ) +void VectorDescriptorMatcher::knnMatchImpl( const Mat& queryImage, std::vector& queryKeypoints, + std::vector >& matches, int knn, + const std::vector& masks, bool compactResult ) { Mat queryDescriptors; extractor->compute( queryImage, queryKeypoints, queryDescriptors ); matcher->knnMatch( queryDescriptors, matches, knn, masks, compactResult ); } -void VectorDescriptorMatcher::radiusMatchImpl( const Mat& queryImage, vector& queryKeypoints, - vector >& matches, float maxDistance, - const vector& masks, bool compactResult ) +void VectorDescriptorMatcher::radiusMatchImpl( const Mat& queryImage, std::vector& queryKeypoints, + std::vector >& matches, float maxDistance, + const std::vector& masks, bool compactResult ) { Mat queryDescriptors; extractor->compute( queryImage, queryKeypoints, queryDescriptors ); diff --git a/modules/features2d/src/mser.cpp b/modules/features2d/src/mser.cpp index 439318013..6581612df 100644 --- a/modules/features2d/src/mser.cpp +++ b/modules/features2d/src/mser.cpp @@ -1263,7 +1263,7 @@ MSER::MSER( int _delta, int _min_area, int _max_area, { } -void MSER::operator()( const Mat& image, vector >& dstcontours, const Mat& mask ) const +void MSER::operator()( const Mat& image, std::vector >& dstcontours, const Mat& mask ) const { CvMat _image = image, _mask, *pmask = 0; if( mask.data ) @@ -1281,19 +1281,19 @@ void MSER::operator()( const Mat& image, vector >& dstcontours, co } -void MserFeatureDetector::detectImpl( const Mat& image, vector& keypoints, const Mat& mask ) const +void MserFeatureDetector::detectImpl( const Mat& image, std::vector& keypoints, const Mat& mask ) const { - vector > msers; + std::vector > msers; (*this)(image, msers, mask); - vector >::const_iterator contour_it = msers.begin(); + std::vector >::const_iterator contour_it = msers.begin(); Rect r(0, 0, image.cols, image.rows); for( ; contour_it != msers.end(); ++contour_it ) { // TODO check transformation from MSER region to KeyPoint RotatedRect rect = fitEllipse(Mat(*contour_it)); - float diam = sqrt(rect.size.height*rect.size.width); + float diam = std::sqrt(rect.size.height*rect.size.width); if( diam > std::numeric_limits::epsilon() && r.contains(rect.center) ) keypoints.push_back( KeyPoint(rect.center, diam) ); diff --git a/modules/features2d/src/orb.cpp b/modules/features2d/src/orb.cpp index 8aeea829a..33c23d161 100644 --- a/modules/features2d/src/orb.cpp +++ b/modules/features2d/src/orb.cpp @@ -50,7 +50,7 @@ const int DESCRIPTOR_SIZE = 32; * blockSize x blockSize patch at given points in an image */ static void -HarrisResponses(const Mat& img, vector& pts, int blockSize, float harris_k) +HarrisResponses(const Mat& img, std::vector& pts, int blockSize, float harris_k) { CV_Assert( img.type() == CV_8UC1 && blockSize*blockSize <= 2048 ); @@ -95,7 +95,7 @@ HarrisResponses(const Mat& img, vector& pts, int blockSize, float harr //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// static float IC_Angle(const Mat& image, const int half_k, Point2f pt, - const vector & u_max) + const std::vector & u_max) { int m_01 = 0, m_10 = 0; @@ -246,7 +246,7 @@ static void computeOrbDescriptor(const KeyPoint& kpt, } -static void initializeOrbPattern( const Point* pattern0, vector& pattern, int ntuples, int tupleSize, int poolSize ) +static void initializeOrbPattern( const Point* pattern0, std::vector& pattern, int ntuples, int tupleSize, int poolSize ) { RNG rng(0x12345678); int i, k, k1; @@ -577,7 +577,7 @@ int ORB::descriptorType() const * @param mask the mask to apply * @param keypoints the resulting keypoints */ -void ORB::operator()(InputArray image, InputArray mask, vector& keypoints) const +void ORB::operator()(InputArray image, InputArray mask, std::vector& keypoints) const { (*this)(image, mask, keypoints, noArray(), false); } @@ -589,11 +589,11 @@ void ORB::operator()(InputArray image, InputArray mask, vector& keypoi * @param scale the scale at which we compute the orientation * @param keypoints the resulting keypoints */ -static void computeOrientation(const Mat& image, vector& keypoints, - int halfPatchSize, const vector& umax) +static void computeOrientation(const Mat& image, std::vector& keypoints, + int halfPatchSize, const std::vector& umax) { // Process each keypoint - for (vector::iterator keypoint = keypoints.begin(), + for (std::vector::iterator keypoint = keypoints.begin(), keypointEnd = keypoints.end(); keypoint != keypointEnd; ++keypoint) { keypoint->angle = IC_Angle(image, halfPatchSize, keypoint->pt, umax); @@ -606,18 +606,18 @@ static void computeOrientation(const Mat& image, vector& keypoints, * @param mask_pyramid the masks to apply at every level * @param keypoints the resulting keypoints, clustered per level */ -static void computeKeyPoints(const vector& imagePyramid, - const vector& maskPyramid, - vector >& allKeypoints, +static void computeKeyPoints(const std::vector& imagePyramid, + const std::vector& maskPyramid, + std::vector >& allKeypoints, int nfeatures, int firstLevel, double scaleFactor, int edgeThreshold, int patchSize, int scoreType ) { int nlevels = (int)imagePyramid.size(); - vector nfeaturesPerLevel(nlevels); + std::vector nfeaturesPerLevel(nlevels); // fill the extractors and descriptors for the corresponding scales float factor = (float)(1.0 / scaleFactor); - float ndesiredFeaturesPerScale = nfeatures*(1 - factor)/(1 - (float)pow((double)factor, (double)nlevels)); + float ndesiredFeaturesPerScale = nfeatures*(1 - factor)/(1 - (float)std::pow((double)factor, (double)nlevels)); int sumFeatures = 0; for( int level = 0; level < nlevels-1; level++ ) @@ -633,12 +633,12 @@ static void computeKeyPoints(const vector& imagePyramid, // pre-compute the end of a row in a circular patch int halfPatchSize = patchSize / 2; - vector umax(halfPatchSize + 2); + std::vector umax(halfPatchSize + 2); - int v, v0, vmax = cvFloor(halfPatchSize * sqrt(2.f) / 2 + 1); - int vmin = cvCeil(halfPatchSize * sqrt(2.f) / 2); + int v, v0, vmax = cvFloor(halfPatchSize * std::sqrt(2.f) / 2 + 1); + int vmin = cvCeil(halfPatchSize * std::sqrt(2.f) / 2); for (v = 0; v <= vmax; ++v) - umax[v] = cvRound(sqrt((double)halfPatchSize * halfPatchSize - v * v)); + umax[v] = cvRound(std::sqrt((double)halfPatchSize * halfPatchSize - v * v)); // Make sure we are symmetric for (v = halfPatchSize, v0 = 0; v >= vmin; --v) @@ -656,7 +656,7 @@ static void computeKeyPoints(const vector& imagePyramid, int featuresNum = nfeaturesPerLevel[level]; allKeypoints[level].reserve(featuresNum*2); - vector & keypoints = allKeypoints[level]; + std::vector & keypoints = allKeypoints[level]; // Detect FAST features, 20 is a good threshold FastFeatureDetector fd(20, true); @@ -680,7 +680,7 @@ static void computeKeyPoints(const vector& imagePyramid, float sf = getScale(level, firstLevel, scaleFactor); // Set the level of the coordinates - for (vector::iterator keypoint = keypoints.begin(), + for (std::vector::iterator keypoint = keypoints.begin(), keypointEnd = keypoints.end(); keypoint != keypointEnd; ++keypoint) { keypoint->octave = level; @@ -699,8 +699,8 @@ static void computeKeyPoints(const vector& imagePyramid, * @param keypoints the keypoints to use * @param descriptors the resulting descriptors */ -static void computeDescriptors(const Mat& image, vector& keypoints, Mat& descriptors, - const vector& pattern, int dsize, int WTA_K) +static void computeDescriptors(const Mat& image, std::vector& keypoints, Mat& descriptors, + const std::vector& pattern, int dsize, int WTA_K) { //convert to grayscale if more than one color CV_Assert(image.type() == CV_8UC1); @@ -720,7 +720,7 @@ static void computeDescriptors(const Mat& image, vector& keypoints, Ma * @param do_keypoints if true, the keypoints are computed, otherwise used as an input * @param do_descriptors if true, also computes the descriptors */ -void ORB::operator()( InputArray _image, InputArray _mask, vector& _keypoints, +void ORB::operator()( InputArray _image, InputArray _mask, std::vector& _keypoints, OutputArray _descriptors, bool useProvidedKeypoints) const { CV_Assert(patchSize >= 2); @@ -760,7 +760,7 @@ void ORB::operator()( InputArray _image, InputArray _mask, vector& _ke } // Pre-compute the scale pyramids - vector imagePyramid(levelsNum), maskPyramid(levelsNum); + std::vector imagePyramid(levelsNum), maskPyramid(levelsNum); for (int level = 0; level < levelsNum; ++level) { float scale = 1/getScale(level, firstLevel, scaleFactor); @@ -811,7 +811,7 @@ void ORB::operator()( InputArray _image, InputArray _mask, vector& _ke } // Pre-compute the keypoints (we keep the best over all scales, so this has to be done beforehand - vector < vector > allKeypoints; + std::vector < std::vector > allKeypoints; if( do_keypoints ) { // Get keypoints, those will be far enough from the border that no check will be required for the descriptor @@ -820,18 +820,18 @@ void ORB::operator()( InputArray _image, InputArray _mask, vector& _ke edgeThreshold, patchSize, scoreType); // make sure we have the right number of keypoints keypoints - /*vector temp; + /*std::vector temp; for (int level = 0; level < n_levels; ++level) { - vector& keypoints = all_keypoints[level]; + std::vector& keypoints = all_keypoints[level]; temp.insert(temp.end(), keypoints.begin(), keypoints.end()); keypoints.clear(); } KeyPoint::retainBest(temp, n_features_); - for (vector::iterator keypoint = temp.begin(), + for (std::vector::iterator keypoint = temp.begin(), keypoint_end = temp.end(); keypoint != keypoint_end; ++keypoint) all_keypoints[keypoint->octave].push_back(*keypoint);*/ } @@ -842,7 +842,7 @@ void ORB::operator()( InputArray _image, InputArray _mask, vector& _ke // Cluster the input keypoints depending on the level they were computed at allKeypoints.resize(levelsNum); - for (vector::iterator keypoint = _keypoints.begin(), + for (std::vector::iterator keypoint = _keypoints.begin(), keypointEnd = _keypoints.end(); keypoint != keypointEnd; ++keypoint) allKeypoints[keypoint->octave].push_back(*keypoint); @@ -852,16 +852,16 @@ void ORB::operator()( InputArray _image, InputArray _mask, vector& _ke if (level == firstLevel) continue; - vector & keypoints = allKeypoints[level]; + std::vector & keypoints = allKeypoints[level]; float scale = 1/getScale(level, firstLevel, scaleFactor); - for (vector::iterator keypoint = keypoints.begin(), + for (std::vector::iterator keypoint = keypoints.begin(), keypointEnd = keypoints.end(); keypoint != keypointEnd; ++keypoint) keypoint->pt *= scale; } } Mat descriptors; - vector pattern; + std::vector pattern; if( do_descriptors ) { @@ -902,7 +902,7 @@ void ORB::operator()( InputArray _image, InputArray _mask, vector& _ke for (int level = 0; level < levelsNum; ++level) { // Get the features and compute their orientation - vector& keypoints = allKeypoints[level]; + std::vector& keypoints = allKeypoints[level]; int nkeypoints = (int)keypoints.size(); // Compute the descriptors @@ -926,7 +926,7 @@ void ORB::operator()( InputArray _image, InputArray _mask, vector& _ke if (level != firstLevel) { float scale = getScale(level, firstLevel, scaleFactor); - for (vector::iterator keypoint = keypoints.begin(), + for (std::vector::iterator keypoint = keypoints.begin(), keypointEnd = keypoints.end(); keypoint != keypointEnd; ++keypoint) keypoint->pt *= scale; } @@ -935,12 +935,12 @@ void ORB::operator()( InputArray _image, InputArray _mask, vector& _ke } } -void ORB::detectImpl( const Mat& image, vector& keypoints, const Mat& mask) const +void ORB::detectImpl( const Mat& image, std::vector& keypoints, const Mat& mask) const { (*this)(image, mask, keypoints, noArray(), false); } -void ORB::computeImpl( const Mat& image, vector& keypoints, Mat& descriptors) const +void ORB::computeImpl( const Mat& image, std::vector& keypoints, Mat& descriptors) const { (*this)(image, Mat(), keypoints, descriptors, true); } diff --git a/modules/features2d/src/stardetector.cpp b/modules/features2d/src/stardetector.cpp index 0ceb3f8c3..3dbea0ac1 100644 --- a/modules/features2d/src/stardetector.cpp +++ b/modules/features2d/src/stardetector.cpp @@ -334,7 +334,7 @@ static bool StarDetectorSuppressLines( const Mat& responses, const Mat& sizes, P static void StarDetectorSuppressNonmax( const Mat& responses, const Mat& sizes, - vector& keypoints, int border, + std::vector& keypoints, int border, int responseThreshold, int lineThresholdProjected, int lineThresholdBinarized, @@ -426,7 +426,7 @@ StarDetector::StarDetector(int _maxSize, int _responseThreshold, {} -void StarDetector::detectImpl( const Mat& image, vector& keypoints, const Mat& mask ) const +void StarDetector::detectImpl( const Mat& image, std::vector& keypoints, const Mat& mask ) const { Mat grayImage = image; if( image.type() != CV_8U ) cvtColor( image, grayImage, CV_BGR2GRAY ); @@ -435,7 +435,7 @@ void StarDetector::detectImpl( const Mat& image, vector& keypoints, co KeyPointsFilter::runByPixelsMask( keypoints, mask ); } -void StarDetector::operator()(const Mat& img, vector& keypoints) const +void StarDetector::operator()(const Mat& img, std::vector& keypoints) const { Mat responses, sizes; int border = StarDetectorComputeResponses( img, responses, sizes, maxSize ); diff --git a/modules/features2d/test/test_brisk.cpp b/modules/features2d/test/test_brisk.cpp index 49d149834..c76afff57 100644 --- a/modules/features2d/test/test_brisk.cpp +++ b/modules/features2d/test/test_brisk.cpp @@ -42,6 +42,7 @@ #include "test_precomp.hpp" +using namespace std; using namespace cv; class CV_BRISKTest : public cvtest::BaseTest diff --git a/modules/features2d/test/test_fast.cpp b/modules/features2d/test/test_fast.cpp index cdf9c8950..cee9152bf 100644 --- a/modules/features2d/test/test_fast.cpp +++ b/modules/features2d/test/test_fast.cpp @@ -42,6 +42,7 @@ #include "test_precomp.hpp" +using namespace std; using namespace cv; class CV_FastTest : public cvtest::BaseTest diff --git a/modules/features2d/test/test_nearestneighbors.cpp b/modules/features2d/test/test_nearestneighbors.cpp index 45131eff2..e61dfce6b 100644 --- a/modules/features2d/test/test_nearestneighbors.cpp +++ b/modules/features2d/test/test_nearestneighbors.cpp @@ -46,6 +46,7 @@ #include #include +using namespace std; using namespace cv; using namespace cv::flann; diff --git a/modules/features2d/test/test_orb.cpp b/modules/features2d/test/test_orb.cpp index 5fff28a92..4ec841a2f 100644 --- a/modules/features2d/test/test_orb.cpp +++ b/modules/features2d/test/test_orb.cpp @@ -42,6 +42,7 @@ #include "test_precomp.hpp" #include "opencv2/highgui/highgui.hpp" +using namespace std; using namespace cv; TEST(Features2D_ORB, _1996) diff --git a/modules/flann/include/opencv2/flann/flann.hpp b/modules/flann/include/opencv2/flann/flann.hpp index d053488ed..8a238933d 100644 --- a/modules/flann/include/opencv2/flann/flann.hpp +++ b/modules/flann/include/opencv2/flann/flann.hpp @@ -103,12 +103,12 @@ public: ~GenericIndex(); - void knnSearch(const vector& query, vector& indices, - vector& dists, int knn, const ::cvflann::SearchParams& params); + void knnSearch(const std::vector& query, std::vector& indices, + std::vector& dists, int knn, const ::cvflann::SearchParams& params); void knnSearch(const Mat& queries, Mat& indices, Mat& dists, int knn, const ::cvflann::SearchParams& params); - int radiusSearch(const vector& query, vector& indices, - vector& dists, DistanceType radius, const ::cvflann::SearchParams& params); + int radiusSearch(const std::vector& query, std::vector& indices, + std::vector& dists, DistanceType radius, const ::cvflann::SearchParams& params); int radiusSearch(const Mat& query, Mat& indices, Mat& dists, DistanceType radius, const ::cvflann::SearchParams& params); @@ -157,7 +157,7 @@ GenericIndex::~GenericIndex() } template -void GenericIndex::knnSearch(const vector& query, vector& indices, vector& dists, int knn, const ::cvflann::SearchParams& searchParams) +void GenericIndex::knnSearch(const std::vector& query, std::vector& indices, std::vector& dists, int knn, const ::cvflann::SearchParams& searchParams) { ::cvflann::Matrix m_query((ElementType*)&query[0], 1, query.size()); ::cvflann::Matrix m_indices(&indices[0], 1, indices.size()); @@ -190,7 +190,7 @@ void GenericIndex::knnSearch(const Mat& queries, Mat& indices, Mat& di } template -int GenericIndex::radiusSearch(const vector& query, vector& indices, vector& dists, DistanceType radius, const ::cvflann::SearchParams& searchParams) +int GenericIndex::radiusSearch(const std::vector& query, std::vector& indices, std::vector& dists, DistanceType radius, const ::cvflann::SearchParams& searchParams) { ::cvflann::Matrix m_query((ElementType*)&query[0], 1, query.size()); ::cvflann::Matrix m_indices(&indices[0], 1, indices.size()); @@ -238,10 +238,10 @@ public: ~Index_(); - void knnSearch(const vector& query, vector& indices, vector& dists, int knn, const ::cvflann::SearchParams& params); + void knnSearch(const std::vector& query, std::vector& indices, std::vector& dists, int knn, const ::cvflann::SearchParams& params); void knnSearch(const Mat& queries, Mat& indices, Mat& dists, int knn, const ::cvflann::SearchParams& params); - int radiusSearch(const vector& query, vector& indices, vector& dists, DistanceType radius, const ::cvflann::SearchParams& params); + int radiusSearch(const std::vector& query, std::vector& indices, std::vector& dists, DistanceType radius, const ::cvflann::SearchParams& params); int radiusSearch(const Mat& query, Mat& indices, Mat& dists, DistanceType radius, const ::cvflann::SearchParams& params); void save(std::string filename) @@ -320,7 +320,7 @@ Index_::~Index_() } template -void Index_::knnSearch(const vector& query, vector& indices, vector& dists, int knn, const ::cvflann::SearchParams& searchParams) +void Index_::knnSearch(const std::vector& query, std::vector& indices, std::vector& dists, int knn, const ::cvflann::SearchParams& searchParams) { ::cvflann::Matrix m_query((ElementType*)&query[0], 1, query.size()); ::cvflann::Matrix m_indices(&indices[0], 1, indices.size()); @@ -351,7 +351,7 @@ void Index_::knnSearch(const Mat& queries, Mat& indices, Mat& dists, int knn, } template -int Index_::radiusSearch(const vector& query, vector& indices, vector& dists, DistanceType radius, const ::cvflann::SearchParams& searchParams) +int Index_::radiusSearch(const std::vector& query, std::vector& indices, std::vector& dists, DistanceType radius, const ::cvflann::SearchParams& searchParams) { ::cvflann::Matrix m_query((ElementType*)&query[0], 1, query.size()); ::cvflann::Matrix m_indices(&indices[0], 1, indices.size()); diff --git a/modules/gpu/include/opencv2/gpu/gpu.hpp b/modules/gpu/include/opencv2/gpu/gpu.hpp index 57f8c1157..96d028ac3 100644 --- a/modules/gpu/include/opencv2/gpu/gpu.hpp +++ b/modules/gpu/include/opencv2/gpu/gpu.hpp @@ -429,13 +429,13 @@ CV_EXPORTS void LUT(const GpuMat& src, const Mat& lut, GpuMat& dst, Stream& stre CV_EXPORTS void merge(const GpuMat* src, size_t n, GpuMat& dst, Stream& stream = Stream::Null()); //! makes multi-channel array out of several single-channel arrays -CV_EXPORTS void merge(const vector& src, GpuMat& dst, Stream& stream = Stream::Null()); +CV_EXPORTS void merge(const std::vector& src, GpuMat& dst, Stream& stream = Stream::Null()); //! copies each plane of a multi-channel array to a dedicated array CV_EXPORTS void split(const GpuMat& src, GpuMat* dst, Stream& stream = Stream::Null()); //! copies each plane of a multi-channel array to a dedicated array -CV_EXPORTS void split(const GpuMat& src, vector& dst, Stream& stream = Stream::Null()); +CV_EXPORTS void split(const GpuMat& src, std::vector& dst, Stream& stream = Stream::Null()); //! computes magnitude of complex (x(i).re, x(i).im) vector //! supports only CV_32FC2 type @@ -1227,9 +1227,9 @@ private: struct CV_EXPORTS HOGConfidence { double scale; - vector locations; - vector confidences; - vector part_scores[4]; + std::vector locations; + std::vector confidences; + std::vector part_scores[4]; }; struct CV_EXPORTS HOGDescriptor @@ -1247,27 +1247,27 @@ struct CV_EXPORTS HOGDescriptor size_t getDescriptorSize() const; size_t getBlockHistogramSize() const; - void setSVMDetector(const vector& detector); + void setSVMDetector(const std::vector& detector); - static vector getDefaultPeopleDetector(); - static vector getPeopleDetector48x96(); - static vector getPeopleDetector64x128(); + static std::vector getDefaultPeopleDetector(); + static std::vector getPeopleDetector48x96(); + static std::vector getPeopleDetector64x128(); - void detect(const GpuMat& img, vector& found_locations, + void detect(const GpuMat& img, std::vector& found_locations, double hit_threshold=0, Size win_stride=Size(), Size padding=Size()); - void detectMultiScale(const GpuMat& img, vector& found_locations, + void detectMultiScale(const GpuMat& img, std::vector& found_locations, double hit_threshold=0, Size win_stride=Size(), Size padding=Size(), double scale0=1.05, int group_threshold=2); - void computeConfidence(const GpuMat& img, vector& hits, double hit_threshold, - Size win_stride, Size padding, vector& locations, vector& confidences); + void computeConfidence(const GpuMat& img, std::vector& hits, double hit_threshold, + Size win_stride, Size padding, std::vector& locations, std::vector& confidences); - void computeConfidenceMultiScale(const GpuMat& img, vector& found_locations, + void computeConfidenceMultiScale(const GpuMat& img, std::vector& found_locations, double hit_threshold, Size win_stride, Size padding, - vector &conf_out, int group_threshold); + std::vector &conf_out, int group_threshold); void getDescriptors(const GpuMat& img, Size win_stride, GpuMat& descriptors, @@ -1640,12 +1640,12 @@ public: int descriptorSize() const; //! upload host keypoints to device memory - static void uploadKeypoints(const vector& keypoints, GpuMat& keypointsGPU); + static void uploadKeypoints(const std::vector& keypoints, GpuMat& keypointsGPU); //! download keypoints from device to host memory - static void downloadKeypoints(const GpuMat& keypointsGPU, vector& keypoints); + static void downloadKeypoints(const GpuMat& keypointsGPU, std::vector& keypoints); //! download descriptors from device to host memory - static void downloadDescriptors(const GpuMat& descriptorsGPU, vector& descriptors); + static void downloadDescriptors(const GpuMat& descriptorsGPU, std::vector& descriptors); //! finds the keypoints using fast hessian detector used in SURF //! supports CV_8UC1 images @@ -1951,8 +1951,8 @@ public: bool useInitialFlow; private: - vector prevPyr_; - vector nextPyr_; + std::vector prevPyr_; + std::vector nextPyr_; GpuMat buf_; diff --git a/modules/gpu/src/arithm.cpp b/modules/gpu/src/arithm.cpp index 7e0aaab68..851ac938e 100644 --- a/modules/gpu/src/arithm.cpp +++ b/modules/gpu/src/arithm.cpp @@ -44,7 +44,6 @@ using namespace cv; using namespace cv::gpu; -using namespace std; #if !defined (HAVE_CUDA) || defined (CUDA_DISABLER) @@ -549,13 +548,13 @@ void cv::gpu::normalize(const GpuMat& src, GpuMat& dst, double a, double b, int double smin = 0, smax = 0; double dmin = std::min(a, b), dmax = std::max(a, b); minMax(src, &smin, &smax, mask, norm_buf); - scale = (dmax - dmin) * (smax - smin > numeric_limits::epsilon() ? 1.0 / (smax - smin) : 0.0); + scale = (dmax - dmin) * (smax - smin > std::numeric_limits::epsilon() ? 1.0 / (smax - smin) : 0.0); shift = dmin - smin * scale; } else if (norm_type == NORM_L2 || norm_type == NORM_L1 || norm_type == NORM_INF) { scale = norm(src, norm_type, mask, norm_buf); - scale = scale > numeric_limits::epsilon() ? a / scale : 0.0; + scale = scale > std::numeric_limits::epsilon() ? a / scale : 0.0; shift = 0; } else diff --git a/modules/gpu/src/bilateral_filter.cpp b/modules/gpu/src/bilateral_filter.cpp index b93526cb5..6aa0f525d 100644 --- a/modules/gpu/src/bilateral_filter.cpp +++ b/modules/gpu/src/bilateral_filter.cpp @@ -44,7 +44,6 @@ using namespace cv; using namespace cv::gpu; -using namespace std; #if !defined (HAVE_CUDA) || defined (CUDA_DISABLER) @@ -107,7 +106,7 @@ namespace GpuMat& table_color, GpuMat& table_space, const GpuMat& disp, const GpuMat& img, GpuMat& dst, Stream& stream) { - short edge_disc = max(short(1), short(ndisp * edge_threshold + 0.5)); + short edge_disc = std::max(short(1), short(ndisp * edge_threshold + 0.5)); short max_disc = short(ndisp * max_disc_threshold + 0.5); disp_load_constants(table_color.ptr(), table_space, ndisp, radius, edge_disc, max_disc); diff --git a/modules/gpu/src/blend.cpp b/modules/gpu/src/blend.cpp index 2ca7da85a..df73afad6 100644 --- a/modules/gpu/src/blend.cpp +++ b/modules/gpu/src/blend.cpp @@ -42,7 +42,6 @@ #include "precomp.hpp" -using namespace std; using namespace cv; using namespace cv::gpu; diff --git a/modules/gpu/src/brute_force_matcher.cpp b/modules/gpu/src/brute_force_matcher.cpp index 095a64adb..4276f75a9 100644 --- a/modules/gpu/src/brute_force_matcher.cpp +++ b/modules/gpu/src/brute_force_matcher.cpp @@ -44,41 +44,40 @@ using namespace cv; using namespace cv::gpu; -using namespace std; #if !defined (HAVE_CUDA) || defined (CUDA_DISABLER) cv::gpu::BFMatcher_GPU::BFMatcher_GPU(int) { throw_nogpu(); } -void cv::gpu::BFMatcher_GPU::add(const vector&) { throw_nogpu(); } -const vector& cv::gpu::BFMatcher_GPU::getTrainDescriptors() const { throw_nogpu(); return trainDescCollection; } +void cv::gpu::BFMatcher_GPU::add(const std::vector&) { throw_nogpu(); } +const std::vector& cv::gpu::BFMatcher_GPU::getTrainDescriptors() const { throw_nogpu(); return trainDescCollection; } void cv::gpu::BFMatcher_GPU::clear() { throw_nogpu(); } bool cv::gpu::BFMatcher_GPU::empty() const { throw_nogpu(); return true; } bool cv::gpu::BFMatcher_GPU::isMaskSupported() const { throw_nogpu(); return true; } void cv::gpu::BFMatcher_GPU::matchSingle(const GpuMat&, const GpuMat&, GpuMat&, GpuMat&, const GpuMat&, Stream&) { throw_nogpu(); } -void cv::gpu::BFMatcher_GPU::matchDownload(const GpuMat&, const GpuMat&, vector&) { throw_nogpu(); } -void cv::gpu::BFMatcher_GPU::matchConvert(const Mat&, const Mat&, vector&) { throw_nogpu(); } -void cv::gpu::BFMatcher_GPU::match(const GpuMat&, const GpuMat&, vector&, const GpuMat&) { throw_nogpu(); } -void cv::gpu::BFMatcher_GPU::makeGpuCollection(GpuMat&, GpuMat&, const vector&) { throw_nogpu(); } +void cv::gpu::BFMatcher_GPU::matchDownload(const GpuMat&, const GpuMat&, std::vector&) { throw_nogpu(); } +void cv::gpu::BFMatcher_GPU::matchConvert(const Mat&, const Mat&, std::vector&) { throw_nogpu(); } +void cv::gpu::BFMatcher_GPU::match(const GpuMat&, const GpuMat&, std::vector&, const GpuMat&) { throw_nogpu(); } +void cv::gpu::BFMatcher_GPU::makeGpuCollection(GpuMat&, GpuMat&, const std::vector&) { throw_nogpu(); } void cv::gpu::BFMatcher_GPU::matchCollection(const GpuMat&, const GpuMat&, GpuMat&, GpuMat&, GpuMat&, const GpuMat&, Stream&) { throw_nogpu(); } -void cv::gpu::BFMatcher_GPU::matchDownload(const GpuMat&, const GpuMat&, const GpuMat&, vector&) { throw_nogpu(); } -void cv::gpu::BFMatcher_GPU::matchConvert(const Mat&, const Mat&, const Mat&, vector&) { throw_nogpu(); } -void cv::gpu::BFMatcher_GPU::match(const GpuMat&, vector&, const vector&) { throw_nogpu(); } +void cv::gpu::BFMatcher_GPU::matchDownload(const GpuMat&, const GpuMat&, const GpuMat&, std::vector&) { throw_nogpu(); } +void cv::gpu::BFMatcher_GPU::matchConvert(const Mat&, const Mat&, const Mat&, std::vector&) { throw_nogpu(); } +void cv::gpu::BFMatcher_GPU::match(const GpuMat&, std::vector&, const std::vector&) { throw_nogpu(); } void cv::gpu::BFMatcher_GPU::knnMatchSingle(const GpuMat&, const GpuMat&, GpuMat&, GpuMat&, GpuMat&, int, const GpuMat&, Stream&) { throw_nogpu(); } -void cv::gpu::BFMatcher_GPU::knnMatchDownload(const GpuMat&, const GpuMat&, vector< vector >&, bool) { throw_nogpu(); } -void cv::gpu::BFMatcher_GPU::knnMatchConvert(const Mat&, const Mat&, vector< vector >&, bool) { throw_nogpu(); } -void cv::gpu::BFMatcher_GPU::knnMatch(const GpuMat&, const GpuMat&, vector< vector >&, int, const GpuMat&, bool) { throw_nogpu(); } +void cv::gpu::BFMatcher_GPU::knnMatchDownload(const GpuMat&, const GpuMat&, std::vector< std::vector >&, bool) { throw_nogpu(); } +void cv::gpu::BFMatcher_GPU::knnMatchConvert(const Mat&, const Mat&, std::vector< std::vector >&, bool) { throw_nogpu(); } +void cv::gpu::BFMatcher_GPU::knnMatch(const GpuMat&, const GpuMat&, std::vector< std::vector >&, int, const GpuMat&, bool) { throw_nogpu(); } void cv::gpu::BFMatcher_GPU::knnMatch2Collection(const GpuMat&, const GpuMat&, GpuMat&, GpuMat&, GpuMat&, const GpuMat&, Stream&) { throw_nogpu(); } -void cv::gpu::BFMatcher_GPU::knnMatch2Download(const GpuMat&, const GpuMat&, const GpuMat&, vector< vector >&, bool) { throw_nogpu(); } -void cv::gpu::BFMatcher_GPU::knnMatch2Convert(const Mat&, const Mat&, const Mat&, vector< vector >&, bool) { throw_nogpu(); } -void cv::gpu::BFMatcher_GPU::knnMatch(const GpuMat&, vector< vector >&, int, const vector&, bool) { throw_nogpu(); } +void cv::gpu::BFMatcher_GPU::knnMatch2Download(const GpuMat&, const GpuMat&, const GpuMat&, std::vector< std::vector >&, bool) { throw_nogpu(); } +void cv::gpu::BFMatcher_GPU::knnMatch2Convert(const Mat&, const Mat&, const Mat&, std::vector< std::vector >&, bool) { throw_nogpu(); } +void cv::gpu::BFMatcher_GPU::knnMatch(const GpuMat&, std::vector< std::vector >&, int, const std::vector&, bool) { throw_nogpu(); } void cv::gpu::BFMatcher_GPU::radiusMatchSingle(const GpuMat&, const GpuMat&, GpuMat&, GpuMat&, GpuMat&, float, const GpuMat&, Stream&) { throw_nogpu(); } -void cv::gpu::BFMatcher_GPU::radiusMatchDownload(const GpuMat&, const GpuMat&, const GpuMat&, vector< vector >&, bool) { throw_nogpu(); } -void cv::gpu::BFMatcher_GPU::radiusMatchConvert(const Mat&, const Mat&, const Mat&, vector< vector >&, bool) { throw_nogpu(); } -void cv::gpu::BFMatcher_GPU::radiusMatch(const GpuMat&, const GpuMat&, vector< vector >&, float, const GpuMat&, bool) { throw_nogpu(); } -void cv::gpu::BFMatcher_GPU::radiusMatchCollection(const GpuMat&, GpuMat&, GpuMat&, GpuMat&, GpuMat&, float, const vector&, Stream&) { throw_nogpu(); } -void cv::gpu::BFMatcher_GPU::radiusMatchDownload(const GpuMat&, const GpuMat&, const GpuMat&, const GpuMat&, vector< vector >&, bool) { throw_nogpu(); } -void cv::gpu::BFMatcher_GPU::radiusMatchConvert(const Mat&, const Mat&, const Mat&, const Mat&, vector< vector >&, bool) { throw_nogpu(); } -void cv::gpu::BFMatcher_GPU::radiusMatch(const GpuMat&, vector< vector >&, float, const vector&, bool) { throw_nogpu(); } +void cv::gpu::BFMatcher_GPU::radiusMatchDownload(const GpuMat&, const GpuMat&, const GpuMat&, std::vector< std::vector >&, bool) { throw_nogpu(); } +void cv::gpu::BFMatcher_GPU::radiusMatchConvert(const Mat&, const Mat&, const Mat&, std::vector< std::vector >&, bool) { throw_nogpu(); } +void cv::gpu::BFMatcher_GPU::radiusMatch(const GpuMat&, const GpuMat&, std::vector< std::vector >&, float, const GpuMat&, bool) { throw_nogpu(); } +void cv::gpu::BFMatcher_GPU::radiusMatchCollection(const GpuMat&, GpuMat&, GpuMat&, GpuMat&, GpuMat&, float, const std::vector&, Stream&) { throw_nogpu(); } +void cv::gpu::BFMatcher_GPU::radiusMatchDownload(const GpuMat&, const GpuMat&, const GpuMat&, const GpuMat&, std::vector< std::vector >&, bool) { throw_nogpu(); } +void cv::gpu::BFMatcher_GPU::radiusMatchConvert(const Mat&, const Mat&, const Mat&, const Mat&, std::vector< std::vector >&, bool) { throw_nogpu(); } +void cv::gpu::BFMatcher_GPU::radiusMatch(const GpuMat&, std::vector< std::vector >&, float, const std::vector&, bool) { throw_nogpu(); } #else /* !defined (HAVE_CUDA) */ @@ -163,12 +162,12 @@ cv::gpu::BFMatcher_GPU::BFMatcher_GPU(int norm_) : norm(norm_) { } -void cv::gpu::BFMatcher_GPU::add(const vector& descCollection) +void cv::gpu::BFMatcher_GPU::add(const std::vector& descCollection) { trainDescCollection.insert(trainDescCollection.end(), descCollection.begin(), descCollection.end()); } -const vector& cv::gpu::BFMatcher_GPU::getTrainDescriptors() const +const std::vector& cv::gpu::BFMatcher_GPU::getTrainDescriptors() const { return trainDescCollection; } @@ -241,7 +240,7 @@ void cv::gpu::BFMatcher_GPU::matchSingle(const GpuMat& query, const GpuMat& trai func(query, train, mask, trainIdx, distance, StreamAccessor::getStream(stream)); } -void cv::gpu::BFMatcher_GPU::matchDownload(const GpuMat& trainIdx, const GpuMat& distance, vector& matches) +void cv::gpu::BFMatcher_GPU::matchDownload(const GpuMat& trainIdx, const GpuMat& distance, std::vector& matches) { if (trainIdx.empty() || distance.empty()) return; @@ -252,7 +251,7 @@ void cv::gpu::BFMatcher_GPU::matchDownload(const GpuMat& trainIdx, const GpuMat& matchConvert(trainIdxCPU, distanceCPU, matches); } -void cv::gpu::BFMatcher_GPU::matchConvert(const Mat& trainIdx, const Mat& distance, vector& matches) +void cv::gpu::BFMatcher_GPU::matchConvert(const Mat& trainIdx, const Mat& distance, std::vector& matches) { if (trainIdx.empty() || distance.empty()) return; @@ -283,7 +282,7 @@ void cv::gpu::BFMatcher_GPU::matchConvert(const Mat& trainIdx, const Mat& distan } void cv::gpu::BFMatcher_GPU::match(const GpuMat& query, const GpuMat& train, - vector& matches, const GpuMat& mask) + std::vector& matches, const GpuMat& mask) { GpuMat trainIdx, distance; matchSingle(query, train, trainIdx, distance, mask); @@ -291,7 +290,7 @@ void cv::gpu::BFMatcher_GPU::match(const GpuMat& query, const GpuMat& train, } void cv::gpu::BFMatcher_GPU::makeGpuCollection(GpuMat& trainCollection, GpuMat& maskCollection, - const vector& masks) + const std::vector& masks) { if (empty()) return; @@ -383,7 +382,7 @@ void cv::gpu::BFMatcher_GPU::matchCollection(const GpuMat& query, const GpuMat& func(query, trainCollection, masks, trainIdx, imgIdx, distance, StreamAccessor::getStream(stream)); } -void cv::gpu::BFMatcher_GPU::matchDownload(const GpuMat& trainIdx, const GpuMat& imgIdx, const GpuMat& distance, vector& matches) +void cv::gpu::BFMatcher_GPU::matchDownload(const GpuMat& trainIdx, const GpuMat& imgIdx, const GpuMat& distance, std::vector& matches) { if (trainIdx.empty() || imgIdx.empty() || distance.empty()) return; @@ -429,7 +428,7 @@ void cv::gpu::BFMatcher_GPU::matchConvert(const Mat& trainIdx, const Mat& imgIdx } } -void cv::gpu::BFMatcher_GPU::match(const GpuMat& query, vector& matches, const vector& masks) +void cv::gpu::BFMatcher_GPU::match(const GpuMat& query, std::vector& matches, const std::vector& masks) { GpuMat trainCollection; GpuMat maskCollection; @@ -510,7 +509,7 @@ void cv::gpu::BFMatcher_GPU::knnMatchSingle(const GpuMat& query, const GpuMat& t } void cv::gpu::BFMatcher_GPU::knnMatchDownload(const GpuMat& trainIdx, const GpuMat& distance, - vector< vector >& matches, bool compactResult) + std::vector< std::vector >& matches, bool compactResult) { if (trainIdx.empty() || distance.empty()) return; @@ -522,7 +521,7 @@ void cv::gpu::BFMatcher_GPU::knnMatchDownload(const GpuMat& trainIdx, const GpuM } void cv::gpu::BFMatcher_GPU::knnMatchConvert(const Mat& trainIdx, const Mat& distance, - vector< vector >& matches, bool compactResult) + std::vector< std::vector >& matches, bool compactResult) { if (trainIdx.empty() || distance.empty()) return; @@ -543,8 +542,8 @@ void cv::gpu::BFMatcher_GPU::knnMatchConvert(const Mat& trainIdx, const Mat& dis for (int queryIdx = 0; queryIdx < nQuery; ++queryIdx) { - matches.push_back(vector()); - vector& curMatches = matches.back(); + matches.push_back(std::vector()); + std::vector& curMatches = matches.back(); curMatches.reserve(k); for (int i = 0; i < k; ++i, ++trainIdx_ptr, ++distance_ptr) @@ -567,7 +566,7 @@ void cv::gpu::BFMatcher_GPU::knnMatchConvert(const Mat& trainIdx, const Mat& dis } void cv::gpu::BFMatcher_GPU::knnMatch(const GpuMat& query, const GpuMat& train, - vector< vector >& matches, int k, const GpuMat& mask, bool compactResult) + std::vector< std::vector >& matches, int k, const GpuMat& mask, bool compactResult) { GpuMat trainIdx, distance, allDist; knnMatchSingle(query, train, trainIdx, distance, allDist, k, mask); @@ -629,7 +628,7 @@ void cv::gpu::BFMatcher_GPU::knnMatch2Collection(const GpuMat& query, const GpuM } void cv::gpu::BFMatcher_GPU::knnMatch2Download(const GpuMat& trainIdx, const GpuMat& imgIdx, const GpuMat& distance, - vector< vector >& matches, bool compactResult) + std::vector< std::vector >& matches, bool compactResult) { if (trainIdx.empty() || imgIdx.empty() || distance.empty()) return; @@ -642,7 +641,7 @@ void cv::gpu::BFMatcher_GPU::knnMatch2Download(const GpuMat& trainIdx, const Gpu } void cv::gpu::BFMatcher_GPU::knnMatch2Convert(const Mat& trainIdx, const Mat& imgIdx, const Mat& distance, - vector< vector >& matches, bool compactResult) + std::vector< std::vector >& matches, bool compactResult) { if (trainIdx.empty() || imgIdx.empty() || distance.empty()) return; @@ -662,8 +661,8 @@ void cv::gpu::BFMatcher_GPU::knnMatch2Convert(const Mat& trainIdx, const Mat& im for (int queryIdx = 0; queryIdx < nQuery; ++queryIdx) { - matches.push_back(vector()); - vector& curMatches = matches.back(); + matches.push_back(std::vector()); + std::vector& curMatches = matches.back(); curMatches.reserve(2); for (int i = 0; i < 2; ++i, ++trainIdx_ptr, ++imgIdx_ptr, ++distance_ptr) @@ -697,8 +696,8 @@ namespace }; } -void cv::gpu::BFMatcher_GPU::knnMatch(const GpuMat& query, vector< vector >& matches, int k, - const vector& masks, bool compactResult) +void cv::gpu::BFMatcher_GPU::knnMatch(const GpuMat& query, std::vector< std::vector >& matches, int k, + const std::vector& masks, bool compactResult) { if (k == 2) { @@ -717,12 +716,12 @@ void cv::gpu::BFMatcher_GPU::knnMatch(const GpuMat& query, vector< vector > curMatches; - vector temp; + std::vector< std::vector > curMatches; + std::vector temp; temp.reserve(2 * k); matches.resize(query.rows); - for_each(matches.begin(), matches.end(), bind2nd(mem_fun_ref(&vector::reserve), k)); + for_each(matches.begin(), matches.end(), bind2nd(mem_fun_ref(&std::vector::reserve), k)); for (size_t imgIdx = 0, size = trainDescCollection.size(); imgIdx < size; ++imgIdx) { @@ -730,8 +729,8 @@ void cv::gpu::BFMatcher_GPU::knnMatch(const GpuMat& query, vector< vector& localMatch = curMatches[queryIdx]; - vector& globalMatch = matches[queryIdx]; + std::vector& localMatch = curMatches[queryIdx]; + std::vector& globalMatch = matches[queryIdx]; for_each(localMatch.begin(), localMatch.end(), ImgIdxSetter(static_cast(imgIdx))); @@ -746,7 +745,7 @@ void cv::gpu::BFMatcher_GPU::knnMatch(const GpuMat& query, vector< vector >::iterator new_end = remove_if(matches.begin(), matches.end(), mem_fun_ref(&vector::empty)); + std::vector< std::vector >::iterator new_end = remove_if(matches.begin(), matches.end(), mem_fun_ref(&std::vector::empty)); matches.erase(new_end, matches.end()); } } @@ -816,7 +815,7 @@ void cv::gpu::BFMatcher_GPU::radiusMatchSingle(const GpuMat& query, const GpuMat } void cv::gpu::BFMatcher_GPU::radiusMatchDownload(const GpuMat& trainIdx, const GpuMat& distance, const GpuMat& nMatches, - vector< vector >& matches, bool compactResult) + std::vector< std::vector >& matches, bool compactResult) { if (trainIdx.empty() || distance.empty() || nMatches.empty()) return; @@ -829,7 +828,7 @@ void cv::gpu::BFMatcher_GPU::radiusMatchDownload(const GpuMat& trainIdx, const G } void cv::gpu::BFMatcher_GPU::radiusMatchConvert(const Mat& trainIdx, const Mat& distance, const Mat& nMatches, - vector< vector >& matches, bool compactResult) + std::vector< std::vector >& matches, bool compactResult) { if (trainIdx.empty() || distance.empty() || nMatches.empty()) return; @@ -855,12 +854,12 @@ void cv::gpu::BFMatcher_GPU::radiusMatchConvert(const Mat& trainIdx, const Mat& if (nMatched == 0) { if (!compactResult) - matches.push_back(vector()); + matches.push_back(std::vector()); continue; } - matches.push_back(vector(nMatched)); - vector& curMatches = matches.back(); + matches.push_back(std::vector(nMatched)); + std::vector& curMatches = matches.back(); for (int i = 0; i < nMatched; ++i, ++trainIdx_ptr, ++distance_ptr) { @@ -878,7 +877,7 @@ void cv::gpu::BFMatcher_GPU::radiusMatchConvert(const Mat& trainIdx, const Mat& } void cv::gpu::BFMatcher_GPU::radiusMatch(const GpuMat& query, const GpuMat& train, - vector< vector >& matches, float maxDistance, const GpuMat& mask, bool compactResult) + std::vector< std::vector >& matches, float maxDistance, const GpuMat& mask, bool compactResult) { GpuMat trainIdx, distance, nMatches; radiusMatchSingle(query, train, trainIdx, distance, nMatches, maxDistance, mask); @@ -886,7 +885,7 @@ void cv::gpu::BFMatcher_GPU::radiusMatch(const GpuMat& query, const GpuMat& trai } void cv::gpu::BFMatcher_GPU::radiusMatchCollection(const GpuMat& query, GpuMat& trainIdx, GpuMat& imgIdx, GpuMat& distance, GpuMat& nMatches, - float maxDistance, const vector& masks, Stream& stream) + float maxDistance, const std::vector& masks, Stream& stream) { if (query.empty() || empty()) return; @@ -940,15 +939,15 @@ void cv::gpu::BFMatcher_GPU::radiusMatchCollection(const GpuMat& query, GpuMat& caller_t func = callers[query.depth()]; CV_Assert(func != 0); - vector trains_(trainDescCollection.begin(), trainDescCollection.end()); - vector masks_(masks.begin(), masks.end()); + std::vector trains_(trainDescCollection.begin(), trainDescCollection.end()); + std::vector masks_(masks.begin(), masks.end()); func(query, &trains_[0], static_cast(trains_.size()), maxDistance, masks_.size() == 0 ? 0 : &masks_[0], trainIdx, imgIdx, distance, nMatches, StreamAccessor::getStream(stream)); } void cv::gpu::BFMatcher_GPU::radiusMatchDownload(const GpuMat& trainIdx, const GpuMat& imgIdx, const GpuMat& distance, const GpuMat& nMatches, - vector< vector >& matches, bool compactResult) + std::vector< std::vector >& matches, bool compactResult) { if (trainIdx.empty() || imgIdx.empty() || distance.empty() || nMatches.empty()) return; @@ -962,7 +961,7 @@ void cv::gpu::BFMatcher_GPU::radiusMatchDownload(const GpuMat& trainIdx, const G } void cv::gpu::BFMatcher_GPU::radiusMatchConvert(const Mat& trainIdx, const Mat& imgIdx, const Mat& distance, const Mat& nMatches, - vector< vector >& matches, bool compactResult) + std::vector< std::vector >& matches, bool compactResult) { if (trainIdx.empty() || imgIdx.empty() || distance.empty() || nMatches.empty()) return; @@ -990,12 +989,12 @@ void cv::gpu::BFMatcher_GPU::radiusMatchConvert(const Mat& trainIdx, const Mat& if (nMatched == 0) { if (!compactResult) - matches.push_back(vector()); + matches.push_back(std::vector()); continue; } - matches.push_back(vector()); - vector& curMatches = matches.back(); + matches.push_back(std::vector()); + std::vector& curMatches = matches.back(); curMatches.reserve(nMatched); for (int i = 0; i < nMatched; ++i, ++trainIdx_ptr, ++imgIdx_ptr, ++distance_ptr) @@ -1013,8 +1012,8 @@ void cv::gpu::BFMatcher_GPU::radiusMatchConvert(const Mat& trainIdx, const Mat& } } -void cv::gpu::BFMatcher_GPU::radiusMatch(const GpuMat& query, vector< vector >& matches, - float maxDistance, const vector& masks, bool compactResult) +void cv::gpu::BFMatcher_GPU::radiusMatch(const GpuMat& query, std::vector< std::vector >& matches, + float maxDistance, const std::vector& masks, bool compactResult) { GpuMat trainIdx, imgIdx, distance, nMatches; radiusMatchCollection(query, trainIdx, imgIdx, distance, nMatches, maxDistance, masks); diff --git a/modules/gpu/src/calib3d.cpp b/modules/gpu/src/calib3d.cpp index e83213f90..ab7f63f45 100644 --- a/modules/gpu/src/calib3d.cpp +++ b/modules/gpu/src/calib3d.cpp @@ -44,7 +44,6 @@ using namespace cv; using namespace cv::gpu; -using namespace std; #if !defined HAVE_CUDA || defined(CUDA_DISABLER) @@ -52,7 +51,7 @@ void cv::gpu::transformPoints(const GpuMat&, const Mat&, const Mat&, GpuMat&, St void cv::gpu::projectPoints(const GpuMat&, const Mat&, const Mat&, const Mat&, const Mat&, GpuMat&, Stream&) { throw_nogpu(); } -void cv::gpu::solvePnPRansac(const Mat&, const Mat&, const Mat&, const Mat&, Mat&, Mat&, bool, int, float, int, vector*) { throw_nogpu(); } +void cv::gpu::solvePnPRansac(const Mat&, const Mat&, const Mat&, const Mat&, Mat&, Mat&, bool, int, float, int, std::vector*) { throw_nogpu(); } #else @@ -130,7 +129,7 @@ void cv::gpu::projectPoints(const GpuMat& src, const Mat& rvec, const Mat& tvec, namespace { // Selects subset_size random different points from [0, num_points - 1] range - void selectRandom(int subset_size, int num_points, vector& subset) + void selectRandom(int subset_size, int num_points, std::vector& subset) { subset.resize(subset_size); for (int i = 0; i < subset_size; ++i) @@ -164,7 +163,7 @@ namespace void operator()(const BlockedRange& range) const { // Input data for generation of the current hypothesis - vector subset_indices(subset_size); + std::vector subset_indices(subset_size); Mat_ object_subset(1, subset_size); Mat_ image_subset(1, subset_size); @@ -212,7 +211,7 @@ namespace void cv::gpu::solvePnPRansac(const Mat& object, const Mat& image, const Mat& camera_mat, const Mat& dist_coef, Mat& rvec, Mat& tvec, bool use_extrinsic_guess, int num_iters, float max_dist, int min_inlier_count, - vector* inliers) + std::vector* inliers) { (void)min_inlier_count; CV_Assert(object.rows == 1 && object.cols > 0 && object.type() == CV_32FC3); diff --git a/modules/gpu/src/cascadeclassifier.cpp b/modules/gpu/src/cascadeclassifier.cpp index 360393397..e82ee9d33 100644 --- a/modules/gpu/src/cascadeclassifier.cpp +++ b/modules/gpu/src/cascadeclassifier.cpp @@ -46,15 +46,14 @@ using namespace cv; using namespace cv::gpu; -using namespace std; #if !defined (HAVE_CUDA) || defined (CUDA_DISABLER) cv::gpu::CascadeClassifier_GPU::CascadeClassifier_GPU() { throw_nogpu(); } -cv::gpu::CascadeClassifier_GPU::CascadeClassifier_GPU(const string&) { throw_nogpu(); } +cv::gpu::CascadeClassifier_GPU::CascadeClassifier_GPU(const std::string&) { throw_nogpu(); } cv::gpu::CascadeClassifier_GPU::~CascadeClassifier_GPU() { throw_nogpu(); } bool cv::gpu::CascadeClassifier_GPU::empty() const { throw_nogpu(); return true; } -bool cv::gpu::CascadeClassifier_GPU::load(const string&) { throw_nogpu(); return true; } +bool cv::gpu::CascadeClassifier_GPU::load(const std::string&) { throw_nogpu(); return true; } Size cv::gpu::CascadeClassifier_GPU::getClassifierSize() const { throw_nogpu(); return Size();} void cv::gpu::CascadeClassifier_GPU::release() { throw_nogpu(); } int cv::gpu::CascadeClassifier_GPU::detectMultiScale( const GpuMat&, GpuMat&, double, int, Size) {throw_nogpu(); return -1;} @@ -72,7 +71,7 @@ public: bool findLargestObject, bool visualizeInPlace, cv::Size ncvMinSize, cv::Size maxObjectSize) = 0; virtual cv::Size getClassifierCvSize() const = 0; - virtual bool read(const string& classifierAsXml) = 0; + virtual bool read(const std::string& classifierAsXml) = 0; }; struct cv::gpu::CascadeClassifier_GPU::HaarCascade : cv::gpu::CascadeClassifier_GPU::CascadeClassifierImpl @@ -83,7 +82,7 @@ public: ncvSetDebugOutputHandler(NCVDebugOutputHandler); } - bool read(const string& filename) + bool read(const std::string& filename) { ncvSafeCall( load(filename) ); return true; @@ -172,7 +171,7 @@ public: private: static void NCVDebugOutputHandler(const std::string &msg) { CV_Error(CV_GpuApiCallError, msg.c_str()); } - NCVStatus load(const string& classifierFile) + NCVStatus load(const std::string& classifierFile) { int devId = cv::gpu::getDevice(); ncvAssertCUDAReturn(cudaGetDeviceProperties(&devProp, devId), NCV_CUDA_ERROR); @@ -459,7 +458,7 @@ public: virtual cv::Size getClassifierCvSize() const { return NxM; } - bool read(const string& classifierAsXml) + bool read(const std::string& classifierAsXml) { FileStorage fs(classifierAsXml, FileStorage::READ); return fs.isOpened() ? read(fs.getFirstTopLevelNode()) : false; @@ -513,10 +512,10 @@ private: const char *GPU_CC_FEATURES = "features"; const char *GPU_CC_RECT = "rect"; - std::string stageTypeStr = (string)root[GPU_CC_STAGE_TYPE]; + std::string stageTypeStr = (std::string)root[GPU_CC_STAGE_TYPE]; CV_Assert(stageTypeStr == GPU_CC_BOOST); - string featureTypeStr = (string)root[GPU_CC_FEATURE_TYPE]; + std::string featureTypeStr = (std::string)root[GPU_CC_FEATURE_TYPE]; CV_Assert(featureTypeStr == GPU_CC_LBP); NxM.width = (int)root[GPU_CC_WIDTH]; @@ -663,7 +662,7 @@ private: cv::gpu::CascadeClassifier_GPU::CascadeClassifier_GPU() : findLargestObject(false), visualizeInPlace(false), impl(0) {} -cv::gpu::CascadeClassifier_GPU::CascadeClassifier_GPU(const string& filename) +cv::gpu::CascadeClassifier_GPU::CascadeClassifier_GPU(const std::string& filename) : findLargestObject(false), visualizeInPlace(false), impl(0) { load(filename); } cv::gpu::CascadeClassifier_GPU::~CascadeClassifier_GPU() { release(); } @@ -689,7 +688,7 @@ int cv::gpu::CascadeClassifier_GPU::detectMultiScale(const GpuMat& image, GpuMat return impl->process(image, objectsBuf, (float)scaleFactor, minNeighbors, findLargestObject, visualizeInPlace, minSize, maxObjectSize); } -bool cv::gpu::CascadeClassifier_GPU::load(const string& filename) +bool cv::gpu::CascadeClassifier_GPU::load(const std::string& filename) { release(); @@ -711,7 +710,7 @@ bool cv::gpu::CascadeClassifier_GPU::load(const string& filename) } const char *GPU_CC_LBP = "LBP"; - string featureTypeStr = (string)fs.getFirstTopLevelNode()["featureType"]; + std::string featureTypeStr = (std::string)fs.getFirstTopLevelNode()["featureType"]; if (featureTypeStr == GPU_CC_LBP) impl = new LbpCascade(); else @@ -743,12 +742,12 @@ struct RectConvert void groupRectangles(std::vector &hypotheses, int groupThreshold, double eps, std::vector *weights) { - vector rects(hypotheses.size()); + std::vector rects(hypotheses.size()); std::transform(hypotheses.begin(), hypotheses.end(), rects.begin(), RectConvert()); if (weights) { - vector weights_int; + std::vector weights_int; weights_int.assign(weights->begin(), weights->end()); cv::groupRectangles(rects, weights_int, groupThreshold, eps); } diff --git a/modules/gpu/src/cudastream.cpp b/modules/gpu/src/cudastream.cpp index f9fbe820e..e302fd1fc 100644 --- a/modules/gpu/src/cudastream.cpp +++ b/modules/gpu/src/cudastream.cpp @@ -42,7 +42,6 @@ #include "precomp.hpp" -using namespace std; using namespace cv; using namespace cv::gpu; @@ -256,7 +255,8 @@ void cv::gpu::Stream::enqueueConvert(const GpuMat& src, GpuMat& dst, int dtype, CV_Error(CV_StsUnsupportedFormat, "The device doesn't support double"); } - bool noScale = fabs(alpha - 1) < numeric_limits::epsilon() && fabs(beta) < numeric_limits::epsilon(); + bool noScale = fabs(alpha - 1) < std::numeric_limits::epsilon() + && fabs(beta) < std::numeric_limits::epsilon(); if (sdepth == ddepth && noScale) { diff --git a/modules/gpu/src/error.cpp b/modules/gpu/src/error.cpp index 53b21cb8d..e01be8010 100644 --- a/modules/gpu/src/error.cpp +++ b/modules/gpu/src/error.cpp @@ -44,7 +44,6 @@ using namespace cv; using namespace cv::gpu; -using namespace std; #ifdef HAVE_CUDA @@ -55,7 +54,7 @@ namespace struct ErrorEntry { int code; - string str; + std::string str; }; struct ErrorEntryComparer @@ -65,13 +64,13 @@ namespace bool operator()(const ErrorEntry& e) const { return e.code == code; } }; - string getErrorString(int code, const ErrorEntry* errors, size_t n) + std::string getErrorString(int code, const ErrorEntry* errors, size_t n) { - size_t idx = find_if(errors, errors + n, ErrorEntryComparer(code)) - errors; + size_t idx = std::find_if(errors, errors + n, ErrorEntryComparer(code)) - errors; - const string& msg = (idx != n) ? errors[idx].str : string("Unknown error code"); + const std::string& msg = (idx != n) ? errors[idx].str : std::string("Unknown error code"); - ostringstream ostr; + std::ostringstream ostr; ostr << msg << " [Code = " << code << "]"; return ostr.str(); @@ -222,25 +221,25 @@ namespace cv { void nppError(int code, const char *file, const int line, const char *func) { - string msg = getErrorString(code, npp_errors, npp_error_num); + std::string msg = getErrorString(code, npp_errors, npp_error_num); cv::gpu::error(msg.c_str(), file, line, func); } void ncvError(int code, const char *file, const int line, const char *func) { - string msg = getErrorString(code, ncv_errors, ncv_error_num); + std::string msg = getErrorString(code, ncv_errors, ncv_error_num); cv::gpu::error(msg.c_str(), file, line, func); } void cufftError(int code, const char *file, const int line, const char *func) { - string msg = getErrorString(code, cufft_errors, cufft_error_num); + std::string msg = getErrorString(code, cufft_errors, cufft_error_num); cv::gpu::error(msg.c_str(), file, line, func); } void cublasError(int code, const char *file, const int line, const char *func) { - string msg = getErrorString(code, cublas_errors, cublas_error_num); + std::string msg = getErrorString(code, cublas_errors, cublas_error_num); cv::gpu::error(msg.c_str(), file, line, func); } } diff --git a/modules/gpu/src/fast.cpp b/modules/gpu/src/fast.cpp index f8b3b9887..e44b9e164 100644 --- a/modules/gpu/src/fast.cpp +++ b/modules/gpu/src/fast.cpp @@ -44,7 +44,6 @@ using namespace cv; using namespace cv::gpu; -using namespace std; #if !defined (HAVE_CUDA) || defined (CUDA_DISABLER) diff --git a/modules/gpu/src/gftt.cpp b/modules/gpu/src/gftt.cpp index 6bb73de75..2c50ed69d 100644 --- a/modules/gpu/src/gftt.cpp +++ b/modules/gpu/src/gftt.cpp @@ -42,7 +42,6 @@ #include "precomp.hpp" -using namespace std; using namespace cv; using namespace cv::gpu; @@ -94,11 +93,11 @@ void cv::gpu::GoodFeaturesToTrackDetector_GPU::operator ()(const GpuMat& image, tmpCorners_.colRange(0, maxCorners > 0 ? std::min(maxCorners, total) : total).copyTo(corners); else { - vector tmp(total); + std::vector tmp(total); Mat tmpMat(1, total, CV_32FC2, (void*)&tmp[0]); tmpCorners_.colRange(0, total).download(tmpMat); - vector tmp2; + std::vector tmp2; tmp2.reserve(total); const int cell_size = cvRound(minDistance); @@ -131,7 +130,7 @@ void cv::gpu::GoodFeaturesToTrackDetector_GPU::operator ()(const GpuMat& image, { for (int xx = x1; xx <= x2; xx++) { - vector& m = grid[yy * grid_width + xx]; + std::vector& m = grid[yy * grid_width + xx]; if (!m.empty()) { diff --git a/modules/gpu/src/global_motion.cpp b/modules/gpu/src/global_motion.cpp index 7531c9327..36c917744 100644 --- a/modules/gpu/src/global_motion.cpp +++ b/modules/gpu/src/global_motion.cpp @@ -42,7 +42,6 @@ #include "precomp.hpp" -using namespace std; using namespace cv; using namespace cv::gpu; diff --git a/modules/gpu/src/hog.cpp b/modules/gpu/src/hog.cpp index 640993f95..a3af032a1 100644 --- a/modules/gpu/src/hog.cpp +++ b/modules/gpu/src/hog.cpp @@ -49,16 +49,16 @@ size_t cv::gpu::HOGDescriptor::getDescriptorSize() const { throw_nogpu(); return size_t cv::gpu::HOGDescriptor::getBlockHistogramSize() const { throw_nogpu(); return 0; } double cv::gpu::HOGDescriptor::getWinSigma() const { throw_nogpu(); return 0; } bool cv::gpu::HOGDescriptor::checkDetectorSize() const { throw_nogpu(); return false; } -void cv::gpu::HOGDescriptor::setSVMDetector(const vector&) { throw_nogpu(); } -void cv::gpu::HOGDescriptor::detect(const GpuMat&, vector&, double, Size, Size) { throw_nogpu(); } -void cv::gpu::HOGDescriptor::detectMultiScale(const GpuMat&, vector&, double, Size, Size, double, int) { throw_nogpu(); } +void cv::gpu::HOGDescriptor::setSVMDetector(const std::vector&) { throw_nogpu(); } +void cv::gpu::HOGDescriptor::detect(const GpuMat&, std::vector&, double, Size, Size) { throw_nogpu(); } +void cv::gpu::HOGDescriptor::detectMultiScale(const GpuMat&, std::vector&, double, Size, Size, double, int) { throw_nogpu(); } void cv::gpu::HOGDescriptor::computeBlockHistograms(const GpuMat&) { throw_nogpu(); } void cv::gpu::HOGDescriptor::getDescriptors(const GpuMat&, Size, GpuMat&, int) { throw_nogpu(); } std::vector cv::gpu::HOGDescriptor::getDefaultPeopleDetector() { throw_nogpu(); return std::vector(); } std::vector cv::gpu::HOGDescriptor::getPeopleDetector48x96() { throw_nogpu(); return std::vector(); } std::vector cv::gpu::HOGDescriptor::getPeopleDetector64x128() { throw_nogpu(); return std::vector(); } -void cv::gpu::HOGDescriptor::computeConfidence(const GpuMat&, vector&, double, Size, Size, vector&, vector&) { throw_nogpu(); } -void cv::gpu::HOGDescriptor::computeConfidenceMultiScale(const GpuMat&, vector&, double, Size, Size, vector&, int) { throw_nogpu(); } +void cv::gpu::HOGDescriptor::computeConfidence(const GpuMat&, std::vector&, double, Size, Size, std::vector&, std::vector&) { throw_nogpu(); } +void cv::gpu::HOGDescriptor::computeConfidenceMultiScale(const GpuMat&, std::vector&, double, Size, Size, std::vector&, int) { throw_nogpu(); } #else @@ -155,7 +155,7 @@ bool cv::gpu::HOGDescriptor::checkDetectorSize() const return detector_size == 0 || detector_size == descriptor_size || detector_size == descriptor_size + 1; } -void cv::gpu::HOGDescriptor::setSVMDetector(const vector& _detector) +void cv::gpu::HOGDescriptor::setSVMDetector(const std::vector& _detector) { std::vector detector_reordered(_detector.size()); @@ -264,8 +264,8 @@ void cv::gpu::HOGDescriptor::getDescriptors(const GpuMat& img, Size win_stride, } } -void cv::gpu::HOGDescriptor::computeConfidence(const GpuMat& img, vector& hits, double hit_threshold, - Size win_stride, Size padding, vector& locations, vector& confidences) +void cv::gpu::HOGDescriptor::computeConfidence(const GpuMat& img, std::vector& hits, double hit_threshold, + Size win_stride, Size padding, std::vector& locations, std::vector& confidences) { CV_Assert(padding == Size(0, 0)); @@ -307,11 +307,11 @@ void cv::gpu::HOGDescriptor::computeConfidence(const GpuMat& img, vector& } } -void cv::gpu::HOGDescriptor::computeConfidenceMultiScale(const GpuMat& img, vector& found_locations, +void cv::gpu::HOGDescriptor::computeConfidenceMultiScale(const GpuMat& img, std::vector& found_locations, double hit_threshold, Size win_stride, Size padding, - vector &conf_out, int group_threshold) + std::vector &conf_out, int group_threshold) { - vector level_scale; + std::vector level_scale; double scale = 1.; int levels = 0; @@ -327,7 +327,7 @@ void cv::gpu::HOGDescriptor::computeConfidenceMultiScale(const GpuMat& img, vect level_scale.resize(levels); std::vector all_candidates; - vector locations; + std::vector locations; for (size_t i = 0; i < level_scale.size(); i++) { @@ -359,7 +359,7 @@ void cv::gpu::HOGDescriptor::computeConfidenceMultiScale(const GpuMat& img, vect } -void cv::gpu::HOGDescriptor::detect(const GpuMat& img, vector& hits, double hit_threshold, Size win_stride, Size padding) +void cv::gpu::HOGDescriptor::detect(const GpuMat& img, std::vector& hits, double hit_threshold, Size win_stride, Size padding) { CV_Assert(img.type() == CV_8UC1 || img.type() == CV_8UC4); CV_Assert(padding == Size(0, 0)); @@ -396,13 +396,13 @@ void cv::gpu::HOGDescriptor::detect(const GpuMat& img, vector& hits, doub -void cv::gpu::HOGDescriptor::detectMultiScale(const GpuMat& img, vector& found_locations, double hit_threshold, +void cv::gpu::HOGDescriptor::detectMultiScale(const GpuMat& img, std::vector& found_locations, double hit_threshold, Size win_stride, Size padding, double scale0, int group_threshold) { CV_Assert(img.type() == CV_8UC1 || img.type() == CV_8UC4); - vector level_scale; + std::vector level_scale; double scale = 1.; int levels = 0; @@ -419,7 +419,7 @@ void cv::gpu::HOGDescriptor::detectMultiScale(const GpuMat& img, vector& f image_scales.resize(levels); std::vector all_candidates; - vector locations; + std::vector locations; for (size_t i = 0; i < level_scale.size(); i++) { @@ -799,7 +799,7 @@ std::vector cv::gpu::HOGDescriptor::getPeopleDetector48x96() -0.119002f, 0.026722f, 0.034853f, -0.060934f, -0.025054f, -0.093026f, -0.035372f, -0.233209f, -0.049869f, -0.039151f, -0.022279f, -0.065380f, -9.063785f }; - return vector(detector, detector + sizeof(detector)/sizeof(detector[0])); + return std::vector(detector, detector + sizeof(detector)/sizeof(detector[0])); } @@ -1613,7 +1613,7 @@ std::vector cv::gpu::HOGDescriptor::getPeopleDetector64x128() -0.01612278f, -1.46097376e-003f, 0.14013411f, -8.96181818e-003f, -0.03250246f, 3.38630192e-003f, 2.64779478e-003f, 0.03359732f, -0.02411991f, -0.04229729f, 0.10666174f, -6.66579151f }; - return vector(detector, detector + sizeof(detector)/sizeof(detector[0])); + return std::vector(detector, detector + sizeof(detector)/sizeof(detector[0])); } #endif diff --git a/modules/gpu/src/hough.cpp b/modules/gpu/src/hough.cpp index 09cf01850..a1e703343 100644 --- a/modules/gpu/src/hough.cpp +++ b/modules/gpu/src/hough.cpp @@ -42,7 +42,6 @@ #include "precomp.hpp" -using namespace std; using namespace cv; using namespace cv::gpu; @@ -311,7 +310,7 @@ void cv::gpu::HoughCircles(const GpuMat& src, GpuMat& circles, HoughCirclesBuf& { for (int xx = x1; xx <= x2; ++xx) { - vector& m = grid[yy * gridWidth + xx]; + std::vector& m = grid[yy * gridWidth + xx]; for(size_t j = 0; j < m.size(); ++j) { @@ -434,9 +433,9 @@ namespace ///////////////////////////////////// // Common - template void releaseVector(vector& v) + template void releaseVector(std::vector& v) { - vector empty; + std::vector empty; empty.swap(v); } @@ -476,11 +475,11 @@ namespace GpuMat outBuf; int posCount; - vector oldPosBuf; - vector oldVoteBuf; - vector newPosBuf; - vector newVoteBuf; - vector indexies; + std::vector oldPosBuf; + std::vector oldVoteBuf; + std::vector newPosBuf; + std::vector newVoteBuf; + std::vector indexies; }; GHT_Pos::GHT_Pos() @@ -610,7 +609,7 @@ namespace const int gridWidth = (imageSize.width + cellSize - 1) / cellSize; const int gridHeight = (imageSize.height + cellSize - 1) / cellSize; - vector< vector > grid(gridWidth * gridHeight); + std::vector< std::vector > grid(gridWidth * gridHeight); const double minDist2 = minDist * minDist; @@ -640,7 +639,7 @@ namespace { for (int xx = x1; xx <= x2; ++xx) { - const vector& m = grid[yy * gridWidth + xx]; + const std::vector& m = grid[yy * gridWidth + xx]; for(size_t j = 0; j < m.size(); ++j) { @@ -1060,11 +1059,11 @@ namespace Feature templFeatures; Feature imageFeatures; - vector< pair > angles; - vector< pair > scales; + std::vector< std::pair > angles; + std::vector< std::pair > scales; GpuMat hist; - vector h_buf; + std::vector h_buf; }; CV_INIT_ALGORITHM(GHT_Guil_Full, "GeneralizedHough_GPU.POSITION_SCALE_ROTATION", @@ -1278,7 +1277,7 @@ namespace if (h_buf[n] >= angleThresh) { const double angle = minAngle + n * angleStep; - angles.push_back(make_pair(angle, h_buf[n])); + angles.push_back(std::make_pair(angle, h_buf[n])); } } } @@ -1302,7 +1301,7 @@ namespace if (h_buf[s] >= scaleThresh) { const double scale = minScale + s * scaleStep; - scales.push_back(make_pair(scale, h_buf[s])); + scales.push_back(std::make_pair(scale, h_buf[s])); } } } diff --git a/modules/gpu/src/match_template.cpp b/modules/gpu/src/match_template.cpp index 4643f3b52..26dcd4b9e 100644 --- a/modules/gpu/src/match_template.cpp +++ b/modules/gpu/src/match_template.cpp @@ -44,7 +44,6 @@ using namespace cv; using namespace cv::gpu; -using namespace std; #if !defined (HAVE_CUDA) || defined (CUDA_DISABLER) diff --git a/modules/gpu/src/mssegmentation.cpp b/modules/gpu/src/mssegmentation.cpp index 39c0b5c68..9eab4d0fb 100644 --- a/modules/gpu/src/mssegmentation.cpp +++ b/modules/gpu/src/mssegmentation.cpp @@ -48,8 +48,6 @@ void cv::gpu::meanShiftSegmentation(const GpuMat&, Mat&, int, int, int, TermCrit #else -using namespace std; - // Auxiliray stuff namespace { @@ -65,9 +63,9 @@ public: int find(int elem); int merge(int set1, int set2); - vector parent; - vector rank; - vector size; + std::vector parent; + std::vector rank; + std::vector size; private: DjSets(const DjSets&); void operator =(const DjSets&); @@ -95,8 +93,8 @@ public: void addEdge(int from, int to, const T& val=T()); - vector start; - vector edges; + std::vector start; + std::vector edges; int numv; int nume_max; @@ -324,7 +322,7 @@ void cv::gpu::meanShiftSegmentation(const GpuMat& src, Mat& dst, int sp, int sr, } } - vector edges; + std::vector edges; edges.reserve(g.numv); // Prepare edges connecting differnet components @@ -353,7 +351,7 @@ void cv::gpu::meanShiftSegmentation(const GpuMat& src, Mat& dst, int sp, int sr, // Compute sum of the pixel's colors which are in the same segment Mat h_src(src); - vector sumcols(nrows * ncols, Vec4i(0, 0, 0, 0)); + std::vector sumcols(nrows * ncols, Vec4i(0, 0, 0, 0)); for (int y = 0; y < nrows; ++y) { Vec4b* h_srcy = h_src.ptr(y); diff --git a/modules/gpu/src/optflowbm.cpp b/modules/gpu/src/optflowbm.cpp index a4321c89c..ea143b654 100644 --- a/modules/gpu/src/optflowbm.cpp +++ b/modules/gpu/src/optflowbm.cpp @@ -42,7 +42,6 @@ #include "precomp.hpp" -using namespace std; using namespace cv; using namespace cv::gpu; @@ -72,7 +71,7 @@ void cv::gpu::calcOpticalFlowBM(const GpuMat& prev, const GpuMat& curr, Size blo vely.create(velSize, CV_32FC1); // scanning scheme coordinates - vector ss((2 * maxRange.width + 1) * (2 * maxRange.height + 1)); + std::vector ss((2 * maxRange.width + 1) * (2 * maxRange.height + 1)); int ssCount = 0; // Calculate scanning scheme diff --git a/modules/gpu/src/optical_flow.cpp b/modules/gpu/src/optical_flow.cpp index 41862809a..3d8fc05ec 100644 --- a/modules/gpu/src/optical_flow.cpp +++ b/modules/gpu/src/optical_flow.cpp @@ -44,7 +44,6 @@ using namespace cv; using namespace cv::gpu; -using namespace std; #if !defined (HAVE_CUDA) || defined (CUDA_DISABLER) diff --git a/modules/gpu/src/optical_flow_farneback.cpp b/modules/gpu/src/optical_flow_farneback.cpp index 91056a67a..bc36a75e5 100644 --- a/modules/gpu/src/optical_flow_farneback.cpp +++ b/modules/gpu/src/optical_flow_farneback.cpp @@ -50,7 +50,6 @@ // leads to an inefficient code. It's for debug purposes only. #define ENABLE_GPU_RESIZE 1 -using namespace std; using namespace cv; using namespace cv::gpu; @@ -153,7 +152,7 @@ void cv::gpu::FarnebackOpticalFlow::prepareGaussian( void cv::gpu::FarnebackOpticalFlow::setPolynomialExpansionConsts(int n, double sigma) { - vector buf(n*6 + 3); + std::vector buf(n*6 + 3); float* g = &buf[0] + n; float* xg = g + n*2 + 1; float* xxg = xg + n*2 + 1; diff --git a/modules/gpu/src/orb.cpp b/modules/gpu/src/orb.cpp index 2fd768dca..95ac04883 100644 --- a/modules/gpu/src/orb.cpp +++ b/modules/gpu/src/orb.cpp @@ -42,7 +42,6 @@ #include "precomp.hpp" -using namespace std; using namespace cv; using namespace cv::gpu; @@ -419,7 +418,7 @@ cv::gpu::ORB_GPU::ORB_GPU(int nFeatures, float scaleFactor, int nLevels, int edg // pre-compute the end of a row in a circular patch int half_patch_size = patchSize_ / 2; - vector u_max(half_patch_size + 2); + std::vector u_max(half_patch_size + 2); for (int v = 0; v <= half_patch_size * std::sqrt(2.f) / 2 + 1; ++v) u_max[v] = cvRound(std::sqrt(static_cast(half_patch_size * half_patch_size - v * v))); diff --git a/modules/gpu/src/pyrlk.cpp b/modules/gpu/src/pyrlk.cpp index 49a6c5a88..71e04e9fc 100644 --- a/modules/gpu/src/pyrlk.cpp +++ b/modules/gpu/src/pyrlk.cpp @@ -42,7 +42,6 @@ #include "precomp.hpp" -using namespace std; using namespace cv; using namespace cv::gpu; diff --git a/modules/gpu/src/softcascade.cpp b/modules/gpu/src/softcascade.cpp index 88402092e..5abcd6308 100644 --- a/modules/gpu/src/softcascade.cpp +++ b/modules/gpu/src/softcascade.cpp @@ -121,17 +121,17 @@ struct cv::gpu::SCascade::Fields static const char *const SC_F_RECT = "rect"; // only Ada Boost supported - std::string stageTypeStr = (string)root[SC_STAGE_TYPE]; + std::string stageTypeStr = (std::string)root[SC_STAGE_TYPE]; CV_Assert(stageTypeStr == SC_BOOST); // only HOG-like integral channel features supported - string featureTypeStr = (string)root[SC_FEATURE_TYPE]; + std::string featureTypeStr = (std::string)root[SC_FEATURE_TYPE]; CV_Assert(featureTypeStr == SC_ICF); int origWidth = (int)root[SC_ORIG_W]; int origHeight = (int)root[SC_ORIG_H]; - std::string fformat = (string)root[SC_FEATURE_FORMAT]; + std::string fformat = (std::string)root[SC_FEATURE_FORMAT]; bool useBoxes = (fformat == "BOX"); ushort shrinkage = cv::saturate_cast((int)root[SC_SHRINKAGE]); diff --git a/modules/gpu/src/speckle_filtering.cpp b/modules/gpu/src/speckle_filtering.cpp index 4125434d6..571cbf657 100644 --- a/modules/gpu/src/speckle_filtering.cpp +++ b/modules/gpu/src/speckle_filtering.cpp @@ -64,7 +64,7 @@ void cv::filterSpeckles( Mat& img, uchar newVal, int maxSpeckleSize, uchar maxDi (img.rows + WinSz + 2)*sizeof(int) + (img.rows+WinSz+2)*MaxD*(WinSz+1)*sizeof(uchar) + 256; int bufSize1 = (img.cols + 9 + 2) * sizeof(int) + 256; - int bufSz = max(bufSize0 * 1, bufSize1 * 2); + int bufSz = std::max(bufSize0 * 1, bufSize1 * 2); _buf.create(1, bufSz, CV_8U); diff --git a/modules/gpu/src/split_merge.cpp b/modules/gpu/src/split_merge.cpp index 434c6e85c..20631e0ec 100644 --- a/modules/gpu/src/split_merge.cpp +++ b/modules/gpu/src/split_merge.cpp @@ -44,14 +44,13 @@ using namespace cv; using namespace cv::gpu; -using namespace std; #if !defined (HAVE_CUDA) || defined (CUDA_DISABLER) void cv::gpu::merge(const GpuMat* /*src*/, size_t /*count*/, GpuMat& /*dst*/, Stream& /*stream*/) { throw_nogpu(); } -void cv::gpu::merge(const vector& /*src*/, GpuMat& /*dst*/, Stream& /*stream*/) { throw_nogpu(); } +void cv::gpu::merge(const std::vector& /*src*/, GpuMat& /*dst*/, Stream& /*stream*/) { throw_nogpu(); } void cv::gpu::split(const GpuMat& /*src*/, GpuMat* /*dst*/, Stream& /*stream*/) { throw_nogpu(); } -void cv::gpu::split(const GpuMat& /*src*/, vector& /*dst*/, Stream& /*stream*/) { throw_nogpu(); } +void cv::gpu::split(const GpuMat& /*src*/, std::vector& /*dst*/, Stream& /*stream*/) { throw_nogpu(); } #else /* !defined (HAVE_CUDA) */ @@ -152,7 +151,7 @@ void cv::gpu::merge(const GpuMat* src, size_t n, GpuMat& dst, Stream& stream) } -void cv::gpu::merge(const vector& src, GpuMat& dst, Stream& stream) +void cv::gpu::merge(const std::vector& src, GpuMat& dst, Stream& stream) { ::merge(&src[0], src.size(), dst, StreamAccessor::getStream(stream)); } @@ -162,7 +161,7 @@ void cv::gpu::split(const GpuMat& src, GpuMat* dst, Stream& stream) ::split(src, dst, StreamAccessor::getStream(stream)); } -void cv::gpu::split(const GpuMat& src, vector& dst, Stream& stream) +void cv::gpu::split(const GpuMat& src, std::vector& dst, Stream& stream) { dst.resize(src.channels()); if(src.channels() > 0) diff --git a/modules/gpu/src/stereobp.cpp b/modules/gpu/src/stereobp.cpp index 0e63cef0c..210158d07 100644 --- a/modules/gpu/src/stereobp.cpp +++ b/modules/gpu/src/stereobp.cpp @@ -44,7 +44,6 @@ using namespace cv; using namespace cv::gpu; -using namespace std; #if !defined (HAVE_CUDA) || defined (CUDA_DISABLER) @@ -95,7 +94,7 @@ void cv::gpu::StereoBeliefPropagation::estimateRecommendedParams(int width, int if ((ndisp & 1) != 0) ndisp++; - int mm = ::max(width, height); + int mm = std::max(width, height); iters = mm / 100 + 2; levels = (int)(::log(static_cast(mm)) + 1) * 4 / 5; @@ -126,13 +125,13 @@ namespace StereoBeliefPropagationImpl(StereoBeliefPropagation& rthis_, GpuMat& u_, GpuMat& d_, GpuMat& l_, GpuMat& r_, GpuMat& u2_, GpuMat& d2_, GpuMat& l2_, GpuMat& r2_, - vector& datas_, GpuMat& out_) + std::vector& datas_, GpuMat& out_) : rthis(rthis_), u(u_), d(d_), l(l_), r(r_), u2(u2_), d2(d2_), l2(l2_), r2(r2_), datas(datas_), out(out_), zero(Scalar::all(0)), scale(rthis_.msg_type == CV_32F ? 1.0f : 10.0f) { CV_Assert(0 < rthis.ndisp && 0 < rthis.iters && 0 < rthis.levels); CV_Assert(rthis.msg_type == CV_32F || rthis.msg_type == CV_16S); - CV_Assert(rthis.msg_type == CV_32F || (1 << (rthis.levels - 1)) * scale * rthis.max_data_term < numeric_limits::max()); + CV_Assert(rthis.msg_type == CV_32F || (1 << (rthis.levels - 1)) * scale * rthis.max_data_term < std::numeric_limits::max()); } void operator()(const GpuMat& left, const GpuMat& right, GpuMat& disp, Stream& stream) @@ -154,7 +153,7 @@ namespace int lowest_cols = cols / divisor; int lowest_rows = rows / divisor; const int min_image_dim_size = 2; - CV_Assert(min(lowest_cols, lowest_rows) > min_image_dim_size); + CV_Assert(std::min(lowest_cols, lowest_rows) > min_image_dim_size); init(stream); @@ -176,7 +175,7 @@ namespace int lowest_cols = cols / divisor; int lowest_rows = rows / divisor; const int min_image_dim_size = 2; - CV_Assert(min(lowest_cols, lowest_rows) > min_image_dim_size); + CV_Assert(std::min(lowest_cols, lowest_rows) > min_image_dim_size); init(stream); @@ -342,7 +341,7 @@ namespace GpuMat& l2; GpuMat& r2; - vector& datas; + std::vector& datas; GpuMat& out; const Scalar zero; @@ -350,7 +349,7 @@ namespace int rows, cols; - vector cols_all, rows_all; + std::vector cols_all, rows_all; }; } diff --git a/modules/gpu/src/stereocsbp.cpp b/modules/gpu/src/stereocsbp.cpp index dd9583214..797184f1a 100644 --- a/modules/gpu/src/stereocsbp.cpp +++ b/modules/gpu/src/stereocsbp.cpp @@ -44,7 +44,6 @@ using namespace cv; using namespace cv::gpu; -using namespace std; #if !defined (HAVE_CUDA) || defined (CUDA_DISABLER) @@ -105,7 +104,7 @@ void cv::gpu::StereoConstantSpaceBP::estimateRecommendedParams(int width, int he if ((ndisp & 1) != 0) ndisp++; - int mm = ::max(width, height); + int mm = std::max(width, height); iters = mm / 100 + ((mm > 1200)? - 4 : 4); levels = (int)::log(static_cast(mm)) * 2 / 3; @@ -154,7 +153,7 @@ static void csbp_operator(StereoConstantSpaceBP& rthis, GpuMat& mbuf, GpuMat& te int rows = left.rows; int cols = left.cols; - rthis.levels = min(rthis.levels, int(log((double)rthis.ndisp) / log(2.0))); + rthis.levels = std::min(rthis.levels, int(log((double)rthis.ndisp) / log(2.0))); int levels = rthis.levels; // compute sizes diff --git a/modules/gpu/src/surf.cpp b/modules/gpu/src/surf.cpp index 024087fe5..123c8ce6e 100644 --- a/modules/gpu/src/surf.cpp +++ b/modules/gpu/src/surf.cpp @@ -44,21 +44,20 @@ using namespace cv; using namespace cv::gpu; -using namespace std; #if !defined (HAVE_CUDA) || defined (CUDA_DISABLER) cv::gpu::SURF_GPU::SURF_GPU() { throw_nogpu(); } cv::gpu::SURF_GPU::SURF_GPU(double, int, int, bool, float, bool) { throw_nogpu(); } int cv::gpu::SURF_GPU::descriptorSize() const { throw_nogpu(); return 0;} -void cv::gpu::SURF_GPU::uploadKeypoints(const vector&, GpuMat&) { throw_nogpu(); } -void cv::gpu::SURF_GPU::downloadKeypoints(const GpuMat&, vector&) { throw_nogpu(); } -void cv::gpu::SURF_GPU::downloadDescriptors(const GpuMat&, vector&) { throw_nogpu(); } +void cv::gpu::SURF_GPU::uploadKeypoints(const std::vector&, GpuMat&) { throw_nogpu(); } +void cv::gpu::SURF_GPU::downloadKeypoints(const GpuMat&, std::vector&) { throw_nogpu(); } +void cv::gpu::SURF_GPU::downloadDescriptors(const GpuMat&, std::vector&) { throw_nogpu(); } void cv::gpu::SURF_GPU::operator()(const GpuMat&, const GpuMat&, GpuMat&) { throw_nogpu(); } void cv::gpu::SURF_GPU::operator()(const GpuMat&, const GpuMat&, GpuMat&, GpuMat&, bool) { throw_nogpu(); } -void cv::gpu::SURF_GPU::operator()(const GpuMat&, const GpuMat&, vector&) { throw_nogpu(); } -void cv::gpu::SURF_GPU::operator()(const GpuMat&, const GpuMat&, vector&, GpuMat&, bool) { throw_nogpu(); } -void cv::gpu::SURF_GPU::operator()(const GpuMat&, const GpuMat&, vector&, vector&, bool) { throw_nogpu(); } +void cv::gpu::SURF_GPU::operator()(const GpuMat&, const GpuMat&, std::vector&) { throw_nogpu(); } +void cv::gpu::SURF_GPU::operator()(const GpuMat&, const GpuMat&, std::vector&, GpuMat&, bool) { throw_nogpu(); } +void cv::gpu::SURF_GPU::operator()(const GpuMat&, const GpuMat&, std::vector&, std::vector&, bool) { throw_nogpu(); } void cv::gpu::SURF_GPU::releaseMemory() { throw_nogpu(); } #else /* !defined (HAVE_CUDA) */ @@ -131,8 +130,8 @@ namespace CV_Assert(layer_rows - 2 * min_margin > 0); CV_Assert(layer_cols - 2 * min_margin > 0); - maxFeatures = min(static_cast(img.size().area() * surf.keypointsRatio), 65535); - maxCandidates = min(static_cast(1.5 * maxFeatures), 65535); + maxFeatures = std::min(static_cast(img.size().area() * surf.keypointsRatio), 65535); + maxCandidates = std::min(static_cast(1.5 * maxFeatures), 65535); CV_Assert(maxFeatures > 0); @@ -263,7 +262,7 @@ int cv::gpu::SURF_GPU::descriptorSize() const return extended ? 128 : 64; } -void cv::gpu::SURF_GPU::uploadKeypoints(const vector& keypoints, GpuMat& keypointsGPU) +void cv::gpu::SURF_GPU::uploadKeypoints(const std::vector& keypoints, GpuMat& keypointsGPU) { if (keypoints.empty()) keypointsGPU.release(); @@ -295,7 +294,7 @@ void cv::gpu::SURF_GPU::uploadKeypoints(const vector& keypoints, GpuMa } } -void cv::gpu::SURF_GPU::downloadKeypoints(const GpuMat& keypointsGPU, vector& keypoints) +void cv::gpu::SURF_GPU::downloadKeypoints(const GpuMat& keypointsGPU, std::vector& keypoints) { const int nFeatures = keypointsGPU.cols; @@ -331,7 +330,7 @@ void cv::gpu::SURF_GPU::downloadKeypoints(const GpuMat& keypointsGPU, vector& descriptors) +void cv::gpu::SURF_GPU::downloadDescriptors(const GpuMat& descriptorsGPU, std::vector& descriptors) { if (descriptorsGPU.empty()) descriptors.clear(); @@ -373,7 +372,7 @@ void cv::gpu::SURF_GPU::operator()(const GpuMat& img, const GpuMat& mask, GpuMat } } -void cv::gpu::SURF_GPU::operator()(const GpuMat& img, const GpuMat& mask, vector& keypoints) +void cv::gpu::SURF_GPU::operator()(const GpuMat& img, const GpuMat& mask, std::vector& keypoints) { GpuMat keypointsGPU; @@ -382,7 +381,7 @@ void cv::gpu::SURF_GPU::operator()(const GpuMat& img, const GpuMat& mask, vector downloadKeypoints(keypointsGPU, keypoints); } -void cv::gpu::SURF_GPU::operator()(const GpuMat& img, const GpuMat& mask, vector& keypoints, +void cv::gpu::SURF_GPU::operator()(const GpuMat& img, const GpuMat& mask, std::vector& keypoints, GpuMat& descriptors, bool useProvidedKeypoints) { GpuMat keypointsGPU; @@ -395,8 +394,8 @@ void cv::gpu::SURF_GPU::operator()(const GpuMat& img, const GpuMat& mask, vector downloadKeypoints(keypointsGPU, keypoints); } -void cv::gpu::SURF_GPU::operator()(const GpuMat& img, const GpuMat& mask, vector& keypoints, - vector& descriptors, bool useProvidedKeypoints) +void cv::gpu::SURF_GPU::operator()(const GpuMat& img, const GpuMat& mask, std::vector& keypoints, + std::vector& descriptors, bool useProvidedKeypoints) { GpuMat descriptorsGPU; diff --git a/modules/gpu/src/tvl1flow.cpp b/modules/gpu/src/tvl1flow.cpp index a598a9ecf..c6aa4be86 100644 --- a/modules/gpu/src/tvl1flow.cpp +++ b/modules/gpu/src/tvl1flow.cpp @@ -51,7 +51,6 @@ void cv::gpu::OpticalFlowDual_TVL1_GPU::procOneScale(const GpuMat&, const GpuMat #else -using namespace std; using namespace cv; using namespace cv::gpu; @@ -215,7 +214,7 @@ void cv::gpu::OpticalFlowDual_TVL1_GPU::procOneScale(const GpuMat& I0, const Gpu { warpBackward(I0, I1, I1x, I1y, u1, u2, I1w, I1wx, I1wy, grad, rho_c); - double error = numeric_limits::max(); + double error = std::numeric_limits::max(); for (int n = 0; error > scaledEpsilon && n < iterations; ++n) { estimateU(I1wx, I1wy, grad, rho_c, p11, p12, p21, p22, u1, u2, diff, l_t, static_cast(theta)); diff --git a/modules/highgui/include/opencv2/highgui/highgui.hpp b/modules/highgui/include/opencv2/highgui/highgui.hpp index a58dd999c..1c41b5281 100644 --- a/modules/highgui/include/opencv2/highgui/highgui.hpp +++ b/modules/highgui/include/opencv2/highgui/highgui.hpp @@ -67,21 +67,21 @@ enum { WND_PROP_OPENGL = CV_WND_PROP_OPENGL // opengl support }; -CV_EXPORTS_W void namedWindow(const string& winname, int flags = WINDOW_AUTOSIZE); -CV_EXPORTS_W void destroyWindow(const string& winname); +CV_EXPORTS_W void namedWindow(const std::string& winname, int flags = WINDOW_AUTOSIZE); +CV_EXPORTS_W void destroyWindow(const std::string& winname); CV_EXPORTS_W void destroyAllWindows(); CV_EXPORTS_W int startWindowThread(); CV_EXPORTS_W int waitKey(int delay = 0); -CV_EXPORTS_W void imshow(const string& winname, InputArray mat); +CV_EXPORTS_W void imshow(const std::string& winname, InputArray mat); -CV_EXPORTS_W void resizeWindow(const string& winname, int width, int height); -CV_EXPORTS_W void moveWindow(const string& winname, int x, int y); +CV_EXPORTS_W void resizeWindow(const std::string& winname, int width, int height); +CV_EXPORTS_W void moveWindow(const std::string& winname, int x, int y); -CV_EXPORTS_W void setWindowProperty(const string& winname, int prop_id, double prop_value);//YV -CV_EXPORTS_W double getWindowProperty(const string& winname, int prop_id);//YV +CV_EXPORTS_W void setWindowProperty(const std::string& winname, int prop_id, double prop_value);//YV +CV_EXPORTS_W double getWindowProperty(const std::string& winname, int prop_id);//YV enum { @@ -110,45 +110,45 @@ enum typedef void (*MouseCallback)(int event, int x, int y, int flags, void* userdata); //! assigns callback for mouse events -CV_EXPORTS void setMouseCallback(const string& winname, MouseCallback onMouse, void* userdata = 0); +CV_EXPORTS void setMouseCallback(const std::string& winname, MouseCallback onMouse, void* userdata = 0); typedef void (CV_CDECL *TrackbarCallback)(int pos, void* userdata); -CV_EXPORTS int createTrackbar(const string& trackbarname, const string& winname, +CV_EXPORTS int createTrackbar(const std::string& trackbarname, const std::string& winname, int* value, int count, TrackbarCallback onChange = 0, void* userdata = 0); -CV_EXPORTS_W int getTrackbarPos(const string& trackbarname, const string& winname); -CV_EXPORTS_W void setTrackbarPos(const string& trackbarname, const string& winname, int pos); +CV_EXPORTS_W int getTrackbarPos(const std::string& trackbarname, const std::string& winname); +CV_EXPORTS_W void setTrackbarPos(const std::string& trackbarname, const std::string& winname, int pos); // OpenGL support typedef void (*OpenGlDrawCallback)(void* userdata); -CV_EXPORTS void setOpenGlDrawCallback(const string& winname, OpenGlDrawCallback onOpenGlDraw, void* userdata = 0); +CV_EXPORTS void setOpenGlDrawCallback(const std::string& winname, OpenGlDrawCallback onOpenGlDraw, void* userdata = 0); -CV_EXPORTS void setOpenGlContext(const string& winname); +CV_EXPORTS void setOpenGlContext(const std::string& winname); -CV_EXPORTS void updateWindow(const string& winname); +CV_EXPORTS void updateWindow(const std::string& winname); //Only for Qt -CV_EXPORTS CvFont fontQt(const string& nameFont, int pointSize=-1, +CV_EXPORTS CvFont fontQt(const std::string& nameFont, int pointSize=-1, Scalar color=Scalar::all(0), int weight=CV_FONT_NORMAL, int style=CV_STYLE_NORMAL, int spacing=0); -CV_EXPORTS void addText( const Mat& img, const string& text, Point org, CvFont font); +CV_EXPORTS void addText( const Mat& img, const std::string& text, Point org, CvFont font); -CV_EXPORTS void displayOverlay(const string& winname, const string& text, int delayms CV_DEFAULT(0)); -CV_EXPORTS void displayStatusBar(const string& winname, const string& text, int delayms CV_DEFAULT(0)); +CV_EXPORTS void displayOverlay(const std::string& winname, const std::string& text, int delayms CV_DEFAULT(0)); +CV_EXPORTS void displayStatusBar(const std::string& winname, const std::string& text, int delayms CV_DEFAULT(0)); -CV_EXPORTS void saveWindowParameters(const string& windowName); -CV_EXPORTS void loadWindowParameters(const string& windowName); +CV_EXPORTS void saveWindowParameters(const std::string& windowName); +CV_EXPORTS void loadWindowParameters(const std::string& windowName); CV_EXPORTS int startLoop(int (*pt2Func)(int argc, char *argv[]), int argc, char* argv[]); CV_EXPORTS void stopLoop(); typedef void (CV_CDECL *ButtonCallback)(int state, void* userdata); -CV_EXPORTS int createButton( const string& bar_name, ButtonCallback on_change, +CV_EXPORTS int createButton( const std::string& bar_name, ButtonCallback on_change, void* userdata=NULL, int type=CV_PUSH_BUTTON, bool initial_button_state=0); @@ -182,14 +182,14 @@ enum IMWRITE_PXM_BINARY =32 }; -CV_EXPORTS_W Mat imread( const string& filename, int flags=1 ); -CV_EXPORTS_W bool imwrite( const string& filename, InputArray img, - const vector& params=vector()); +CV_EXPORTS_W Mat imread( const std::string& filename, int flags=1 ); +CV_EXPORTS_W bool imwrite( const std::string& filename, InputArray img, + const std::vector& params=std::vector()); CV_EXPORTS_W Mat imdecode( InputArray buf, int flags ); CV_EXPORTS Mat imdecode( InputArray buf, int flags, Mat* dst ); -CV_EXPORTS_W bool imencode( const string& ext, InputArray img, - CV_OUT vector& buf, - const vector& params=vector()); +CV_EXPORTS_W bool imencode( const std::string& ext, InputArray img, + CV_OUT std::vector& buf, + const std::vector& params=std::vector()); #ifndef CV_NO_VIDEO_CAPTURE_CPP_API @@ -200,11 +200,11 @@ class CV_EXPORTS_W VideoCapture { public: CV_WRAP VideoCapture(); - CV_WRAP VideoCapture(const string& filename); + CV_WRAP VideoCapture(const std::string& filename); CV_WRAP VideoCapture(int device); virtual ~VideoCapture(); - CV_WRAP virtual bool open(const string& filename); + CV_WRAP virtual bool open(const std::string& filename); CV_WRAP virtual bool open(int device); CV_WRAP virtual bool isOpened() const; CV_WRAP virtual void release(); @@ -226,11 +226,11 @@ class CV_EXPORTS_W VideoWriter { public: CV_WRAP VideoWriter(); - CV_WRAP VideoWriter(const string& filename, int fourcc, double fps, + CV_WRAP VideoWriter(const std::string& filename, int fourcc, double fps, Size frameSize, bool isColor=true); virtual ~VideoWriter(); - CV_WRAP virtual bool open(const string& filename, int fourcc, double fps, + CV_WRAP virtual bool open(const std::string& filename, int fourcc, double fps, Size frameSize, bool isColor=true); CV_WRAP virtual bool isOpened() const; CV_WRAP virtual void release(); diff --git a/modules/highgui/perf/perf_input.cpp b/modules/highgui/perf/perf_input.cpp index 0c1e8e0a7..b32f88da9 100644 --- a/modules/highgui/perf/perf_input.cpp +++ b/modules/highgui/perf/perf_input.cpp @@ -9,7 +9,7 @@ using std::tr1::make_tuple; using std::tr1::get; -typedef perf::TestBaseWithParam VideoCapture_Reading; +typedef perf::TestBaseWithParam VideoCapture_Reading; PERF_TEST_P(VideoCapture_Reading, ReadFile, testing::Values( "highgui/video/big_buck_bunny.avi", "highgui/video/big_buck_bunny.mov", diff --git a/modules/highgui/perf/perf_output.cpp b/modules/highgui/perf/perf_output.cpp index 6428bb4f0..50d86adf7 100644 --- a/modules/highgui/perf/perf_output.cpp +++ b/modules/highgui/perf/perf_output.cpp @@ -8,7 +8,7 @@ using namespace perf; using std::tr1::make_tuple; using std::tr1::get; -typedef std::tr1::tuple VideoWriter_Writing_t; +typedef std::tr1::tuple VideoWriter_Writing_t; typedef perf::TestBaseWithParam VideoWriter_Writing; PERF_TEST_P(VideoWriter_Writing, WriteFrame, diff --git a/modules/highgui/src/bitstrm.cpp b/modules/highgui/src/bitstrm.cpp index dd8bec87c..89f46fb59 100644 --- a/modules/highgui/src/bitstrm.cpp +++ b/modules/highgui/src/bitstrm.cpp @@ -110,7 +110,7 @@ void RBaseStream::readBlock() } -bool RBaseStream::open( const string& filename ) +bool RBaseStream::open( const std::string& filename ) { close(); allocate(); @@ -388,7 +388,7 @@ void WBaseStream::writeBlock() } -bool WBaseStream::open( const string& filename ) +bool WBaseStream::open( const std::string& filename ) { close(); allocate(); @@ -403,7 +403,7 @@ bool WBaseStream::open( const string& filename ) return m_file != 0; } -bool WBaseStream::open( vector& buf ) +bool WBaseStream::open( std::vector& buf ) { close(); allocate(); diff --git a/modules/highgui/src/bitstrm.hpp b/modules/highgui/src/bitstrm.hpp index e476d9c56..221c2c709 100644 --- a/modules/highgui/src/bitstrm.hpp +++ b/modules/highgui/src/bitstrm.hpp @@ -66,7 +66,7 @@ public: RBaseStream(); virtual ~RBaseStream(); - virtual bool open( const string& filename ); + virtual bool open( const std::string& filename ); virtual bool open( const Mat& buf ); virtual void close(); bool isOpened(); @@ -123,8 +123,8 @@ public: WBaseStream(); virtual ~WBaseStream(); - virtual bool open( const string& filename ); - virtual bool open( vector& buf ); + virtual bool open( const std::string& filename ); + virtual bool open( std::vector& buf ); virtual void close(); bool isOpened(); int getPos(); @@ -138,7 +138,7 @@ protected: int m_block_pos; FILE* m_file; bool m_is_opened; - vector* m_buf; + std::vector* m_buf; virtual void writeBlock(); virtual void release(); diff --git a/modules/highgui/src/cap.cpp b/modules/highgui/src/cap.cpp index 03c819f7a..012f712dc 100644 --- a/modules/highgui/src/cap.cpp +++ b/modules/highgui/src/cap.cpp @@ -445,7 +445,7 @@ namespace cv VideoCapture::VideoCapture() {} -VideoCapture::VideoCapture(const string& filename) +VideoCapture::VideoCapture(const std::string& filename) { open(filename); } @@ -460,7 +460,7 @@ VideoCapture::~VideoCapture() cap.release(); } -bool VideoCapture::open(const string& filename) +bool VideoCapture::open(const std::string& filename) { if (!isOpened()) cap = cvCreateFileCapture(filename.c_str()); @@ -532,7 +532,7 @@ double VideoCapture::get(int propId) VideoWriter::VideoWriter() {} -VideoWriter::VideoWriter(const string& filename, int fourcc, double fps, Size frameSize, bool isColor) +VideoWriter::VideoWriter(const std::string& filename, int fourcc, double fps, Size frameSize, bool isColor) { open(filename, fourcc, fps, frameSize, isColor); } @@ -547,7 +547,7 @@ VideoWriter::~VideoWriter() release(); } -bool VideoWriter::open(const string& filename, int fourcc, double fps, Size frameSize, bool isColor) +bool VideoWriter::open(const std::string& filename, int fourcc, double fps, Size frameSize, bool isColor) { writer = cvCreateVideoWriter(filename.c_str(), fourcc, fps, frameSize, isColor); return isOpened(); diff --git a/modules/highgui/src/cap_avfoundation.mm b/modules/highgui/src/cap_avfoundation.mm index dfbb2a0cd..76c49a981 100644 --- a/modules/highgui/src/cap_avfoundation.mm +++ b/modules/highgui/src/cap_avfoundation.mm @@ -36,10 +36,6 @@ #import -//#import - -using namespace std; - /********************** Declaration of class headers ************************/ /***************************************************************************** diff --git a/modules/highgui/src/cap_qtkit.mm b/modules/highgui/src/cap_qtkit.mm index c7afffa07..34d1518de 100644 --- a/modules/highgui/src/cap_qtkit.mm +++ b/modules/highgui/src/cap_qtkit.mm @@ -33,8 +33,6 @@ #include #import -using namespace std; - /********************** Declaration of class headers ************************/ /***************************************************************************** @@ -248,7 +246,7 @@ CvCaptureCAM::CvCaptureCAM(int cameraNum) { camNum = cameraNum; if (!startCaptureDevice(camNum)) { - cout << "Warning, camera failed to properly initialize!" << endl; + std::cout << "Warning, camera failed to properly initialize!" << std::endl; started = 0; } else { started = 1; @@ -259,7 +257,7 @@ CvCaptureCAM::CvCaptureCAM(int cameraNum) { CvCaptureCAM::~CvCaptureCAM() { stopCaptureDevice(); - cout << "Cleaned up camera." << endl; + std::cout << "Cleaned up camera." << std::endl; } int CvCaptureCAM::didStart() { @@ -320,7 +318,7 @@ int CvCaptureCAM::startCaptureDevice(int cameraNum) { arrayByAddingObjectsFromArray:[QTCaptureDevice inputDevicesWithMediaType:QTMediaTypeMuxed]] retain]; if ([devices count] == 0) { - cout << "QTKit didn't find any attached Video Input Devices!" << endl; + std::cout << "QTKit didn't find any attached Video Input Devices!" << std::endl; [localpool drain]; return 0; } @@ -340,7 +338,7 @@ int CvCaptureCAM::startCaptureDevice(int cameraNum) { success = [device open:&error]; if (!success) { - cout << "QTKit failed to open a Video Capture Device" << endl; + std::cout << "QTKit failed to open a Video Capture Device" << std::endl; [localpool drain]; return 0; } @@ -351,7 +349,7 @@ int CvCaptureCAM::startCaptureDevice(int cameraNum) { success = [mCaptureSession addInput:mCaptureDeviceInput error:&error]; if (!success) { - cout << "QTKit failed to start capture session with opened Capture Device" << endl; + std::cout << "QTKit failed to start capture session with opened Capture Device" << std::endl; [localpool drain]; return 0; } @@ -383,7 +381,7 @@ int CvCaptureCAM::startCaptureDevice(int cameraNum) { success = [mCaptureSession addOutput:mCaptureDecompressedVideoOutput error:&error]; if (!success) { - cout << "QTKit failed to add Output to Capture Session" << endl; + std::cout << "QTKit failed to add Output to Capture Session" << std::endl; [localpool drain]; return 0; } @@ -525,7 +523,7 @@ didDropVideoFrameWithSampleBuffer:(QTSampleBuffer *)sampleBuffer (void)captureOutput; (void)sampleBuffer; (void)connection; - cout << "Camera dropped frame!" << endl; + std::cout << "Camera dropped frame!" << std::endl; } -(IplImage*) getOutput { @@ -634,7 +632,7 @@ CvCaptureFile::CvCaptureFile(const char* filename) { forKey:QTMovieLoopsAttribute]; if (mCaptureSession == nil) { - cout << "WARNING: Couldn't read movie file " << filename << endl; + std::cout << "WARNING: Couldn't read movie file " << filename << std::endl; [localpool drain]; started = 0; return; @@ -803,7 +801,7 @@ double CvCaptureFile::getProperty(int property_id){ double retval; QTTime t; - //cerr << "get_prop"<= len && memcmp( signature.c_str(), m_signature.c_str(), len ) == 0; @@ -96,25 +96,25 @@ bool BaseImageEncoder::isFormatSupported( int depth ) const return depth == CV_8U; } -string BaseImageEncoder::getDescription() const +std::string BaseImageEncoder::getDescription() const { return m_description; } -bool BaseImageEncoder::setDestination( const string& filename ) +bool BaseImageEncoder::setDestination( const std::string& filename ) { m_filename = filename; m_buf = 0; return true; } -bool BaseImageEncoder::setDestination( vector& buf ) +bool BaseImageEncoder::setDestination( std::vector& buf ) { if( !m_buf_supported ) return false; m_buf = &buf; m_buf->clear(); - m_filename = string(); + m_filename = std::string(); return true; } diff --git a/modules/highgui/src/grfmt_base.hpp b/modules/highgui/src/grfmt_base.hpp index 49420f431..a97fa2919 100644 --- a/modules/highgui/src/grfmt_base.hpp +++ b/modules/highgui/src/grfmt_base.hpp @@ -65,21 +65,21 @@ public: int height() const { return m_height; }; virtual int type() const { return m_type; }; - virtual bool setSource( const string& filename ); + virtual bool setSource( const std::string& filename ); virtual bool setSource( const Mat& buf ); virtual bool readHeader() = 0; virtual bool readData( Mat& img ) = 0; virtual size_t signatureLength() const; - virtual bool checkSignature( const string& signature ) const; + virtual bool checkSignature( const std::string& signature ) const; virtual ImageDecoder newDecoder() const; protected: int m_width; // width of the image ( filled by readHeader ) int m_height; // height of the image ( filled by readHeader ) int m_type; - string m_filename; - string m_signature; + std::string m_filename; + std::string m_signature; Mat m_buf; bool m_buf_supported; }; @@ -93,23 +93,23 @@ public: virtual ~BaseImageEncoder() {}; virtual bool isFormatSupported( int depth ) const; - virtual bool setDestination( const string& filename ); - virtual bool setDestination( vector& buf ); - virtual bool write( const Mat& img, const vector& params ) = 0; + virtual bool setDestination( const std::string& filename ); + virtual bool setDestination( std::vector& buf ); + virtual bool write( const Mat& img, const std::vector& params ) = 0; - virtual string getDescription() const; + virtual std::string getDescription() const; virtual ImageEncoder newEncoder() const; virtual void throwOnEror() const; protected: - string m_description; + std::string m_description; - string m_filename; - vector* m_buf; + std::string m_filename; + std::vector* m_buf; bool m_buf_supported; - string m_last_error; + std::string m_last_error; }; } diff --git a/modules/highgui/src/grfmt_bmp.cpp b/modules/highgui/src/grfmt_bmp.cpp index 3da9bc311..5f1083e43 100644 --- a/modules/highgui/src/grfmt_bmp.cpp +++ b/modules/highgui/src/grfmt_bmp.cpp @@ -499,7 +499,7 @@ ImageEncoder BmpEncoder::newEncoder() const return new BmpEncoder; } -bool BmpEncoder::write( const Mat& img, const vector& ) +bool BmpEncoder::write( const Mat& img, const std::vector& ) { int width = img.cols, height = img.rows, channels = img.channels(); int fileStep = (width*channels + 3) & -4; diff --git a/modules/highgui/src/grfmt_bmp.hpp b/modules/highgui/src/grfmt_bmp.hpp index 404a9bdf7..b4443b7dc 100644 --- a/modules/highgui/src/grfmt_bmp.hpp +++ b/modules/highgui/src/grfmt_bmp.hpp @@ -89,7 +89,7 @@ public: BmpEncoder(); ~BmpEncoder(); - bool write( const Mat& img, const vector& params ); + bool write( const Mat& img, const std::vector& params ); ImageEncoder newEncoder() const; }; diff --git a/modules/highgui/src/grfmt_exr.cpp b/modules/highgui/src/grfmt_exr.cpp index c29f4ba36..a537e66fa 100644 --- a/modules/highgui/src/grfmt_exr.cpp +++ b/modules/highgui/src/grfmt_exr.cpp @@ -580,7 +580,7 @@ bool ExrEncoder::isFormatSupported( int depth ) const // TODO scale appropriately -bool ExrEncoder::write( const Mat& img, const vector& ) +bool ExrEncoder::write( const Mat& img, const std::vector& ) { int width = img.cols, height = img.rows; int depth = img.depth(), channels = img.channels(); diff --git a/modules/highgui/src/grfmt_exr.hpp b/modules/highgui/src/grfmt_exr.hpp index b9467c6d2..93dfb91c5 100644 --- a/modules/highgui/src/grfmt_exr.hpp +++ b/modules/highgui/src/grfmt_exr.hpp @@ -106,7 +106,7 @@ public: ~ExrEncoder(); bool isFormatSupported( int depth ) const; - bool write( const Mat& img, const vector& params ); + bool write( const Mat& img, const std::vector& params ); ImageEncoder newEncoder() const; }; diff --git a/modules/highgui/src/grfmt_jpeg.cpp b/modules/highgui/src/grfmt_jpeg.cpp index 3dedf440d..7054d6dbc 100644 --- a/modules/highgui/src/grfmt_jpeg.cpp +++ b/modules/highgui/src/grfmt_jpeg.cpp @@ -478,7 +478,7 @@ bool JpegDecoder::readData( Mat& img ) struct JpegDestination { struct jpeg_destination_mgr pub; - vector *buf, *dst; + std::vector *buf, *dst; }; METHODDEF(void) @@ -537,7 +537,7 @@ ImageEncoder JpegEncoder::newEncoder() const return new JpegEncoder; } -bool JpegEncoder::write( const Mat& img, const vector& params ) +bool JpegEncoder::write( const Mat& img, const std::vector& params ) { m_last_error.clear(); @@ -552,7 +552,7 @@ bool JpegEncoder::write( const Mat& img, const vector& params ) fileWrapper fw; int width = img.cols, height = img.rows; - vector out_buf(1 << 12); + std::vector out_buf(1 << 12); AutoBuffer _buffer; uchar* buffer; diff --git a/modules/highgui/src/grfmt_jpeg.hpp b/modules/highgui/src/grfmt_jpeg.hpp index 1a6d1ab1f..8455b197b 100644 --- a/modules/highgui/src/grfmt_jpeg.hpp +++ b/modules/highgui/src/grfmt_jpeg.hpp @@ -79,7 +79,7 @@ public: JpegEncoder(); virtual ~JpegEncoder(); - bool write( const Mat& img, const vector& params ); + bool write( const Mat& img, const std::vector& params ); ImageEncoder newEncoder() const; }; diff --git a/modules/highgui/src/grfmt_jpeg2000.cpp b/modules/highgui/src/grfmt_jpeg2000.cpp index d9080e5d4..e09eccc90 100644 --- a/modules/highgui/src/grfmt_jpeg2000.cpp +++ b/modules/highgui/src/grfmt_jpeg2000.cpp @@ -82,7 +82,7 @@ static JasperInitializer initialize_jasper; Jpeg2KDecoder::Jpeg2KDecoder() { - m_signature = '\0' + string() + '\0' + string() + '\0' + string("\x0cjP \r\n\x87\n"); + m_signature = '\0' + std::string() + '\0' + std::string() + '\0' + std::string("\x0cjP \r\n\x87\n"); m_stream = 0; m_image = 0; } @@ -418,7 +418,7 @@ bool Jpeg2KEncoder::isFormatSupported( int depth ) const } -bool Jpeg2KEncoder::write( const Mat& _img, const vector& ) +bool Jpeg2KEncoder::write( const Mat& _img, const std::vector& ) { int width = _img.cols, height = _img.rows; int depth = _img.depth(), channels = _img.channels(); diff --git a/modules/highgui/src/grfmt_jpeg2000.hpp b/modules/highgui/src/grfmt_jpeg2000.hpp index 636a8c1d1..0c0954f8b 100644 --- a/modules/highgui/src/grfmt_jpeg2000.hpp +++ b/modules/highgui/src/grfmt_jpeg2000.hpp @@ -80,7 +80,7 @@ public: virtual ~Jpeg2KEncoder(); bool isFormatSupported( int depth ) const; - bool write( const Mat& img, const vector& params ); + bool write( const Mat& img, const std::vector& params ); ImageEncoder newEncoder() const; protected: diff --git a/modules/highgui/src/grfmt_png.cpp b/modules/highgui/src/grfmt_png.cpp index 196b1e65f..77b317f0f 100644 --- a/modules/highgui/src/grfmt_png.cpp +++ b/modules/highgui/src/grfmt_png.cpp @@ -324,7 +324,7 @@ void PngEncoder::flushBuf(void*) { } -bool PngEncoder::write( const Mat& img, const vector& params ) +bool PngEncoder::write( const Mat& img, const std::vector& params ) { png_structp png_ptr = png_create_write_struct( PNG_LIBPNG_VER_STRING, 0, 0, 0 ); png_infop info_ptr = 0; diff --git a/modules/highgui/src/grfmt_png.hpp b/modules/highgui/src/grfmt_png.hpp index afcca84b4..3a3d004ff 100644 --- a/modules/highgui/src/grfmt_png.hpp +++ b/modules/highgui/src/grfmt_png.hpp @@ -85,7 +85,7 @@ public: virtual ~PngEncoder(); bool isFormatSupported( int depth ) const; - bool write( const Mat& img, const vector& params ); + bool write( const Mat& img, const std::vector& params ); ImageEncoder newEncoder() const; diff --git a/modules/highgui/src/grfmt_pxm.cpp b/modules/highgui/src/grfmt_pxm.cpp index 57b222eb3..c2eb100d7 100644 --- a/modules/highgui/src/grfmt_pxm.cpp +++ b/modules/highgui/src/grfmt_pxm.cpp @@ -107,7 +107,7 @@ size_t PxMDecoder::signatureLength() const return 3; } -bool PxMDecoder::checkSignature( const string& signature ) const +bool PxMDecoder::checkSignature( const std::string& signature ) const { return signature.size() >= 3 && signature[0] == 'P' && '1' <= signature[1] && signature[1] <= '6' && @@ -367,7 +367,7 @@ bool PxMEncoder::isFormatSupported( int depth ) const } -bool PxMEncoder::write( const Mat& img, const vector& params ) +bool PxMEncoder::write( const Mat& img, const std::vector& params ) { bool isBinary = true; diff --git a/modules/highgui/src/grfmt_pxm.hpp b/modules/highgui/src/grfmt_pxm.hpp index 289275a73..59c669414 100644 --- a/modules/highgui/src/grfmt_pxm.hpp +++ b/modules/highgui/src/grfmt_pxm.hpp @@ -61,7 +61,7 @@ public: void close(); size_t signatureLength() const; - bool checkSignature( const string& signature ) const; + bool checkSignature( const std::string& signature ) const; ImageDecoder newDecoder() const; protected: @@ -82,7 +82,7 @@ public: virtual ~PxMEncoder(); bool isFormatSupported( int depth ) const; - bool write( const Mat& img, const vector& params ); + bool write( const Mat& img, const std::vector& params ); ImageEncoder newEncoder() const; }; diff --git a/modules/highgui/src/grfmt_sunras.cpp b/modules/highgui/src/grfmt_sunras.cpp index 19f8db4ed..a16e5d800 100644 --- a/modules/highgui/src/grfmt_sunras.cpp +++ b/modules/highgui/src/grfmt_sunras.cpp @@ -395,7 +395,7 @@ SunRasterEncoder::~SunRasterEncoder() { } -bool SunRasterEncoder::write( const Mat& img, const vector& ) +bool SunRasterEncoder::write( const Mat& img, const std::vector& ) { bool result = false; int y, width = img.cols, height = img.rows, channels = img.channels(); diff --git a/modules/highgui/src/grfmt_sunras.hpp b/modules/highgui/src/grfmt_sunras.hpp index af9b6b8aa..ef09f9b1f 100644 --- a/modules/highgui/src/grfmt_sunras.hpp +++ b/modules/highgui/src/grfmt_sunras.hpp @@ -95,7 +95,7 @@ public: SunRasterEncoder(); virtual ~SunRasterEncoder(); - bool write( const Mat& img, const vector& params ); + bool write( const Mat& img, const std::vector& params ); ImageEncoder newEncoder() const; }; diff --git a/modules/highgui/src/grfmt_tiff.cpp b/modules/highgui/src/grfmt_tiff.cpp index 5179531f5..f289ad19c 100644 --- a/modules/highgui/src/grfmt_tiff.cpp +++ b/modules/highgui/src/grfmt_tiff.cpp @@ -94,7 +94,7 @@ size_t TiffDecoder::signatureLength() const return 4; } -bool TiffDecoder::checkSignature( const string& signature ) const +bool TiffDecoder::checkSignature( const std::string& signature ) const { return signature.size() >= 4 && (memcmp(signature.c_str(), fmtSignTiffII, 4) == 0 || @@ -402,7 +402,7 @@ void TiffEncoder::writeTag( WLByteStream& strm, TiffTag tag, #ifdef HAVE_TIFF -static void readParam(const vector& params, int key, int& value) +static void readParam(const std::vector& params, int key, int& value) { for(size_t i = 0; i + 1 < params.size(); i += 2) if(params[i] == key) @@ -412,7 +412,7 @@ static void readParam(const vector& params, int key, int& value) } } -bool TiffEncoder::writeLibTiff( const Mat& img, const vector& params) +bool TiffEncoder::writeLibTiff( const Mat& img, const std::vector& params) { int channels = img.channels(); int width = img.cols, height = img.rows; @@ -542,9 +542,9 @@ bool TiffEncoder::writeLibTiff( const Mat& img, const vector& params) #endif #ifdef HAVE_TIFF -bool TiffEncoder::write( const Mat& img, const vector& params) +bool TiffEncoder::write( const Mat& img, const std::vector& params) #else -bool TiffEncoder::write( const Mat& img, const vector& /*params*/) +bool TiffEncoder::write( const Mat& img, const std::vector& /*params*/) #endif { int channels = img.channels(); diff --git a/modules/highgui/src/grfmt_tiff.hpp b/modules/highgui/src/grfmt_tiff.hpp index 831854828..a958a9307 100644 --- a/modules/highgui/src/grfmt_tiff.hpp +++ b/modules/highgui/src/grfmt_tiff.hpp @@ -102,7 +102,7 @@ public: void close(); size_t signatureLength() const; - bool checkSignature( const string& signature ) const; + bool checkSignature( const std::string& signature ) const; ImageDecoder newDecoder() const; protected: @@ -120,7 +120,7 @@ public: bool isFormatSupported( int depth ) const; - bool write( const Mat& img, const vector& params ); + bool write( const Mat& img, const std::vector& params ); ImageEncoder newEncoder() const; protected: @@ -128,7 +128,7 @@ protected: TiffFieldType fieldType, int count, int value ); - bool writeLibTiff( const Mat& img, const vector& params ); + bool writeLibTiff( const Mat& img, const std::vector& params ); }; } diff --git a/modules/highgui/src/loadsave.cpp b/modules/highgui/src/loadsave.cpp index 51c6e8189..00ae49d46 100644 --- a/modules/highgui/src/loadsave.cpp +++ b/modules/highgui/src/loadsave.cpp @@ -86,13 +86,13 @@ struct ImageCodecInitializer #endif } - vector decoders; - vector encoders; + std::vector decoders; + std::vector encoders; }; static ImageCodecInitializer codecs; -static ImageDecoder findDecoder( const string& filename ) +static ImageDecoder findDecoder( const std::string& filename ) { size_t i, maxlen = 0; for( i = 0; i < codecs.decoders.size(); i++ ) @@ -104,7 +104,7 @@ static ImageDecoder findDecoder( const string& filename ) FILE* f= fopen( filename.c_str(), "rb" ); if( !f ) return ImageDecoder(); - string signature(maxlen, ' '); + std::string signature(maxlen, ' '); maxlen = fread( &signature[0], 1, maxlen, f ); fclose(f); signature = signature.substr(0, maxlen); @@ -133,7 +133,7 @@ static ImageDecoder findDecoder( const Mat& buf ) size_t bufSize = buf.rows*buf.cols*buf.elemSize(); maxlen = std::min(maxlen, bufSize); - string signature(maxlen, ' '); + std::string signature(maxlen, ' '); memcpy( &signature[0], buf.data, maxlen ); for( i = 0; i < codecs.decoders.size(); i++ ) @@ -145,7 +145,7 @@ static ImageDecoder findDecoder( const Mat& buf ) return ImageDecoder(); } -static ImageEncoder findEncoder( const string& _ext ) +static ImageEncoder findEncoder( const std::string& _ext ) { if( _ext.size() <= 1 ) return ImageEncoder(); @@ -159,7 +159,7 @@ static ImageEncoder findEncoder( const string& _ext ) for( size_t i = 0; i < codecs.encoders.size(); i++ ) { - string description = codecs.encoders[i]->getDescription(); + std::string description = codecs.encoders[i]->getDescription(); const char* descr = strchr( description.c_str(), '(' ); while( descr ) @@ -187,7 +187,7 @@ static ImageEncoder findEncoder( const string& _ext ) enum { LOAD_CVMAT=0, LOAD_IMAGE=1, LOAD_MAT=2 }; static void* -imread_( const string& filename, int flags, int hdrtype, Mat* mat=0 ) +imread_( const std::string& filename, int flags, int hdrtype, Mat* mat=0 ) { IplImage* image = 0; CvMat *matrix = 0; @@ -249,15 +249,15 @@ imread_( const string& filename, int flags, int hdrtype, Mat* mat=0 ) hdrtype == LOAD_IMAGE ? (void*)image : (void*)mat; } -Mat imread( const string& filename, int flags ) +Mat imread( const std::string& filename, int flags ) { Mat img; imread_( filename, flags, LOAD_MAT, &img ); return img; } -static bool imwrite_( const string& filename, const Mat& image, - const vector& params, bool flipv ) +static bool imwrite_( const std::string& filename, const Mat& image, + const std::vector& params, bool flipv ) { Mat temp; const Mat* pimage = ℑ @@ -288,8 +288,8 @@ static bool imwrite_( const string& filename, const Mat& image, return code; } -bool imwrite( const string& filename, InputArray _img, - const vector& params ) +bool imwrite( const std::string& filename, InputArray _img, + const std::vector& params ) { Mat img = _img.getMat(); return imwrite_(filename, img, params, false); @@ -302,7 +302,7 @@ imdecode_( const Mat& buf, int flags, int hdrtype, Mat* mat=0 ) IplImage* image = 0; CvMat *matrix = 0; Mat temp, *data = &temp; - string filename; + std::string filename; ImageDecoder decoder = findDecoder(buf); if( decoder.empty() ) @@ -396,8 +396,8 @@ Mat imdecode( InputArray _buf, int flags, Mat* dst ) return *dst; } -bool imencode( const string& ext, InputArray _image, - vector& buf, const vector& params ) +bool imencode( const std::string& ext, InputArray _image, + std::vector& buf, const std::vector& params ) { Mat image = _image.getMat(); @@ -425,7 +425,7 @@ bool imencode( const string& ext, InputArray _image, } else { - string filename = tempfile(); + std::string filename = tempfile(); code = encoder->setDestination(filename); CV_Assert( code ); @@ -487,7 +487,7 @@ cvSaveImage( const char* filename, const CvArr* arr, const int* _params ) ; } return cv::imwrite_(filename, cv::cvarrToMat(arr), - i > 0 ? cv::vector(_params, _params+i) : cv::vector(), + i > 0 ? std::vector(_params, _params+i) : std::vector(), CV_IS_IMAGE(arr) && ((const IplImage*)arr)->origin == IPL_ORIGIN_BL ); } @@ -524,7 +524,7 @@ cvEncodeImage( const char* ext, const CvArr* arr, const int* _params ) cv::flip(img, temp, 0); img = temp; } - cv::vector buf; + std::vector buf; bool code = cv::imencode(ext, img, buf, i > 0 ? std::vector(_params, _params+i) : std::vector() ); diff --git a/modules/highgui/src/window.cpp b/modules/highgui/src/window.cpp index 05cb5ef2e..a151be2df 100644 --- a/modules/highgui/src/window.cpp +++ b/modules/highgui/src/window.cpp @@ -153,12 +153,12 @@ CV_IMPL double cvGetWindowProperty(const char* name, int prop_id) } } -void cv::namedWindow( const string& winname, int flags ) +void cv::namedWindow( const std::string& winname, int flags ) { cvNamedWindow( winname.c_str(), flags ); } -void cv::destroyWindow( const string& winname ) +void cv::destroyWindow( const std::string& winname ) { cvDestroyWindow( winname.c_str() ); } @@ -168,22 +168,22 @@ void cv::destroyAllWindows() cvDestroyAllWindows(); } -void cv::resizeWindow( const string& winname, int width, int height ) +void cv::resizeWindow( const std::string& winname, int width, int height ) { cvResizeWindow( winname.c_str(), width, height ); } -void cv::moveWindow( const string& winname, int x, int y ) +void cv::moveWindow( const std::string& winname, int x, int y ) { cvMoveWindow( winname.c_str(), x, y ); } -void cv::setWindowProperty(const string& winname, int prop_id, double prop_value) +void cv::setWindowProperty(const std::string& winname, int prop_id, double prop_value) { cvSetWindowProperty( winname.c_str(), prop_id, prop_value); } -double cv::getWindowProperty(const string& winname, int prop_id) +double cv::getWindowProperty(const std::string& winname, int prop_id) { return cvGetWindowProperty(winname.c_str(), prop_id); } @@ -193,7 +193,7 @@ int cv::waitKey(int delay) return cvWaitKey(delay); } -int cv::createTrackbar(const string& trackbarName, const string& winName, +int cv::createTrackbar(const std::string& trackbarName, const std::string& winName, int* value, int count, TrackbarCallback callback, void* userdata) { @@ -201,17 +201,17 @@ int cv::createTrackbar(const string& trackbarName, const string& winName, value, count, callback, userdata); } -void cv::setTrackbarPos( const string& trackbarName, const string& winName, int value ) +void cv::setTrackbarPos( const std::string& trackbarName, const std::string& winName, int value ) { cvSetTrackbarPos(trackbarName.c_str(), winName.c_str(), value ); } -int cv::getTrackbarPos( const string& trackbarName, const string& winName ) +int cv::getTrackbarPos( const std::string& trackbarName, const std::string& winName ) { return cvGetTrackbarPos(trackbarName.c_str(), winName.c_str()); } -void cv::setMouseCallback( const string& windowName, MouseCallback onMouse, void* param) +void cv::setMouseCallback( const std::string& windowName, MouseCallback onMouse, void* param) { cvSetMouseCallback(windowName.c_str(), onMouse, param); } @@ -223,17 +223,17 @@ int cv::startWindowThread() // OpenGL support -void cv::setOpenGlDrawCallback(const string& name, OpenGlDrawCallback callback, void* userdata) +void cv::setOpenGlDrawCallback(const std::string& name, OpenGlDrawCallback callback, void* userdata) { cvSetOpenGlDrawCallback(name.c_str(), callback, userdata); } -void cv::setOpenGlContext(const string& windowName) +void cv::setOpenGlContext(const std::string& windowName) { cvSetOpenGlContext(windowName.c_str()); } -void cv::updateWindow(const string& windowName) +void cv::updateWindow(const std::string& windowName) { cvUpdateWindow(windowName.c_str()); } @@ -254,7 +254,7 @@ namespace } #endif // HAVE_OPENGL -void cv::imshow( const string& winname, InputArray _img ) +void cv::imshow( const std::string& winname, InputArray _img ) { #ifndef HAVE_OPENGL Mat img = _img.getMat(); @@ -342,23 +342,23 @@ CV_IMPL void cvUpdateWindow(const char*) #if defined (HAVE_QT) -CvFont cv::fontQt(const string& nameFont, int pointSize, Scalar color, int weight, int style, int /*spacing*/) +CvFont cv::fontQt(const std::string& nameFont, int pointSize, Scalar color, int weight, int style, int /*spacing*/) { return cvFontQt(nameFont.c_str(), pointSize,color,weight, style); } -void cv::addText( const Mat& img, const string& text, Point org, CvFont font) +void cv::addText( const Mat& img, const std::string& text, Point org, CvFont font) { CvMat _img = img; cvAddText( &_img, text.c_str(), org,&font); } -void cv::displayStatusBar(const string& name, const string& text, int delayms) +void cv::displayStatusBar(const std::string& name, const std::string& text, int delayms) { cvDisplayStatusBar(name.c_str(),text.c_str(), delayms); } -void cv::displayOverlay(const string& name, const string& text, int delayms) +void cv::displayOverlay(const std::string& name, const std::string& text, int delayms) { cvDisplayOverlay(name.c_str(),text.c_str(), delayms); } @@ -373,40 +373,40 @@ void cv::stopLoop() cvStopLoop(); } -void cv::saveWindowParameters(const string& windowName) +void cv::saveWindowParameters(const std::string& windowName) { cvSaveWindowParameters(windowName.c_str()); } -void cv::loadWindowParameters(const string& windowName) +void cv::loadWindowParameters(const std::string& windowName) { cvLoadWindowParameters(windowName.c_str()); } -int cv::createButton(const string& button_name, ButtonCallback on_change, void* userdata, int button_type , bool initial_button_state ) +int cv::createButton(const std::string& button_name, ButtonCallback on_change, void* userdata, int button_type , bool initial_button_state ) { return cvCreateButton(button_name.c_str(), on_change, userdata, button_type , initial_button_state ); } #else -CvFont cv::fontQt(const string&, int, Scalar, int, int, int) +CvFont cv::fontQt(const std::string&, int, Scalar, int, int, int) { CV_Error(CV_StsNotImplemented, "The library is compiled without QT support"); return CvFont(); } -void cv::addText( const Mat&, const string&, Point, CvFont) +void cv::addText( const Mat&, const std::string&, Point, CvFont) { CV_Error(CV_StsNotImplemented, "The library is compiled without QT support"); } -void cv::displayStatusBar(const string&, const string&, int) +void cv::displayStatusBar(const std::string&, const std::string&, int) { CV_Error(CV_StsNotImplemented, "The library is compiled without QT support"); } -void cv::displayOverlay(const string&, const string&, int ) +void cv::displayOverlay(const std::string&, const std::string&, int ) { CV_Error(CV_StsNotImplemented, "The library is compiled without QT support"); } @@ -422,17 +422,17 @@ void cv::stopLoop() CV_Error(CV_StsNotImplemented, "The library is compiled without QT support"); } -void cv::saveWindowParameters(const string&) +void cv::saveWindowParameters(const std::string&) { CV_Error(CV_StsNotImplemented, "The library is compiled without QT support"); } -void cv::loadWindowParameters(const string&) +void cv::loadWindowParameters(const std::string&) { CV_Error(CV_StsNotImplemented, "The library is compiled without QT support"); } -int cv::createButton(const string&, ButtonCallback, void*, int , bool ) +int cv::createButton(const std::string&, ButtonCallback, void*, int , bool ) { CV_Error(CV_StsNotImplemented, "The library is compiled without QT support"); return 0; diff --git a/modules/highgui/src/window_cocoa.mm b/modules/highgui/src/window_cocoa.mm index d3a68107f..fca6ff939 100644 --- a/modules/highgui/src/window_cocoa.mm +++ b/modules/highgui/src/window_cocoa.mm @@ -71,7 +71,6 @@ CV_IMPL int cvWaitKey (int maxWait) {return 0;} #import #include -using namespace std; const int TOP_BORDER = 7; const int MIN_SLIDER_WIDTH=200; diff --git a/modules/highgui/test/test_drawing.cpp b/modules/highgui/test/test_drawing.cpp index 256b907d2..a23df6b9b 100644 --- a/modules/highgui/test/test_drawing.cpp +++ b/modules/highgui/test/test_drawing.cpp @@ -43,6 +43,7 @@ #include "test_precomp.hpp" #include "opencv2/highgui/highgui.hpp" +using namespace std; using namespace cv; //#define DRAW_TEST_IMAGE diff --git a/modules/highgui/test/test_grfmt.cpp b/modules/highgui/test/test_grfmt.cpp index 8366fcdff..54d2fe98f 100644 --- a/modules/highgui/test/test_grfmt.cpp +++ b/modules/highgui/test/test_grfmt.cpp @@ -103,7 +103,7 @@ public: { ts->printf(ts->LOG, "image type depth:%d channels:%d ext: %s\n", CV_8U, num_channels, ext_from_int(ext).c_str()); Mat img(img_r * k, img_c * k, CV_MAKETYPE(CV_8U, num_channels), Scalar::all(0)); - circle(img, Point2i((img_c * k) / 2, (img_r * k) / 2), cv::min((img_r * k), (img_c * k)) / 4 , Scalar::all(255)); + circle(img, Point2i((img_c * k) / 2, (img_r * k) / 2), std::min((img_r * k), (img_c * k)) / 4 , Scalar::all(255)); string img_path = cv::tempfile(ext_from_int(ext).c_str()); ts->printf(ts->LOG, "writing image : %s\n", img_path.c_str()); @@ -132,7 +132,7 @@ public: // jpeg ts->printf(ts->LOG, "image type depth:%d channels:%d ext: %s\n", CV_8U, num_channels, ".jpg"); Mat img(img_r * k, img_c * k, CV_MAKETYPE(CV_8U, num_channels), Scalar::all(0)); - circle(img, Point2i((img_c * k) / 2, (img_r * k) / 2), cv::min((img_r * k), (img_c * k)) / 4 , Scalar::all(255)); + circle(img, Point2i((img_c * k) / 2, (img_r * k) / 2), std::min((img_r * k), (img_c * k)) / 4 , Scalar::all(255)); string filename = cv::tempfile(".jpg"); imwrite(filename, img); @@ -162,7 +162,7 @@ public: // tiff ts->printf(ts->LOG, "image type depth:%d channels:%d ext: %s\n", CV_16U, num_channels, ".tiff"); Mat img(img_r * k, img_c * k, CV_MAKETYPE(CV_16U, num_channels), Scalar::all(0)); - circle(img, Point2i((img_c * k) / 2, (img_r * k) / 2), cv::min((img_r * k), (img_c * k)) / 4 , Scalar::all(255)); + circle(img, Point2i((img_c * k) / 2, (img_r * k) / 2), std::min((img_r * k), (img_c * k)) / 4 , Scalar::all(255)); string filename = cv::tempfile(".tiff"); imwrite(filename, img); diff --git a/modules/imgproc/include/opencv2/imgproc/imgproc.hpp b/modules/imgproc/include/opencv2/imgproc/imgproc.hpp index 34df8f2fc..8b055645a 100644 --- a/modules/imgproc/include/opencv2/imgproc/imgproc.hpp +++ b/modules/imgproc/include/opencv2/imgproc/imgproc.hpp @@ -1,7 +1,3 @@ -/*! \file imgproc.hpp - \brief The Image Processing - */ - /*M/////////////////////////////////////////////////////////////////////////////////////// // // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. @@ -268,14 +264,14 @@ public: Rect roi; int dx1, dx2; int rowBorderType, columnBorderType; - vector borderTab; + std::vector borderTab; int borderElemSize; - vector ringBuf; - vector srcRow; - vector constBorderValue; - vector constBorderRow; + std::vector ringBuf; + std::vector srcRow; + std::vector constBorderValue; + std::vector constBorderRow; int bufStep, startY, startY0, endY, rowCount, dstY; - vector rows; + std::vector rows; Ptr filter2D; Ptr rowFilter; @@ -717,10 +713,10 @@ CV_EXPORTS void calcHist( const Mat* images, int nimages, bool uniform=true, bool accumulate=false ); CV_EXPORTS_W void calcHist( InputArrayOfArrays images, - const vector& channels, + const std::vector& channels, InputArray mask, OutputArray hist, - const vector& histSize, - const vector& ranges, + const std::vector& histSize, + const std::vector& ranges, bool accumulate=false ); //! computes back projection for the set of images @@ -735,16 +731,16 @@ CV_EXPORTS void calcBackProject( const Mat* images, int nimages, OutputArray backProject, const float** ranges, double scale=1, bool uniform=true ); -CV_EXPORTS_W void calcBackProject( InputArrayOfArrays images, const vector& channels, +CV_EXPORTS_W void calcBackProject( InputArrayOfArrays images, const std::vector& channels, InputArray hist, OutputArray dst, - const vector& ranges, + const std::vector& ranges, double scale ); /*CV_EXPORTS void calcBackProjectPatch( const Mat* images, int nimages, const int* channels, InputArray hist, OutputArray dst, Size patchSize, int method, double factor=1 ); -CV_EXPORTS_W void calcBackProjectPatch( InputArrayOfArrays images, const vector& channels, +CV_EXPORTS_W void calcBackProjectPatch( InputArrayOfArrays images, const std::vector& channels, InputArray hist, OutputArray dst, Size patchSize, int method, double factor=1 );*/ @@ -1215,14 +1211,14 @@ public: CV_WRAP void initDelaunay(Rect rect); CV_WRAP int insert(Point2f pt); - CV_WRAP void insert(const vector& ptvec); + CV_WRAP void insert(const std::vector& ptvec); CV_WRAP int locate(Point2f pt, CV_OUT int& edge, CV_OUT int& vertex); CV_WRAP int findNearest(Point2f pt, CV_OUT Point2f* nearestPt=0); - CV_WRAP void getEdgeList(CV_OUT vector& edgeList) const; - CV_WRAP void getTriangleList(CV_OUT vector& triangleList) const; - CV_WRAP void getVoronoiFacetList(const vector& idx, CV_OUT vector >& facetList, - CV_OUT vector& facetCenters); + CV_WRAP void getEdgeList(CV_OUT std::vector& edgeList) const; + CV_WRAP void getTriangleList(CV_OUT std::vector& triangleList) const; + CV_WRAP void getVoronoiFacetList(const std::vector& idx, CV_OUT std::vector >& facetList, + CV_OUT std::vector& facetCenters); CV_WRAP Point2f getVertex(int vertex, CV_OUT int* firstEdge=0) const; @@ -1266,8 +1262,8 @@ protected: int pt[4]; }; - vector vtx; - vector qedges; + std::vector vtx; + std::vector qedges; int freeQEdge; int freePoint; bool validGeometry; diff --git a/modules/imgproc/perf/perf_canny.cpp b/modules/imgproc/perf/perf_canny.cpp index 92aa0cd30..2046556a6 100644 --- a/modules/imgproc/perf/perf_canny.cpp +++ b/modules/imgproc/perf/perf_canny.cpp @@ -6,7 +6,7 @@ using namespace perf; using std::tr1::make_tuple; using std::tr1::get; -typedef std::tr1::tuple > Img_Aperture_L2_thresholds_t; +typedef std::tr1::tuple > Img_Aperture_L2_thresholds_t; typedef perf::TestBaseWithParam Img_Aperture_L2_thresholds; PERF_TEST_P(Img_Aperture_L2_thresholds, canny, @@ -18,7 +18,7 @@ PERF_TEST_P(Img_Aperture_L2_thresholds, canny, ) ) { - String filename = getDataPath(get<0>(GetParam())); + string filename = getDataPath(get<0>(GetParam())); int aperture = get<1>(GetParam()); bool useL2 = get<2>(GetParam()); double thresh_low = get<0>(get<3>(GetParam())); diff --git a/modules/imgproc/perf/perf_cornerEigenValsAndVecs.cpp b/modules/imgproc/perf/perf_cornerEigenValsAndVecs.cpp index 29fd3eb01..1fbf7655f 100644 --- a/modules/imgproc/perf/perf_cornerEigenValsAndVecs.cpp +++ b/modules/imgproc/perf/perf_cornerEigenValsAndVecs.cpp @@ -8,7 +8,7 @@ using std::tr1::get; CV_ENUM(BorderType, BORDER_REPLICATE, BORDER_CONSTANT, BORDER_REFLECT, BORDER_REFLECT_101) -typedef std::tr1::tuple Img_BlockSize_ApertureSize_BorderType_t; +typedef std::tr1::tuple Img_BlockSize_ApertureSize_BorderType_t; typedef perf::TestBaseWithParam Img_BlockSize_ApertureSize_BorderType; PERF_TEST_P(Img_BlockSize_ApertureSize_BorderType, cornerEigenValsAndVecs, @@ -20,7 +20,7 @@ PERF_TEST_P(Img_BlockSize_ApertureSize_BorderType, cornerEigenValsAndVecs, ) ) { - String filename = getDataPath(get<0>(GetParam())); + string filename = getDataPath(get<0>(GetParam())); int blockSize = get<1>(GetParam()); int apertureSize = get<2>(GetParam()); BorderType borderType = get<3>(GetParam()); diff --git a/modules/imgproc/perf/perf_cornerHarris.cpp b/modules/imgproc/perf/perf_cornerHarris.cpp index 8d6beb8be..4006a7be3 100644 --- a/modules/imgproc/perf/perf_cornerHarris.cpp +++ b/modules/imgproc/perf/perf_cornerHarris.cpp @@ -8,7 +8,7 @@ using std::tr1::get; CV_ENUM(BorderType, BORDER_REPLICATE, BORDER_CONSTANT, BORDER_REFLECT, BORDER_REFLECT_101) -typedef std::tr1::tuple Img_BlockSize_ApertureSize_k_BorderType_t; +typedef std::tr1::tuple Img_BlockSize_ApertureSize_k_BorderType_t; typedef perf::TestBaseWithParam Img_BlockSize_ApertureSize_k_BorderType; PERF_TEST_P(Img_BlockSize_ApertureSize_k_BorderType, cornerHarris, @@ -21,7 +21,7 @@ PERF_TEST_P(Img_BlockSize_ApertureSize_k_BorderType, cornerHarris, ) ) { - String filename = getDataPath(get<0>(GetParam())); + string filename = getDataPath(get<0>(GetParam())); int blockSize = get<1>(GetParam()); int apertureSize = get<2>(GetParam()); double k = get<3>(GetParam()); diff --git a/modules/imgproc/perf/perf_filter2d.cpp b/modules/imgproc/perf/perf_filter2d.cpp index 297b524f9..5bdd47017 100644 --- a/modules/imgproc/perf/perf_filter2d.cpp +++ b/modules/imgproc/perf/perf_filter2d.cpp @@ -11,7 +11,7 @@ using std::tr1::get; CV_ENUM(BorderMode, BORDER_CONSTANT, BORDER_REPLICATE, BORDER_REFLECT_101); typedef TestBaseWithParam< tr1::tuple > TestFilter2d; -typedef TestBaseWithParam< tr1::tuple > Image_KernelSize; +typedef TestBaseWithParam< tr1::tuple > Image_KernelSize; PERF_TEST_P( TestFilter2d, Filter2d, Combine( @@ -48,7 +48,7 @@ PERF_TEST_P( Image_KernelSize, GaborFilter2d, Values(16, 32, 64) ) ) { - String fileName = getDataPath(get<0>(GetParam())); + string fileName = getDataPath(get<0>(GetParam())); Mat sourceImage = imread(fileName, IMREAD_GRAYSCALE); if( sourceImage.empty() ) { diff --git a/modules/imgproc/perf/perf_goodFeaturesToTrack.cpp b/modules/imgproc/perf/perf_goodFeaturesToTrack.cpp index 8177d6bb3..558734c4d 100644 --- a/modules/imgproc/perf/perf_goodFeaturesToTrack.cpp +++ b/modules/imgproc/perf/perf_goodFeaturesToTrack.cpp @@ -6,7 +6,7 @@ using namespace perf; using std::tr1::make_tuple; using std::tr1::get; -typedef std::tr1::tuple Image_MaxCorners_QualityLevel_MinDistance_BlockSize_UseHarris_t; +typedef std::tr1::tuple Image_MaxCorners_QualityLevel_MinDistance_BlockSize_UseHarris_t; typedef perf::TestBaseWithParam Image_MaxCorners_QualityLevel_MinDistance_BlockSize_UseHarris; PERF_TEST_P(Image_MaxCorners_QualityLevel_MinDistance_BlockSize_UseHarris, goodFeaturesToTrack, @@ -19,7 +19,7 @@ PERF_TEST_P(Image_MaxCorners_QualityLevel_MinDistance_BlockSize_UseHarris, goodF ) ) { - String filename = getDataPath(get<0>(GetParam())); + string filename = getDataPath(get<0>(GetParam())); int maxCorners = get<1>(GetParam()); double qualityLevel = get<2>(GetParam()); int blockSize = get<3>(GetParam()); diff --git a/modules/imgproc/perf/perf_houghLines.cpp b/modules/imgproc/perf/perf_houghLines.cpp index aee9d87d9..2b3c36cb2 100644 --- a/modules/imgproc/perf/perf_houghLines.cpp +++ b/modules/imgproc/perf/perf_houghLines.cpp @@ -8,7 +8,7 @@ using namespace perf; using std::tr1::make_tuple; using std::tr1::get; -typedef std::tr1::tuple Image_RhoStep_ThetaStep_Threshold_t; +typedef std::tr1::tuple Image_RhoStep_ThetaStep_Threshold_t; typedef perf::TestBaseWithParam Image_RhoStep_ThetaStep_Threshold; PERF_TEST_P(Image_RhoStep_ThetaStep_Threshold, HoughLines, @@ -20,7 +20,7 @@ PERF_TEST_P(Image_RhoStep_ThetaStep_Threshold, HoughLines, ) ) { - String filename = getDataPath(get<0>(GetParam())); + string filename = getDataPath(get<0>(GetParam())); double rhoStep = get<1>(GetParam()); double thetaStep = get<2>(GetParam()); int threshold = get<3>(GetParam()); diff --git a/modules/imgproc/src/color.cpp b/modules/imgproc/src/color.cpp index 934d19096..fedda05f8 100644 --- a/modules/imgproc/src/color.cpp +++ b/modules/imgproc/src/color.cpp @@ -1256,8 +1256,8 @@ static void initLabTabs() for(i = 0; i <= GAMMA_TAB_SIZE; i++) { float x = i*scale; - g[i] = x <= 0.04045f ? x*(1.f/12.92f) : (float)pow((double)(x + 0.055)*(1./1.055), 2.4); - ig[i] = x <= 0.0031308 ? x*12.92f : (float)(1.055*pow((double)x, 1./2.4) - 0.055); + g[i] = x <= 0.04045f ? x*(1.f/12.92f) : (float)std::pow((double)(x + 0.055)*(1./1.055), 2.4); + ig[i] = x <= 0.0031308 ? x*12.92f : (float)(1.055*std::pow((double)x, 1./2.4) - 0.055); } splineBuild(g, GAMMA_TAB_SIZE, sRGBGammaTab); splineBuild(ig, GAMMA_TAB_SIZE, sRGBInvGammaTab); @@ -1265,7 +1265,7 @@ static void initLabTabs() for(i = 0; i < 256; i++) { float x = i*(1.f/255.f); - sRGBGammaTab_b[i] = saturate_cast(255.f*(1 << gamma_shift)*(x <= 0.04045f ? x*(1.f/12.92f) : (float)pow((double)(x + 0.055)*(1./1.055), 2.4))); + sRGBGammaTab_b[i] = saturate_cast(255.f*(1 << gamma_shift)*(x <= 0.04045f ? x*(1.f/12.92f) : (float)std::pow((double)(x + 0.055)*(1./1.055), 2.4))); linearGammaTab_b[i] = (ushort)(i*(1 << gamma_shift)); } @@ -1408,9 +1408,9 @@ struct RGB2Lab_f float Y = R*C3 + G*C4 + B*C5; float Z = R*C6 + G*C7 + B*C8; - float FX = X > 0.008856f ? pow(X, _1_3) : (7.787f * X + _a); - float FY = Y > 0.008856f ? pow(Y, _1_3) : (7.787f * Y + _a); - float FZ = Z > 0.008856f ? pow(Z, _1_3) : (7.787f * Z + _a); + float FX = X > 0.008856f ? std::pow(X, _1_3) : (7.787f * X + _a); + float FY = Y > 0.008856f ? std::pow(Y, _1_3) : (7.787f * Y + _a); + float FZ = Z > 0.008856f ? std::pow(Z, _1_3) : (7.787f * Z + _a); float L = Y > 0.008856f ? (116.f * FY - 16.f) : (903.3f * Y); float a = 500.f * (FX - FY); diff --git a/modules/imgproc/src/convhull.cpp b/modules/imgproc/src/convhull.cpp index 1fcff3fb4..7fad264e7 100644 --- a/modules/imgproc/src/convhull.cpp +++ b/modules/imgproc/src/convhull.cpp @@ -113,7 +113,7 @@ static int Sklansky_( Point_<_Tp>** array, int start, int end, int* stack, int n stack[stacksize-1] = pnext; } } - + return --stacksize; } @@ -210,7 +210,7 @@ void convexHull( InputArray _points, OutputArray _hull, bool clockwise, bool ret for( i = tr_count - 1; i > 0; i-- ) hullbuf[nout++] = pointer[tr_stack[i]] - data0; int stop_idx = tr_count > 2 ? tr_stack[1] : tl_count > 2 ? tl_stack[tl_count - 2] : -1; - + // lower half int *bl_stack = stack; int bl_count = !is_float ? @@ -280,7 +280,7 @@ void convexityDefects( InputArray _points, InputArray _hull, OutputArray _defect const Point* ptr = (const Point*)points.data; const int* hptr = hull.ptr(); - vector defects; + std::vector defects; // 1. recognize co-orientation of the contour and its hull bool rev_orientation = ((hptr[1] > hptr[0]) + (hptr[2] > hptr[1]) + (hptr[0] > hptr[2])) != 2; @@ -297,7 +297,7 @@ void convexityDefects( InputArray _points, InputArray _hull, OutputArray _defect Point pt0 = ptr[hcurr], pt1 = ptr[hnext]; double dx0 = pt1.x - pt0.x; double dy0 = pt1.y - pt0.y; - double scale = dx0 == 0 && dy0 == 0 ? 0. : 1./sqrt(dx0*dx0 + dy0*dy0); + double scale = dx0 == 0 && dy0 == 0 ? 0. : 1./std::sqrt(dx0*dx0 + dy0*dy0); int defect_deepest_point = -1; double defect_depth = 0; @@ -380,10 +380,10 @@ bool isContourConvex( InputArray _contour ) Mat contour = _contour.getMat(); int total = contour.checkVector(2), depth = contour.depth(); CV_Assert(total >= 0 && (depth == CV_32F || depth == CV_32S)); - + if( total == 0 ) return false; - + return depth == CV_32S ? isContourConvex_((const Point*)contour.data, total ) : isContourConvex_((const Point2f*)contour.data, total ); @@ -502,7 +502,7 @@ cvConvexHull2( const CvArr* array, void* hull_storage, ptseq->header_size < (int)sizeof(CvContour) || &ptseq->flags == &contour_header.flags ); } - + return hull.s; } @@ -658,7 +658,7 @@ CV_IMPL CvSeq* cvConvexityDefects( const CvArr* array, dx0 = (double)hull_next->x - (double)hull_cur->x; dy0 = (double)hull_next->y - (double)hull_cur->y; assert( dx0 != 0 || dy0 != 0 ); - scale = 1./sqrt(dx0*dx0 + dy0*dy0); + scale = 1./std::sqrt(dx0*dx0 + dy0*dy0); defect.start = hull_cur; defect.end = hull_next; diff --git a/modules/imgproc/src/deriv.cpp b/modules/imgproc/src/deriv.cpp index 8950b6186..4383c12fb 100644 --- a/modules/imgproc/src/deriv.cpp +++ b/modules/imgproc/src/deriv.cpp @@ -100,7 +100,7 @@ static void getSobelKernels( OutputArray _kx, OutputArray _ky, if( _ksize % 2 == 0 || _ksize > 31 ) CV_Error( CV_StsOutOfRange, "The kernel size must be odd and not larger than 31" ); - vector kerI(std::max(ksizeX, ksizeY) + 1); + std::vector kerI(std::max(ksizeX, ksizeY) + 1); CV_Assert( dx >= 0 && dy >= 0 && dx+dy > 0 ); diff --git a/modules/imgproc/src/featureselect.cpp b/modules/imgproc/src/featureselect.cpp index 827fd409c..bcb9bd709 100644 --- a/modules/imgproc/src/featureselect.cpp +++ b/modules/imgproc/src/featureselect.cpp @@ -75,7 +75,7 @@ void cv::goodFeaturesToTrack( InputArray _image, OutputArray _corners, Size imgsize = image.size(); - vector tmpCorners; + std::vector tmpCorners; // collect list of pointers to features - put them into temporary image for( int y = 1; y < imgsize.height - 1; y++ ) @@ -93,7 +93,7 @@ void cv::goodFeaturesToTrack( InputArray _image, OutputArray _corners, } sort( tmpCorners, greaterThanPtr() ); - vector corners; + std::vector corners; size_t i, j, total = tmpCorners.size(), ncorners = 0; if(minDistance >= 1) @@ -136,7 +136,7 @@ void cv::goodFeaturesToTrack( InputArray _image, OutputArray _corners, { for( int xx = x1; xx <= x2; xx++ ) { - vector &m = grid[yy*grid_width + xx]; + std::vector &m = grid[yy*grid_width + xx]; if( m.size() ) { @@ -224,7 +224,7 @@ cvGoodFeaturesToTrack( const void* _image, void*, void*, int use_harris, double harris_k ) { cv::Mat image = cv::cvarrToMat(_image), mask; - cv::vector corners; + std::vector corners; if( _maskImage ) mask = cv::cvarrToMat(_maskImage); diff --git a/modules/imgproc/src/filter.cpp b/modules/imgproc/src/filter.cpp index a2bfa6a4b..bef3fe29f 100644 --- a/modules/imgproc/src/filter.cpp +++ b/modules/imgproc/src/filter.cpp @@ -1954,7 +1954,7 @@ struct FilterVec_8u Mat kernel; _kernel.convertTo(kernel, CV_32F, 1./(1 << _bits), 0); delta = (float)(_delta/(1 << _bits)); - vector coords; + std::vector coords; preprocess2DKernel(kernel, coords, coeffs); _nz = (int)coords.size(); } @@ -2024,7 +2024,7 @@ struct FilterVec_8u } int _nz; - vector coeffs; + std::vector coeffs; float delta; }; @@ -2037,7 +2037,7 @@ struct FilterVec_8u16s Mat kernel; _kernel.convertTo(kernel, CV_32F, 1./(1 << _bits), 0); delta = (float)(_delta/(1 << _bits)); - vector coords; + std::vector coords; preprocess2DKernel(kernel, coords, coeffs); _nz = (int)coords.size(); } @@ -2107,7 +2107,7 @@ struct FilterVec_8u16s } int _nz; - vector coeffs; + std::vector coeffs; float delta; }; @@ -2118,7 +2118,7 @@ struct FilterVec_32f FilterVec_32f(const Mat& _kernel, int, double _delta) { delta = (float)_delta; - vector coords; + std::vector coords; preprocess2DKernel(_kernel, coords, coeffs); _nz = (int)coords.size(); } @@ -2179,7 +2179,7 @@ struct FilterVec_32f } int _nz; - vector coeffs; + std::vector coeffs; float delta; }; @@ -2989,7 +2989,7 @@ cv::Ptr cv::createSeparableLinearFilter( namespace cv { -void preprocess2DKernel( const Mat& kernel, vector& coords, vector& coeffs ) +void preprocess2DKernel( const Mat& kernel, std::vector& coords, std::vector& coeffs ) { int i, j, k, nz = countNonZero(kernel), ktype = kernel.type(); if(nz == 0) @@ -3107,9 +3107,9 @@ template struct Filter2D : public BaseFi } } - vector coords; - vector coeffs; - vector ptrs; + std::vector coords; + std::vector coeffs; + std::vector ptrs; KT delta; CastOp castOp0; VecOp vecOp; diff --git a/modules/imgproc/src/floodfill.cpp b/modules/imgproc/src/floodfill.cpp index e4e64b9d1..54a58513e 100644 --- a/modules/imgproc/src/floodfill.cpp +++ b/modules/imgproc/src/floodfill.cpp @@ -457,7 +457,7 @@ int cv::floodFill( InputOutputArray _image, InputOutputArray _mask, Scalar loDiff, Scalar upDiff, int flags ) { ConnectedComp comp; - vector buffer; + std::vector buffer; if( rect ) *rect = Rect(); diff --git a/modules/imgproc/src/gabor.cpp b/modules/imgproc/src/gabor.cpp index 567ed8f2f..0f2da7f2c 100644 --- a/modules/imgproc/src/gabor.cpp +++ b/modules/imgproc/src/gabor.cpp @@ -84,7 +84,7 @@ cv::Mat cv::getGaborKernel( Size ksize, double sigma, double theta, double xr = x*c + y*s; double yr = -x*s + y*c; - double v = scale*exp(ex*xr*xr + ey*yr*yr)*cos(cscale*xr + psi); + double v = scale*std::exp(ex*xr*xr + ey*yr*yr)*cos(cscale*xr + psi); if( ktype == CV_32F ) kernel.at(ymax - y, xmax - x) = (float)v; else diff --git a/modules/imgproc/src/generalized_hough.cpp b/modules/imgproc/src/generalized_hough.cpp index 846a55fe9..ab0890ef8 100644 --- a/modules/imgproc/src/generalized_hough.cpp +++ b/modules/imgproc/src/generalized_hough.cpp @@ -42,7 +42,6 @@ #include "precomp.hpp" #include -using namespace std; using namespace cv; namespace @@ -50,9 +49,9 @@ namespace ///////////////////////////////////// // Common - template void releaseVector(vector& v) + template void releaseVector(std::vector& v) { - vector empty; + std::vector empty; empty.swap(v); } @@ -63,7 +62,7 @@ namespace bool notNull(float v) { - return fabs(v) > numeric_limits::epsilon(); + return fabs(v) > std::numeric_limits::epsilon(); } class GHT_Pos : public GeneralizedHough @@ -95,8 +94,8 @@ namespace Mat imageDx; Mat imageDy; - vector posOutBuf; - vector voteOutBuf; + std::vector posOutBuf; + std::vector voteOutBuf; }; GHT_Pos::GHT_Pos() @@ -168,10 +167,10 @@ namespace CV_Assert(!hasVotes || voteOutBuf.size() == oldSize); - vector oldPosBuf(posOutBuf); - vector oldVoteBuf(voteOutBuf); + std::vector oldPosBuf(posOutBuf); + std::vector oldVoteBuf(voteOutBuf); - vector indexies(oldSize); + std::vector indexies(oldSize); for (size_t i = 0; i < oldSize; ++i) indexies[i] = i; sortIndexies(&indexies[0], oldSize, &oldVoteBuf[0]); @@ -183,7 +182,7 @@ namespace const int gridWidth = (imageSize.width + cellSize - 1) / cellSize; const int gridHeight = (imageSize.height + cellSize - 1) / cellSize; - vector< vector > grid(gridWidth * gridHeight); + std::vector< std::vector > grid(gridWidth * gridHeight); const double minDist2 = minDist * minDist; @@ -213,7 +212,7 @@ namespace { for (int xx = x1; xx <= x2; ++xx) { - const vector& m = grid[yy * gridWidth + xx]; + const std::vector& m = grid[yy * gridWidth + xx]; for(size_t j = 0; j < m.size(); ++j) { @@ -288,7 +287,7 @@ namespace int votesThreshold; double dp; - vector< vector > r_table; + std::vector< std::vector > r_table; Mat hist; }; @@ -327,7 +326,7 @@ namespace const double thetaScale = levels / 360.0; r_table.resize(levels + 1); - for_each(r_table.begin(), r_table.end(), mem_fun_ref(&vector::clear)); + for_each(r_table.begin(), r_table.end(), mem_fun_ref(&std::vector::clear)); for (int y = 0; y < templSize.height; ++y) { @@ -387,7 +386,7 @@ namespace const float theta = fastAtan2(dyRow[x], dxRow[x]); const int n = cvRound(theta * thetaScale); - const vector& r_row = r_table[n]; + const std::vector& r_row = r_table[n]; for (size_t j = 0; j < r_row.size(); ++j) { @@ -512,7 +511,7 @@ namespace const float theta = fastAtan2(dyRow[x], dxRow[x]); const int n = cvRound(theta * thetaScale); - const vector& r_row = base->r_table[n]; + const std::vector& r_row = base->r_table[n]; for (size_t j = 0; j < r_row.size(); ++j) { @@ -682,7 +681,7 @@ namespace theta += 360.0; const int n = cvRound(theta * thetaScale); - const vector& r_row = base->r_table[n]; + const std::vector& r_row = base->r_table[n]; for (size_t j = 0; j < r_row.size(); ++j) { @@ -816,8 +815,8 @@ namespace Point2d r2; }; - void buildFeatureList(const Mat& edges, const Mat& dx, const Mat& dy, vector< vector >& features, Point2d center = Point2d()); - void getContourPoints(const Mat& edges, const Mat& dx, const Mat& dy, vector& points); + void buildFeatureList(const Mat& edges, const Mat& dx, const Mat& dy, std::vector< std::vector >& features, Point2d center = Point2d()); + void getContourPoints(const Mat& edges, const Mat& dx, const Mat& dy, std::vector& points); void calcOrientation(); void calcScale(double angle); @@ -841,11 +840,11 @@ namespace double dp; int posThresh; - vector< vector > templFeatures; - vector< vector > imageFeatures; + std::vector< std::vector > templFeatures; + std::vector< std::vector > imageFeatures; - vector< pair > angles; - vector< pair > scales; + std::vector< std::pair > angles; + std::vector< std::pair > scales; }; CV_INIT_ALGORITHM(GHT_Guil_Full, "GeneralizedHough.POSITION_SCALE_ROTATION", @@ -940,7 +939,7 @@ namespace } } - void GHT_Guil_Full::buildFeatureList(const Mat& edges, const Mat& dx, const Mat& dy, vector< vector >& features, Point2d center) + void GHT_Guil_Full::buildFeatureList(const Mat& edges, const Mat& dx, const Mat& dy, std::vector< std::vector >& features, Point2d center) { CV_Assert(levels > 0); @@ -948,12 +947,12 @@ namespace const double alphaScale = levels / 360.0; - vector points; + std::vector points; getContourPoints(edges, dx, dy, points); features.resize(levels + 1); - for_each(features.begin(), features.end(), mem_fun_ref(&vector::clear)); - for_each(features.begin(), features.end(), bind2nd(mem_fun_ref(&vector::reserve), maxSize)); + for_each(features.begin(), features.end(), mem_fun_ref(&std::vector::clear)); + for_each(features.begin(), features.end(), bind2nd(mem_fun_ref(&std::vector::reserve), maxSize)); for (size_t i = 0; i < points.size(); ++i) { @@ -990,7 +989,7 @@ namespace } } - void GHT_Guil_Full::getContourPoints(const Mat& edges, const Mat& dx, const Mat& dy, vector& points) + void GHT_Guil_Full::getContourPoints(const Mat& edges, const Mat& dx, const Mat& dy, std::vector& points) { CV_Assert(edges.type() == CV_8UC1); CV_Assert(dx.type() == CV_32FC1 && dx.size == edges.size); @@ -1032,11 +1031,11 @@ namespace const double iAngleStep = 1.0 / angleStep; const int angleRange = cvCeil((maxAngle - minAngle) * iAngleStep); - vector OHist(angleRange + 1, 0); + std::vector OHist(angleRange + 1, 0); for (int i = 0; i <= levels; ++i) { - const vector& templRow = templFeatures[i]; - const vector& imageRow = imageFeatures[i]; + const std::vector& templRow = templFeatures[i]; + const std::vector& imageRow = imageFeatures[i]; for (size_t j = 0; j < templRow.size(); ++j) { @@ -1063,7 +1062,7 @@ namespace if (OHist[n] >= angleThresh) { const double angle = minAngle + n * angleStep; - angles.push_back(make_pair(angle, OHist[n])); + angles.push_back(std::make_pair(angle, OHist[n])); } } } @@ -1080,12 +1079,12 @@ namespace const double iScaleStep = 1.0 / scaleStep; const int scaleRange = cvCeil((maxScale - minScale) * iScaleStep); - vector SHist(scaleRange + 1, 0); + std::vector SHist(scaleRange + 1, 0); for (int i = 0; i <= levels; ++i) { - const vector& templRow = templFeatures[i]; - const vector& imageRow = imageFeatures[i]; + const std::vector& templRow = templFeatures[i]; + const std::vector& imageRow = imageFeatures[i]; for (size_t j = 0; j < templRow.size(); ++j) { @@ -1117,7 +1116,7 @@ namespace if (SHist[s] >= scaleThresh) { const double scale = minScale + s * scaleStep; - scales.push_back(make_pair(scale, SHist[s])); + scales.push_back(std::make_pair(scale, SHist[s])); } } } @@ -1141,8 +1140,8 @@ namespace for (int i = 0; i <= levels; ++i) { - const vector& templRow = templFeatures[i]; - const vector& imageRow = imageFeatures[i]; + const std::vector& templRow = templFeatures[i]; + const std::vector& imageRow = imageFeatures[i]; for (size_t j = 0; j < templRow.size(); ++j) { diff --git a/modules/imgproc/src/geometry.cpp b/modules/imgproc/src/geometry.cpp index e0eb22971..5c529e5b5 100644 --- a/modules/imgproc/src/geometry.cpp +++ b/modules/imgproc/src/geometry.cpp @@ -231,13 +231,13 @@ double cv::pointPolygonTest( InputArray _contour, Point2f pt, bool measureDist ) dist_num = -dist_num; counter += dist_num > 0; } - - result = sqrt(min_dist_num/min_dist_denom); + + result = std::sqrt(min_dist_num/min_dist_denom); if( counter % 2 == 0 ) result = -result; } } - + return result; } diff --git a/modules/imgproc/src/grabcut.cpp b/modules/imgproc/src/grabcut.cpp index 943d42efe..c0967a1dc 100644 --- a/modules/imgproc/src/grabcut.cpp +++ b/modules/imgproc/src/grabcut.cpp @@ -347,10 +347,10 @@ static void initMaskWithRect( Mat& mask, Size imgSize, Rect rect ) mask.create( imgSize, CV_8UC1 ); mask.setTo( GC_BGD ); - rect.x = max(0, rect.x); - rect.y = max(0, rect.y); - rect.width = min(rect.width, imgSize.width-rect.x); - rect.height = min(rect.height, imgSize.height-rect.y); + rect.x = std::max(0, rect.x); + rect.y = std::max(0, rect.y); + rect.width = std::min(rect.width, imgSize.width-rect.x); + rect.height = std::min(rect.height, imgSize.height-rect.y); (mask(rect)).setTo( Scalar(GC_PR_FGD) ); } @@ -364,7 +364,7 @@ static void initGMMs( const Mat& img, const Mat& mask, GMM& bgdGMM, GMM& fgdGMM const int kMeansType = KMEANS_PP_CENTERS; Mat bgdLabels, fgdLabels; - vector bgdSamples, fgdSamples; + std::vector bgdSamples, fgdSamples; Point p; for( p.y = 0; p.y < img.rows; p.y++ ) { diff --git a/modules/imgproc/src/histogram.cpp b/modules/imgproc/src/histogram.cpp index 61509d344..8b8f05cd7 100644 --- a/modules/imgproc/src/histogram.cpp +++ b/modules/imgproc/src/histogram.cpp @@ -54,7 +54,7 @@ static const size_t OUT_OF_RANGE = (size_t)1 << (sizeof(size_t)*8 - 2); static void calcHistLookupTables_8u( const Mat& hist, const SparseMat& shist, int dims, const float** ranges, const double* uniranges, - bool uniform, bool issparse, vector& _tab ) + bool uniform, bool issparse, std::vector& _tab ) { const int low = 0, high = 256; int i, j; @@ -117,8 +117,8 @@ calcHistLookupTables_8u( const Mat& hist, const SparseMat& shist, static void histPrepareImages( const Mat* images, int nimages, const int* channels, const Mat& mask, int dims, const int* histSize, const float** ranges, bool uniform, - vector& ptrs, vector& deltas, - Size& imsize, vector& uniranges ) + std::vector& ptrs, std::vector& deltas, + Size& imsize, std::vector& uniranges ) { int i, j, c; CV_Assert( channels != 0 || nimages == dims ); @@ -216,7 +216,7 @@ template class calcHist1D_Invoker { public: - calcHist1D_Invoker( const vector& _ptrs, const vector& _deltas, + calcHist1D_Invoker( const std::vector& _ptrs, const std::vector& _deltas, Mat& hist, const double* _uniranges, int sz, int dims, Size& imageSize ) : mask_(_ptrs[dims]), @@ -288,7 +288,7 @@ template class calcHist2D_Invoker { public: - calcHist2D_Invoker( const vector& _ptrs, const vector& _deltas, + calcHist2D_Invoker( const std::vector& _ptrs, const std::vector& _deltas, Mat& hist, const double* _uniranges, const int* size, int dims, Size& imageSize, size_t* hstep ) : mask_(_ptrs[dims]), @@ -362,7 +362,7 @@ template class calcHist3D_Invoker { public: - calcHist3D_Invoker( const vector& _ptrs, const vector& _deltas, + calcHist3D_Invoker( const std::vector& _ptrs, const std::vector& _deltas, Size imsize, Mat& hist, const double* uniranges, int _dims, size_t* hstep, int* size ) : mask_(_ptrs[_dims]), @@ -448,8 +448,8 @@ private: class CalcHist1D_8uInvoker { public: - CalcHist1D_8uInvoker( const vector& ptrs, const vector& deltas, - Size imsize, Mat& hist, int dims, const vector& tab, + CalcHist1D_8uInvoker( const std::vector& ptrs, const std::vector& deltas, + Size imsize, Mat& hist, int dims, const std::vector& tab, tbb::mutex* lock ) : mask_(ptrs[dims]), mstep_(deltas[dims*2 + 1]), @@ -569,8 +569,8 @@ private: class CalcHist2D_8uInvoker { public: - CalcHist2D_8uInvoker( const vector& _ptrs, const vector& _deltas, - Size imsize, Mat& hist, int dims, const vector& _tab, + CalcHist2D_8uInvoker( const std::vector& _ptrs, const std::vector& _deltas, + Size imsize, Mat& hist, int dims, const std::vector& _tab, tbb::mutex* lock ) : mask_(_ptrs[dims]), mstep_(_deltas[dims*2 + 1]), @@ -654,8 +654,8 @@ private: class CalcHist3D_8uInvoker { public: - CalcHist3D_8uInvoker( const vector& _ptrs, const vector& _deltas, - Size imsize, Mat& hist, int dims, const vector& tab ) + CalcHist3D_8uInvoker( const std::vector& _ptrs, const std::vector& _deltas, + Size imsize, Mat& hist, int dims, const std::vector& tab ) : mask_(_ptrs[dims]), mstep_(_deltas[dims*2 + 1]), histogramSize_(hist.size.p), histogramType_(hist.type()), @@ -723,8 +723,8 @@ private: }; static void -callCalcHist2D_8u( vector& _ptrs, const vector& _deltas, - Size imsize, Mat& hist, int dims, vector& _tab ) +callCalcHist2D_8u( std::vector& _ptrs, const std::vector& _deltas, + Size imsize, Mat& hist, int dims, std::vector& _tab ) { int grainSize = imsize.height / tbb::task_scheduler_init::default_num_threads(); tbb::mutex histogramWriteLock; @@ -734,8 +734,8 @@ callCalcHist2D_8u( vector& _ptrs, const vector& _deltas, } static void -callCalcHist3D_8u( vector& _ptrs, const vector& _deltas, - Size imsize, Mat& hist, int dims, vector& _tab ) +callCalcHist3D_8u( std::vector& _ptrs, const std::vector& _deltas, + Size imsize, Mat& hist, int dims, std::vector& _tab ) { CalcHist3D_8uInvoker body(_ptrs, _deltas, imsize, hist, dims, _tab); parallel_for(BlockedRange(0, imsize.height), body); @@ -743,7 +743,7 @@ callCalcHist3D_8u( vector& _ptrs, const vector& _deltas, #endif template static void -calcHist_( vector& _ptrs, const vector& _deltas, +calcHist_( std::vector& _ptrs, const std::vector& _deltas, Size imsize, Mat& hist, int dims, const float** _ranges, const double* _uniranges, bool uniform ) { @@ -976,7 +976,7 @@ calcHist_( vector& _ptrs, const vector& _deltas, static void -calcHist_8u( vector& _ptrs, const vector& _deltas, +calcHist_8u( std::vector& _ptrs, const std::vector& _deltas, Size imsize, Mat& hist, int dims, const float** _ranges, const double* _uniranges, bool uniform ) { @@ -986,7 +986,7 @@ calcHist_8u( vector& _ptrs, const vector& _deltas, int x; const uchar* mask = _ptrs[dims]; int mstep = _deltas[dims*2 + 1]; - vector _tab; + std::vector _tab; calcHistLookupTables_8u( hist, SparseMat(), dims, _ranges, _uniranges, uniform, false, _tab ); const size_t* tab = &_tab[0]; @@ -1189,9 +1189,9 @@ void cv::calcHist( const Mat* images, int nimages, const int* channels, else hist.convertTo(ihist, CV_32S); - vector ptrs; - vector deltas; - vector uniranges; + std::vector ptrs; + std::vector deltas; + std::vector uniranges; Size imsize; CV_Assert( !mask.data || mask.type() == CV_8UC1 ); @@ -1218,7 +1218,7 @@ namespace cv { template static void -calcSparseHist_( vector& _ptrs, const vector& _deltas, +calcSparseHist_( std::vector& _ptrs, const std::vector& _deltas, Size imsize, SparseMat& hist, int dims, const float** _ranges, const double* _uniranges, bool uniform ) { @@ -1302,7 +1302,7 @@ calcSparseHist_( vector& _ptrs, const vector& _deltas, static void -calcSparseHist_8u( vector& _ptrs, const vector& _deltas, +calcSparseHist_8u( std::vector& _ptrs, const std::vector& _deltas, Size imsize, SparseMat& hist, int dims, const float** _ranges, const double* _uniranges, bool uniform ) { @@ -1312,7 +1312,7 @@ calcSparseHist_8u( vector& _ptrs, const vector& _deltas, const uchar* mask = _ptrs[dims]; int mstep = _deltas[dims*2 + 1]; int idx[CV_MAX_DIM]; - vector _tab; + std::vector _tab; calcHistLookupTables_8u( Mat(), hist, dims, _ranges, _uniranges, uniform, true, _tab ); const size_t* tab = &_tab[0]; @@ -1362,9 +1362,9 @@ static void calcHist( const Mat* images, int nimages, const int* channels, } } - vector ptrs; - vector deltas; - vector uniranges; + std::vector ptrs; + std::vector deltas; + std::vector uniranges; Size imsize; CV_Assert( !mask.data || mask.type() == CV_8UC1 ); @@ -1405,10 +1405,10 @@ void cv::calcHist( const Mat* images, int nimages, const int* channels, } -void cv::calcHist( InputArrayOfArrays images, const vector& channels, +void cv::calcHist( InputArrayOfArrays images, const std::vector& channels, InputArray mask, OutputArray hist, - const vector& histSize, - const vector& ranges, + const std::vector& histSize, + const std::vector& ranges, bool accumulate ) { int i, dims = (int)histSize.size(), rsz = (int)ranges.size(), csz = (int)channels.size(); @@ -1440,7 +1440,7 @@ namespace cv { template static void -calcBackProj_( vector& _ptrs, const vector& _deltas, +calcBackProj_( std::vector& _ptrs, const std::vector& _deltas, Size imsize, const Mat& hist, int dims, const float** _ranges, const double* _uniranges, float scale, bool uniform ) { @@ -1605,7 +1605,7 @@ calcBackProj_( vector& _ptrs, const vector& _deltas, static void -calcBackProj_8u( vector& _ptrs, const vector& _deltas, +calcBackProj_8u( std::vector& _ptrs, const std::vector& _deltas, Size imsize, const Mat& hist, int dims, const float** _ranges, const double* _uniranges, float scale, bool uniform ) { @@ -1615,7 +1615,7 @@ calcBackProj_8u( vector& _ptrs, const vector& _deltas, int i, x; uchar* bproj = _ptrs[dims]; int bpstep = _deltas[dims*2 + 1]; - vector _tab; + std::vector _tab; calcHistLookupTables_8u( hist, SparseMat(), dims, _ranges, _uniranges, uniform, false, _tab ); const size_t* tab = &_tab[0]; @@ -1733,9 +1733,9 @@ void cv::calcBackProject( const Mat* images, int nimages, const int* channels, const float** ranges, double scale, bool uniform ) { Mat hist = _hist.getMat(); - vector ptrs; - vector deltas; - vector uniranges; + std::vector ptrs; + std::vector deltas; + std::vector uniranges; Size imsize; int dims = hist.dims == 2 && hist.size[1] == 1 ? 1 : hist.dims; @@ -1762,7 +1762,7 @@ namespace cv { template static void -calcSparseBackProj_( vector& _ptrs, const vector& _deltas, +calcSparseBackProj_( std::vector& _ptrs, const std::vector& _deltas, Size imsize, const SparseMat& hist, int dims, const float** _ranges, const double* _uniranges, float scale, bool uniform ) { @@ -1847,7 +1847,7 @@ calcSparseBackProj_( vector& _ptrs, const vector& _deltas, static void -calcSparseBackProj_8u( vector& _ptrs, const vector& _deltas, +calcSparseBackProj_8u( std::vector& _ptrs, const std::vector& _deltas, Size imsize, const SparseMat& hist, int dims, const float** _ranges, const double* _uniranges, float scale, bool uniform ) { @@ -1856,7 +1856,7 @@ calcSparseBackProj_8u( vector& _ptrs, const vector& _deltas, int i, x; uchar* bproj = _ptrs[dims]; int bpstep = _deltas[dims*2 + 1]; - vector _tab; + std::vector _tab; int idx[CV_MAX_DIM]; calcHistLookupTables_8u( Mat(), hist, dims, _ranges, _uniranges, uniform, true, _tab ); @@ -1895,9 +1895,9 @@ void cv::calcBackProject( const Mat* images, int nimages, const int* channels, const SparseMat& hist, OutputArray _backProject, const float** ranges, double scale, bool uniform ) { - vector ptrs; - vector deltas; - vector uniranges; + std::vector ptrs; + std::vector deltas; + std::vector uniranges; Size imsize; int dims = hist.dims(); @@ -1924,9 +1924,9 @@ void cv::calcBackProject( const Mat* images, int nimages, const int* channels, } -void cv::calcBackProject( InputArrayOfArrays images, const vector& channels, +void cv::calcBackProject( InputArrayOfArrays images, const std::vector& channels, InputArray hist, OutputArray dst, - const vector& ranges, + const std::vector& ranges, double scale ) { Mat H0 = hist.getMat(), H; @@ -2734,7 +2734,7 @@ cvCalcArrHist( CvArr** img, CvHistogram* hist, int accumulate, const CvArr* mask int i, dims = cvGetDims( hist->bins, size); bool uniform = CV_IS_UNIFORM_HIST(hist); - cv::vector images(dims); + std::vector images(dims); for( i = 0; i < dims; i++ ) images[i] = cv::cvarrToMat(img[i]); @@ -2810,7 +2810,7 @@ cvCalcArrBackProject( CvArr** img, CvArr* dst, const CvHistogram* hist ) } } - cv::vector images(dims); + std::vector images(dims); for( i = 0; i < dims; i++ ) images[i] = cv::cvarrToMat(img[i]); diff --git a/modules/imgproc/src/hough.cpp b/modules/imgproc/src/hough.cpp index b5b67ad6e..42901c243 100644 --- a/modules/imgproc/src/hough.cpp +++ b/modules/imgproc/src/hough.cpp @@ -60,7 +60,7 @@ struct hough_cmp_gt const int* aux; }; - + /* Here image is an input raster; step is it's step; size characterizes it's ROI; @@ -72,7 +72,7 @@ Functions return the actual number of found lines. */ static void HoughLinesStandard( const Mat& img, float rho, float theta, - int threshold, vector& lines, int linesMax ) + int threshold, std::vector& lines, int linesMax ) { int i, j; float irho = 1 / rho; @@ -88,7 +88,7 @@ HoughLinesStandard( const Mat& img, float rho, float theta, int numrho = cvRound(((width + height) * 2 + 1) / rho); AutoBuffer _accum((numangle+2) * (numrho+2)); - vector _sort_buf; + std::vector _sort_buf; AutoBuffer _tabSin(numangle); AutoBuffer _tabCos(numangle); int *accum = _accum; @@ -131,7 +131,7 @@ HoughLinesStandard( const Mat& img, float rho, float theta, cv::sort(_sort_buf, hough_cmp_gt(accum)); // stage 4. store the first min(total,linesMax) lines to the output buffer - linesMax = min(linesMax, (int)_sort_buf.size()); + linesMax = std::min(linesMax, (int)_sort_buf.size()); double scale = 1./(numrho+2); for( i = 0; i < linesMax; i++ ) { @@ -153,17 +153,17 @@ struct hough_index hough_index() : value(0), rho(0.f), theta(0.f) {} hough_index(int _val, float _rho, float _theta) : value(_val), rho(_rho), theta(_theta) {} - + int value; float rho, theta; }; - + static void HoughLinesSDiv( const Mat& img, float rho, float theta, int threshold, int srn, int stn, - vector& lines, int linesMax ) + std::vector& lines, int linesMax ) { #define _POINT(row, column)\ (image_src[(row)*step+(column)]) @@ -183,7 +183,7 @@ HoughLinesSDiv( const Mat& img, int count; int cmax = 0; - vector lst; + std::vector lst; CV_Assert( img.type() == CV_8UC1 ); CV_Assert( linesMax > 0 && rho > 0 && theta > 0 ); @@ -202,19 +202,19 @@ HoughLinesSDiv( const Mat& img, float isrho = 1 / srho; float istheta = 1 / stheta; - int rn = cvFloor( sqrt( (double)w * w + (double)h * h ) * irho ); + int rn = cvFloor( std::sqrt( (double)w * w + (double)h * h ) * irho ); int tn = cvFloor( 2 * CV_PI * itheta ); lst.push_back(hough_index(threshold, -1.f, 0.f)); // Precalculate sin table - vector _sinTable( 5 * tn * stn ); + std::vector _sinTable( 5 * tn * stn ); float* sinTable = &_sinTable[0]; for( index = 0; index < 5 * tn * stn; index++ ) sinTable[index] = (float)cos( stheta * index * 0.2f ); - vector _caccum(rn * tn, (uchar)0); + std::vector _caccum(rn * tn, (uchar)0); uchar* caccum = &_caccum[0]; // Counting all feature pixels @@ -222,7 +222,7 @@ HoughLinesSDiv( const Mat& img, for( col = 0; col < w; col++ ) fn += _POINT( row, col ) != 0; - vector _x(fn), _y(fn); + std::vector _x(fn), _y(fn); int* x = &_x[0], *y = &_y[0]; // Full Hough Transform (it's accumulator update part) @@ -250,7 +250,7 @@ HoughLinesSDiv( const Mat& img, /* Update the accumulator */ t = (float) fabs( cvFastArctan( yc, xc ) * d2r ); - r = (float) sqrt( (double)xc * xc + (double)yc * yc ); + r = (float) std::sqrt( (double)xc * xc + (double)yc * yc ); r0 = r * irho; ti0 = cvFloor( (t + CV_PI*0.5) * itheta ); @@ -294,7 +294,7 @@ HoughLinesSDiv( const Mat& img, return; } - vector _buffer(srn * stn + 2); + std::vector _buffer(srn * stn + 2); uchar* buffer = &_buffer[0]; uchar* mcaccum = buffer + 1; @@ -318,7 +318,7 @@ HoughLinesSDiv( const Mat& img, // Update the accumulator t = (float) fabs( cvFastArctan( yc, xc ) * d2r ); - r = (float) sqrt( (double)xc * xc + (double)yc * yc ) * isrho; + r = (float) std::sqrt( (double)xc * xc + (double)yc * yc ) * isrho; ti0 = cvFloor( (t + CV_PI * 0.5) * istheta ); ti2 = (ti * stn - ti0) * 5; r0 = (float) ri *srn; @@ -379,7 +379,7 @@ static void HoughLinesProbabilistic( Mat& image, float rho, float theta, int threshold, int lineLength, int lineGap, - vector& lines, int linesMax ) + std::vector& lines, int linesMax ) { Point pt; float irho = 1 / rho; @@ -395,7 +395,7 @@ HoughLinesProbabilistic( Mat& image, Mat accum = Mat::zeros( numangle, numrho, CV_32SC1 ); Mat mask( height, width, CV_8UC1 ); - vector trigtab(numangle*2); + std::vector trigtab(numangle*2); for( int n = 0; n < numangle; n++ ) { @@ -404,7 +404,7 @@ HoughLinesProbabilistic( Mat& image, } const float* ttab = &trigtab[0]; uchar* mdata0 = mask.data; - vector nzloc; + std::vector nzloc; // stage 1. collect non-zero image points for( pt.y = 0; pt.y < height; pt.y++ ) @@ -601,7 +601,7 @@ void cv::HoughLines( InputArray _image, OutputArray _lines, double srn, double stn ) { Mat image = _image.getMat(); - vector lines; + std::vector lines; if( srn == 0 && stn == 0 ) HoughLinesStandard(image, (float)rho, (float)theta, threshold, lines, INT_MAX); @@ -617,7 +617,7 @@ void cv::HoughLinesP(InputArray _image, OutputArray _lines, double minLineLength, double maxGap ) { Mat image = _image.getMat(); - vector lines; + std::vector lines; HoughLinesProbabilistic(image, (float)rho, (float)theta, threshold, cvRound(minLineLength), cvRound(maxGap), lines, INT_MAX); Mat(lines).copyTo(_lines); } @@ -806,7 +806,7 @@ icvHoughCirclesGradient( CvMat* img, float dp, float min_dist, if( !edges_row[x] || (vx == 0 && vy == 0) ) continue; - float mag = sqrt(vx*vx+vy*vy); + float mag = std::sqrt(vx*vx+vy*vy); assert( mag >= 1 ); sx = cvRound((vx*idp)*ONE/mag); sy = cvRound((vy*idp)*ONE/mag); diff --git a/modules/imgproc/src/imgwarp.cpp b/modules/imgproc/src/imgwarp.cpp index 623b0eb6a..f344f8b1a 100644 --- a/modules/imgproc/src/imgwarp.cpp +++ b/modules/imgproc/src/imgwarp.cpp @@ -1763,7 +1763,7 @@ static int computeResizeAreaTab( int ssize, int dsize, int cn, double scale, Dec { double fsx1 = dx * scale; double fsx2 = fsx1 + scale; - double cellWidth = min(scale, ssize - fsx1); + double cellWidth = std::min(scale, ssize - fsx1); int sx1 = cvCeil(fsx1), sx2 = cvFloor(fsx2); @@ -1791,7 +1791,7 @@ static int computeResizeAreaTab( int ssize, int dsize, int cn, double scale, Dec assert( k < ssize*2 ); tab[k].di = dx * cn; tab[k].si = sx2 * cn; - tab[k++].alpha = (float)(min(min(fsx2 - sx2, 1.), cellWidth) / cellWidth); + tab[k++].alpha = (float)(std::min(std::min(fsx2 - sx2, 1.), cellWidth) / cellWidth); } } return k; @@ -4009,7 +4009,7 @@ cvLogPolar( const CvArr* srcarr, CvArr* dstarr, double xx = bufx.data.fl[x]; double yy = bufy.data.fl[x]; - double p = log(sqrt(xx*xx + yy*yy) + 1.)*M; + double p = log(std::sqrt(xx*xx + yy*yy) + 1.)*M; double a = atan2(yy,xx); if( a < 0 ) a = 2*CV_PI + a; diff --git a/modules/imgproc/src/linefit.cpp b/modules/imgproc/src/linefit.cpp index e31663620..61969b502 100644 --- a/modules/imgproc/src/linefit.cpp +++ b/modules/imgproc/src/linefit.cpp @@ -189,7 +189,7 @@ static void fitLine3D_wods( const Point3f * points, int count, float *weights, f i = evl[0] < evl[1] ? (evl[0] < evl[2] ? 0 : 2) : (evl[1] < evl[2] ? 1 : 2); v = &evc[i * 3]; - n = (float) sqrt( (double)v[0] * v[0] + (double)v[1] * v[1] + (double)v[2] * v[2] ); + n = (float) std::sqrt( (double)v[0] * v[0] + (double)v[1] * v[1] + (double)v[2] * v[2] ); n = (float)MAX(n, eps); line[0] = v[0] / n; line[1] = v[1] / n; @@ -240,7 +240,7 @@ static double calcDist3D( const Point3f* points, int count, float *_line, float p2 = vz * x - vx * z; p3 = vx * y - vy * x; - dist[j] = (float) sqrt( p1*p1 + p2*p2 + p3*p3 ); + dist[j] = (float) std::sqrt( p1*p1 + p2*p2 + p3*p3 ); sum_dist += dist[j]; } @@ -264,7 +264,7 @@ static void weightL12( float *d, int count, float *w ) for( i = 0; i < count; i++ ) { - w[i] = 1.0f / (float) sqrt( 1 + (double) (d[i] * d[i] * 0.5) ); + w[i] = 1.0f / (float) std::sqrt( 1 + (double) (d[i] * d[i] * 0.5) ); } } diff --git a/modules/imgproc/src/morph.cpp b/modules/imgproc/src/morph.cpp index a63e08ff0..4a939d9bb 100644 --- a/modules/imgproc/src/morph.cpp +++ b/modules/imgproc/src/morph.cpp @@ -790,7 +790,7 @@ template struct MorphFilter : BaseFilter ksize = _kernel.size(); CV_Assert( _kernel.type() == CV_8U ); - vector coeffs; // we do not really the values of non-zero + std::vector coeffs; // we do not really the values of non-zero // kernel elements, just their locations preprocess2DKernel( _kernel, coords, coeffs ); ptrs.resize( coords.size() ); @@ -839,8 +839,8 @@ template struct MorphFilter : BaseFilter } } - vector coords; - vector ptrs; + std::vector coords; + std::vector ptrs; VecOp vecOp; }; @@ -1104,8 +1104,8 @@ public: void operator () ( const BlockedRange& range ) const { - int row0 = min(cvRound(range.begin() * src.rows / nStripes), src.rows); - int row1 = min(cvRound(range.end() * src.rows / nStripes), src.rows); + int row0 = std::min(cvRound(range.begin() * src.rows / nStripes), src.rows); + int row1 = std::min(cvRound(range.end() * src.rows / nStripes), src.rows); /*if(0) printf("Size = (%d, %d), range[%d,%d), row0 = %d, row1 = %d\n", diff --git a/modules/imgproc/src/phasecorr.cpp b/modules/imgproc/src/phasecorr.cpp index 3b6c2eb4a..d21a4938f 100644 --- a/modules/imgproc/src/phasecorr.cpp +++ b/modules/imgproc/src/phasecorr.cpp @@ -359,7 +359,7 @@ static void fftShift(InputOutputArray _out) return; } - vector planes; + std::vector planes; split(out, planes); int xMid = out.cols >> 1; diff --git a/modules/imgproc/src/precomp.hpp b/modules/imgproc/src/precomp.hpp index dc2650bf4..4d8e1daf4 100644 --- a/modules/imgproc/src/precomp.hpp +++ b/modules/imgproc/src/precomp.hpp @@ -91,7 +91,7 @@ static inline Point normalizeAnchor( Point anchor, Size ksize ) return anchor; } -void preprocess2DKernel( const Mat& kernel, vector& coords, vector& coeffs ); +void preprocess2DKernel( const Mat& kernel, std::vector& coords, std::vector& coeffs ); void crossCorr( const Mat& src, const Mat& templ, Mat& dst, Size corrsize, int ctype, Point anchor=Point(0,0), double delta=0, diff --git a/modules/imgproc/src/rotcalipers.cpp b/modules/imgproc/src/rotcalipers.cpp index b0ce3020b..cc43732c2 100644 --- a/modules/imgproc/src/rotcalipers.cpp +++ b/modules/imgproc/src/rotcalipers.cpp @@ -138,7 +138,7 @@ static void rotatingCalipers( const Point2f* points, int n, int mode, float* out vect[i].x = (float)dx; vect[i].y = (float)dy; - inv_vect_length[i] = (float)(1./sqrt(dx*dx + dy*dy)); + inv_vect_length[i] = (float)(1./std::sqrt(dx*dx + dy*dy)); pt0 = pt; } @@ -321,10 +321,10 @@ static void rotatingCalipers( const Point2f* points, int n, int mode, float* out out[0] = px; out[1] = py; - + out[2] = A1 * buf[2]; out[3] = B1 * buf[2]; - + out[4] = A2 * buf[4]; out[5] = B2 * buf[4]; } @@ -336,7 +336,7 @@ static void rotatingCalipers( const Point2f* points, int n, int mode, float* out break; } } - + } @@ -345,35 +345,35 @@ cv::RotatedRect cv::minAreaRect( InputArray _points ) Mat hull; Point2f out[3]; RotatedRect box; - + convexHull(_points, hull, true, true); - + if( hull.depth() != CV_32F ) { Mat temp; hull.convertTo(temp, CV_32F); hull = temp; } - + int n = hull.checkVector(2); const Point2f* hpoints = (const Point2f*)hull.data; - + if( n > 2 ) { rotatingCalipers( hpoints, n, CALIPERS_MINAREARECT, (float*)out ); box.center.x = out[0].x + (out[1].x + out[2].x)*0.5f; box.center.y = out[0].y + (out[1].y + out[2].y)*0.5f; - box.size.width = (float)sqrt((double)out[1].x*out[1].x + (double)out[1].y*out[1].y); - box.size.height = (float)sqrt((double)out[2].x*out[2].x + (double)out[2].y*out[2].y); + box.size.width = (float)std::sqrt((double)out[1].x*out[1].x + (double)out[1].y*out[1].y); + box.size.height = (float)std::sqrt((double)out[2].x*out[2].x + (double)out[2].y*out[2].y); box.angle = (float)atan2( (double)out[1].y, (double)out[1].x ); } else if( n == 2 ) { box.center.x = (hpoints[0].x + hpoints[1].x)*0.5f; box.center.y = (hpoints[0].y + hpoints[1].y)*0.5f; - double dx = hpoints[1].x - hpoints[0].x; + double dx = hpoints[1].x - hpoints[0].x; double dy = hpoints[1].y - hpoints[0].y; - box.size.width = (float)sqrt(dx*dx + dy*dy); + box.size.width = (float)std::sqrt(dx*dx + dy*dy); box.size.height = 0; box.angle = (float)atan2( dy, dx ); } @@ -382,7 +382,7 @@ cv::RotatedRect cv::minAreaRect( InputArray _points ) if( n == 1 ) box.center = hpoints[0]; } - + box.angle = (float)(box.angle*180/CV_PI); return box; } diff --git a/modules/imgproc/src/segmentation.cpp b/modules/imgproc/src/segmentation.cpp index 3d78585b3..9679add1c 100644 --- a/modules/imgproc/src/segmentation.cpp +++ b/modules/imgproc/src/segmentation.cpp @@ -64,7 +64,7 @@ struct WSQueue static int -allocWSNodes( vector& storage ) +allocWSNodes( std::vector& storage ) { int sz = (int)storage.size(); int newsz = MAX(128, sz*3/2); @@ -93,7 +93,7 @@ void cv::watershed( InputArray _src, InputOutputArray _markers ) Mat src = _src.getMat(), dst = _markers.getMat(); Size size = src.size(); - vector storage; + std::vector storage; int free_node = 0, node; WSQueue q[NQ]; int active_queue; diff --git a/modules/imgproc/src/shapedescr.cpp b/modules/imgproc/src/shapedescr.cpp index a506535af..93368be96 100644 --- a/modules/imgproc/src/shapedescr.cpp +++ b/modules/imgproc/src/shapedescr.cpp @@ -284,7 +284,7 @@ void cv::minEnclosingCircle( InputArray _points, Point2f& _center, float& _radiu radius = MAX(radius, t); } - radius = (float)(sqrt(radius)*(1 + eps)); + radius = (float)(std::sqrt(radius)*(1 + eps)); } _center = center; @@ -428,7 +428,7 @@ cv::RotatedRect cv::fitEllipse( InputArray _points ) bd[0] = gfp[3]; bd[1] = gfp[4]; solve( A, b, x, DECOMP_SVD ); - + // re-fit for parameters A - C with those center coordinates A = Mat( n, 3, CV_64F, Ad ); b = Mat( n, 1, CV_64F, bd ); @@ -443,7 +443,7 @@ cv::RotatedRect cv::fitEllipse( InputArray _points ) Ad[i * 3 + 2] = (p.x - rp[0]) * (p.y - rp[1]); } solve(A, b, x, DECOMP_SVD); - + // store angle and radii rp[4] = -0.5 * atan2(gfp[2], gfp[1] - gfp[0]); // convert from APP angle usage t = sin(-2.0 * rp[4]); @@ -453,11 +453,11 @@ cv::RotatedRect cv::fitEllipse( InputArray _points ) t = gfp[1] - gfp[0]; rp[2] = fabs(gfp[0] + gfp[1] - t); if( rp[2] > min_eps ) - rp[2] = sqrt(2.0 / rp[2]); + rp[2] = std::sqrt(2.0 / rp[2]); rp[3] = fabs(gfp[0] + gfp[1] + t); if( rp[3] > min_eps ) - rp[3] = sqrt(2.0 / rp[3]); - + rp[3] = std::sqrt(2.0 / rp[3]); + box.center.x = (float)rp[0] + c.x; box.center.y = (float)rp[1] + c.y; box.size.width = (float)(rp[2]*2); @@ -472,7 +472,7 @@ cv::RotatedRect cv::fitEllipse( InputArray _points ) box.angle += 360; if( box.angle > 360 ) box.angle -= 360; - + return box; } @@ -596,7 +596,7 @@ static Rect pointSetBoundingRect( const Mat& points ) v.i = CV_TOGGLE_FLT(ymax); ymax = cvFloor(v.f); } } - + return Rect(xmin, ymin, xmax - xmin + 1, ymax - ymin + 1); } @@ -688,7 +688,7 @@ static Rect maskBoundingRect( const Mat& img ) ymax = i; } } - + if( xmin >= size.width ) xmin = ymin = 0; return Rect(xmin, ymin, xmax - xmin + 1, ymax - ymin + 1); @@ -1029,7 +1029,7 @@ cvArcLength( const void *array, CvSlice slice, int is_closed ) } } } - + return perimeter; } diff --git a/modules/imgproc/src/smooth.cpp b/modules/imgproc/src/smooth.cpp index c84abe5c6..a685ba5b9 100644 --- a/modules/imgproc/src/smooth.cpp +++ b/modules/imgproc/src/smooth.cpp @@ -193,7 +193,7 @@ template struct ColumnSum : public BaseColumnFilter double scale; int sumCount; - vector sum; + std::vector sum; }; @@ -335,7 +335,7 @@ template<> struct ColumnSum : public BaseColumnFilter double scale; int sumCount; - vector sum; + std::vector sum; }; template<> struct ColumnSum : public BaseColumnFilter @@ -472,7 +472,7 @@ template<> struct ColumnSum : public BaseColumnFilter double scale; int sumCount; - vector sum; + std::vector sum; }; @@ -607,7 +607,7 @@ template<> struct ColumnSum : public BaseColumnFilter double scale; int sumCount; - vector sum; + std::vector sum; }; @@ -957,8 +957,8 @@ medianBlur_8u_O1( const Mat& _src, Mat& _dst, int ksize ) int STRIPE_SIZE = std::min( _dst.cols, 512/cn ); - vector _h_coarse(1 * 16 * (STRIPE_SIZE + 2*r) * cn + 16); - vector _h_fine(16 * 16 * (STRIPE_SIZE + 2*r) * cn + 16); + std::vector _h_coarse(1 * 16 * (STRIPE_SIZE + 2*r) * cn + 16); + std::vector _h_fine(16 * 16 * (STRIPE_SIZE + 2*r) * cn + 16); HT* h_coarse = alignPtr(&_h_coarse[0], 16); HT* h_fine = alignPtr(&_h_fine[0], 16); #if MEDIAN_HAVE_SIMD @@ -1891,9 +1891,9 @@ bilateralFilter_8u( const Mat& src, Mat& dst, int d, Mat temp; copyMakeBorder( src, temp, radius, radius, radius, radius, borderType ); - vector _color_weight(cn*256); - vector _space_weight(d*d); - vector _space_ofs(d*d); + std::vector _color_weight(cn*256); + std::vector _space_weight(d*d); + std::vector _space_ofs(d*d); float* color_weight = &_color_weight[0]; float* space_weight = &_space_weight[0]; int* space_ofs = &_space_ofs[0]; @@ -2149,15 +2149,15 @@ bilateralFilter_32f( const Mat& src, Mat& dst, int d, patchNaNs( temp, insteadNaNValue ); // this replacement of NaNs makes the assumption that depth values are nonnegative // TODO: make insteadNaNValue avalible in the outside function interface to control the cases breaking the assumption // allocate lookup tables - vector _space_weight(d*d); - vector _space_ofs(d*d); + std::vector _space_weight(d*d); + std::vector _space_ofs(d*d); float* space_weight = &_space_weight[0]; int* space_ofs = &_space_ofs[0]; // assign a length which is slightly more than needed len = (float)(maxValSrc - minValSrc) * cn; kExpNumBins = kExpNumBinsPerChannel * cn; - vector _expLUT(kExpNumBins+2); + std::vector _expLUT(kExpNumBins+2); float* expLUT = &_expLUT[0]; scale_index = kExpNumBins/len; diff --git a/modules/imgproc/src/subdivision2d.cpp b/modules/imgproc/src/subdivision2d.cpp index 16e847714..d849d2aa1 100644 --- a/modules/imgproc/src/subdivision2d.cpp +++ b/modules/imgproc/src/subdivision2d.cpp @@ -477,7 +477,7 @@ int Subdiv2D::insert(Point2f pt) return curr_point; } -void Subdiv2D::insert(const vector& ptvec) +void Subdiv2D::insert(const std::vector& ptvec) { for( size_t i = 0; i < ptvec.size(); i++ ) insert(ptvec[i]); @@ -706,7 +706,7 @@ int Subdiv2D::findNearest(Point2f pt, Point2f* nearestPt) return vertex; } -void Subdiv2D::getEdgeList(vector& edgeList) const +void Subdiv2D::getEdgeList(std::vector& edgeList) const { edgeList.clear(); @@ -723,11 +723,11 @@ void Subdiv2D::getEdgeList(vector& edgeList) const } } -void Subdiv2D::getTriangleList(vector& triangleList) const +void Subdiv2D::getTriangleList(std::vector& triangleList) const { triangleList.clear(); int i, total = (int)(qedges.size()*4); - vector edgemask(total, false); + std::vector edgemask(total, false); for( i = 4; i < total; i += 2 ) { @@ -747,15 +747,15 @@ void Subdiv2D::getTriangleList(vector& triangleList) const } } -void Subdiv2D::getVoronoiFacetList(const vector& idx, - CV_OUT vector >& facetList, - CV_OUT vector& facetCenters) +void Subdiv2D::getVoronoiFacetList(const std::vector& idx, + CV_OUT std::vector >& facetList, + CV_OUT std::vector& facetCenters) { calcVoronoi(); facetList.clear(); facetCenters.clear(); - vector buf; + std::vector buf; size_t i, total; if( idx.empty() ) diff --git a/modules/imgproc/src/templmatch.cpp b/modules/imgproc/src/templmatch.cpp index ec7a92a22..f87c296a3 100644 --- a/modules/imgproc/src/templmatch.cpp +++ b/modules/imgproc/src/templmatch.cpp @@ -300,8 +300,8 @@ void cv::matchTemplate( InputArray _img, InputArray _templ, OutputArray _result, } templSum2 /= invArea; - templNorm = sqrt(templNorm); - templNorm /= sqrt(invArea); // care of accuracy here + templNorm = std::sqrt(templNorm); + templNorm /= std::sqrt(invArea); // care of accuracy here q0 = (double*)sqsum.data; q1 = q0 + templ.cols*cn; @@ -359,7 +359,7 @@ void cv::matchTemplate( InputArray _img, InputArray _templ, OutputArray _result, if( isNormed ) { - t = sqrt(MAX(wndSum2 - wndMean2,0))*templNorm; + t = std::sqrt(MAX(wndSum2 - wndMean2,0))*templNorm; if( fabs(num) < t ) num /= t; else if( fabs(num) < t*1.125 ) diff --git a/modules/imgproc/src/undistort.cpp b/modules/imgproc/src/undistort.cpp index fc13b500d..de5a5c76c 100644 --- a/modules/imgproc/src/undistort.cpp +++ b/modules/imgproc/src/undistort.cpp @@ -415,7 +415,7 @@ static Point2f mapPointSpherical(const Point2f& p, float alpha, Vec4d* J, int pr double x = p.x, y = p.y; double beta = 1 + 2*alpha; double v = x*x + y*y + 1, iv = 1/v; - double u = sqrt(beta*v + alpha*alpha); + double u = std::sqrt(beta*v + alpha*alpha); double k = (u - alpha)*iv; double kv = (v*beta/u - (u - alpha)*2)*iv*iv; @@ -436,8 +436,8 @@ static Point2f mapPointSpherical(const Point2f& p, float alpha, Vec4d* J, int pr if(J) { - double fx1 = iR/sqrt(1 - x1*x1); - double fy1 = iR/sqrt(1 - y1*y1); + double fx1 = iR/std::sqrt(1 - x1*x1); + double fy1 = iR/std::sqrt(1 - y1*y1); *J = Vec4d(fx1*(kx*x + k), fx1*ky*x, fy1*kx*y, fy1*(ky*y + k)); } return Point2f((float)asin(x1), (float)asin(y1)); diff --git a/modules/java/generator/gen_java.py b/modules/java/generator/gen_java.py index 0f3ba1d33..42f816ba2 100755 --- a/modules/java/generator/gen_java.py +++ b/modules/java/generator/gen_java.py @@ -202,32 +202,32 @@ type_dict = { # "complex" : { j_type : "?", jn_args : (("", ""),), jn_name : "", jni_var : "", jni_name : "", "suffix" : "?" }, - "vector_Point" : { "j_type" : "MatOfPoint", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector %(n)s", "suffix" : "J" }, - "vector_Point2f" : { "j_type" : "MatOfPoint2f", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector %(n)s", "suffix" : "J" }, - #"vector_Point2d" : { "j_type" : "MatOfPoint2d", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector %(n)s", "suffix" : "J" }, - "vector_Point3i" : { "j_type" : "MatOfPoint3", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector %(n)s", "suffix" : "J" }, - "vector_Point3f" : { "j_type" : "MatOfPoint3f", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector %(n)s", "suffix" : "J" }, - #"vector_Point3d" : { "j_type" : "MatOfPoint3d", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector %(n)s", "suffix" : "J" }, - "vector_KeyPoint" : { "j_type" : "MatOfKeyPoint", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector %(n)s", "suffix" : "J" }, - "vector_DMatch" : { "j_type" : "MatOfDMatch", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector %(n)s", "suffix" : "J" }, - "vector_Rect" : { "j_type" : "MatOfRect", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector %(n)s", "suffix" : "J" }, - "vector_uchar" : { "j_type" : "MatOfByte", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector %(n)s", "suffix" : "J" }, - "vector_char" : { "j_type" : "MatOfByte", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector %(n)s", "suffix" : "J" }, - "vector_int" : { "j_type" : "MatOfInt", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector %(n)s", "suffix" : "J" }, - "vector_float" : { "j_type" : "MatOfFloat", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector %(n)s", "suffix" : "J" }, - "vector_double" : { "j_type" : "MatOfDouble", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector %(n)s", "suffix" : "J" }, - "vector_Vec4i" : { "j_type" : "MatOfInt4", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector %(n)s", "suffix" : "J" }, - "vector_Vec4f" : { "j_type" : "MatOfFloat4", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector %(n)s", "suffix" : "J" }, - "vector_Vec6f" : { "j_type" : "MatOfFloat6", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector %(n)s", "suffix" : "J" }, + "vector_Point" : { "j_type" : "MatOfPoint", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "std::vector %(n)s", "suffix" : "J" }, + "vector_Point2f" : { "j_type" : "MatOfPoint2f", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "std::vector %(n)s", "suffix" : "J" }, + #"vector_Point2d" : { "j_type" : "MatOfPoint2d", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "std::vector %(n)s", "suffix" : "J" }, + "vector_Point3i" : { "j_type" : "MatOfPoint3", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "std::vector %(n)s", "suffix" : "J" }, + "vector_Point3f" : { "j_type" : "MatOfPoint3f", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "std::vector %(n)s", "suffix" : "J" }, + #"vector_Point3d" : { "j_type" : "MatOfPoint3d", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "std::vector %(n)s", "suffix" : "J" }, + "vector_KeyPoint" : { "j_type" : "MatOfKeyPoint", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "std::vector %(n)s", "suffix" : "J" }, + "vector_DMatch" : { "j_type" : "MatOfDMatch", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "std::vector %(n)s", "suffix" : "J" }, + "vector_Rect" : { "j_type" : "MatOfRect", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "std::vector %(n)s", "suffix" : "J" }, + "vector_uchar" : { "j_type" : "MatOfByte", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "std::vector %(n)s", "suffix" : "J" }, + "vector_char" : { "j_type" : "MatOfByte", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "std::vector %(n)s", "suffix" : "J" }, + "vector_int" : { "j_type" : "MatOfInt", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "std::vector %(n)s", "suffix" : "J" }, + "vector_float" : { "j_type" : "MatOfFloat", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "std::vector %(n)s", "suffix" : "J" }, + "vector_double" : { "j_type" : "MatOfDouble", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "std::vector %(n)s", "suffix" : "J" }, + "vector_Vec4i" : { "j_type" : "MatOfInt4", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "std::vector %(n)s", "suffix" : "J" }, + "vector_Vec4f" : { "j_type" : "MatOfFloat4", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "std::vector %(n)s", "suffix" : "J" }, + "vector_Vec6f" : { "j_type" : "MatOfFloat6", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "std::vector %(n)s", "suffix" : "J" }, - "vector_Mat" : { "j_type" : "List", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector %(n)s", "suffix" : "J" }, + "vector_Mat" : { "j_type" : "List", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "std::vector %(n)s", "suffix" : "J" }, - "vector_vector_KeyPoint": { "j_type" : "List", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector< vector > %(n)s" }, - "vector_vector_DMatch" : { "j_type" : "List", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector< vector > %(n)s" }, - "vector_vector_char" : { "j_type" : "List", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector< vector > %(n)s" }, - "vector_vector_Point" : { "j_type" : "List", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector< vector > %(n)s" }, - "vector_vector_Point2f" : { "j_type" : "List", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector< vector > %(n)s" }, - "vector_vector_Point3f" : { "j_type" : "List", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector< vector > %(n)s" }, + "vector_vector_KeyPoint": { "j_type" : "List", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "std::vector< std::vector > %(n)s" }, + "vector_vector_DMatch" : { "j_type" : "List", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "std::vector< std::vector > %(n)s" }, + "vector_vector_char" : { "j_type" : "List", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "std::vector< std::vector > %(n)s" }, + "vector_vector_Point" : { "j_type" : "List", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "std::vector< std::vector > %(n)s" }, + "vector_vector_Point2f" : { "j_type" : "List", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "std::vector< std::vector > %(n)s" }, + "vector_vector_Point3f" : { "j_type" : "List", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "std::vector< std::vector > %(n)s" }, "Mat" : { "j_type" : "Mat", "jn_type" : "long", "jn_args" : (("__int64", ".nativeObj"),), "jni_var" : "Mat& %(n)s = *((Mat*)%(n)s_nativeObj)", @@ -287,10 +287,6 @@ type_dict = { "jni_type" : "jstring", "jni_name" : "n_%(n)s", "jni_var" : 'const char* utf_%(n)s = env->GetStringUTFChars(%(n)s, 0); std::string n_%(n)s( utf_%(n)s ? utf_%(n)s : "" ); env->ReleaseStringUTFChars(%(n)s, utf_%(n)s)', "suffix" : "Ljava_lang_String_2"}, - "String" : { "j_type" : "String", "jn_type" : "String", - "jni_type" : "jstring", "jni_name" : "n_%(n)s", - "jni_var" : 'const char* utf_%(n)s = env->GetStringUTFChars(%(n)s, 0); String n_%(n)s( utf_%(n)s ? utf_%(n)s : "" ); env->ReleaseStringUTFChars(%(n)s, utf_%(n)s)', - "suffix" : "Ljava_lang_String_2"}, "c_string": { "j_type" : "String", "jn_type" : "String", "jni_type" : "jstring", "jni_name" : "n_%(n)s.c_str()", "jni_var" : 'const char* utf_%(n)s = env->GetStringUTFChars(%(n)s, 0); std::string n_%(n)s( utf_%(n)s ? utf_%(n)s : "" ); env->ReleaseStringUTFChars(%(n)s, utf_%(n)s)', @@ -419,7 +415,7 @@ JNIEXPORT jdoubleArray JNICALL Java_org_opencv_core_Core_n_1minMaxLocManual { 'j_code' : """ - // C++: Size getTextSize(const string& text, int fontFace, double fontScale, int thickness, int* baseLine); + // C++: Size getTextSize(const std::string& text, int fontFace, double fontScale, int thickness, int* baseLine); //javadoc:getTextSize(text, fontFace, fontScale, thickness, baseLine) public static Size getTextSize(String text, int fontFace, double fontScale, int thickness, int[] baseLine) { if(baseLine != null && baseLine.length != 1) @@ -432,7 +428,7 @@ JNIEXPORT jdoubleArray JNICALL Java_org_opencv_core_Core_n_1minMaxLocManual """ private static native double[] n_getTextSize(String text, int fontFace, double fontScale, int thickness, int[] baseLine);\n""", 'cpp_code' : """ -// C++: Size getTextSize(const string& text, int fontFace, double fontScale, int thickness, int* baseLine); +// C++: Size getTextSize(const std::string& text, int fontFace, double fontScale, int thickness, int* baseLine); JNIEXPORT jdoubleArray JNICALL Java_org_opencv_core_Core_n_1getTextSize (JNIEnv*, jclass, jstring, jint, jdouble, jint, jintArray); JNIEXPORT jdoubleArray JNICALL Java_org_opencv_core_Core_n_1getTextSize @@ -1208,6 +1204,8 @@ extern "C" { retval = fi.ctype + " _retval_ = " if fi.ctype == "void": retval = "" + elif fi.ctype == "string": + retval = "std::" + retval elif fi.ctype.startswith('vector'): retval = type_dict[fi.ctype]['jni_var'] % {"n" : '_ret_val_vector_'} + " = " c_epilogue.append("Mat* _retval_ = new Mat();") diff --git a/modules/java/generator/src/cpp/converters.cpp b/modules/java/generator/src/cpp/converters.cpp index 9acf318db..f03ddcee1 100644 --- a/modules/java/generator/src/cpp/converters.cpp +++ b/modules/java/generator/src/cpp/converters.cpp @@ -8,14 +8,14 @@ using namespace cv; // vector_int -void Mat_to_vector_int(Mat& mat, vector& v_int) +void Mat_to_vector_int(Mat& mat, std::vector& v_int) { v_int.clear(); CHECK_MAT(mat.type()==CV_32SC1 && mat.cols==1); - v_int = (vector) mat; + v_int = (std::vector) mat; } -void vector_int_to_Mat(vector& v_int, Mat& mat) +void vector_int_to_Mat(std::vector& v_int, Mat& mat) { mat = Mat(v_int, true); } @@ -23,14 +23,14 @@ void vector_int_to_Mat(vector& v_int, Mat& mat) //vector_double -void Mat_to_vector_double(Mat& mat, vector& v_double) +void Mat_to_vector_double(Mat& mat, std::vector& v_double) { v_double.clear(); CHECK_MAT(mat.type()==CV_64FC1 && mat.cols==1); - v_double = (vector) mat; + v_double = (std::vector) mat; } -void vector_double_to_Mat(vector& v_double, Mat& mat) +void vector_double_to_Mat(std::vector& v_double, Mat& mat) { mat = Mat(v_double, true); } @@ -38,14 +38,14 @@ void vector_double_to_Mat(vector& v_double, Mat& mat) // vector_float -void Mat_to_vector_float(Mat& mat, vector& v_float) +void Mat_to_vector_float(Mat& mat, std::vector& v_float) { v_float.clear(); CHECK_MAT(mat.type()==CV_32FC1 && mat.cols==1); - v_float = (vector) mat; + v_float = (std::vector) mat; } -void vector_float_to_Mat(vector& v_float, Mat& mat) +void vector_float_to_Mat(std::vector& v_float, Mat& mat) { mat = Mat(v_float, true); } @@ -53,26 +53,26 @@ void vector_float_to_Mat(vector& v_float, Mat& mat) //vector_uchar -void Mat_to_vector_uchar(Mat& mat, vector& v_uchar) +void Mat_to_vector_uchar(Mat& mat, std::vector& v_uchar) { v_uchar.clear(); CHECK_MAT(mat.type()==CV_8UC1 && mat.cols==1); - v_uchar = (vector) mat; + v_uchar = (std::vector) mat; } -void vector_uchar_to_Mat(vector& v_uchar, Mat& mat) +void vector_uchar_to_Mat(std::vector& v_uchar, Mat& mat) { mat = Mat(v_uchar, true); } -void Mat_to_vector_char(Mat& mat, vector& v_char) +void Mat_to_vector_char(Mat& mat, std::vector& v_char) { v_char.clear(); CHECK_MAT(mat.type()==CV_8SC1 && mat.cols==1); - v_char = (vector) mat; + v_char = (std::vector) mat; } -void vector_char_to_Mat(vector& v_char, Mat& mat) +void vector_char_to_Mat(std::vector& v_char, Mat& mat) { mat = Mat(v_char, true); } @@ -80,102 +80,102 @@ void vector_char_to_Mat(vector& v_char, Mat& mat) //vector_Rect -void Mat_to_vector_Rect(Mat& mat, vector& v_rect) +void Mat_to_vector_Rect(Mat& mat, std::vector& v_rect) { v_rect.clear(); CHECK_MAT(mat.type()==CV_32SC4 && mat.cols==1); - v_rect = (vector) mat; + v_rect = (std::vector) mat; } -void vector_Rect_to_Mat(vector& v_rect, Mat& mat) +void vector_Rect_to_Mat(std::vector& v_rect, Mat& mat) { mat = Mat(v_rect, true); } //vector_Point -void Mat_to_vector_Point(Mat& mat, vector& v_point) +void Mat_to_vector_Point(Mat& mat, std::vector& v_point) { v_point.clear(); CHECK_MAT(mat.type()==CV_32SC2 && mat.cols==1); - v_point = (vector) mat; + v_point = (std::vector) mat; } //vector_Point2f -void Mat_to_vector_Point2f(Mat& mat, vector& v_point) +void Mat_to_vector_Point2f(Mat& mat, std::vector& v_point) { v_point.clear(); CHECK_MAT(mat.type()==CV_32FC2 && mat.cols==1); - v_point = (vector) mat; + v_point = (std::vector) mat; } //vector_Point2d -void Mat_to_vector_Point2d(Mat& mat, vector& v_point) +void Mat_to_vector_Point2d(Mat& mat, std::vector& v_point) { v_point.clear(); CHECK_MAT(mat.type()==CV_64FC2 && mat.cols==1); - v_point = (vector) mat; + v_point = (std::vector) mat; } //vector_Point3i -void Mat_to_vector_Point3i(Mat& mat, vector& v_point) +void Mat_to_vector_Point3i(Mat& mat, std::vector& v_point) { v_point.clear(); CHECK_MAT(mat.type()==CV_32SC3 && mat.cols==1); - v_point = (vector) mat; + v_point = (std::vector) mat; } //vector_Point3f -void Mat_to_vector_Point3f(Mat& mat, vector& v_point) +void Mat_to_vector_Point3f(Mat& mat, std::vector& v_point) { v_point.clear(); CHECK_MAT(mat.type()==CV_32FC3 && mat.cols==1); - v_point = (vector) mat; + v_point = (std::vector) mat; } //vector_Point3d -void Mat_to_vector_Point3d(Mat& mat, vector& v_point) +void Mat_to_vector_Point3d(Mat& mat, std::vector& v_point) { v_point.clear(); CHECK_MAT(mat.type()==CV_64FC3 && mat.cols==1); - v_point = (vector) mat; + v_point = (std::vector) mat; } -void vector_Point_to_Mat(vector& v_point, Mat& mat) +void vector_Point_to_Mat(std::vector& v_point, Mat& mat) { mat = Mat(v_point, true); } -void vector_Point2f_to_Mat(vector& v_point, Mat& mat) +void vector_Point2f_to_Mat(std::vector& v_point, Mat& mat) { mat = Mat(v_point, true); } -void vector_Point2d_to_Mat(vector& v_point, Mat& mat) +void vector_Point2d_to_Mat(std::vector& v_point, Mat& mat) { mat = Mat(v_point, true); } -void vector_Point3i_to_Mat(vector& v_point, Mat& mat) +void vector_Point3i_to_Mat(std::vector& v_point, Mat& mat) { mat = Mat(v_point, true); } -void vector_Point3f_to_Mat(vector& v_point, Mat& mat) +void vector_Point3f_to_Mat(std::vector& v_point, Mat& mat) { mat = Mat(v_point, true); } -void vector_Point3d_to_Mat(vector& v_point, Mat& mat) +void vector_Point3d_to_Mat(std::vector& v_point, Mat& mat) { mat = Mat(v_point, true); } #ifdef HAVE_OPENCV_FEATURES2D //vector_KeyPoint -void Mat_to_vector_KeyPoint(Mat& mat, vector& v_kp) +void Mat_to_vector_KeyPoint(Mat& mat, std::vector& v_kp) { v_kp.clear(); CHECK_MAT(mat.type()==CV_32FC(7) && mat.cols==1); @@ -189,7 +189,7 @@ void Mat_to_vector_KeyPoint(Mat& mat, vector& v_kp) } -void vector_KeyPoint_to_Mat(vector& v_kp, Mat& mat) +void vector_KeyPoint_to_Mat(std::vector& v_kp, Mat& mat) { int count = (int)v_kp.size(); mat.create(count, 1, CV_32FC(7)); @@ -235,7 +235,7 @@ void vector_Mat_to_Mat(std::vector& v_mat, cv::Mat& mat) #ifdef HAVE_OPENCV_FEATURES2D //vector_DMatch -void Mat_to_vector_DMatch(Mat& mat, vector& v_dm) +void Mat_to_vector_DMatch(Mat& mat, std::vector& v_dm) { v_dm.clear(); CHECK_MAT(mat.type()==CV_32FC4 && mat.cols==1); @@ -249,7 +249,7 @@ void Mat_to_vector_DMatch(Mat& mat, vector& v_dm) } -void vector_DMatch_to_Mat(vector& v_dm, Mat& mat) +void vector_DMatch_to_Mat(std::vector& v_dm, Mat& mat) { int count = (int)v_dm.size(); mat.create(count, 1, CV_32FC4); @@ -261,62 +261,62 @@ void vector_DMatch_to_Mat(vector& v_dm, Mat& mat) } #endif -void Mat_to_vector_vector_Point(Mat& mat, vector< vector< Point > >& vv_pt) +void Mat_to_vector_vector_Point(Mat& mat, std::vector< std::vector< Point > >& vv_pt) { - vector vm; + std::vector vm; vm.reserve( mat.rows ); Mat_to_vector_Mat(mat, vm); for(size_t i=0; i vpt; + std::vector vpt; Mat_to_vector_Point(vm[i], vpt); vv_pt.push_back(vpt); } } -void Mat_to_vector_vector_Point2f(Mat& mat, vector< vector< Point2f > >& vv_pt) +void Mat_to_vector_vector_Point2f(Mat& mat, std::vector< std::vector< Point2f > >& vv_pt) { - vector vm; + std::vector vm; vm.reserve( mat.rows ); Mat_to_vector_Mat(mat, vm); for(size_t i=0; i vpt; + std::vector vpt; Mat_to_vector_Point2f(vm[i], vpt); vv_pt.push_back(vpt); } } -void Mat_to_vector_vector_Point3f(Mat& mat, vector< vector< Point3f > >& vv_pt) +void Mat_to_vector_vector_Point3f(Mat& mat, std::vector< std::vector< Point3f > >& vv_pt) { - vector vm; + std::vector vm; vm.reserve( mat.rows ); Mat_to_vector_Mat(mat, vm); for(size_t i=0; i vpt; + std::vector vpt; Mat_to_vector_Point3f(vm[i], vpt); vv_pt.push_back(vpt); } } #ifdef HAVE_OPENCV_FEATURES2D -void Mat_to_vector_vector_KeyPoint(Mat& mat, vector< vector< KeyPoint > >& vv_kp) +void Mat_to_vector_vector_KeyPoint(Mat& mat, std::vector< std::vector< KeyPoint > >& vv_kp) { - vector vm; + std::vector vm; vm.reserve( mat.rows ); Mat_to_vector_Mat(mat, vm); for(size_t i=0; i vkp; + std::vector vkp; Mat_to_vector_KeyPoint(vm[i], vkp); vv_kp.push_back(vkp); } } -void vector_vector_KeyPoint_to_Mat(vector< vector< KeyPoint > >& vv_kp, Mat& mat) +void vector_vector_KeyPoint_to_Mat(std::vector< std::vector< KeyPoint > >& vv_kp, Mat& mat) { - vector vm; + std::vector vm; vm.reserve( vv_kp.size() ); for(size_t i=0; i >& vv_kp, Mat& mat vector_Mat_to_Mat(vm, mat); } -void Mat_to_vector_vector_DMatch(Mat& mat, vector< vector< DMatch > >& vv_dm) +void Mat_to_vector_vector_DMatch(Mat& mat, std::vector< std::vector< DMatch > >& vv_dm) { - vector vm; + std::vector vm; vm.reserve( mat.rows ); Mat_to_vector_Mat(mat, vm); for(size_t i=0; i vdm; + std::vector vdm; Mat_to_vector_DMatch(vm[i], vdm); vv_dm.push_back(vdm); } } -void vector_vector_DMatch_to_Mat(vector< vector< DMatch > >& vv_dm, Mat& mat) +void vector_vector_DMatch_to_Mat(std::vector< std::vector< DMatch > >& vv_dm, Mat& mat) { - vector vm; + std::vector vm; vm.reserve( vv_dm.size() ); for(size_t i=0; i >& vv_dm, Mat& mat) } #endif -void Mat_to_vector_vector_char(Mat& mat, vector< vector< char > >& vv_ch) +void Mat_to_vector_vector_char(Mat& mat, std::vector< std::vector< char > >& vv_ch) { - vector vm; + std::vector vm; vm.reserve( mat.rows ); Mat_to_vector_Mat(mat, vm); for(size_t i=0; i vch; + std::vector vch; Mat_to_vector_char(vm[i], vch); vv_ch.push_back(vch); } } -void vector_vector_char_to_Mat(vector< vector< char > >& vv_ch, Mat& mat) +void vector_vector_char_to_Mat(std::vector< std::vector< char > >& vv_ch, Mat& mat) { - vector vm; + std::vector vm; vm.reserve( vv_ch.size() ); for(size_t i=0; i >& vv_ch, Mat& mat) vector_Mat_to_Mat(vm, mat); } -void vector_vector_Point_to_Mat(vector< vector< Point > >& vv_pt, Mat& mat) +void vector_vector_Point_to_Mat(std::vector< std::vector< Point > >& vv_pt, Mat& mat) { - vector vm; + std::vector vm; vm.reserve( vv_pt.size() ); for(size_t i=0; i >& vv_pt, Mat& mat) vector_Mat_to_Mat(vm, mat); } -void vector_vector_Point2f_to_Mat(vector< vector< Point2f > >& vv_pt, Mat& mat) +void vector_vector_Point2f_to_Mat(std::vector< std::vector< Point2f > >& vv_pt, Mat& mat) { - vector vm; + std::vector vm; vm.reserve( vv_pt.size() ); for(size_t i=0; i >& vv_pt, Mat& mat) vector_Mat_to_Mat(vm, mat); } -void vector_vector_Point3f_to_Mat(vector< vector< Point3f > >& vv_pt, Mat& mat) +void vector_vector_Point3f_to_Mat(std::vector< std::vector< Point3f > >& vv_pt, Mat& mat) { - vector vm; + std::vector vm; vm.reserve( vv_pt.size() ); for(size_t i=0; i >& vv_pt, Mat& mat) vector_Mat_to_Mat(vm, mat); } -void vector_Vec4i_to_Mat(vector& v_vec, Mat& mat) +void vector_Vec4i_to_Mat(std::vector& v_vec, Mat& mat) { mat = Mat(v_vec, true); } -void vector_Vec4f_to_Mat(vector& v_vec, Mat& mat) +void vector_Vec4f_to_Mat(std::vector& v_vec, Mat& mat) { mat = Mat(v_vec, true); } -void vector_Vec6f_to_Mat(vector& v_vec, Mat& mat) +void vector_Vec6f_to_Mat(std::vector& v_vec, Mat& mat) { mat = Mat(v_vec, true); } diff --git a/modules/java/generator/src/cpp/features2d_manual.hpp b/modules/java/generator/src/cpp/features2d_manual.hpp index e03b4ffca..4c43757ff 100644 --- a/modules/java/generator/src/cpp/features2d_manual.hpp +++ b/modules/java/generator/src/cpp/features2d_manual.hpp @@ -16,8 +16,8 @@ class CV_EXPORTS_AS(FeatureDetector) javaFeatureDetector : public FeatureDetecto public: #if 0 //DO NOT REMOVE! The block is required for sources parser - CV_WRAP void detect( const Mat& image, CV_OUT vector& keypoints, const Mat& mask=Mat() ) const; - CV_WRAP void detect( const vector& images, CV_OUT vector >& keypoints, const vector& masks=vector() ) const; + CV_WRAP void detect( const Mat& image, CV_OUT std::vector& keypoints, const Mat& mask=Mat() ) const; + CV_WRAP void detect( const std::vector& images, CV_OUT std::vector >& keypoints, const std::vector& masks=std::vector() ) const; CV_WRAP virtual bool empty() const; #endif @@ -84,7 +84,7 @@ public: //not supported: SimpleBlob, Dense CV_WRAP static javaFeatureDetector* create( int detectorType ) { - string name; + std::string name; if (detectorType > DYNAMICDETECTOR) { name = "Dynamic"; @@ -146,14 +146,14 @@ public: return (javaFeatureDetector*)((FeatureDetector*) detector); } - CV_WRAP void write( const string& fileName ) const + CV_WRAP void write( const std::string& fileName ) const { FileStorage fs(fileName, FileStorage::WRITE); ((FeatureDetector*)this)->write(fs); fs.release(); } - CV_WRAP void read( const string& fileName ) + CV_WRAP void read( const std::string& fileName ) { FileStorage fs(fileName, FileStorage::READ); ((FeatureDetector*)this)->read(fs.root()); @@ -167,25 +167,25 @@ public: #if 0 //DO NOT REMOVE! The block is required for sources parser CV_WRAP virtual bool isMaskSupported() const; - CV_WRAP virtual void add( const vector& descriptors ); - CV_WRAP const vector& getTrainDescriptors() const; + CV_WRAP virtual void add( const std::vector& descriptors ); + CV_WRAP const std::vector& getTrainDescriptors() const; CV_WRAP virtual void clear(); CV_WRAP virtual bool empty() const; CV_WRAP virtual void train(); CV_WRAP void match( const Mat& queryDescriptors, const Mat& trainDescriptors, - CV_OUT vector& matches, const Mat& mask=Mat() ) const; + CV_OUT std::vector& matches, const Mat& mask=Mat() ) const; CV_WRAP void knnMatch( const Mat& queryDescriptors, const Mat& trainDescriptors, - CV_OUT vector >& matches, int k, + CV_OUT std::vector >& matches, int k, const Mat& mask=Mat(), bool compactResult=false ) const; CV_WRAP void radiusMatch( const Mat& queryDescriptors, const Mat& trainDescriptors, - CV_OUT vector >& matches, float maxDistance, + CV_OUT std::vector >& matches, float maxDistance, const Mat& mask=Mat(), bool compactResult=false ) const; - CV_WRAP void match( const Mat& queryDescriptors, CV_OUT vector& matches, - const vector& masks=vector() ); - CV_WRAP void knnMatch( const Mat& queryDescriptors, CV_OUT vector >& matches, int k, - const vector& masks=vector(), bool compactResult=false ); - CV_WRAP void radiusMatch( const Mat& queryDescriptors, CV_OUT vector >& matches, float maxDistance, - const vector& masks=vector(), bool compactResult=false ); + CV_WRAP void match( const Mat& queryDescriptors, CV_OUT std::vector& matches, + const std::vector& masks=std::vector() ); + CV_WRAP void knnMatch( const Mat& queryDescriptors, CV_OUT std::vector >& matches, int k, + const std::vector& masks=std::vector(), bool compactResult=false ); + CV_WRAP void radiusMatch( const Mat& queryDescriptors, CV_OUT std::vector >& matches, float maxDistance, + const std::vector& masks=std::vector(), bool compactResult=false ); #endif enum @@ -208,7 +208,7 @@ public: //supported: FlannBased, BruteForce, BruteForce-L1, BruteForce-Hamming, BruteForce-HammingLUT CV_WRAP static javaDescriptorMatcher* create( int matcherType ) { - string name; + std::string name; switch(matcherType) { @@ -240,14 +240,14 @@ public: return (javaDescriptorMatcher*)((DescriptorMatcher*) matcher); } - CV_WRAP void write( const string& fileName ) const + CV_WRAP void write( const std::string& fileName ) const { FileStorage fs(fileName, FileStorage::WRITE); ((DescriptorMatcher*)this)->write(fs); fs.release(); } - CV_WRAP void read( const string& fileName ) + CV_WRAP void read( const std::string& fileName ) { FileStorage fs(fileName, FileStorage::READ); ((DescriptorMatcher*)this)->read(fs.root()); @@ -260,8 +260,8 @@ class CV_EXPORTS_AS(DescriptorExtractor) javaDescriptorExtractor : public Descri public: #if 0 //DO NOT REMOVE! The block is required for sources parser - CV_WRAP void compute( const Mat& image, vector& keypoints, Mat& descriptors ) const; - CV_WRAP void compute( const vector& images, vector >& keypoints, CV_OUT vector& descriptors ) const; + CV_WRAP void compute( const Mat& image, std::vector& keypoints, Mat& descriptors ) const; + CV_WRAP void compute( const std::vector& images, std::vector >& keypoints, CV_OUT std::vector& descriptors ) const; CV_WRAP virtual int descriptorSize() const; CV_WRAP virtual int descriptorType() const; @@ -294,7 +294,7 @@ public: //not supported: Calonder CV_WRAP static javaDescriptorExtractor* create( int extractorType ) { - string name; + std::string name; if (extractorType > OPPONENTEXTRACTOR) { @@ -332,14 +332,14 @@ public: return (javaDescriptorExtractor*)((DescriptorExtractor*) extractor); } - CV_WRAP void write( const string& fileName ) const + CV_WRAP void write( const std::string& fileName ) const { FileStorage fs(fileName, FileStorage::WRITE); ((DescriptorExtractor*)this)->write(fs); fs.release(); } - CV_WRAP void read( const string& fileName ) + CV_WRAP void read( const std::string& fileName ) { FileStorage fs(fileName, FileStorage::READ); ((DescriptorExtractor*)this)->read(fs.root()); @@ -352,35 +352,35 @@ class CV_EXPORTS_AS(GenericDescriptorMatcher) javaGenericDescriptorMatcher : pub public: #if 0 //DO NOT REMOVE! The block is required for sources parser - CV_WRAP virtual void add( const vector& images, - vector >& keypoints ); - CV_WRAP const vector& getTrainImages() const; - CV_WRAP const vector >& getTrainKeypoints() const; + CV_WRAP virtual void add( const std::vector& images, + std::vector >& keypoints ); + CV_WRAP const std::vector& getTrainImages() const; + CV_WRAP const std::vector >& getTrainKeypoints() const; CV_WRAP virtual void clear(); CV_WRAP virtual bool isMaskSupported(); CV_WRAP virtual void train(); - CV_WRAP void classify( const Mat& queryImage, CV_IN_OUT vector& queryKeypoints, - const Mat& trainImage, vector& trainKeypoints ) const; - CV_WRAP void classify( const Mat& queryImage, CV_IN_OUT vector& queryKeypoints ); - CV_WRAP void match( const Mat& queryImage, vector& queryKeypoints, - const Mat& trainImage, vector& trainKeypoints, - CV_OUT vector& matches, const Mat& mask=Mat() ) const; - CV_WRAP void knnMatch( const Mat& queryImage, vector& queryKeypoints, - const Mat& trainImage, vector& trainKeypoints, - CV_OUT vector >& matches, int k, + CV_WRAP void classify( const Mat& queryImage, CV_IN_OUT std::vector& queryKeypoints, + const Mat& trainImage, std::vector& trainKeypoints ) const; + CV_WRAP void classify( const Mat& queryImage, CV_IN_OUT std::vector& queryKeypoints ); + CV_WRAP void match( const Mat& queryImage, std::vector& queryKeypoints, + const Mat& trainImage, std::vector& trainKeypoints, + CV_OUT std::vector& matches, const Mat& mask=Mat() ) const; + CV_WRAP void knnMatch( const Mat& queryImage, std::vector& queryKeypoints, + const Mat& trainImage, std::vector& trainKeypoints, + CV_OUT std::vector >& matches, int k, const Mat& mask=Mat(), bool compactResult=false ) const; - CV_WRAP void radiusMatch( const Mat& queryImage, vector& queryKeypoints, - const Mat& trainImage, vector& trainKeypoints, - CV_OUT vector >& matches, float maxDistance, + CV_WRAP void radiusMatch( const Mat& queryImage, std::vector& queryKeypoints, + const Mat& trainImage, std::vector& trainKeypoints, + CV_OUT std::vector >& matches, float maxDistance, const Mat& mask=Mat(), bool compactResult=false ) const; - CV_WRAP void match( const Mat& queryImage, vector& queryKeypoints, - CV_OUT vector& matches, const vector& masks=vector() ); - CV_WRAP void knnMatch( const Mat& queryImage, vector& queryKeypoints, - CV_OUT vector >& matches, int k, - const vector& masks=vector(), bool compactResult=false ); - CV_WRAP void radiusMatch( const Mat& queryImage, vector& queryKeypoints, - CV_OUT vector >& matches, float maxDistance, - const vector& masks=vector(), bool compactResult=false ); + CV_WRAP void match( const Mat& queryImage, std::vector& queryKeypoints, + CV_OUT std::vector& matches, const std::vector& masks=std::vector() ); + CV_WRAP void knnMatch( const Mat& queryImage, std::vector& queryKeypoints, + CV_OUT std::vector >& matches, int k, + const std::vector& masks=std::vector(), bool compactResult=false ); + CV_WRAP void radiusMatch( const Mat& queryImage, std::vector& queryKeypoints, + CV_OUT std::vector >& matches, float maxDistance, + const std::vector& masks=std::vector(), bool compactResult=false ); CV_WRAP virtual bool empty() const; #endif @@ -401,7 +401,7 @@ public: //unsupported: Vector CV_WRAP static javaGenericDescriptorMatcher* create( int matcherType ) { - string name; + std::string name; switch(matcherType) { @@ -421,14 +421,14 @@ public: return (javaGenericDescriptorMatcher*)((GenericDescriptorMatcher*) matcher); } - CV_WRAP void write( const string& fileName ) const + CV_WRAP void write( const std::string& fileName ) const { FileStorage fs(fileName, FileStorage::WRITE); ((GenericDescriptorMatcher*)this)->write(fs); fs.release(); } - CV_WRAP void read( const string& fileName ) + CV_WRAP void read( const std::string& fileName ) { FileStorage fs(fileName, FileStorage::READ); ((GenericDescriptorMatcher*)this)->read(fs.root()); @@ -448,21 +448,21 @@ enum }; // Draw keypoints. -CV_EXPORTS_W void drawKeypoints( const Mat& image, const vector& keypoints, Mat& outImage, +CV_EXPORTS_W void drawKeypoints( const Mat& image, const std::vector& keypoints, Mat& outImage, const Scalar& color=Scalar::all(-1), int flags=0 ); // Draws matches of keypints from two images on output image. -CV_EXPORTS_W void drawMatches( const Mat& img1, const vector& keypoints1, - const Mat& img2, const vector& keypoints2, - const vector& matches1to2, Mat& outImg, +CV_EXPORTS_W void drawMatches( const Mat& img1, const std::vector& keypoints1, + const Mat& img2, const std::vector& keypoints2, + const std::vector& matches1to2, Mat& outImg, const Scalar& matchColor=Scalar::all(-1), const Scalar& singlePointColor=Scalar::all(-1), - const vector& matchesMask=vector(), int flags=0 ); + const std::vector& matchesMask=std::vector(), int flags=0 ); -CV_EXPORTS_AS(drawMatches2) void drawMatches( const Mat& img1, const vector& keypoints1, - const Mat& img2, const vector& keypoints2, - const vector >& matches1to2, Mat& outImg, +CV_EXPORTS_AS(drawMatches2) void drawMatches( const Mat& img1, const std::vector& keypoints1, + const Mat& img2, const std::vector& keypoints2, + const std::vector >& matches1to2, Mat& outImg, const Scalar& matchColor=Scalar::all(-1), const Scalar& singlePointColor=Scalar::all(-1), - const vector >& matchesMask=vector >(), int flags=0); + const std::vector >& matchesMask=std::vector >(), int flags=0); #endif diff --git a/modules/legacy/include/opencv2/legacy/legacy.hpp b/modules/legacy/include/opencv2/legacy/legacy.hpp index 114413128..104aace82 100644 --- a/modules/legacy/include/opencv2/legacy/legacy.hpp +++ b/modules/legacy/include/opencv2/legacy/legacy.hpp @@ -1877,17 +1877,17 @@ public: LDetector(int _radius, int _threshold, int _nOctaves, int _nViews, double _baseFeatureSize, double _clusteringDistance); void operator()(const Mat& image, - CV_OUT vector& keypoints, + CV_OUT std::vector& keypoints, int maxCount=0, bool scaleCoords=true) const; - void operator()(const vector& pyr, - CV_OUT vector& keypoints, + void operator()(const std::vector& pyr, + CV_OUT std::vector& keypoints, int maxCount=0, bool scaleCoords=true) const; - void getMostStable2D(const Mat& image, CV_OUT vector& keypoints, + void getMostStable2D(const Mat& image, CV_OUT std::vector& keypoints, int maxCount, const PatchGenerator& patchGenerator) const; void setVerbose(bool verbose); void read(const FileNode& node); - void write(FileStorage& fs, const String& name=String()) const; + void write(FileStorage& fs, const std::string& name=std::string()) const; int radius; int threshold; @@ -1906,9 +1906,9 @@ class CV_EXPORTS FernClassifier public: FernClassifier(); FernClassifier(const FileNode& node); - FernClassifier(const vector >& points, - const vector& refimgs, - const vector >& labels=vector >(), + FernClassifier(const std::vector >& points, + const std::vector& refimgs, + const std::vector >& labels=std::vector >(), int _nclasses=0, int _patchSize=PATCH_SIZE, int _signatureSize=DEFAULT_SIGNATURE_SIZE, int _nstructs=DEFAULT_STRUCTS, @@ -1918,9 +1918,9 @@ public: const PatchGenerator& patchGenerator=PatchGenerator()); virtual ~FernClassifier(); virtual void read(const FileNode& n); - virtual void write(FileStorage& fs, const String& name=String()) const; + virtual void write(FileStorage& fs, const std::string& name=std::string()) const; virtual void trainFromSingleView(const Mat& image, - const vector& keypoints, + const std::vector& keypoints, int _patchSize=PATCH_SIZE, int _signatureSize=DEFAULT_SIGNATURE_SIZE, int _nstructs=DEFAULT_STRUCTS, @@ -1928,9 +1928,9 @@ public: int _nviews=DEFAULT_VIEWS, int _compressionMethod=COMPRESSION_NONE, const PatchGenerator& patchGenerator=PatchGenerator()); - virtual void train(const vector >& points, - const vector& refimgs, - const vector >& labels=vector >(), + virtual void train(const std::vector >& points, + const std::vector& refimgs, + const std::vector >& labels=std::vector >(), int _nclasses=0, int _patchSize=PATCH_SIZE, int _signatureSize=DEFAULT_SIGNATURE_SIZE, int _nstructs=DEFAULT_STRUCTS, @@ -1938,8 +1938,8 @@ public: int _nviews=DEFAULT_VIEWS, int _compressionMethod=COMPRESSION_NONE, const PatchGenerator& patchGenerator=PatchGenerator()); - virtual int operator()(const Mat& img, Point2f kpt, vector& signature) const; - virtual int operator()(const Mat& patch, vector& signature) const; + virtual int operator()(const Mat& img, Point2f kpt, std::vector& signature) const; + virtual int operator()(const Mat& patch, std::vector& signature) const; virtual void clear(); virtual bool empty() const; void setVerbose(bool verbose); @@ -1990,9 +1990,9 @@ protected: int compressionMethod; int leavesPerStruct; Size patchSize; - vector features; - vector classCounters; - vector posteriors; + std::vector features; + std::vector classCounters; + std::vector posteriors; }; @@ -2032,9 +2032,9 @@ public: RandomizedTree(); ~RandomizedTree(); - void train(vector const& base_set, RNG &rng, + void train(std::vector const& base_set, RNG &rng, int depth, int views, size_t reduced_num_dim, int num_quant_bits); - void train(vector const& base_set, RNG &rng, + void train(std::vector const& base_set, RNG &rng, PatchGenerator &make_patch, int depth, int views, size_t reduced_num_dim, int num_quant_bits); @@ -2069,10 +2069,10 @@ private: int classes_; int depth_; int num_leaves_; - vector nodes_; + std::vector nodes_; float **posteriors_; // 16-bytes aligned posteriors uchar **posteriors2_; // 16-bytes aligned posteriors - vector leaf_counts_; + std::vector leaf_counts_; void createNodes(int num_nodes, RNG &rng); void allocPosteriorsAligned(int num_leaves, int num_classes); @@ -2142,14 +2142,14 @@ public: static const size_t DEFAULT_NUM_QUANT_BITS = 4; RTreeClassifier(); - void train(vector const& base_set, + void train(std::vector const& base_set, RNG &rng, int num_trees = RTreeClassifier::DEFAULT_TREES, int depth = RandomizedTree::DEFAULT_DEPTH, int views = RandomizedTree::DEFAULT_VIEWS, size_t reduced_num_dim = RandomizedTree::DEFAULT_REDUCED_NUM_DIM, int num_quant_bits = DEFAULT_NUM_QUANT_BITS); - void train(vector const& base_set, + void train(std::vector const& base_set, RNG &rng, PatchGenerator &make_patch, int num_trees = RTreeClassifier::DEFAULT_TREES, @@ -2186,7 +2186,7 @@ public: void setFloatPosteriorsFromTextfile_176(std::string url); float countZeroElements(); - vector trees_; + std::vector trees_; private: int classes_; @@ -2356,7 +2356,7 @@ protected: CvAffinePose* m_affine_poses; // an array of poses CvMat** m_transforms; // an array of affine transforms corresponding to poses - string m_feature_name; // the name of the feature associated with the descriptor + std::string m_feature_name; // the name of the feature associated with the descriptor CvPoint m_center; // the coordinates of the feature (the center of the input image ROI) int m_pca_dim_high; // the number of descriptor pca components to use for generating affine poses @@ -2382,7 +2382,7 @@ public: const char* pca_hr_config = 0, const char* pca_desc_config = 0, int pyr_levels = 1, int pca_dim_high = 100, int pca_dim_low = 100); - OneWayDescriptorBase(CvSize patch_size, int pose_count, const string &pca_filename, const string &train_path = string(), const string &images_list = string(), + OneWayDescriptorBase(CvSize patch_size, int pose_count, const std::string &pca_filename, const std::string &train_path = std::string(), const std::string &images_list = std::string(), float _scale_min = 0.7f, float _scale_max=1.5f, float _scale_step=1.2f, int pyr_levels = 1, int pca_dim_high = 100, int pca_dim_low = 100); @@ -2412,7 +2412,7 @@ public: // - src: input image // - features: input features // - pyr_levels: the number of pyramid levels - void CreateDescriptorsFromImage(IplImage* src, const vector& features); + void CreateDescriptorsFromImage(IplImage* src, const std::vector& features); // CreatePCADescriptors: generates descriptors for PCA components, needed for fast generation of feature descriptors void CreatePCADescriptors(); @@ -2436,8 +2436,8 @@ public: // - distances: distance from the input patch to the closest feature pose (n) // - _scales: scales of the input patch // - scale_ranges: input scales variation (float[2]) - void FindDescriptor(IplImage* patch, int n, vector& desc_idxs, vector& pose_idxs, - vector& distances, vector& _scales, float* scale_ranges = 0) const; + void FindDescriptor(IplImage* patch, int n, std::vector& desc_idxs, std::vector& pose_idxs, + std::vector& distances, std::vector& _scales, float* scale_ranges = 0) const; // FindDescriptor: finds the closest descriptor // - src: input image @@ -2465,7 +2465,7 @@ public: void InitializeDescriptor(int desc_idx, IplImage* train_image, const KeyPoint& keypoint, const char* feature_label); // InitializeDescriptors: load features from an image and create descriptors for each of them - void InitializeDescriptors(IplImage* train_image, const vector& features, + void InitializeDescriptors(IplImage* train_image, const std::vector& features, const char* feature_label = "", int desc_start_idx = 0); // Write: writes this object to a file storage @@ -2516,7 +2516,7 @@ public: void ConvertDescriptorsArrayToTree(); // Converting pca_descriptors array to KD tree // GetPCAFilename: get default PCA filename - static string GetPCAFilename () { return "pca.yml"; } + static std::string GetPCAFilename () { return "pca.yml"; } virtual bool empty() const { return m_train_feature_count <= 0 ? true : false; } @@ -2568,8 +2568,8 @@ public: OneWayDescriptorObject(CvSize patch_size, int pose_count, const char* train_path, const char* pca_config, const char* pca_hr_config = 0, const char* pca_desc_config = 0, int pyr_levels = 1); - OneWayDescriptorObject(CvSize patch_size, int pose_count, const string &pca_filename, - const string &train_path = string (), const string &images_list = string (), + OneWayDescriptorObject(CvSize patch_size, int pose_count, const std::string &pca_filename, + const std::string &train_path = std::string (), const std::string &images_list = std::string (), float _scale_min = 0.7f, float _scale_max=1.5f, float _scale_step=1.2f, int pyr_levels = 1); @@ -2581,10 +2581,10 @@ public: void Allocate(int train_feature_count, int object_feature_count); - void SetLabeledFeatures(const vector& features) {m_train_features = features;}; - vector& GetLabeledFeatures() {return m_train_features;}; - const vector& GetLabeledFeatures() const {return m_train_features;}; - vector _GetLabeledFeatures() const; + void SetLabeledFeatures(const std::vector& features) {m_train_features = features;}; + std::vector& GetLabeledFeatures() {return m_train_features;}; + const std::vector& GetLabeledFeatures() const {return m_train_features;}; + std::vector _GetLabeledFeatures() const; // IsDescriptorObject: returns 1 if descriptor with specified index is positive, otherwise 0 int IsDescriptorObject(int desc_idx) const; @@ -2597,7 +2597,7 @@ public: int GetDescriptorPart(int desc_idx) const; - void InitializeObjectDescriptors(IplImage* train_image, const vector& features, + void InitializeObjectDescriptors(IplImage* train_image, const std::vector& features, const char* feature_label, int desc_start_idx = 0, float scale = 1.0f, int is_background = 0); @@ -2606,7 +2606,7 @@ public: protected: int* m_part_id; // contains part id for each of object descriptors - vector m_train_features; // train features + std::vector m_train_features; // train features int m_object_feature_count; // the number of the positive features }; @@ -2633,16 +2633,16 @@ public: Params( int poseCount = POSE_COUNT, Size patchSize = Size(PATCH_WIDTH, PATCH_HEIGHT), - string pcaFilename = string(), - string trainPath = string(), string trainImagesList = string(), + std::string pcaFilename = std::string(), + std::string trainPath = std::string(), std::string trainImagesList = std::string(), float minScale = GET_MIN_SCALE(), float maxScale = GET_MAX_SCALE(), float stepScale = GET_STEP_SCALE() ); int poseCount; Size patchSize; - string pcaFilename; - string trainPath; - string trainImagesList; + std::string pcaFilename; + std::string trainPath; + std::string trainImagesList; float minScale, maxScale, stepScale; }; @@ -2673,12 +2673,12 @@ protected: // The minimum distance to each training patch with all its affine poses is found over all scales. // The class ID of a match is returned for each keypoint. The distance is calculated over PCA components // loaded with DescriptorOneWay::Initialize, kd tree is used for finding minimum distances. - virtual void knnMatchImpl( const Mat& queryImage, vector& queryKeypoints, - vector >& matches, int k, - const vector& masks, bool compactResult ); - virtual void radiusMatchImpl( const Mat& queryImage, vector& queryKeypoints, - vector >& matches, float maxDistance, - const vector& masks, bool compactResult ); + virtual void knnMatchImpl( const Mat& queryImage, std::vector& queryKeypoints, + std::vector >& matches, int k, + const std::vector& masks, bool compactResult ); + virtual void radiusMatchImpl( const Mat& queryImage, std::vector& queryKeypoints, + std::vector >& matches, float maxDistance, + const std::vector& masks, bool compactResult ); Ptr base; Params params; @@ -2706,7 +2706,7 @@ public: int compressionMethod=FernClassifier::COMPRESSION_NONE, const PatchGenerator& patchGenerator=PatchGenerator() ); - Params( const string& filename ); + Params( const std::string& filename ); int nclasses; int patchSize; @@ -2717,7 +2717,7 @@ public: int compressionMethod; PatchGenerator patchGenerator; - string filename; + std::string filename; }; FernDescriptorMatcher( const Params& params=Params() ); @@ -2736,16 +2736,16 @@ public: virtual Ptr clone( bool emptyTrainData=false ) const; protected: - virtual void knnMatchImpl( const Mat& queryImage, vector& queryKeypoints, - vector >& matches, int k, - const vector& masks, bool compactResult ); - virtual void radiusMatchImpl( const Mat& queryImage, vector& queryKeypoints, - vector >& matches, float maxDistance, - const vector& masks, bool compactResult ); + virtual void knnMatchImpl( const Mat& queryImage, std::vector& queryKeypoints, + std::vector >& matches, int k, + const std::vector& masks, bool compactResult ); + virtual void radiusMatchImpl( const Mat& queryImage, std::vector& queryKeypoints, + std::vector >& matches, float maxDistance, + const std::vector& masks, bool compactResult ); void trainFernClassifier(); void calcBestProbAndMatchIdx( const Mat& image, const Point2f& pt, - float& bestProb, int& bestMatchIdx, vector& signature ); + float& bestProb, int& bestMatchIdx, std::vector& signature ); Ptr classifier; Params params; int prevTrainCount; @@ -2759,7 +2759,7 @@ template class CV_EXPORTS CalonderDescriptorExtractor : public DescriptorExtractor { public: - CalonderDescriptorExtractor( const string& classifierFile ); + CalonderDescriptorExtractor( const std::string& classifierFile ); virtual void read( const FileNode &fn ); virtual void write( FileStorage &fs ) const; @@ -2770,7 +2770,7 @@ public: virtual bool empty() const; protected: - virtual void computeImpl( const Mat& image, vector& keypoints, Mat& descriptors ) const; + virtual void computeImpl( const Mat& image, std::vector& keypoints, Mat& descriptors ) const; RTreeClassifier classifier_; static const int BORDER_SIZE = 16; @@ -2784,7 +2784,7 @@ CalonderDescriptorExtractor::CalonderDescriptorExtractor(const std::string& c template void CalonderDescriptorExtractor::computeImpl( const Mat& image, - vector& keypoints, + std::vector& keypoints, Mat& descriptors) const { // Cannot compute descriptors for keypoints on the image border. @@ -2838,7 +2838,7 @@ class CV_EXPORTS PlanarObjectDetector public: PlanarObjectDetector(); PlanarObjectDetector(const FileNode& node); - PlanarObjectDetector(const vector& pyr, int _npoints=300, + PlanarObjectDetector(const std::vector& pyr, int _npoints=300, int _patchSize=FernClassifier::PATCH_SIZE, int _nstructs=FernClassifier::DEFAULT_STRUCTS, int _structSize=FernClassifier::DEFAULT_STRUCT_SIZE, @@ -2846,14 +2846,14 @@ public: const LDetector& detector=LDetector(), const PatchGenerator& patchGenerator=PatchGenerator()); virtual ~PlanarObjectDetector(); - virtual void train(const vector& pyr, int _npoints=300, + virtual void train(const std::vector& pyr, int _npoints=300, int _patchSize=FernClassifier::PATCH_SIZE, int _nstructs=FernClassifier::DEFAULT_STRUCTS, int _structSize=FernClassifier::DEFAULT_STRUCT_SIZE, int _nviews=FernClassifier::DEFAULT_VIEWS, const LDetector& detector=LDetector(), const PatchGenerator& patchGenerator=PatchGenerator()); - virtual void train(const vector& pyr, const vector& keypoints, + virtual void train(const std::vector& pyr, const std::vector& keypoints, int _patchSize=FernClassifier::PATCH_SIZE, int _nstructs=FernClassifier::DEFAULT_STRUCTS, int _structSize=FernClassifier::DEFAULT_STRUCT_SIZE, @@ -2861,22 +2861,22 @@ public: const LDetector& detector=LDetector(), const PatchGenerator& patchGenerator=PatchGenerator()); Rect getModelROI() const; - vector getModelPoints() const; + std::vector getModelPoints() const; const LDetector& getDetector() const; const FernClassifier& getClassifier() const; void setVerbose(bool verbose); void read(const FileNode& node); - void write(FileStorage& fs, const String& name=String()) const; - bool operator()(const Mat& image, CV_OUT Mat& H, CV_OUT vector& corners) const; - bool operator()(const vector& pyr, const vector& keypoints, - CV_OUT Mat& H, CV_OUT vector& corners, - CV_OUT vector* pairs=0) const; + void write(FileStorage& fs, const std::string& name=std::string()) const; + bool operator()(const Mat& image, CV_OUT Mat& H, CV_OUT std::vector& corners) const; + bool operator()(const std::vector& pyr, const std::vector& keypoints, + CV_OUT Mat& H, CV_OUT std::vector& corners, + CV_OUT std::vector* pairs=0) const; protected: bool verbose; Rect modelROI; - vector modelPoints; + std::vector modelPoints; LDetector ldetector; FernClassifier fernClassifier; }; diff --git a/modules/legacy/src/calonder.cpp b/modules/legacy/src/calonder.cpp index b53e7d8fc..73f274862 100644 --- a/modules/legacy/src/calonder.cpp +++ b/modules/legacy/src/calonder.cpp @@ -44,8 +44,6 @@ #include #include -using namespace std; - class CSMatrixGenerator { public: typedef enum { PDT_GAUSS=1, PDT_BERNOULLI, PDT_DBFRIENDLY } PHI_DISTR_TYPE; diff --git a/modules/legacy/src/em.cpp b/modules/legacy/src/em.cpp index 05e667899..200f74313 100644 --- a/modules/legacy/src/em.cpp +++ b/modules/legacy/src/em.cpp @@ -123,7 +123,7 @@ void CvEM::set_mat_hdrs() int K = emObj.get("nclusters"); covsHdrs.resize(K); covsPtrs.resize(K); - const std::vector& covs = emObj.get >("covs"); + const std::vector& covs = emObj.get >("covs"); for(size_t i = 0; i < covsHdrs.size(); i++) { covsHdrs[i] = covs[i]; @@ -137,7 +137,7 @@ void CvEM::set_mat_hdrs() static void init_params(const CvEMParams& src, Mat& prbs, Mat& weights, - Mat& means, vector& covsHdrs) + Mat& means, std::vector& covsHdrs) { prbs = src.probs; weights = src.weights; @@ -244,9 +244,9 @@ Mat CvEM::getMeans() const return emObj.get("means"); } -void CvEM::getCovs(vector& _covs) const +void CvEM::getCovs(std::vector& _covs) const { - _covs = emObj.get >("covs"); + _covs = emObj.get >("covs"); } Mat CvEM::getWeights() const diff --git a/modules/legacy/src/features2d.cpp b/modules/legacy/src/features2d.cpp index 93ab461c0..e985ec226 100644 --- a/modules/legacy/src/features2d.cpp +++ b/modules/legacy/src/features2d.cpp @@ -69,7 +69,7 @@ cvExtractSURF( const CvArr* _img, const CvArr* _mask, Mat img = cvarrToMat(_img), mask; if(_mask) mask = cvarrToMat(_mask); - vector kpt; + std::vector kpt; Mat descr; Ptr surf = Algorithm::create("Feature2D.SURF"); @@ -111,7 +111,7 @@ cvGetStarKeypoints( const CvArr* _img, CvMemStorage* storage, params.lineThresholdProjected, params.lineThresholdBinarized, params.suppressNonmaxSize); - vector kpts; + std::vector kpts; star->detect(cvarrToMat(_img), kpts, Mat()); CvSeq* seq = cvCreateSeq(0, sizeof(CvSeq), sizeof(CvStarKeypoint), storage); diff --git a/modules/legacy/src/oneway.cpp b/modules/legacy/src/oneway.cpp index f838c2ae7..f4c0a992b 100644 --- a/modules/legacy/src/oneway.cpp +++ b/modules/legacy/src/oneway.cpp @@ -145,9 +145,9 @@ namespace cv{ void readPCAFeatures(const char *filename, CvMat** avg, CvMat** eigenvectors, const char *postfix = ""); void readPCAFeatures(const FileNode &fn, CvMat** avg, CvMat** eigenvectors, const char* postfix = ""); void savePCAFeatures(FileStorage &fs, const char* postfix, CvMat* avg, CvMat* eigenvectors); - void calcPCAFeatures(vector& patches, FileStorage &fs, const char* postfix, CvMat** avg, + void calcPCAFeatures(std::vector& patches, FileStorage &fs, const char* postfix, CvMat** avg, CvMat** eigenvectors); - void loadPCAFeatures(const char* path, const char* images_list, vector& patches, CvSize patch_size); + void loadPCAFeatures(const char* path, const char* images_list, std::vector& patches, CvSize patch_size); void generatePCAFeatures(const char* path, const char* img_filename, FileStorage& fs, const char* postfix, CvSize patch_size, CvMat** avg, CvMat** eigenvectors); @@ -1287,8 +1287,8 @@ namespace cv{ } - OneWayDescriptorBase::OneWayDescriptorBase(CvSize patch_size, int pose_count, const string &pca_filename, - const string &train_path, const string &images_list, float _scale_min, float _scale_max, + OneWayDescriptorBase::OneWayDescriptorBase(CvSize patch_size, int pose_count, const std::string &pca_filename, + const std::string &train_path, const std::string &images_list, float _scale_min, float _scale_max, float _scale_step, int pyr_levels, int pca_dim_high, int pca_dim_low) : m_pca_dim_high(pca_dim_high), m_pca_dim_low(pca_dim_low), scale_min(_scale_min), scale_max(_scale_max), scale_step(_scale_step) @@ -1695,7 +1695,7 @@ namespace cv{ fs.writeObj(buf, eigenvectors); } - void calcPCAFeatures(vector& patches, FileStorage &fs, const char* postfix, CvMat** avg, + void calcPCAFeatures(std::vector& patches, FileStorage &fs, const char* postfix, CvMat** avg, CvMat** eigenvectors) { int width = patches[0]->width; @@ -1732,9 +1732,9 @@ namespace cv{ cvReleaseMat(&eigenvalues); } - static void extractPatches (IplImage *img, vector& patches, CvSize patch_size) + static void extractPatches (IplImage *img, std::vector& patches, CvSize patch_size) { - vector features; + std::vector features; Ptr surf_extractor = FeatureDetector::create("SURF"); if( surf_extractor.empty() ) CV_Error(CV_StsNotImplemented, "OpenCV was built without SURF support"); @@ -1767,7 +1767,7 @@ namespace cv{ } /* - void loadPCAFeatures(const FileNode &fn, vector& patches, CvSize patch_size) + void loadPCAFeatures(const FileNode &fn, std::vector& patches, CvSize patch_size) { FileNodeIterator begin = fn.begin(); for (FileNodeIterator i = fn.begin(); i != fn.end(); i++) @@ -1779,7 +1779,7 @@ namespace cv{ } */ - void loadPCAFeatures(const char* path, const char* images_list, vector& patches, CvSize patch_size) + void loadPCAFeatures(const char* path, const char* images_list, std::vector& patches, CvSize patch_size) { char images_filename[1024]; sprintf(images_filename, "%s/%s", path, images_list); @@ -1819,7 +1819,7 @@ namespace cv{ void generatePCAFeatures(const char* path, const char* img_filename, FileStorage& fs, const char* postfix, CvSize patch_size, CvMat** avg, CvMat** eigenvectors) { - vector patches; + std::vector patches; loadPCAFeatures(path, img_filename, patches, patch_size); calcPCAFeatures(patches, fs, postfix, avg, eigenvectors); } @@ -1828,7 +1828,7 @@ namespace cv{ void generatePCAFeatures(const FileNode &fn, const char* postfix, CvSize patch_size, CvMat** avg, CvMat** eigenvectors) { - vector patches; + std::vector patches; loadPCAFeatures(fn, patches, patch_size); calcPCAFeatures(patches, fs, postfix, avg, eigenvectors); } @@ -1951,7 +1951,7 @@ namespace cv{ } } - void OneWayDescriptorBase::InitializeDescriptors(IplImage* train_image, const vector& features, + void OneWayDescriptorBase::InitializeDescriptors(IplImage* train_image, const std::vector& features, const char* feature_label, int desc_start_idx) { for(int i = 0; i < (int)features.size(); i++) @@ -2027,7 +2027,7 @@ namespace cv{ } - void OneWayDescriptorObject::InitializeObjectDescriptors(IplImage* train_image, const vector& features, + void OneWayDescriptorObject::InitializeObjectDescriptors(IplImage* train_image, const std::vector& features, const char* feature_label, int desc_start_idx, float scale, int is_background) { InitializeDescriptors(train_image, features, feature_label, desc_start_idx); @@ -2080,8 +2080,8 @@ namespace cv{ m_part_id = 0; } - OneWayDescriptorObject::OneWayDescriptorObject(CvSize patch_size, int pose_count, const string &pca_filename, - const string &train_path, const string &images_list, float _scale_min, float _scale_max, float _scale_step, int pyr_levels) : + OneWayDescriptorObject::OneWayDescriptorObject(CvSize patch_size, int pose_count, const std::string &pca_filename, + const std::string &train_path, const std::string &images_list, float _scale_min, float _scale_max, float _scale_step, int pyr_levels) : OneWayDescriptorBase(patch_size, pose_count, pca_filename, train_path, images_list, _scale_min, _scale_max, _scale_step, pyr_levels) { m_part_id = 0; @@ -2093,9 +2093,9 @@ namespace cv{ delete []m_part_id; } - vector OneWayDescriptorObject::_GetLabeledFeatures() const + std::vector OneWayDescriptorObject::_GetLabeledFeatures() const { - vector features; + std::vector features; for(size_t i = 0; i < m_train_features.size(); i++) { features.push_back(m_train_features[i]); @@ -2166,8 +2166,8 @@ namespace cv{ * OneWayDescriptorMatcher * \****************************************************************************************/ - OneWayDescriptorMatcher::Params::Params( int _poseCount, Size _patchSize, string _pcaFilename, - string _trainPath, string _trainImagesList, + OneWayDescriptorMatcher::Params::Params( int _poseCount, Size _patchSize, std::string _pcaFilename, + std::string _trainPath, std::string _trainImagesList, float _minScale, float _maxScale, float _stepScale ) : poseCount(_poseCount), patchSize(_patchSize), pcaFilename(_pcaFilename), trainPath(_trainPath), trainImagesList(_trainImagesList), @@ -2212,7 +2212,7 @@ namespace cv{ base->Allocate( (int)trainPointCollection.keypointCount() ); prevTrainCount = (int)trainPointCollection.keypointCount(); - const vector >& points = trainPointCollection.getKeypoints(); + const std::vector >& points = trainPointCollection.getKeypoints(); int count = 0; for( size_t i = 0; i < points.size(); i++ ) { @@ -2232,9 +2232,9 @@ namespace cv{ return false; } - void OneWayDescriptorMatcher::knnMatchImpl( const Mat& queryImage, vector& queryKeypoints, - vector >& matches, int knn, - const vector& /*masks*/, bool /*compactResult*/ ) + void OneWayDescriptorMatcher::knnMatchImpl( const Mat& queryImage, std::vector& queryKeypoints, + std::vector >& matches, int knn, + const std::vector& /*masks*/, bool /*compactResult*/ ) { train(); @@ -2251,9 +2251,9 @@ namespace cv{ } } - void OneWayDescriptorMatcher::radiusMatchImpl( const Mat& queryImage, vector& queryKeypoints, - vector >& matches, float maxDistance, - const vector& /*masks*/, bool /*compactResult*/ ) + void OneWayDescriptorMatcher::radiusMatchImpl( const Mat& queryImage, std::vector& queryKeypoints, + std::vector >& matches, float maxDistance, + const std::vector& /*masks*/, bool /*compactResult*/ ) { train(); @@ -2271,7 +2271,7 @@ namespace cv{ void OneWayDescriptorMatcher::read( const FileNode &fn ) { - base = new OneWayDescriptorObject( params.patchSize, params.poseCount, string (), string (), string (), + base = new OneWayDescriptorObject( params.patchSize, params.poseCount, std::string (), std::string (), std::string (), params.minScale, params.maxScale, params.stepScale ); base->Read (fn); } diff --git a/modules/legacy/src/optflowbm.cpp b/modules/legacy/src/optflowbm.cpp index 53d843892..afab0c1fe 100644 --- a/modules/legacy/src/optflowbm.cpp +++ b/modules/legacy/src/optflowbm.cpp @@ -99,7 +99,7 @@ cvCalcOpticalFlowBM( const void* srcarrA, const void* srcarrB, const int BIG_DIFF=128; // scanning scheme coordinates - cv::vector _ss((2 * maxRange.width + 1) * (2 * maxRange.height + 1)); + std::vector _ss((2 * maxRange.width + 1) * (2 * maxRange.height + 1)); CvPoint* ss = &_ss[0]; int ss_count = 0; @@ -110,7 +110,7 @@ cvCalcOpticalFlowBM( const void* srcarrA, const void* srcarrB, int i, j; - cv::vector _blockA(cvAlign(blSize + 16, 16)); + std::vector _blockA(cvAlign(blSize + 16, 16)); uchar* blockA = (uchar*)cvAlignPtr(&_blockA[0], 16); // Calculate scanning scheme diff --git a/modules/legacy/src/planardetect.cpp b/modules/legacy/src/planardetect.cpp index ca699754d..6c5e96ff8 100644 --- a/modules/legacy/src/planardetect.cpp +++ b/modules/legacy/src/planardetect.cpp @@ -253,7 +253,7 @@ LDetector::LDetector(int _radius, int _threshold, int _nOctaves, int _nViews, { } -static void getDiscreteCircle(int R, vector& circle, vector& filledHCircle) +static void getDiscreteCircle(int R, std::vector& circle, std::vector& filledHCircle) { int x = R, y = 0; for( ;;y++ ) @@ -310,7 +310,7 @@ struct CmpKeypointScores }; -void LDetector::getMostStable2D(const Mat& image, vector& keypoints, +void LDetector::getMostStable2D(const Mat& image, std::vector& keypoints, int maxPoints, const PatchGenerator& _patchGenerator) const { PatchGenerator patchGenerator = _patchGenerator; @@ -321,7 +321,7 @@ void LDetector::getMostStable2D(const Mat& image, vector& keypoints, double *M = (double*)matM.data, *iM = (double*)_iM.data; RNG& rng = theRNG(); int i, k; - vector tempKeypoints; + std::vector tempKeypoints; double d2 = clusteringDistance*clusteringDistance; keypoints.clear(); @@ -427,21 +427,21 @@ static Point2f adjustCorner(const float* fval, float& fvaln) return Point2f((float)dx, (float)dy); } -void LDetector::operator()(const Mat& image, vector& keypoints, int maxCount, bool scaleCoords) const +void LDetector::operator()(const Mat& image, std::vector& keypoints, int maxCount, bool scaleCoords) const { - vector pyr; + std::vector pyr; buildPyramid(image, pyr, std::max(nOctaves-1, 0)); (*this)(pyr, keypoints, maxCount, scaleCoords); } -void LDetector::operator()(const vector& pyr, vector& keypoints, int maxCount, bool scaleCoords) const +void LDetector::operator()(const std::vector& pyr, std::vector& keypoints, int maxCount, bool scaleCoords) const { const int lthreshold = 3; int L, x, y, i, j, k, tau = lthreshold; Mat scoreBuf(pyr[0].size(), CV_16S), maskBuf(pyr[0].size(), CV_8U); int scoreElSize = (int)scoreBuf.elemSize(); - vector circle0; - vector fhcircle0, circle, fcircle_s, fcircle; + std::vector circle0; + std::vector fhcircle0, circle, fcircle_s, fcircle; getDiscreteCircle(radius, circle0, fhcircle0); CV_Assert(fhcircle0.size() == (size_t)(radius+1) && circle0.size() % 2 == 0); keypoints.clear(); @@ -617,7 +617,7 @@ void LDetector::read(const FileNode& objnode) clusteringDistance = (int)objnode["clustering-distance"]; } -void LDetector::write(FileStorage& fs, const String& name) const +void LDetector::write(FileStorage& fs, const std::string& name) const { WriteStructContext ws(fs, name, CV_NODE_MAP); @@ -691,9 +691,9 @@ Size FernClassifier::getPatchSize() const } -FernClassifier::FernClassifier(const vector >& points, - const vector& refimgs, - const vector >& labels, +FernClassifier::FernClassifier(const std::vector >& points, + const std::vector& refimgs, + const std::vector >& labels, int _nclasses, int _patchSize, int _signatureSize, int _nstructs, int _structSize, int _nviews, int _compressionMethod, @@ -707,7 +707,7 @@ FernClassifier::FernClassifier(const vector >& points, } -void FernClassifier::write(FileStorage& fs, const String& objname) const +void FernClassifier::write(FileStorage& fs, const std::string& objname) const { WriteStructContext ws(fs, objname, CV_NODE_MAP); @@ -767,8 +767,8 @@ void FernClassifier::read(const FileNode& objnode) void FernClassifier::clear() { signatureSize = nclasses = nstructs = structSize = compressionMethod = leavesPerStruct = 0; - vector().swap(features); - vector().swap(posteriors); + std::vector().swap(features); + std::vector().swap(posteriors); } bool FernClassifier::empty() const @@ -815,9 +815,9 @@ void FernClassifier::prepare(int _nclasses, int _patchSize, int _signatureSize, int i, nfeatures = structSize*nstructs; - features = vector( nfeatures ); - posteriors = vector( leavesPerStruct*nstructs*nclasses, 1.f ); - classCounters = vector( nclasses, leavesPerStruct ); + features = std::vector( nfeatures ); + posteriors = std::vector( leavesPerStruct*nstructs*nclasses, 1.f ); + classCounters = std::vector( nclasses, leavesPerStruct ); CV_Assert( patchSize.width <= 256 && patchSize.height <= 256 ); RNG& rng = theRNG(); @@ -832,7 +832,7 @@ void FernClassifier::prepare(int _nclasses, int _patchSize, int _signatureSize, } } -static int calcNumPoints( const vector >& points ) +static int calcNumPoints( const std::vector >& points ) { size_t count = 0; for( size_t i = 0; i < points.size(); i++ ) @@ -840,9 +840,9 @@ static int calcNumPoints( const vector >& points ) return (int)count; } -void FernClassifier::train(const vector >& points, - const vector& refimgs, - const vector >& labels, +void FernClassifier::train(const std::vector >& points, + const std::vector& refimgs, + const std::vector >& labels, int _nclasses, int _patchSize, int _signatureSize, int _nstructs, int _structSize, int _nviews, int _compressionMethod, @@ -892,7 +892,7 @@ void FernClassifier::train(const vector >& points, void FernClassifier::trainFromSingleView(const Mat& image, - const vector& keypoints, + const std::vector& keypoints, int _patchSize, int _signatureSize, int _nstructs, int _structSize, int _nviews, int _compressionMethod, @@ -911,7 +911,7 @@ void FernClassifier::trainFromSingleView(const Mat& image, Mat canvas(cvRound(std::max(image.cols,image.rows)*maxScale + patchSize.width*2 + 10), cvRound(std::max(image.cols,image.rows)*maxScale + patchSize.width*2 + 10), image.type()); Mat noisebuf; - vector pyrbuf(maxOctave+1), pyr(maxOctave+1); + std::vector pyrbuf(maxOctave+1), pyr(maxOctave+1); Point2f center0((image.cols-1)*0.5f, (image.rows-1)*0.5f), center1((canvas.cols - 1)*0.5f, (canvas.rows - 1)*0.5f); Mat matM(2, 3, CV_64F); @@ -997,7 +997,7 @@ void FernClassifier::trainFromSingleView(const Mat& image, } -int FernClassifier::operator()(const Mat& img, Point2f pt, vector& signature) const +int FernClassifier::operator()(const Mat& img, Point2f pt, std::vector& signature) const { Mat patch; getRectSubPix(img, patchSize, pt, patch, img.type()); @@ -1005,7 +1005,7 @@ int FernClassifier::operator()(const Mat& img, Point2f pt, vector& signat } -int FernClassifier::operator()(const Mat& patch, vector& signature) const +int FernClassifier::operator()(const Mat& patch, std::vector& signature) const { if( posteriors.empty() ) CV_Error(CV_StsNullPtr, @@ -1051,7 +1051,7 @@ int FernClassifier::operator()(const Mat& patch, vector& signature) const void FernClassifier::finalize(RNG&) { int i, j, k, n = nclasses; - vector invClassCounters(n); + std::vector invClassCounters(n); Mat_ _temp(1, n); double* temp = &_temp(0,0); @@ -1093,7 +1093,7 @@ void FernClassifier::finalize(RNG&) csmatrix.create(m, n); rng.fill(csmatrix, RNG::UNIFORM, Scalar::all(0), Scalar::all(2)); } - vector dst(m); + std::vector dst(m); for( i = 0; i < totalLeaves; i++ ) { @@ -1228,7 +1228,7 @@ nstructs(_nstructs), structSize(_structSize), nviews(_nviews), compressionMethod(_compressionMethod), patchGenerator(_patchGenerator) {} -FernDescriptorMatcher::Params::Params( const string& _filename ) +FernDescriptorMatcher::Params::Params( const std::string& _filename ) { filename = _filename; } @@ -1263,11 +1263,11 @@ void FernDescriptorMatcher::train() { assert( params.filename.empty() ); - vector > points( trainPointCollection.imageCount() ); + std::vector > points( trainPointCollection.imageCount() ); for( size_t imgIdx = 0; imgIdx < trainPointCollection.imageCount(); imgIdx++ ) KeyPoint::convert( trainPointCollection.getKeypoints((int)imgIdx), points[imgIdx] ); - classifier = new FernClassifier( points, trainPointCollection.getImages(), vector >(), 0, // each points is a class + classifier = new FernClassifier( points, trainPointCollection.getImages(), std::vector >(), 0, // each points is a class params.patchSize, params.signatureSize, params.nstructs, params.structSize, params.nviews, params.compressionMethod, params.patchGenerator ); } @@ -1279,7 +1279,7 @@ bool FernDescriptorMatcher::isMaskSupported() } void FernDescriptorMatcher::calcBestProbAndMatchIdx( const Mat& image, const Point2f& pt, - float& bestProb, int& bestMatchIdx, vector& signature ) + float& bestProb, int& bestMatchIdx, std::vector& signature ) { (*classifier)( image, pt, signature); @@ -1295,14 +1295,14 @@ void FernDescriptorMatcher::calcBestProbAndMatchIdx( const Mat& image, const Poi } } -void FernDescriptorMatcher::knnMatchImpl( const Mat& queryImage, vector& queryKeypoints, - vector >& matches, int knn, - const vector& /*masks*/, bool /*compactResult*/ ) +void FernDescriptorMatcher::knnMatchImpl( const Mat& queryImage, std::vector& queryKeypoints, + std::vector >& matches, int knn, + const std::vector& /*masks*/, bool /*compactResult*/ ) { train(); matches.resize( queryKeypoints.size() ); - vector signature( (size_t)classifier->getClassCount() ); + std::vector signature( (size_t)classifier->getClassCount() ); for( size_t queryIdx = 0; queryIdx < queryKeypoints.size(); queryIdx++ ) { @@ -1331,13 +1331,13 @@ void FernDescriptorMatcher::knnMatchImpl( const Mat& queryImage, vector& queryKeypoints, - vector >& matches, float maxDistance, - const vector& /*masks*/, bool /*compactResult*/ ) +void FernDescriptorMatcher::radiusMatchImpl( const Mat& queryImage, std::vector& queryKeypoints, + std::vector >& matches, float maxDistance, + const std::vector& /*masks*/, bool /*compactResult*/ ) { train(); matches.resize( queryKeypoints.size() ); - vector signature( (size_t)classifier->getClassCount() ); + std::vector signature( (size_t)classifier->getClassCount() ); for( size_t i = 0; i < queryKeypoints.size(); i++ ) { @@ -1413,7 +1413,7 @@ PlanarObjectDetector::PlanarObjectDetector(const FileNode& node) read(node); } -PlanarObjectDetector::PlanarObjectDetector(const vector& pyr, int npoints, +PlanarObjectDetector::PlanarObjectDetector(const std::vector& pyr, int npoints, int patchSize, int nstructs, int structSize, int nviews, const LDetector& detector, const PatchGenerator& patchGenerator) @@ -1426,12 +1426,12 @@ PlanarObjectDetector::~PlanarObjectDetector() { } -vector PlanarObjectDetector::getModelPoints() const +std::vector PlanarObjectDetector::getModelPoints() const { return modelPoints; } -void PlanarObjectDetector::train(const vector& pyr, int npoints, +void PlanarObjectDetector::train(const std::vector& pyr, int npoints, int patchSize, int nstructs, int structSize, int nviews, const LDetector& detector, const PatchGenerator& patchGenerator) @@ -1448,7 +1448,7 @@ void PlanarObjectDetector::train(const vector& pyr, int npoints, FernClassifier::COMPRESSION_NONE, patchGenerator); } -void PlanarObjectDetector::train(const vector& pyr, const vector& keypoints, +void PlanarObjectDetector::train(const std::vector& pyr, const std::vector& keypoints, int patchSize, int nstructs, int structSize, int nviews, const LDetector& detector, const PatchGenerator& patchGenerator) @@ -1476,7 +1476,7 @@ void PlanarObjectDetector::read(const FileNode& node) } -void PlanarObjectDetector::write(FileStorage& fs, const String& objname) const +void PlanarObjectDetector::write(FileStorage& fs, const std::string& objname) const { WriteStructContext ws(fs, objname, CV_NODE_MAP); @@ -1493,24 +1493,24 @@ void PlanarObjectDetector::write(FileStorage& fs, const String& objname) const } -bool PlanarObjectDetector::operator()(const Mat& image, Mat& H, vector& corners) const +bool PlanarObjectDetector::operator()(const Mat& image, Mat& H, std::vector& corners) const { - vector pyr; + std::vector pyr; buildPyramid(image, pyr, ldetector.nOctaves - 1); - vector keypoints; + std::vector keypoints; ldetector(pyr, keypoints); return (*this)(pyr, keypoints, H, corners); } -bool PlanarObjectDetector::operator()(const vector& pyr, const vector& keypoints, - Mat& matH, vector& corners, vector* pairs) const +bool PlanarObjectDetector::operator()(const std::vector& pyr, const std::vector& keypoints, + Mat& matH, std::vector& corners, std::vector* pairs) const { int i, j, m = (int)modelPoints.size(), n = (int)keypoints.size(); - vector bestMatches(m, -1); - vector maxLogProb(m, -FLT_MAX); - vector signature; - vector fromPt, toPt; + std::vector bestMatches(m, -1); + std::vector maxLogProb(m, -FLT_MAX); + std::vector signature; + std::vector fromPt, toPt; for( i = 0; i < n; i++ ) { @@ -1539,7 +1539,7 @@ bool PlanarObjectDetector::operator()(const vector& pyr, const vector mask; + std::vector mask; matH = findHomography(fromPt, toPt, RANSAC, 10, mask); if( matH.data ) { diff --git a/modules/legacy/src/stereogc.cpp b/modules/legacy/src/stereogc.cpp index 42466a063..72182e921 100644 --- a/modules/legacy/src/stereogc.cpp +++ b/modules/legacy/src/stereogc.cpp @@ -41,8 +41,6 @@ #include "precomp.hpp" -using namespace std; - #undef INFINITY #define INFINITY 10000 #define OCCLUSION_PENALTY 10000 diff --git a/modules/legacy/test/test_bruteforcematcher.cpp b/modules/legacy/test/test_bruteforcematcher.cpp index b9b250200..c6c40f845 100644 --- a/modules/legacy/test/test_bruteforcematcher.cpp +++ b/modules/legacy/test/test_bruteforcematcher.cpp @@ -1,5 +1,6 @@ #include "test_precomp.hpp" +using namespace std; using namespace cv; struct CV_EXPORTS L2Fake : public L2 diff --git a/modules/ml/include/opencv2/ml/ml.hpp b/modules/ml/include/opencv2/ml/ml.hpp index 80ad0e790..1e68c4871 100644 --- a/modules/ml/include/opencv2/ml/ml.hpp +++ b/modules/ml/include/opencv2/ml/ml.hpp @@ -604,7 +604,7 @@ protected: virtual void setTrainData(int startStep, const Mat& samples, const Mat* probs0, const Mat* means0, - const vector* covs0, + const std::vector* covs0, const Mat* weights0); bool doTrain(int startStep, @@ -633,11 +633,11 @@ protected: CV_PROP Mat weights; CV_PROP Mat means; - CV_PROP vector covs; + CV_PROP std::vector covs; - vector covsEigenValues; - vector covsRotateMats; - vector invCovsEigenValues; + std::vector covsEigenValues; + std::vector covsRotateMats; + std::vector invCovsEigenValues; Mat logWeightDivDet; }; } // namespace cv diff --git a/modules/ml/src/em.cpp b/modules/ml/src/em.cpp index 12c720dcf..86cbaba24 100644 --- a/modules/ml/src/em.cpp +++ b/modules/ml/src/em.cpp @@ -99,7 +99,7 @@ bool EM::trainE(InputArray samples, OutputArray probs) { Mat samplesMat = samples.getMat(); - vector covs0; + std::vector covs0; _covs0.getMatVector(covs0); Mat means0 = _means0.getMat(), weights0 = _weights0.getMat(); @@ -156,7 +156,7 @@ bool EM::isTrained() const static void checkTrainData(int startStep, const Mat& samples, int nclusters, int covMatType, const Mat* probs, const Mat* means, - const vector* covs, const Mat* weights) + const std::vector* covs, const Mat* weights) { // Check samples. CV_Assert(!samples.empty()); @@ -244,7 +244,7 @@ void preprocessProbability(Mat& probs) void EM::setTrainData(int startStep, const Mat& samples, const Mat* probs0, const Mat* means0, - const vector* covs0, + const std::vector* covs0, const Mat* weights0) { clear(); diff --git a/modules/ml/src/gbt.cpp b/modules/ml/src/gbt.cpp index 6671a3495..a409b7ab3 100644 --- a/modules/ml/src/gbt.cpp +++ b/modules/ml/src/gbt.cpp @@ -1,26 +1,13 @@ #include "precomp.hpp" -#include #include -using namespace std; - #define pCvSeq CvSeq* #define pCvDTreeNode CvDTreeNode* #define CV_CMP_FLOAT(a,b) ((a) < (b)) static CV_IMPLEMENT_QSORT_EX( icvSortFloat, float, CV_CMP_FLOAT, float) -//=========================================================================== -static string ToString(int i) -{ - stringstream tmp; - tmp << i; - - return tmp.str(); -} - - //=========================================================================== //----------------------------- CvGBTreesParams ----------------------------- //=========================================================================== @@ -1143,8 +1130,7 @@ void CvGBTrees::write( CvFileStorage* fs, const char* name ) const for ( int j=0; j < class_count; ++j ) { - s = "trees_"; - s += ToString(j); + s = cv::format("trees_%d", j); cvStartWriteStruct( fs, s.c_str(), CV_NODE_SEQ ); cvStartReadSeq( weak[j], &reader ); @@ -1197,8 +1183,7 @@ void CvGBTrees::read( CvFileStorage* fs, CvFileNode* node ) for (int j=0; jtag) ) diff --git a/modules/ml/src/tree.cpp b/modules/ml/src/tree.cpp index 1ba94fcaf..6f128ebdd 100644 --- a/modules/ml/src/tree.cpp +++ b/modules/ml/src/tree.cpp @@ -2181,7 +2181,7 @@ CvDTreeSplit* CvDTree::find_split_cat_class( CvDTreeNode* node, int vi, float in int base_size = m*(3 + mi)*sizeof(int) + (mi+1)*sizeof(double); if( m > 2 && mi > data->params.max_categories ) - base_size += (m*min(data->params.max_categories, n) + mi)*sizeof(int); + base_size += (m*std::min(data->params.max_categories, n) + mi)*sizeof(int); else base_size += mi*sizeof(int*); cv::AutoBuffer inn_buf(base_size); @@ -3300,7 +3300,7 @@ void CvDTree::split_node_data( CvDTreeNode* node ) data->free_node_data(node); } -float CvDTree::calc_error( CvMLData* _data, int type, vector *resp ) +float CvDTree::calc_error( CvMLData* _data, int type, std::vector *resp ) { float err = 0; const CvMat* values = _data->get_values(); diff --git a/modules/nonfree/include/opencv2/nonfree/features2d.hpp b/modules/nonfree/include/opencv2/nonfree/features2d.hpp index f23bec8bc..0c95829a7 100644 --- a/modules/nonfree/include/opencv2/nonfree/features2d.hpp +++ b/modules/nonfree/include/opencv2/nonfree/features2d.hpp @@ -70,24 +70,24 @@ public: //! finds the keypoints using SIFT algorithm void operator()(InputArray img, InputArray mask, - vector& keypoints) const; + std::vector& keypoints) const; //! finds the keypoints and computes descriptors for them using SIFT algorithm. //! Optionally it can compute descriptors for the user-provided keypoints void operator()(InputArray img, InputArray mask, - vector& keypoints, + std::vector& keypoints, OutputArray descriptors, bool useProvidedKeypoints=false) const; AlgorithmInfo* info() const; - void buildGaussianPyramid( const Mat& base, vector& pyr, int nOctaves ) const; - void buildDoGPyramid( const vector& pyr, vector& dogpyr ) const; - void findScaleSpaceExtrema( const vector& gauss_pyr, const vector& dog_pyr, - vector& keypoints ) const; + void buildGaussianPyramid( const Mat& base, std::vector& pyr, int nOctaves ) const; + void buildDoGPyramid( const std::vector& pyr, std::vector& dogpyr ) const; + void findScaleSpaceExtrema( const std::vector& gauss_pyr, const std::vector& dog_pyr, + std::vector& keypoints ) const; protected: - void detectImpl( const Mat& image, vector& keypoints, const Mat& mask=Mat() ) const; - void computeImpl( const Mat& image, vector& keypoints, Mat& descriptors ) const; + void detectImpl( const Mat& image, std::vector& keypoints, const Mat& mask=Mat() ) const; + void computeImpl( const Mat& image, std::vector& keypoints, Mat& descriptors ) const; CV_PROP_RW int nfeatures; CV_PROP_RW int nOctaveLayers; @@ -122,10 +122,10 @@ public: //! finds the keypoints using fast hessian detector used in SURF void operator()(InputArray img, InputArray mask, - CV_OUT vector& keypoints) const; + CV_OUT std::vector& keypoints) const; //! finds the keypoints and computes their descriptors. Optionally it can compute descriptors for the user-provided keypoints void operator()(InputArray img, InputArray mask, - CV_OUT vector& keypoints, + CV_OUT std::vector& keypoints, OutputArray descriptors, bool useProvidedKeypoints=false) const; @@ -139,8 +139,8 @@ public: protected: - void detectImpl( const Mat& image, vector& keypoints, const Mat& mask=Mat() ) const; - void computeImpl( const Mat& image, vector& keypoints, Mat& descriptors ) const; + void detectImpl( const Mat& image, std::vector& keypoints, const Mat& mask=Mat() ) const; + void computeImpl( const Mat& image, std::vector& keypoints, Mat& descriptors ) const; }; typedef SURF SurfFeatureDetector; diff --git a/modules/nonfree/perf/perf_surf.cpp b/modules/nonfree/perf/perf_surf.cpp index 20935a9a1..d9129775f 100644 --- a/modules/nonfree/perf/perf_surf.cpp +++ b/modules/nonfree/perf/perf_surf.cpp @@ -14,7 +14,7 @@ typedef perf::TestBaseWithParam surf; PERF_TEST_P(surf, detect, testing::Values(SURF_IMAGES)) { - String filename = getDataPath(GetParam()); + string filename = getDataPath(GetParam()); Mat frame = imread(filename, IMREAD_GRAYSCALE); if (frame.empty()) @@ -32,7 +32,7 @@ PERF_TEST_P(surf, detect, testing::Values(SURF_IMAGES)) PERF_TEST_P(surf, extract, testing::Values(SURF_IMAGES)) { - String filename = getDataPath(GetParam()); + string filename = getDataPath(GetParam()); Mat frame = imread(filename, IMREAD_GRAYSCALE); if (frame.empty()) @@ -53,7 +53,7 @@ PERF_TEST_P(surf, extract, testing::Values(SURF_IMAGES)) PERF_TEST_P(surf, full, testing::Values(SURF_IMAGES)) { - String filename = getDataPath(GetParam()); + string filename = getDataPath(GetParam()); Mat frame = imread(filename, IMREAD_GRAYSCALE); if (frame.empty()) diff --git a/modules/nonfree/src/sift.cpp b/modules/nonfree/src/sift.cpp index 58ebd3101..4161c4911 100644 --- a/modules/nonfree/src/sift.cpp +++ b/modules/nonfree/src/sift.cpp @@ -209,18 +209,18 @@ static Mat createInitialImage( const Mat& img, bool doubleImageSize, float sigma } -void SIFT::buildGaussianPyramid( const Mat& base, vector& pyr, int nOctaves ) const +void SIFT::buildGaussianPyramid( const Mat& base, std::vector& pyr, int nOctaves ) const { - vector sig(nOctaveLayers + 3); + std::vector sig(nOctaveLayers + 3); pyr.resize(nOctaves*(nOctaveLayers + 3)); // precompute Gaussian sigmas using the following formula: // \sigma_{total}^2 = \sigma_{i}^2 + \sigma_{i-1}^2 sig[0] = sigma; - double k = pow( 2., 1. / nOctaveLayers ); + double k = std::pow( 2., 1. / nOctaveLayers ); for( int i = 1; i < nOctaveLayers + 3; i++ ) { - double sig_prev = pow(k, (double)(i-1))*sigma; + double sig_prev = std::pow(k, (double)(i-1))*sigma; double sig_total = sig_prev*k; sig[i] = std::sqrt(sig_total*sig_total - sig_prev*sig_prev); } @@ -249,7 +249,7 @@ void SIFT::buildGaussianPyramid( const Mat& base, vector& pyr, int nOctaves } -void SIFT::buildDoGPyramid( const vector& gpyr, vector& dogpyr ) const +void SIFT::buildDoGPyramid( const std::vector& gpyr, std::vector& dogpyr ) const { int nOctaves = (int)gpyr.size()/(nOctaveLayers + 3); dogpyr.resize( nOctaves*(nOctaveLayers + 2) ); @@ -341,7 +341,7 @@ static float calcOrientationHist( const Mat& img, Point pt, int radius, // Interpolates a scale-space extremum's location and scale to subpixel // accuracy to form an image feature. Rejects features with low contrast. // Based on Section 4 of Lowe's paper. -static bool adjustLocalExtrema( const vector& dog_pyr, KeyPoint& kpt, int octv, +static bool adjustLocalExtrema( const std::vector& dog_pyr, KeyPoint& kpt, int octv, int& layer, int& r, int& c, int nOctaveLayers, float contrastThreshold, float edgeThreshold, float sigma ) { @@ -447,8 +447,8 @@ static bool adjustLocalExtrema( const vector& dog_pyr, KeyPoint& kpt, int o // // Detects features at extrema in DoG scale space. Bad features are discarded // based on contrast and ratio of principal curvatures. -void SIFT::findScaleSpaceExtrema( const vector& gauss_pyr, const vector& dog_pyr, - vector& keypoints ) const +void SIFT::findScaleSpaceExtrema( const std::vector& gauss_pyr, const std::vector& dog_pyr, + std::vector& keypoints ) const { int nOctaves = (int)gauss_pyr.size()/(nOctaveLayers + 3); int threshold = cvFloor(0.5 * contrastThreshold / nOctaveLayers * 255 * SIFT_FIXPT_SCALE); @@ -673,7 +673,7 @@ static void calcSIFTDescriptor( const Mat& img, Point2f ptf, float ori, float sc #endif } -static void calcDescriptors(const vector& gpyr, const vector& keypoints, +static void calcDescriptors(const std::vector& gpyr, const std::vector& keypoints, Mat& descriptors, int nOctaveLayers, int firstOctave ) { int d = SIFT_DESCR_WIDTH, n = SIFT_DESCR_HIST_BINS; @@ -717,14 +717,14 @@ int SIFT::descriptorType() const void SIFT::operator()(InputArray _image, InputArray _mask, - vector& keypoints) const + std::vector& keypoints) const { (*this)(_image, _mask, keypoints, noArray()); } void SIFT::operator()(InputArray _image, InputArray _mask, - vector& keypoints, + std::vector& keypoints, OutputArray _descriptors, bool useProvidedKeypoints) const { @@ -757,8 +757,8 @@ void SIFT::operator()(InputArray _image, InputArray _mask, } Mat base = createInitialImage(image, firstOctave < 0, (float)sigma); - vector gpyr, dogpyr; - int nOctaves = actualNOctaves > 0 ? actualNOctaves : cvRound(log( (double)std::min( base.cols, base.rows ) ) / log(2.) - 2) - firstOctave; + std::vector gpyr, dogpyr; + int nOctaves = actualNOctaves > 0 ? actualNOctaves : cvRound(std::log( (double)std::min( base.cols, base.rows ) ) / std::log(2.) - 2) - firstOctave; //double t, tf = getTickFrequency(); //t = (double)getTickCount(); @@ -811,12 +811,12 @@ void SIFT::operator()(InputArray _image, InputArray _mask, } } -void SIFT::detectImpl( const Mat& image, vector& keypoints, const Mat& mask) const +void SIFT::detectImpl( const Mat& image, std::vector& keypoints, const Mat& mask) const { (*this)(image, mask, keypoints, noArray()); } -void SIFT::computeImpl( const Mat& image, vector& keypoints, Mat& descriptors) const +void SIFT::computeImpl( const Mat& image, std::vector& keypoints, Mat& descriptors) const { (*this)(image, Mat(), keypoints, descriptors, true); } diff --git a/modules/nonfree/src/surf.cpp b/modules/nonfree/src/surf.cpp index bb6d53e4b..ea310478b 100644 --- a/modules/nonfree/src/surf.cpp +++ b/modules/nonfree/src/surf.cpp @@ -260,9 +260,9 @@ interpolateKeypoint( float N9[3][9], int dx, int dy, int ds, KeyPoint& kpt ) // Multi-threaded construction of the scale-space pyramid struct SURFBuildInvoker { - SURFBuildInvoker( const Mat& _sum, const vector& _sizes, - const vector& _sampleSteps, - vector& _dets, vector& _traces ) + SURFBuildInvoker( const Mat& _sum, const std::vector& _sizes, + const std::vector& _sampleSteps, + std::vector& _dets, std::vector& _traces ) { sum = &_sum; sizes = &_sizes; @@ -278,19 +278,19 @@ struct SURFBuildInvoker } const Mat *sum; - const vector *sizes; - const vector *sampleSteps; - vector* dets; - vector* traces; + const std::vector *sizes; + const std::vector *sampleSteps; + std::vector* dets; + std::vector* traces; }; // Multi-threaded search of the scale-space pyramid for keypoints struct SURFFindInvoker { SURFFindInvoker( const Mat& _sum, const Mat& _mask_sum, - const vector& _dets, const vector& _traces, - const vector& _sizes, const vector& _sampleSteps, - const vector& _middleIndices, vector& _keypoints, + const std::vector& _dets, const std::vector& _traces, + const std::vector& _sizes, const std::vector& _sampleSteps, + const std::vector& _middleIndices, std::vector& _keypoints, int _nOctaveLayers, float _hessianThreshold ) { sum = &_sum; @@ -306,8 +306,8 @@ struct SURFFindInvoker } static void findMaximaInLayer( const Mat& sum, const Mat& mask_sum, - const vector& dets, const vector& traces, - const vector& sizes, vector& keypoints, + const std::vector& dets, const std::vector& traces, + const std::vector& sizes, std::vector& keypoints, int octave, int layer, float hessianThreshold, int sampleStep ); void operator()(const BlockedRange& range) const @@ -324,12 +324,12 @@ struct SURFFindInvoker const Mat *sum; const Mat *mask_sum; - const vector* dets; - const vector* traces; - const vector* sizes; - const vector* sampleSteps; - const vector* middleIndices; - vector* keypoints; + const std::vector* dets; + const std::vector* traces; + const std::vector* sizes; + const std::vector* sampleSteps; + const std::vector* middleIndices; + std::vector* keypoints; int nOctaveLayers; float hessianThreshold; @@ -348,8 +348,8 @@ tbb::mutex SURFFindInvoker::findMaximaInLayer_m; * scale-space pyramid */ void SURFFindInvoker::findMaximaInLayer( const Mat& sum, const Mat& mask_sum, - const vector& dets, const vector& traces, - const vector& sizes, vector& keypoints, + const std::vector& dets, const std::vector& traces, + const std::vector& sizes, std::vector& keypoints, int octave, int layer, float hessianThreshold, int sampleStep ) { // Wavelet Data @@ -465,7 +465,7 @@ struct KeypointGreater }; -static void fastHessianDetector( const Mat& sum, const Mat& mask_sum, vector& keypoints, +static void fastHessianDetector( const Mat& sum, const Mat& mask_sum, std::vector& keypoints, int nOctaves, int nOctaveLayers, float hessianThreshold ) { /* Sampling step along image x and y axes at first octave. This is doubled @@ -476,11 +476,11 @@ static void fastHessianDetector( const Mat& sum, const Mat& mask_sum, vector dets(nTotalLayers); - vector traces(nTotalLayers); - vector sizes(nTotalLayers); - vector sampleSteps(nTotalLayers); - vector middleIndices(nMiddleLayers); + std::vector dets(nTotalLayers); + std::vector traces(nTotalLayers); + std::vector sizes(nTotalLayers); + std::vector sampleSteps(nTotalLayers); + std::vector middleIndices(nMiddleLayers); keypoints.clear(); @@ -523,7 +523,7 @@ struct SURFInvoker enum { ORI_RADIUS = 6, ORI_WIN = 60, PATCH_SZ = 20 }; SURFInvoker( const Mat& _img, const Mat& _sum, - vector& _keypoints, Mat& _descriptors, + std::vector& _keypoints, Mat& _descriptors, bool _extended, bool _upright ) { keypoints = &_keypoints; @@ -850,7 +850,7 @@ struct SURFInvoker // unit vector is essential for contrast invariance vec = descriptors->ptr(k); - float scale = (float)(1./(sqrt(square_mag) + DBL_EPSILON)); + float scale = (float)(1./(std::sqrt(square_mag) + DBL_EPSILON)); for( kk = 0; kk < dsize; kk++ ) vec[kk] *= scale; } @@ -859,16 +859,16 @@ struct SURFInvoker // Parameters const Mat* img; const Mat* sum; - vector* keypoints; + std::vector* keypoints; Mat* descriptors; bool extended; bool upright; // Pre-calculated values int nOriSamples; - vector apt; - vector aptw; - vector DW; + std::vector apt; + std::vector aptw; + std::vector DW; }; @@ -894,13 +894,13 @@ int SURF::descriptorSize() const { return extended ? 128 : 64; } int SURF::descriptorType() const { return CV_32F; } void SURF::operator()(InputArray imgarg, InputArray maskarg, - CV_OUT vector& keypoints) const + CV_OUT std::vector& keypoints) const { (*this)(imgarg, maskarg, keypoints, noArray(), false); } void SURF::operator()(InputArray _img, InputArray _mask, - CV_OUT vector& keypoints, + CV_OUT std::vector& keypoints, OutputArray _descriptors, bool useProvidedKeypoints) const { @@ -986,12 +986,12 @@ void SURF::operator()(InputArray _img, InputArray _mask, } -void SURF::detectImpl( const Mat& image, vector& keypoints, const Mat& mask) const +void SURF::detectImpl( const Mat& image, std::vector& keypoints, const Mat& mask) const { (*this)(image, mask, keypoints, noArray(), false); } -void SURF::computeImpl( const Mat& image, vector& keypoints, Mat& descriptors) const +void SURF::computeImpl( const Mat& image, std::vector& keypoints, Mat& descriptors) const { (*this)(image, Mat(), keypoints, descriptors, true); } diff --git a/modules/objdetect/include/opencv2/objdetect/objdetect.hpp b/modules/objdetect/include/opencv2/objdetect/objdetect.hpp index f9138e242..549238164 100644 --- a/modules/objdetect/include/opencv2/objdetect/objdetect.hpp +++ b/modules/objdetect/include/opencv2/objdetect/objdetect.hpp @@ -307,32 +307,32 @@ public: }; LatentSvmDetector(); - LatentSvmDetector( const vector& filenames, const vector& classNames=vector() ); + LatentSvmDetector( const std::vector& filenames, const std::vector& classNames=std::vector() ); virtual ~LatentSvmDetector(); virtual void clear(); virtual bool empty() const; - bool load( const vector& filenames, const vector& classNames=vector() ); + bool load( const std::vector& filenames, const std::vector& classNames=std::vector() ); virtual void detect( const Mat& image, - vector& objectDetections, + std::vector& objectDetections, float overlapThreshold=0.5f, int numThreads=-1 ); - const vector& getClassNames() const; + const std::vector& getClassNames() const; size_t getClassCount() const; private: - vector detectors; - vector classNames; + std::vector detectors; + std::vector classNames; }; -CV_EXPORTS void groupRectangles(CV_OUT CV_IN_OUT vector& rectList, int groupThreshold, double eps=0.2); -CV_EXPORTS_W void groupRectangles(CV_OUT CV_IN_OUT vector& rectList, CV_OUT vector& weights, int groupThreshold, double eps=0.2); -CV_EXPORTS void groupRectangles( vector& rectList, int groupThreshold, double eps, vector* weights, vector* levelWeights ); -CV_EXPORTS void groupRectangles(vector& rectList, vector& rejectLevels, - vector& levelWeights, int groupThreshold, double eps=0.2); -CV_EXPORTS void groupRectangles_meanshift(vector& rectList, vector& foundWeights, vector& foundScales, +CV_EXPORTS void groupRectangles(CV_OUT CV_IN_OUT std::vector& rectList, int groupThreshold, double eps=0.2); +CV_EXPORTS_W void groupRectangles(CV_OUT CV_IN_OUT std::vector& rectList, CV_OUT std::vector& weights, int groupThreshold, double eps=0.2); +CV_EXPORTS void groupRectangles( std::vector& rectList, int groupThreshold, double eps, std::vector* weights, std::vector* levelWeights ); +CV_EXPORTS void groupRectangles(std::vector& rectList, std::vector& rejectLevels, + std::vector& levelWeights, int groupThreshold, double eps=0.2); +CV_EXPORTS void groupRectangles_meanshift(std::vector& rectList, std::vector& foundWeights, std::vector& foundScales, double detectThreshold = 0.0, Size winDetSize = Size(64, 128)); @@ -369,23 +369,23 @@ class CV_EXPORTS_W CascadeClassifier { public: CV_WRAP CascadeClassifier(); - CV_WRAP CascadeClassifier( const string& filename ); + CV_WRAP CascadeClassifier( const std::string& filename ); virtual ~CascadeClassifier(); CV_WRAP virtual bool empty() const; - CV_WRAP bool load( const string& filename ); + CV_WRAP bool load( const std::string& filename ); virtual bool read( const FileNode& node ); CV_WRAP virtual void detectMultiScale( const Mat& image, - CV_OUT vector& objects, + CV_OUT std::vector& objects, double scaleFactor=1.1, int minNeighbors=3, int flags=0, Size minSize=Size(), Size maxSize=Size() ); CV_WRAP virtual void detectMultiScale( const Mat& image, - CV_OUT vector& objects, - vector& rejectLevels, - vector& levelWeights, + CV_OUT std::vector& objects, + std::vector& rejectLevels, + std::vector& levelWeights, double scaleFactor=1.1, int minNeighbors=3, int flags=0, Size minSize=Size(), @@ -400,11 +400,11 @@ public: protected: //virtual bool detectSingleScale( const Mat& image, int stripCount, Size processingRectSize, - // int stripSize, int yStep, double factor, vector& candidates ); + // int stripSize, int yStep, double factor, std::vector& candidates ); virtual bool detectSingleScale( const Mat& image, int stripCount, Size processingRectSize, - int stripSize, int yStep, double factor, vector& candidates, - vector& rejectLevels, vector& levelWeights, bool outputRejectLevels=false); + int stripSize, int yStep, double factor, std::vector& candidates, + std::vector& rejectLevels, std::vector& levelWeights, bool outputRejectLevels=false); protected: enum { BOOST = 0 }; @@ -460,11 +460,11 @@ protected: int ncategories; Size origWinSize; - vector stages; - vector classifiers; - vector nodes; - vector leaves; - vector subsets; + std::vector stages; + std::vector classifiers; + std::vector nodes; + std::vector leaves; + std::vector subsets; }; Data data; @@ -496,9 +496,9 @@ struct DetectionROI // scale(size) of the bounding box double scale; // set of requrested locations to be evaluated - vector locations; + std::vector locations; // vector that will contain confidence values for each location - vector confidences; + std::vector confidences; }; struct CV_EXPORTS_W HOGDescriptor @@ -524,7 +524,7 @@ public: gammaCorrection(_gammaCorrection), nlevels(_nlevels) {} - CV_WRAP HOGDescriptor(const String& filename) + CV_WRAP HOGDescriptor(const std::string& filename) { load(filename); } @@ -543,34 +543,34 @@ public: CV_WRAP virtual void setSVMDetector(InputArray _svmdetector); virtual bool read(FileNode& fn); - virtual void write(FileStorage& fs, const String& objname) const; + virtual void write(FileStorage& fs, const std::string& objname) const; - CV_WRAP virtual bool load(const String& filename, const String& objname=String()); - CV_WRAP virtual void save(const String& filename, const String& objname=String()) const; + CV_WRAP virtual bool load(const std::string& filename, const std::string& objname=std::string()); + CV_WRAP virtual void save(const std::string& filename, const std::string& objname=std::string()) const; virtual void copyTo(HOGDescriptor& c) const; CV_WRAP virtual void compute(const Mat& img, - CV_OUT vector& descriptors, + CV_OUT std::vector& descriptors, Size winStride=Size(), Size padding=Size(), - const vector& locations=vector()) const; + const std::vector& locations=std::vector()) const; //with found weights output - CV_WRAP virtual void detect(const Mat& img, CV_OUT vector& foundLocations, - CV_OUT vector& weights, + CV_WRAP virtual void detect(const Mat& img, CV_OUT std::vector& foundLocations, + CV_OUT std::vector& weights, double hitThreshold=0, Size winStride=Size(), Size padding=Size(), - const vector& searchLocations=vector()) const; + const std::vector& searchLocations=std::vector()) const; //without found weights output - virtual void detect(const Mat& img, CV_OUT vector& foundLocations, + virtual void detect(const Mat& img, CV_OUT std::vector& foundLocations, double hitThreshold=0, Size winStride=Size(), Size padding=Size(), - const vector& searchLocations=vector()) const; + const std::vector& searchLocations=std::vector()) const; //with result weights output - CV_WRAP virtual void detectMultiScale(const Mat& img, CV_OUT vector& foundLocations, - CV_OUT vector& foundWeights, double hitThreshold=0, + CV_WRAP virtual void detectMultiScale(const Mat& img, CV_OUT std::vector& foundLocations, + CV_OUT std::vector& foundWeights, double hitThreshold=0, Size winStride=Size(), Size padding=Size(), double scale=1.05, double finalThreshold=2.0,bool useMeanshiftGrouping = false) const; //without found weights output - virtual void detectMultiScale(const Mat& img, CV_OUT vector& foundLocations, + virtual void detectMultiScale(const Mat& img, CV_OUT std::vector& foundLocations, double hitThreshold=0, Size winStride=Size(), Size padding=Size(), double scale=1.05, double finalThreshold=2.0, bool useMeanshiftGrouping = false) const; @@ -578,8 +578,8 @@ public: CV_WRAP virtual void computeGradient(const Mat& img, CV_OUT Mat& grad, CV_OUT Mat& angleOfs, Size paddingTL=Size(), Size paddingBR=Size()) const; - CV_WRAP static vector getDefaultPeopleDetector(); - CV_WRAP static vector getDaimlerPeopleDetector(); + CV_WRAP static std::vector getDefaultPeopleDetector(); + CV_WRAP static std::vector getDaimlerPeopleDetector(); CV_PROP Size winSize; CV_PROP Size blockSize; @@ -591,12 +591,12 @@ public: CV_PROP int histogramNormType; CV_PROP double L2HysThreshold; CV_PROP bool gammaCorrection; - CV_PROP vector svmDetector; + CV_PROP std::vector svmDetector; CV_PROP int nlevels; // evaluate specified ROI and return confidence value for each location - virtual void detectROI(const cv::Mat& img, const vector &locations, + virtual void detectROI(const cv::Mat& img, const std::vector &locations, CV_OUT std::vector& foundLocations, CV_OUT std::vector& confidences, double hitThreshold = 0, cv::Size winStride = Size(), cv::Size padding = Size()) const; @@ -614,11 +614,11 @@ public: CV_EXPORTS_W void findDataMatrix(InputArray image, - CV_OUT vector& codes, + CV_OUT std::vector& codes, OutputArray corners=noArray(), OutputArrayOfArrays dmtx=noArray()); CV_EXPORTS_W void drawDataMatrixCodes(InputOutputArray image, - const vector& codes, + const std::vector& codes, InputArray corners); } @@ -641,16 +641,6 @@ CV_EXPORTS std::deque cvFindDataMatrix(CvMat *im); namespace cv { namespace linemod { -using cv::FileNode; -using cv::FileStorage; -using cv::Mat; -using cv::noArray; -using cv::OutputArrayOfArrays; -using cv::Point; -using cv::Ptr; -using cv::Rect; -using cv::Size; - /// @todo Convert doxy comments to rst /** diff --git a/modules/objdetect/src/cascadedetect.cpp b/modules/objdetect/src/cascadedetect.cpp index 46a232ed6..2e5d1b18a 100644 --- a/modules/objdetect/src/cascadedetect.cpp +++ b/modules/objdetect/src/cascadedetect.cpp @@ -132,7 +132,7 @@ public: }; -void groupRectangles(vector& rectList, int groupThreshold, double eps, vector* weights, vector* levelWeights) +void groupRectangles(std::vector& rectList, int groupThreshold, double eps, std::vector* weights, std::vector* levelWeights) { if( groupThreshold <= 0 || rectList.empty() ) { @@ -146,13 +146,13 @@ void groupRectangles(vector& rectList, int groupThreshold, double eps, vec return; } - vector labels; + std::vector labels; int nclasses = partition(rectList, labels, SimilarRects(eps)); - vector rrects(nclasses); - vector rweights(nclasses, 0); - vector rejectLevels(nclasses, 0); - vector rejectWeights(nclasses, DBL_MIN); + std::vector rrects(nclasses); + std::vector rweights(nclasses, 0); + std::vector rejectLevels(nclasses, 0); + std::vector rejectWeights(nclasses, DBL_MIN); int i, j, nlabels = (int)labels.size(); for( i = 0; i < nlabels; i++ ) { @@ -236,8 +236,8 @@ void groupRectangles(vector& rectList, int groupThreshold, double eps, vec class MeanshiftGrouping { public: - MeanshiftGrouping(const Point3d& densKer, const vector& posV, - const vector& wV, double eps, int maxIter = 20) + MeanshiftGrouping(const Point3d& densKer, const std::vector& posV, + const std::vector& wV, double eps, int maxIter = 20) { densityKernel = densKer; weightsV = wV; @@ -256,7 +256,7 @@ public: } } - void getModes(vector& modesV, vector& resWeightsV, const double eps) + void getModes(std::vector& modesV, std::vector& resWeightsV, const double eps) { for (size_t i=0; i positionsV; - vector weightsV; + std::vector positionsV; + std::vector weightsV; Point3d densityKernel; int positionsCount; - vector meanshiftV; - vector distanceV; + std::vector meanshiftV; + std::vector distanceV; int iterMax; double modeEps; @@ -305,8 +305,8 @@ protected: Point3d bPt = inPt; Point3d sPt = densityKernel; - sPt.x *= exp(aPt.z); - sPt.y *= exp(aPt.z); + sPt.x *= std::exp(aPt.z); + sPt.y *= std::exp(aPt.z); aPt.x /= sPt.x; aPt.y /= sPt.y; @@ -338,8 +338,8 @@ protected: Point3d aPt = positionsV[i]; Point3d sPt = densityKernel; - sPt.x *= exp(aPt.z); - sPt.y *= exp(aPt.z); + sPt.x *= std::exp(aPt.z); + sPt.y *= std::exp(aPt.z); aPt -= inPt; @@ -370,8 +370,8 @@ protected: double getDistance(Point3d p1, Point3d p2) const { Point3d ns = densityKernel; - ns.x *= exp(p2.z); - ns.y *= exp(p2.z); + ns.x *= std::exp(p2.z); + ns.y *= std::exp(p2.z); p2 -= p1; p2.x /= ns.x; p2.y /= ns.y; @@ -380,12 +380,12 @@ protected: } }; //new grouping function with using meanshift -static void groupRectangles_meanshift(vector& rectList, double detectThreshold, vector* foundWeights, - vector& scales, Size winDetSize) +static void groupRectangles_meanshift(std::vector& rectList, double detectThreshold, std::vector* foundWeights, + std::vector& scales, Size winDetSize) { int detectionCount = (int)rectList.size(); - vector hits(detectionCount), resultHits; - vector hitWeights(detectionCount), resultWeights; + std::vector hits(detectionCount), resultHits; + std::vector hitWeights(detectionCount), resultWeights; Point2d hitCenter; for (int i=0; i < detectionCount; i++) @@ -409,7 +409,7 @@ static void groupRectangles_meanshift(vector& rectList, double detectThres for (unsigned i=0; i < resultHits.size(); ++i) { - double scale = exp(resultHits[i].z); + double scale = std::exp(resultHits[i].z); hitCenter.x = resultHits[i].x; hitCenter.y = resultHits[i].y; Size s( int(winDetSize.width * scale), int(winDetSize.height * scale) ); @@ -424,23 +424,23 @@ static void groupRectangles_meanshift(vector& rectList, double detectThres } } -void groupRectangles(vector& rectList, int groupThreshold, double eps) +void groupRectangles(std::vector& rectList, int groupThreshold, double eps) { groupRectangles(rectList, groupThreshold, eps, 0, 0); } -void groupRectangles(vector& rectList, vector& weights, int groupThreshold, double eps) +void groupRectangles(std::vector& rectList, std::vector& weights, int groupThreshold, double eps) { groupRectangles(rectList, groupThreshold, eps, &weights, 0); } //used for cascade detection algorithm for ROC-curve calculating -void groupRectangles(vector& rectList, vector& rejectLevels, vector& levelWeights, int groupThreshold, double eps) +void groupRectangles(std::vector& rectList, std::vector& rejectLevels, std::vector& levelWeights, int groupThreshold, double eps) { groupRectangles(rectList, groupThreshold, eps, &rejectLevels, &levelWeights); } //can be used for HOG detection algorithm only -void groupRectangles_meanshift(vector& rectList, vector& foundWeights, - vector& foundScales, double detectThreshold, Size winDetSize) +void groupRectangles_meanshift(std::vector& rectList, std::vector& foundWeights, + std::vector& foundScales, double detectThreshold, Size winDetSize) { groupRectangles_meanshift(rectList, detectThreshold, &foundWeights, foundScales, winDetSize); } @@ -483,7 +483,7 @@ bool HaarEvaluator::Feature :: read( const FileNode& node ) HaarEvaluator::HaarEvaluator() { - features = new vector(); + features = new std::vector(); } HaarEvaluator::~HaarEvaluator() { @@ -578,7 +578,7 @@ bool HaarEvaluator::setWindow( Point pt ) double nf = (double)normrect.area() * valsqsum - (double)valsum * valsum; if( nf > 0. ) - nf = sqrt(nf); + nf = std::sqrt(nf); else nf = 1.; varianceNormFactor = 1./nf; @@ -598,7 +598,7 @@ bool LBPEvaluator::Feature :: read(const FileNode& node ) LBPEvaluator::LBPEvaluator() { - features = new vector(); + features = new std::vector(); } LBPEvaluator::~LBPEvaluator() { @@ -678,7 +678,7 @@ bool HOGEvaluator::Feature :: read( const FileNode& node ) HOGEvaluator::HOGEvaluator() { - features = new vector(); + features = new std::vector(); } HOGEvaluator::~HOGEvaluator() @@ -745,7 +745,7 @@ bool HOGEvaluator::setWindow(Point pt) return true; } -void HOGEvaluator::integralHistogram(const Mat &img, vector &histogram, Mat &norm, int nbins) const +void HOGEvaluator::integralHistogram(const Mat &img, std::vector &histogram, Mat &norm, int nbins) const { CV_Assert( img.type() == CV_8U || img.type() == CV_8UC3 ); int x, y, binIdx; @@ -854,7 +854,7 @@ CascadeClassifier::CascadeClassifier() { } -CascadeClassifier::CascadeClassifier(const string& filename) +CascadeClassifier::CascadeClassifier(const std::string& filename) { load(filename); } @@ -868,7 +868,7 @@ bool CascadeClassifier::empty() const return oldCascade.empty() && data.stages.empty(); } -bool CascadeClassifier::load(const string& filename) +bool CascadeClassifier::load(const std::string& filename) { oldCascade.release(); data = Data(); @@ -948,7 +948,7 @@ class CascadeClassifierInvoker : public ParallelLoopBody { public: CascadeClassifierInvoker( CascadeClassifier& _cc, Size _sz1, int _stripSize, int _yStep, double _factor, - vector& _vec, vector& _levels, vector& _weights, bool outputLevels, const Mat& _mask, Mutex* _mtx) + std::vector& _vec, std::vector& _levels, std::vector& _weights, bool outputLevels, const Mat& _mask, Mutex* _mtx) { classifier = &_cc; processingRectSize = _sz1; @@ -969,7 +969,7 @@ public: Size winSize(cvRound(classifier->data.origWinSize.width * scalingFactor), cvRound(classifier->data.origWinSize.height * scalingFactor)); int y1 = range.start * stripSize; - int y2 = min(range.end * stripSize, processingRectSize.height); + int y2 = std::min(range.end * stripSize, processingRectSize.height); for( int y = y1; y < y2; y += yStep ) { for( int x = 0; x < processingRectSize.width; x += yStep ) @@ -1012,12 +1012,12 @@ public: } CascadeClassifier* classifier; - vector* rectangles; + std::vector* rectangles; Size processingRectSize; int stripSize, yStep; double scalingFactor; - vector *rejectLevels; - vector *levelWeights; + std::vector *rejectLevels; + std::vector *levelWeights; Mat mask; Mutex* mtx; }; @@ -1026,8 +1026,8 @@ struct getRect { Rect operator ()(const CvAvgComp& e) const { return e.rect; } } bool CascadeClassifier::detectSingleScale( const Mat& image, int stripCount, Size processingRectSize, - int stripSize, int yStep, double factor, vector& candidates, - vector& levels, vector& weights, bool outputRejectLevels ) + int stripSize, int yStep, double factor, std::vector& candidates, + std::vector& levels, std::vector& weights, bool outputRejectLevels ) { if( !featureEvaluator->setImage( image, data.origWinSize ) ) return false; @@ -1041,9 +1041,9 @@ bool CascadeClassifier::detectSingleScale( const Mat& image, int stripCount, Siz currentMask=maskGenerator->generateMask(image); } - vector candidatesVector; - vector rejectLevels; - vector levelWeights; + std::vector candidatesVector; + std::vector rejectLevels; + std::vector levelWeights; Mutex mtx; if( outputRejectLevels ) { @@ -1087,9 +1087,9 @@ bool CascadeClassifier::setImage(const Mat& image) return featureEvaluator->setImage(image, data.origWinSize); } -void CascadeClassifier::detectMultiScale( const Mat& image, vector& objects, - vector& rejectLevels, - vector& levelWeights, +void CascadeClassifier::detectMultiScale( const Mat& image, std::vector& objects, + std::vector& rejectLevels, + std::vector& levelWeights, double scaleFactor, int minNeighbors, int flags, Size minObjectSize, Size maxObjectSize, bool outputRejectLevels ) @@ -1107,7 +1107,7 @@ void CascadeClassifier::detectMultiScale( const Mat& image, vector& object CvMat _image = image; CvSeq* _objects = cvHaarDetectObjectsForROC( &_image, oldCascade, storage, rejectLevels, levelWeights, scaleFactor, minNeighbors, flags, minObjectSize, maxObjectSize, outputRejectLevels ); - vector vecAvgComp; + std::vector vecAvgComp; Seq(_objects).copyTo(vecAvgComp); objects.resize(vecAvgComp.size()); std::transform(vecAvgComp.begin(), vecAvgComp.end(), objects.begin(), getRect()); @@ -1133,7 +1133,7 @@ void CascadeClassifier::detectMultiScale( const Mat& image, vector& object } Mat imageBuffer(image.rows + 1, image.cols + 1, CV_8U); - vector candidates; + std::vector candidates; for( double factor = 1; ; factor *= scaleFactor ) { @@ -1194,12 +1194,12 @@ void CascadeClassifier::detectMultiScale( const Mat& image, vector& object } } -void CascadeClassifier::detectMultiScale( const Mat& image, vector& objects, +void CascadeClassifier::detectMultiScale( const Mat& image, std::vector& objects, double scaleFactor, int minNeighbors, int flags, Size minObjectSize, Size maxObjectSize) { - vector fakeLevels; - vector fakeWeights; + std::vector fakeLevels; + std::vector fakeWeights; detectMultiScale( image, objects, fakeLevels, fakeWeights, scaleFactor, minNeighbors, flags, minObjectSize, maxObjectSize, false ); } @@ -1209,13 +1209,13 @@ bool CascadeClassifier::Data::read(const FileNode &root) static const float THRESHOLD_EPS = 1e-5f; // load stage params - string stageTypeStr = (string)root[CC_STAGE_TYPE]; + std::string stageTypeStr = (std::string)root[CC_STAGE_TYPE]; if( stageTypeStr == CC_BOOST ) stageType = BOOST; else return false; - string featureTypeStr = (string)root[CC_FEATURE_TYPE]; + std::string featureTypeStr = (std::string)root[CC_FEATURE_TYPE]; if( featureTypeStr == CC_HAAR ) featureType = FeatureEvaluator::HAAR; else if( featureTypeStr == CC_LBP ) diff --git a/modules/objdetect/src/cascadedetect.hpp b/modules/objdetect/src/cascadedetect.hpp index 904c207b3..c6da4b9ff 100644 --- a/modules/objdetect/src/cascadedetect.hpp +++ b/modules/objdetect/src/cascadedetect.hpp @@ -103,7 +103,7 @@ public: protected: Size origWinSize; - Ptr > features; + Ptr > features; Feature* featuresPtr; // optimization bool hasTiltedFeatures; @@ -194,7 +194,7 @@ public: { return (*this)(featureIdx); } protected: Size origWinSize; - Ptr > features; + Ptr > features; Feature* featuresPtr; // optimization Mat sum0, sum; Rect normrect; @@ -247,7 +247,7 @@ public: { Feature(); float calc( int offset ) const; - void updatePtrs( const vector& _hist, const Mat &_normSum ); + void updatePtrs( const std::vector& _hist, const Mat &_normSum ); bool read( const FileNode& node ); enum { CELL_NUM = 4, BIN_NUM = 9 }; @@ -274,12 +274,12 @@ public: } private: - virtual void integralHistogram( const Mat& srcImage, vector &histogram, Mat &norm, int nbins ) const; + virtual void integralHistogram( const Mat& srcImage, std::vector &histogram, Mat &norm, int nbins ) const; Size origWinSize; - Ptr > features; + Ptr > features; Feature* featuresPtr; - vector hist; + std::vector hist; Mat normSum; int offset; }; @@ -300,7 +300,7 @@ inline float HOGEvaluator::Feature :: calc( int _offset ) const return res; } -inline void HOGEvaluator::Feature :: updatePtrs( const vector &_hist, const Mat &_normSum ) +inline void HOGEvaluator::Feature :: updatePtrs( const std::vector &_hist, const Mat &_normSum ) { int binIdx = featComponent % BIN_NUM; int cellIdx = featComponent / BIN_NUM; diff --git a/modules/objdetect/src/datamatrix.cpp b/modules/objdetect/src/datamatrix.cpp index 9388ab6cc..374d73ba4 100644 --- a/modules/objdetect/src/datamatrix.cpp +++ b/modules/objdetect/src/datamatrix.cpp @@ -1,17 +1,8 @@ #include "precomp.hpp" -#if CV_SSE2 -#include -#endif - #include #include -using namespace std; - -#undef NDEBUG -#include - class Sampler { public: CvMat *im; @@ -310,7 +301,7 @@ static int decode(Sampler &sa, code &cc) } } -static deque trailto(CvMat *v, int x, int y, CvMat *terminal) +static std::deque trailto(CvMat *v, int x, int y, CvMat *terminal) { CvPoint np; /* Return the last 10th of the trail of points following v from (x,y) @@ -319,7 +310,7 @@ static deque trailto(CvMat *v, int x, int y, CvMat *terminal) int ex = x + ((short*)cvPtr2D(terminal, y, x))[0]; int ey = y + ((short*)cvPtr2D(terminal, y, x))[1]; - deque r; + std::deque r; while ((x != ex) || (y != ey)) { np.x = x; np.y = y; @@ -338,7 +329,7 @@ static deque trailto(CvMat *v, int x, int y, CvMat *terminal) } #endif -deque cvFindDataMatrix(CvMat *im) +std::deque cvFindDataMatrix(CvMat *im) { #if CV_SSE2 int r = im->rows; @@ -386,7 +377,7 @@ deque cvFindDataMatrix(CvMat *im) cfollow(vc, cxy); cfollow(vcc, ccxy); - deque candidates; + std::deque candidates; { int x, y; int rows = cxy->rows; @@ -437,13 +428,13 @@ deque cvFindDataMatrix(CvMat *im) } } - deque codes; + std::deque codes; size_t i, j, k; while (!candidates.empty()) { CvPoint o = candidates.front(); candidates.pop_front(); - deque ptc = trailto(vc, o.x, o.y, cxy); - deque ptcc = trailto(vcc, o.x, o.y, ccxy); + std::deque ptc = trailto(vc, o.x, o.y, cxy); + std::deque ptcc = trailto(vcc, o.x, o.y, ccxy); for (j = 0; j < ptc.size(); j++) { for (k = 0; k < ptcc.size(); k++) { code cc; @@ -476,7 +467,7 @@ endo: ; // end search for this o cvReleaseMat(&cxy); cvReleaseMat(&ccxy); - deque rc; + std::deque rc; for (i = 0; i < codes.size(); i++) { CvDataMatrixCode cc; strcpy(cc.msg, codes[i].msg); @@ -487,7 +478,7 @@ endo: ; // end search for this o return rc; #else (void)im; - deque rc; + std::deque rc; return rc; #endif } @@ -498,13 +489,13 @@ namespace cv { void findDataMatrix(InputArray _image, - vector& codes, + std::vector& codes, OutputArray _corners, OutputArrayOfArrays _dmtx) { Mat image = _image.getMat(); CvMat m(image); - deque rc = cvFindDataMatrix(&m); + std::deque rc = cvFindDataMatrix(&m); int i, n = (int)rc.size(); Mat corners; @@ -522,7 +513,7 @@ void findDataMatrix(InputArray _image, for( i = 0; i < n; i++ ) { CvDataMatrixCode& rc_i = rc[i]; - codes[i] = string(rc_i.msg); + codes[i] = std::string(rc_i.msg); if( corners.data ) { @@ -544,7 +535,7 @@ void findDataMatrix(InputArray _image, } void drawDataMatrixCodes(InputOutputArray _image, - const vector& codes, + const std::vector& codes, InputArray _corners) { Mat image = _image.getMat(); diff --git a/modules/objdetect/src/haar.cpp b/modules/objdetect/src/haar.cpp index 0a5f8873a..416616273 100644 --- a/modules/objdetect/src/haar.cpp +++ b/modules/objdetect/src/haar.cpp @@ -854,7 +854,7 @@ cvRunHaarClassifierCascadeSum( const CvHaarClassifierCascade* _cascade, cascade->pq2[pq_offset] + cascade->pq3[pq_offset]; variance_norm_factor = variance_norm_factor*cascade->inv_window_area - mean*mean; if( variance_norm_factor >= 0. ) - variance_norm_factor = sqrt(variance_norm_factor); + variance_norm_factor = std::sqrt(variance_norm_factor); else variance_norm_factor = 1.; @@ -1305,7 +1305,7 @@ public: { Size winSize0 = cascade->orig_window_size; Size winSize(cvRound(winSize0.width*factor), cvRound(winSize0.height*factor)); - int y1 = range.start*stripSize, y2 = min(range.end*stripSize, sum1.rows - 1 - winSize0.height); + int y1 = range.start*stripSize, y2 = std::min(range.end*stripSize, sum1.rows - 1 - winSize0.height); if (y2 <= y1 || sum1.cols <= 1 + winSize0.width) return; diff --git a/modules/objdetect/src/hog.cpp b/modules/objdetect/src/hog.cpp index f1a32c434..977f5b030 100644 --- a/modules/objdetect/src/hog.cpp +++ b/modules/objdetect/src/hog.cpp @@ -120,7 +120,7 @@ bool HOGDescriptor::read(FileNode& obj) return true; } -void HOGDescriptor::write(FileStorage& fs, const String& objName) const +void HOGDescriptor::write(FileStorage& fs, const std::string& objName) const { if( !objName.empty() ) fs << objName; @@ -142,14 +142,14 @@ void HOGDescriptor::write(FileStorage& fs, const String& objName) const fs << "}"; } -bool HOGDescriptor::load(const String& filename, const String& objname) +bool HOGDescriptor::load(const std::string& filename, const std::string& objname) { FileStorage fs(filename, FileStorage::READ); FileNode obj = !objname.empty() ? fs[objname] : fs.getFirstTopLevelNode(); return read(obj); } -void HOGDescriptor::save(const String& filename, const String& objName) const +void HOGDescriptor::save(const std::string& filename, const std::string& objName) const { FileStorage fs(filename, FileStorage::WRITE); write(fs, !objName.empty() ? objName : FileStorage::getDefaultObjectName(filename)); @@ -409,11 +409,11 @@ struct HOGCache const float* getBlock(Point pt, float* buf); virtual void normalizeBlockHistogram(float* histogram) const; - vector pixData; - vector blockData; + std::vector pixData; + std::vector blockData; bool useCache; - vector ymaxCached; + std::vector ymaxCached; Size winSize, cacheStride; Size nblocks, ncells; int blockHistogramSize; @@ -791,9 +791,9 @@ Rect HOGCache::getWindow(Size imageSize, Size winStride, int idx) const } -void HOGDescriptor::compute(const Mat& img, vector& descriptors, +void HOGDescriptor::compute(const Mat& img, std::vector& descriptors, Size winStride, Size padding, - const vector& locations) const + const std::vector& locations) const { if( winStride == Size() ) winStride = cellSize; @@ -854,8 +854,8 @@ void HOGDescriptor::compute(const Mat& img, vector& descriptors, void HOGDescriptor::detect(const Mat& img, - vector& hits, vector& weights, double hitThreshold, - Size winStride, Size padding, const vector& locations) const + std::vector& hits, std::vector& weights, double hitThreshold, + Size winStride, Size padding, const std::vector& locations) const { hits.clear(); if( svmDetector.empty() ) @@ -882,7 +882,7 @@ void HOGDescriptor::detect(const Mat& img, size_t dsize = getDescriptorSize(); double rho = svmDetector.size() > dsize ? svmDetector[dsize] : 0; - vector blockHist(blockHistogramSize); + std::vector blockHist(blockHistogramSize); for( size_t i = 0; i < nwindows; i++ ) { @@ -932,10 +932,10 @@ void HOGDescriptor::detect(const Mat& img, } } -void HOGDescriptor::detect(const Mat& img, vector& hits, double hitThreshold, - Size winStride, Size padding, const vector& locations) const +void HOGDescriptor::detect(const Mat& img, std::vector& hits, double hitThreshold, + Size winStride, Size padding, const std::vector& locations) const { - vector weightsV; + std::vector weightsV; detect(img, hits, weightsV, hitThreshold, winStride, padding, locations); } @@ -965,8 +965,8 @@ public: double minScale = i1 > 0 ? levelScale[i1] : i2 > 1 ? levelScale[i1+1] : std::max(img.cols, img.rows); Size maxSz(cvCeil(img.cols/minScale), cvCeil(img.rows/minScale)); Mat smallerImgBuf(maxSz, img.type()); - vector locations; - vector hitsWeights; + std::vector locations; + std::vector hitsWeights; for( i = i1; i < i2; i++ ) { @@ -1019,14 +1019,14 @@ public: void HOGDescriptor::detectMultiScale( - const Mat& img, vector& foundLocations, vector& foundWeights, + const Mat& img, std::vector& foundLocations, std::vector& foundWeights, double hitThreshold, Size winStride, Size padding, double scale0, double finalThreshold, bool useMeanshiftGrouping) const { double scale = 1.; int levels = 0; - vector levelScale; + std::vector levelScale; for( levels = 0; levels < nlevels; levels++ ) { levelScale.push_back(scale); @@ -1064,11 +1064,11 @@ void HOGDescriptor::detectMultiScale( } } -void HOGDescriptor::detectMultiScale(const Mat& img, vector& foundLocations, +void HOGDescriptor::detectMultiScale(const Mat& img, std::vector& foundLocations, double hitThreshold, Size winStride, Size padding, double scale0, double finalThreshold, bool useMeanshiftGrouping) const { - vector foundWeights; + std::vector foundWeights; detectMultiScale(img, foundLocations, foundWeights, hitThreshold, winStride, padding, scale0, finalThreshold, useMeanshiftGrouping); } @@ -1078,7 +1078,7 @@ typedef RTTIImpl HOGRTTI; CvType hog_type( CV_TYPE_NAME_HOG_DESCRIPTOR, HOGRTTI::isInstance, HOGRTTI::release, HOGRTTI::read, HOGRTTI::write, HOGRTTI::clone); -vector HOGDescriptor::getDefaultPeopleDetector() +std::vector HOGDescriptor::getDefaultPeopleDetector() { static const float detector[] = { 0.05359386f, -0.14721455f, -0.05532170f, 0.05077307f, @@ -1886,11 +1886,11 @@ vector HOGDescriptor::getDefaultPeopleDetector() -0.01612278f, -1.46097376e-003f, 0.14013411f, -8.96181818e-003f, -0.03250246f, 3.38630192e-003f, 2.64779478e-003f, 0.03359732f, -0.02411991f, -0.04229729f, 0.10666174f, -6.66579151f }; - return vector(detector, detector + sizeof(detector)/sizeof(detector[0])); + return std::vector(detector, detector + sizeof(detector)/sizeof(detector[0])); } //This function renurn 1981 SVM coeffs obtained from daimler's base. //To use these coeffs the detection window size should be (48,96) -vector HOGDescriptor::getDaimlerPeopleDetector() +std::vector HOGDescriptor::getDaimlerPeopleDetector() { static const float detector[] = { 0.294350f, -0.098796f, -0.129522f, 0.078753f, @@ -2389,7 +2389,7 @@ vector HOGDescriptor::getDaimlerPeopleDetector() -0.025054f, -0.093026f, -0.035372f, -0.233209f, -0.049869f, -0.039151f, -0.022279f, -0.065380f, -9.063785f}; - return vector(detector, detector + sizeof(detector)/sizeof(detector[0])); + return std::vector(detector, detector + sizeof(detector)/sizeof(detector[0])); } class HOGConfInvoker : public ParallelLoopBody @@ -2415,7 +2415,7 @@ public: Size maxSz(cvCeil(img.cols/(*locations)[0].scale), cvCeil(img.rows/(*locations)[0].scale)); Mat smallerImgBuf(maxSz, img.type()); - vector dets; + std::vector dets; for( i = i1; i < i2; i++ ) { @@ -2451,7 +2451,7 @@ public: Mutex* mtx; }; -void HOGDescriptor::detectROI(const cv::Mat& img, const vector &locations, +void HOGDescriptor::detectROI(const cv::Mat& img, const std::vector &locations, CV_OUT std::vector& foundLocations, CV_OUT std::vector& confidences, double hitThreshold, cv::Size winStride, cv::Size padding) const @@ -2489,7 +2489,7 @@ void HOGDescriptor::detectROI(const cv::Mat& img, const vector &locat size_t dsize = getDescriptorSize(); double rho = svmDetector.size() > dsize ? svmDetector[dsize] : 0; - vector blockHist(blockHistogramSize); + std::vector blockHist(blockHistogramSize); for( size_t i = 0; i < nwindows; i++ ) { diff --git a/modules/objdetect/src/latentsvmdetector.cpp b/modules/objdetect/src/latentsvmdetector.cpp index 743b93ee1..492e73f7c 100644 --- a/modules/objdetect/src/latentsvmdetector.cpp +++ b/modules/objdetect/src/latentsvmdetector.cpp @@ -158,7 +158,7 @@ LatentSvmDetector::ObjectDetection::ObjectDetection( const Rect& _rect, float _s LatentSvmDetector::LatentSvmDetector() {} -LatentSvmDetector::LatentSvmDetector( const vector& filenames, const vector& _classNames ) +LatentSvmDetector::LatentSvmDetector( const std::vector& filenames, const std::vector& _classNames ) { load( filenames, _classNames ); } @@ -182,7 +182,7 @@ bool LatentSvmDetector::empty() const return detectors.empty(); } -const vector& LatentSvmDetector::getClassNames() const +const std::vector& LatentSvmDetector::getClassNames() const { return classNames; } @@ -192,13 +192,13 @@ size_t LatentSvmDetector::getClassCount() const return classNames.size(); } -static string extractModelName( const string& filename ) +static std::string extractModelName( const std::string& filename ) { size_t startPos = filename.rfind('/'); - if( startPos == string::npos ) + if( startPos == std::string::npos ) startPos = filename.rfind('\\'); - if( startPos == string::npos ) + if( startPos == std::string::npos ) startPos = 0; else startPos++; @@ -210,7 +210,7 @@ static string extractModelName( const string& filename ) return filename.substr(startPos, substrLength); } -bool LatentSvmDetector::load( const vector& filenames, const vector& _classNames ) +bool LatentSvmDetector::load( const std::vector& filenames, const std::vector& _classNames ) { clear(); @@ -218,7 +218,7 @@ bool LatentSvmDetector::load( const vector& filenames, const vector& filenames, const vector& objectDetections, + std::vector& objectDetections, float overlapThreshold, int numThreads ) { diff --git a/modules/objdetect/test/test_latentsvmdetector.cpp b/modules/objdetect/test/test_latentsvmdetector.cpp index b595d7ac5..fbd0a5d78 100644 --- a/modules/objdetect/test/test_latentsvmdetector.cpp +++ b/modules/objdetect/test/test_latentsvmdetector.cpp @@ -52,6 +52,7 @@ #include "tbb/task_scheduler_init.h" #endif +using namespace std; using namespace cv; const int num_detections = 3; diff --git a/modules/ocl/include/opencv2/ocl/ocl.hpp b/modules/ocl/include/opencv2/ocl/ocl.hpp index 6953ef512..84a7779ac 100644 --- a/modules/ocl/include/opencv2/ocl/ocl.hpp +++ b/modules/ocl/include/opencv2/ocl/ocl.hpp @@ -56,7 +56,6 @@ namespace cv { namespace ocl { - using std::auto_ptr; enum { CVCL_DEVICE_TYPE_DEFAULT = (1 << 0), @@ -78,7 +77,7 @@ namespace cv ~Info(); void release(); Info &operator = (const Info &m); - std::vector DeviceName; + std::vector DeviceName; }; //////////////////////////////// Initialization & Info //////////////////////// //this function may be obsoleted @@ -113,8 +112,8 @@ namespace cv { protected: Context(); - friend class auto_ptr; - static auto_ptr clCxt; + friend class std::auto_ptr; + static std::auto_ptr clCxt; public: ~Context(); @@ -127,7 +126,7 @@ namespace cv //! Calls a kernel, by string. Pass globalThreads = NULL, and cleanUp = true, to finally clean-up without executing. CV_EXPORTS double openCLExecuteKernelInterop(Context *clCxt , - const char **source, string kernelName, + const char **source, std::string kernelName, size_t globalThreads[3], size_t localThreads[3], std::vector< std::pair > &args, int channels, int depth, const char *build_options, @@ -136,7 +135,7 @@ namespace cv //! Calls a kernel, by file. Pass globalThreads = NULL, and cleanUp = true, to finally clean-up without executing. CV_EXPORTS double openCLExecuteKernelInterop(Context *clCxt , - const char **fileName, const int numFiles, string kernelName, + const char **fileName, const int numFiles, std::string kernelName, size_t globalThreads[3], size_t localThreads[3], std::vector< std::pair > &args, int channels, int depth, const char *build_options, @@ -326,12 +325,12 @@ namespace cv //! Compose a multi-channel array from several single-channel arrays // Support all types CV_EXPORTS void merge(const oclMat *src, size_t n, oclMat &dst); - CV_EXPORTS void merge(const vector &src, oclMat &dst); + CV_EXPORTS void merge(const std::vector &src, oclMat &dst); //! Divides multi-channel array into several single-channel arrays // Support all types CV_EXPORTS void split(const oclMat &src, oclMat *dst); - CV_EXPORTS void split(const oclMat &src, vector &dst); + CV_EXPORTS void split(const oclMat &src, std::vector &dst); ////////////////////////////// Arithmetics /////////////////////////////////// //#if defined DOUBLE_SUPPORT @@ -933,19 +932,19 @@ namespace cv - void setSVMDetector(const vector &detector); + void setSVMDetector(const std::vector &detector); - static vector getDefaultPeopleDetector(); + static std::vector getDefaultPeopleDetector(); - static vector getPeopleDetector48x96(); + static std::vector getPeopleDetector48x96(); - static vector getPeopleDetector64x128(); + static std::vector getPeopleDetector64x128(); - void detect(const oclMat &img, vector &found_locations, + void detect(const oclMat &img, std::vector &found_locations, double hit_threshold = 0, Size win_stride = Size(), @@ -953,7 +952,7 @@ namespace cv - void detectMultiScale(const oclMat &img, vector &found_locations, + void detectMultiScale(const oclMat &img, std::vector &found_locations, double hit_threshold = 0, Size win_stride = Size(), @@ -1112,17 +1111,17 @@ namespace cv //! upload host keypoints to device memory - void uploadKeypoints(const vector &keypoints, oclMat &keypointsocl); + void uploadKeypoints(const std::vector &keypoints, oclMat &keypointsocl); //! download keypoints from device to host memory - void downloadKeypoints(const oclMat &keypointsocl, vector &keypoints); + void downloadKeypoints(const oclMat &keypointsocl, std::vector &keypoints); //! download descriptors from device to host memory - void downloadDescriptors(const oclMat &descriptorsocl, vector &descriptors); + void downloadDescriptors(const oclMat &descriptorsocl, std::vector &descriptors); @@ -1264,7 +1263,7 @@ namespace cv ResultType operator()( const T *a, const T *b, int size ) const { - return (ResultType)sqrt((double)normL2Sqr(a, b, size)); + return (ResultType)std::sqrt((double)normL2Sqr(a, b, size)); } }; @@ -1725,7 +1724,7 @@ namespace cv - void buildImagePyramid(const oclMat &img0, vector &pyr, bool withBorder); + void buildImagePyramid(const oclMat &img0, std::vector &pyr, bool withBorder); @@ -1735,9 +1734,9 @@ namespace cv - vector prevPyr_; + std::vector prevPyr_; - vector nextPyr_; + std::vector nextPyr_; diff --git a/modules/ocl/src/arithm.cpp b/modules/ocl/src/arithm.cpp index a7e4fd90b..64b03b332 100644 --- a/modules/ocl/src/arithm.cpp +++ b/modules/ocl/src/arithm.cpp @@ -55,7 +55,6 @@ using namespace cv; using namespace cv::ocl; -using namespace std; namespace cv { @@ -130,7 +129,7 @@ inline int divUp(int total, int grain) /////////////////////// add subtract multiply divide ///////////////////////// ////////////////////////////////////////////////////////////////////////////// template -void arithmetic_run(const oclMat &src1, const oclMat &src2, oclMat &dst, string kernelName, const char **kernelString, void *_scalar) +void arithmetic_run(const oclMat &src1, const oclMat &src2, oclMat &dst, std::string kernelName, const char **kernelString, void *_scalar) { if(src1.clCxt -> impl -> double_support == 0 && src1.type() == CV_64F) { @@ -166,34 +165,34 @@ void arithmetic_run(const oclMat &src1, const oclMat &src2, oclMat &dst, string }; int dst_step1 = dst.cols * dst.elemSize(); - vector > args; - args.push_back( make_pair( sizeof(cl_mem), (void *)&src1.data )); - args.push_back( make_pair( sizeof(cl_int), (void *)&src1.step )); - args.push_back( make_pair( sizeof(cl_int), (void *)&src1.offset )); - args.push_back( make_pair( sizeof(cl_mem), (void *)&src2.data )); - args.push_back( make_pair( sizeof(cl_int), (void *)&src2.step )); - args.push_back( make_pair( sizeof(cl_int), (void *)&src2.offset )); - args.push_back( make_pair( sizeof(cl_mem), (void *)&dst.data )); - args.push_back( make_pair( sizeof(cl_int), (void *)&dst.step )); - args.push_back( make_pair( sizeof(cl_int), (void *)&dst.offset )); - args.push_back( make_pair( sizeof(cl_int), (void *)&src1.rows )); - args.push_back( make_pair( sizeof(cl_int), (void *)&cols )); - args.push_back( make_pair( sizeof(cl_int), (void *)&dst_step1 )); + std::vector > args; + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&src1.data )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src1.step )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src1.offset )); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&src2.data )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src2.step )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src2.offset )); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&dst.data )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dst.step )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dst.offset )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src1.rows )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&cols )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dst_step1 )); T scalar; if(_scalar != NULL) { double scalar1 = *((double *)_scalar); scalar = (T)scalar1; - args.push_back( make_pair( sizeof(T), (void *)&scalar )); + args.push_back( std::make_pair( sizeof(T), (void *)&scalar )); } openCLExecuteKernel(clCxt, kernelString, kernelName, globalThreads, localThreads, args, -1, depth); } -static void arithmetic_run(const oclMat &src1, const oclMat &src2, oclMat &dst, string kernelName, const char **kernelString) +static void arithmetic_run(const oclMat &src1, const oclMat &src2, oclMat &dst, std::string kernelName, const char **kernelString) { arithmetic_run(src1, src2, dst, kernelName, kernelString, (void *)NULL); } -static void arithmetic_run(const oclMat &src1, const oclMat &src2, oclMat &dst, const oclMat &mask, string kernelName, const char **kernelString) +static void arithmetic_run(const oclMat &src1, const oclMat &src2, oclMat &dst, const oclMat &mask, std::string kernelName, const char **kernelString) { if(src1.clCxt -> impl -> double_support == 0 && src1.type() == CV_64F) { @@ -231,22 +230,22 @@ static void arithmetic_run(const oclMat &src1, const oclMat &src2, oclMat &dst, }; int dst_step1 = dst.cols * dst.elemSize(); - vector > args; - args.push_back( make_pair( sizeof(cl_mem), (void *)&src1.data )); - args.push_back( make_pair( sizeof(cl_int), (void *)&src1.step )); - args.push_back( make_pair( sizeof(cl_int), (void *)&src1.offset )); - args.push_back( make_pair( sizeof(cl_mem), (void *)&src2.data )); - args.push_back( make_pair( sizeof(cl_int), (void *)&src2.step )); - args.push_back( make_pair( sizeof(cl_int), (void *)&src2.offset )); - args.push_back( make_pair( sizeof(cl_mem), (void *)&mask.data )); - args.push_back( make_pair( sizeof(cl_int), (void *)&mask.step )); - args.push_back( make_pair( sizeof(cl_int), (void *)&mask.offset )); - args.push_back( make_pair( sizeof(cl_mem), (void *)&dst.data )); - args.push_back( make_pair( sizeof(cl_int), (void *)&dst.step )); - args.push_back( make_pair( sizeof(cl_int), (void *)&dst.offset )); - args.push_back( make_pair( sizeof(cl_int), (void *)&src1.rows )); - args.push_back( make_pair( sizeof(cl_int), (void *)&cols )); - args.push_back( make_pair( sizeof(cl_int), (void *)&dst_step1 )); + std::vector > args; + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&src1.data )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src1.step )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src1.offset )); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&src2.data )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src2.step )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src2.offset )); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&mask.data )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&mask.step )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&mask.offset )); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&dst.data )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dst.step )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dst.offset )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src1.rows )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&cols )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dst_step1 )); openCLExecuteKernel(clCxt, kernelString, kernelName, globalThreads, localThreads, args, channels, depth); } @@ -267,7 +266,7 @@ void cv::ocl::subtract(const oclMat &src1, const oclMat &src2, oclMat &dst, cons { arithmetic_run(src1, src2, dst, mask, "arithm_sub_with_mask", &arithm_sub); } -typedef void (*MulDivFunc)(const oclMat &src1, const oclMat &src2, oclMat &dst, string kernelName, +typedef void (*MulDivFunc)(const oclMat &src1, const oclMat &src2, oclMat &dst, std::string kernelName, const char **kernelString, void *scalar); void cv::ocl::multiply(const oclMat &src1, const oclMat &src2, oclMat &dst, double scalar) @@ -287,7 +286,7 @@ void cv::ocl::divide(const oclMat &src1, const oclMat &src2, oclMat &dst, double } template -void arithmetic_scalar_run(const oclMat &src1, const Scalar &src2, oclMat &dst, const oclMat &mask, string kernelName, const char **kernelString, int isMatSubScalar) +void arithmetic_scalar_run(const oclMat &src1, const Scalar &src2, oclMat &dst, const oclMat &mask, std::string kernelName, const char **kernelString, int isMatSubScalar) { if(src1.clCxt -> impl -> double_support == 0 && src1.type() == CV_64F) { @@ -332,34 +331,34 @@ void arithmetic_scalar_run(const oclMat &src1, const Scalar &src2, oclMat &dst, }; int dst_step1 = dst.cols * dst.elemSize(); - vector > args; - args.push_back( make_pair( sizeof(cl_mem) , (void *)&src1.data )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&src1.step )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&src1.offset)); - args.push_back( make_pair( sizeof(cl_mem) , (void *)&dst.data )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&dst.step )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&dst.offset)); + std::vector > args; + args.push_back( std::make_pair( sizeof(cl_mem) , (void *)&src1.data )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&src1.step )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&src1.offset)); + args.push_back( std::make_pair( sizeof(cl_mem) , (void *)&dst.data )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&dst.step )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&dst.offset)); if(mask.data) { - args.push_back( make_pair( sizeof(cl_mem) , (void *)&mask.data )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&mask.step )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&mask.offset)); + args.push_back( std::make_pair( sizeof(cl_mem) , (void *)&mask.data )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&mask.step )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&mask.offset)); } - args.push_back( make_pair( sizeof(CL_WT) , (void *)&s )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&src1.rows )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&cols )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&dst_step1 )); + args.push_back( std::make_pair( sizeof(CL_WT) , (void *)&s )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&src1.rows )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&cols )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&dst_step1 )); if(isMatSubScalar != 0) { isMatSubScalar = isMatSubScalar > 0 ? 1 : 0; - args.push_back( make_pair( sizeof(cl_int) , (void *)&isMatSubScalar)); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&isMatSubScalar)); } openCLExecuteKernel(clCxt, kernelString, kernelName, globalThreads, localThreads, args, channels, depth); } -static void arithmetic_scalar_run(const oclMat &src, oclMat &dst, string kernelName, const char **kernelString, double scalar) +static void arithmetic_scalar_run(const oclMat &src, oclMat &dst, std::string kernelName, const char **kernelString, double scalar) { if(src.clCxt -> impl -> double_support == 0 && src.type() == CV_64F) { @@ -394,32 +393,32 @@ static void arithmetic_scalar_run(const oclMat &src, oclMat &dst, string kernelN }; int dst_step1 = dst.cols * dst.elemSize(); - vector > args; - args.push_back( make_pair( sizeof(cl_mem), (void *)&src.data )); - args.push_back( make_pair( sizeof(cl_int), (void *)&src.step )); - args.push_back( make_pair( sizeof(cl_int), (void *)&src.offset )); - args.push_back( make_pair( sizeof(cl_mem), (void *)&dst.data )); - args.push_back( make_pair( sizeof(cl_int), (void *)&dst.step )); - args.push_back( make_pair( sizeof(cl_int), (void *)&dst.offset )); - args.push_back( make_pair( sizeof(cl_int), (void *)&src.rows )); - args.push_back( make_pair( sizeof(cl_int), (void *)&cols )); - args.push_back( make_pair( sizeof(cl_int), (void *)&dst_step1 )); + std::vector > args; + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&src.data )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src.step )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src.offset )); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&dst.data )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dst.step )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dst.offset )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src.rows )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&cols )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dst_step1 )); if(src.clCxt -> impl -> double_support != 0) - args.push_back( make_pair( sizeof(cl_double), (void *)&scalar )); + args.push_back( std::make_pair( sizeof(cl_double), (void *)&scalar )); else { float f_scalar = (float)scalar; - args.push_back( make_pair( sizeof(cl_float), (void *)&f_scalar)); + args.push_back( std::make_pair( sizeof(cl_float), (void *)&f_scalar)); } openCLExecuteKernel(clCxt, kernelString, kernelName, globalThreads, localThreads, args, -1, depth); } -typedef void (*ArithmeticFuncS)(const oclMat &src1, const Scalar &src2, oclMat &dst, const oclMat &mask, string kernelName, const char **kernelString, int isMatSubScalar); +typedef void (*ArithmeticFuncS)(const oclMat &src1, const Scalar &src2, oclMat &dst, const oclMat &mask, std::string kernelName, const char **kernelString, int isMatSubScalar); -static void arithmetic_scalar(const oclMat &src1, const Scalar &src2, oclMat &dst, const oclMat &mask, string kernelName, const char **kernelString, int isMatSubScalar) +static void arithmetic_scalar(const oclMat &src1, const Scalar &src2, oclMat &dst, const oclMat &mask, std::string kernelName, const char **kernelString, int isMatSubScalar) { static ArithmeticFuncS tab[8] = { @@ -437,14 +436,14 @@ static void arithmetic_scalar(const oclMat &src1, const Scalar &src2, oclMat &ds cv::ocl::error("Unsupported arithmetic operation", __FILE__, __LINE__); func(src1, src2, dst, mask, kernelName, kernelString, isMatSubScalar); } -static void arithmetic_scalar(const oclMat &src1, const Scalar &src2, oclMat &dst, const oclMat &mask, string kernelName, const char **kernelString) +static void arithmetic_scalar(const oclMat &src1, const Scalar &src2, oclMat &dst, const oclMat &mask, std::string kernelName, const char **kernelString) { arithmetic_scalar(src1, src2, dst, mask, kernelName, kernelString, 0); } void cv::ocl::add(const oclMat &src1, const Scalar &src2, oclMat &dst, const oclMat &mask) { - string kernelName = mask.data ? "arithm_s_add_with_mask" : "arithm_s_add"; + std::string kernelName = mask.data ? "arithm_s_add_with_mask" : "arithm_s_add"; const char **kernelString = mask.data ? &arithm_add_scalar_mask : &arithm_add_scalar; arithmetic_scalar( src1, src2, dst, mask, kernelName, kernelString); @@ -452,13 +451,13 @@ void cv::ocl::add(const oclMat &src1, const Scalar &src2, oclMat &dst, const ocl void cv::ocl::subtract(const oclMat &src1, const Scalar &src2, oclMat &dst, const oclMat &mask) { - string kernelName = mask.data ? "arithm_s_sub_with_mask" : "arithm_s_sub"; + std::string kernelName = mask.data ? "arithm_s_sub_with_mask" : "arithm_s_sub"; const char **kernelString = mask.data ? &arithm_sub_scalar_mask : &arithm_sub_scalar; arithmetic_scalar( src1, src2, dst, mask, kernelName, kernelString, 1); } void cv::ocl::subtract(const Scalar &src2, const oclMat &src1, oclMat &dst, const oclMat &mask) { - string kernelName = mask.data ? "arithm_s_sub_with_mask" : "arithm_s_sub"; + std::string kernelName = mask.data ? "arithm_s_sub_with_mask" : "arithm_s_sub"; const char **kernelString = mask.data ? &arithm_sub_scalar_mask : &arithm_sub_scalar; arithmetic_scalar( src1, src2, dst, mask, kernelName, kernelString, -1); } @@ -470,7 +469,7 @@ void cv::ocl::divide(double scalar, const oclMat &src, oclMat &dst) return; } - string kernelName = "arithm_s_div"; + std::string kernelName = "arithm_s_div"; arithmetic_scalar_run(src, dst, kernelName, &arithm_div, scalar); } ////////////////////////////////////////////////////////////////////////////// @@ -482,14 +481,14 @@ void cv::ocl::absdiff(const oclMat &src1, const oclMat &src2, oclMat &dst) } void cv::ocl::absdiff(const oclMat &src1, const Scalar &src2, oclMat &dst) { - string kernelName = "arithm_s_absdiff"; + std::string kernelName = "arithm_s_absdiff"; oclMat mask; arithmetic_scalar( src1, src2, dst, mask, kernelName, &arithm_absdiff); } ////////////////////////////////////////////////////////////////////////////// ///////////////////////////////// compare /////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// -static void compare_run(const oclMat &src1, const oclMat &src2, oclMat &dst, string kernelName, const char **kernelString) +static void compare_run(const oclMat &src1, const oclMat &src2, oclMat &dst, std::string kernelName, const char **kernelString) { dst.create(src1.size(), CV_8UC1); CV_Assert(src1.oclchannels() == 1); @@ -506,19 +505,19 @@ static void compare_run(const oclMat &src1, const oclMat &src2, oclMat &dst, str 1 }; int dst_step1 = dst.cols * dst.elemSize(); - vector > args; - args.push_back( make_pair( sizeof(cl_mem), (void *)&src1.data )); - args.push_back( make_pair( sizeof(cl_int), (void *)&src1.step )); - args.push_back( make_pair( sizeof(cl_int), (void *)&src1.offset )); - args.push_back( make_pair( sizeof(cl_mem), (void *)&src2.data )); - args.push_back( make_pair( sizeof(cl_int), (void *)&src2.step )); - args.push_back( make_pair( sizeof(cl_int), (void *)&src2.offset )); - args.push_back( make_pair( sizeof(cl_mem), (void *)&dst.data )); - args.push_back( make_pair( sizeof(cl_int), (void *)&dst.step )); - args.push_back( make_pair( sizeof(cl_int), (void *)&dst.offset )); - args.push_back( make_pair( sizeof(cl_int), (void *)&src1.rows )); - args.push_back( make_pair( sizeof(cl_int), (void *)&cols )); - args.push_back( make_pair( sizeof(cl_int), (void *)&dst_step1 )); + std::vector > args; + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&src1.data )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src1.step )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src1.offset )); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&src2.data )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src2.step )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src2.offset )); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&dst.data )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dst.step )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dst.offset )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src1.rows )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&cols )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dst_step1 )); openCLExecuteKernel(clCxt, kernelString, kernelName, globalThreads, localThreads, args, -1, depth); } @@ -526,10 +525,10 @@ void cv::ocl::compare(const oclMat &src1, const oclMat &src2, oclMat &dst , int { if(src1.clCxt -> impl -> double_support == 0 && src1.type() == CV_64F) { - cout << "Selected device do not support double" << endl; + std::cout << "Selected device do not support double" << std::endl; return; } - string kernelName; + std::string kernelName; const char **kernelString = NULL; switch( cmpOp ) { @@ -570,7 +569,7 @@ void cv::ocl::compare(const oclMat &src1, const oclMat &src2, oclMat &dst , int //type = 0 sum,type = 1 absSum,type = 2 sqrSum static void arithmetic_sum_buffer_run(const oclMat &src, cl_mem &dst, int vlen , int groupnum, int type = 0) { - vector > args; + std::vector > args; int all_cols = src.step / (vlen * src.elemSize1()); int pre_cols = (src.offset % src.step) / (vlen * src.elemSize1()); int sec_cols = all_cols - (src.offset % src.step + src.cols * src.elemSize() - 1) / (vlen * src.elemSize1()) - 1; @@ -582,13 +581,13 @@ static void arithmetic_sum_buffer_run(const oclMat &src, cl_mem &dst, int vlen , char build_options[512]; CV_Assert(type == 0 || type == 1 || type == 2); sprintf(build_options, "-D DEPTH_%d -D REPEAT_S%d -D REPEAT_E%d -D FUNC_TYPE_%d", src.depth(), repeat_s, repeat_e, type); - args.push_back( make_pair( sizeof(cl_int) , (void *)&cols )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&invalid_cols )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&offset)); - args.push_back( make_pair( sizeof(cl_int) , (void *)&elemnum)); - args.push_back( make_pair( sizeof(cl_int) , (void *)&groupnum)); - args.push_back( make_pair( sizeof(cl_mem) , (void *)&src.data)); - args.push_back( make_pair( sizeof(cl_mem) , (void *)&dst )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&cols )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&invalid_cols )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&offset)); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&elemnum)); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&groupnum)); + args.push_back( std::make_pair( sizeof(cl_mem) , (void *)&src.data)); + args.push_back( std::make_pair( sizeof(cl_mem) , (void *)&dst )); size_t gt[3] = {groupnum * 256, 1, 1}, lt[3] = {256, 1, 1}; if(src.oclchannels() != 3) openCLExecuteKernel(src.clCxt, &arithm_sum, "arithm_op_sum", gt, lt, args, -1, -1, build_options); @@ -701,9 +700,9 @@ void cv::ocl::meanStdDev(const oclMat &src, Scalar &mean, Scalar &stddev) ////////////////////////////////////////////////////////////////////////////// //////////////////////////////////// minMax ///////////////////////////////// ////////////////////////////////////////////////////////////////////////////// -static void arithmetic_minMax_run(const oclMat &src, const oclMat &mask, cl_mem &dst, int vlen , int groupnum, string kernelName) +static void arithmetic_minMax_run(const oclMat &src, const oclMat &mask, cl_mem &dst, int vlen , int groupnum, std::string kernelName) { - vector > args; + std::vector > args; int all_cols = src.step / (vlen * src.elemSize1()); int pre_cols = (src.offset % src.step) / (vlen * src.elemSize1()); int sec_cols = all_cols - (src.offset % src.step + src.cols * src.elemSize() - 1) / (vlen * src.elemSize1()) - 1; @@ -714,12 +713,12 @@ static void arithmetic_minMax_run(const oclMat &src, const oclMat &mask, cl_mem int repeat_e = (offset + cols) * vlen - src.offset / src.elemSize1() - src.cols * src.oclchannels(); char build_options[50]; sprintf(build_options, "-D DEPTH_%d -D REPEAT_S%d -D REPEAT_E%d", src.depth(), repeat_s, repeat_e); - args.push_back( make_pair( sizeof(cl_int) , (void *)&cols )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&invalid_cols )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&offset)); - args.push_back( make_pair( sizeof(cl_int) , (void *)&elemnum)); - args.push_back( make_pair( sizeof(cl_int) , (void *)&groupnum)); - args.push_back( make_pair( sizeof(cl_mem) , (void *)&src.data)); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&cols )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&invalid_cols )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&offset)); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&elemnum)); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&groupnum)); + args.push_back( std::make_pair( sizeof(cl_mem) , (void *)&src.data)); if(!mask.empty()) { int mall_cols = mask.step / (vlen * mask.elemSize1()); @@ -728,19 +727,19 @@ static void arithmetic_minMax_run(const oclMat &src, const oclMat &mask, cl_mem int minvalid_cols = mpre_cols + msec_cols; int moffset = mask.offset / (vlen * mask.elemSize1()); - args.push_back( make_pair( sizeof(cl_int) , (void *)&minvalid_cols )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&moffset )); - args.push_back( make_pair( sizeof(cl_mem) , (void *)&mask.data )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&minvalid_cols )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&moffset )); + args.push_back( std::make_pair( sizeof(cl_mem) , (void *)&mask.data )); } - args.push_back( make_pair( sizeof(cl_mem) , (void *)&dst )); + args.push_back( std::make_pair( sizeof(cl_mem) , (void *)&dst )); size_t gt[3] = {groupnum * 256, 1, 1}, lt[3] = {256, 1, 1}; openCLExecuteKernel(src.clCxt, &arithm_minMax, kernelName, gt, lt, args, -1, -1, build_options); } -static void arithmetic_minMax_mask_run(const oclMat &src, const oclMat &mask, cl_mem &dst, int vlen, int groupnum, string kernelName) +static void arithmetic_minMax_mask_run(const oclMat &src, const oclMat &mask, cl_mem &dst, int vlen, int groupnum, std::string kernelName) { - vector > args; + std::vector > args; size_t gt[3] = {groupnum * 256, 1, 1}, lt[3] = {256, 1, 1}; char build_options[50]; if(src.oclchannels() == 1) @@ -753,16 +752,16 @@ static void arithmetic_minMax_mask_run(const oclMat &src, const oclMat &mask, cl int moffset = mask.offset / mask.elemSize1(); int elemnum = cols * src.rows; sprintf(build_options, "-D DEPTH_%d -D REPEAT_E%d", src.depth(), repeat_me); - args.push_back( make_pair( sizeof(cl_int) , (void *)&cols )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&invalid_cols )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&offset)); - args.push_back( make_pair( sizeof(cl_int) , (void *)&elemnum)); - args.push_back( make_pair( sizeof(cl_int) , (void *)&groupnum)); - args.push_back( make_pair( sizeof(cl_mem) , (void *)&src.data)); - args.push_back( make_pair( sizeof(cl_int) , (void *)&minvalid_cols )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&moffset )); - args.push_back( make_pair( sizeof(cl_mem) , (void *)&mask.data )); - args.push_back( make_pair( sizeof(cl_mem) , (void *)&dst )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&cols )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&invalid_cols )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&offset)); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&elemnum)); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&groupnum)); + args.push_back( std::make_pair( sizeof(cl_mem) , (void *)&src.data)); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&minvalid_cols )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&moffset )); + args.push_back( std::make_pair( sizeof(cl_mem) , (void *)&mask.data )); + args.push_back( std::make_pair( sizeof(cl_mem) , (void *)&dst )); // printf("elemnum:%d,cols:%d,invalid_cols:%d,offset:%d,minvalid_cols:%d,moffset:%d,repeat_e:%d\r\n", // elemnum,cols,invalid_cols,offset,minvalid_cols,moffset,repeat_me); openCLExecuteKernel(src.clCxt, &arithm_minMax_mask, kernelName, gt, lt, args, -1, -1, build_options); @@ -892,7 +891,7 @@ double cv::ocl::norm(const oclMat &src1, const oclMat &src2, int normType) ////////////////////////////////////////////////////////////////////////////// ////////////////////////////////// flip ////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// -static void arithmetic_flip_rows_run(const oclMat &src, oclMat &dst, string kernelName) +static void arithmetic_flip_rows_run(const oclMat &src, oclMat &dst, std::string kernelName) { if(src.clCxt -> impl -> double_support == 0 && src.type() == CV_64F) { @@ -927,21 +926,21 @@ static void arithmetic_flip_rows_run(const oclMat &src, oclMat &dst, string kern }; int dst_step1 = dst.cols * dst.elemSize(); - vector > args; - args.push_back( make_pair( sizeof(cl_mem), (void *)&src.data )); - args.push_back( make_pair( sizeof(cl_int), (void *)&src.step )); - args.push_back( make_pair( sizeof(cl_int), (void *)&src.offset )); - args.push_back( make_pair( sizeof(cl_mem), (void *)&dst.data )); - args.push_back( make_pair( sizeof(cl_int), (void *)&dst.step )); - args.push_back( make_pair( sizeof(cl_int), (void *)&dst.offset )); - args.push_back( make_pair( sizeof(cl_int), (void *)&dst.rows )); - args.push_back( make_pair( sizeof(cl_int), (void *)&cols )); - args.push_back( make_pair( sizeof(cl_int), (void *)&rows )); - args.push_back( make_pair( sizeof(cl_int), (void *)&dst_step1 )); + std::vector > args; + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&src.data )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src.step )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src.offset )); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&dst.data )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dst.step )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dst.offset )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dst.rows )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&cols )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&rows )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dst_step1 )); openCLExecuteKernel(clCxt, &arithm_flip, kernelName, globalThreads, localThreads, args, -1, depth); } -static void arithmetic_flip_cols_run(const oclMat &src, oclMat &dst, string kernelName, bool isVertical) +static void arithmetic_flip_cols_run(const oclMat &src, oclMat &dst, std::string kernelName, bool isVertical) { if(src.clCxt -> impl -> double_support == 0 && src.type() == CV_64F) { @@ -975,22 +974,22 @@ static void arithmetic_flip_cols_run(const oclMat &src, oclMat &dst, string kern }; int dst_step1 = dst.cols * dst.elemSize(); - vector > args; - args.push_back( make_pair( sizeof(cl_mem), (void *)&src.data )); - args.push_back( make_pair( sizeof(cl_int), (void *)&src.step )); - args.push_back( make_pair( sizeof(cl_int), (void *)&src.offset )); - args.push_back( make_pair( sizeof(cl_mem), (void *)&dst.data )); - args.push_back( make_pair( sizeof(cl_int), (void *)&dst.step )); - args.push_back( make_pair( sizeof(cl_int), (void *)&dst.offset )); - args.push_back( make_pair( sizeof(cl_int), (void *)&dst.rows )); - args.push_back( make_pair( sizeof(cl_int), (void *)&dst.cols )); + std::vector > args; + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&src.data )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src.step )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src.offset )); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&dst.data )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dst.step )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dst.offset )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dst.rows )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dst.cols )); if(isVertical) - args.push_back( make_pair( sizeof(cl_int), (void *)&rows )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&rows )); else - args.push_back( make_pair( sizeof(cl_int), (void *)&cols )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&cols )); - args.push_back( make_pair( sizeof(cl_int), (void *)&dst_step1 )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dst_step1 )); const char **kernelString = isVertical ? &arithm_flip_rc : &arithm_flip; @@ -1012,7 +1011,7 @@ void cv::ocl::flip(const oclMat &src, oclMat &dst, int flipCode) ////////////////////////////////////////////////////////////////////////////// ////////////////////////////////// LUT ////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// -static void arithmetic_lut_run(const oclMat &src1, const oclMat &src2, oclMat &dst, string kernelName) +static void arithmetic_lut_run(const oclMat &src1, const oclMat &src2, oclMat &dst, std::string kernelName) { Context *clCxt = src1.clCxt; int channels = src1.oclchannels(); @@ -1053,23 +1052,23 @@ static void arithmetic_lut_run(const oclMat &src1, const oclMat &src2, oclMat &d CV_Assert(src1.rows == dst.rows); CV_Assert(src1.oclchannels() == dst.oclchannels()); // CV_Assert(src1.step == dst.step); - vector > args; + std::vector > args; if(globalSize[0] != 0) { - args.push_back( make_pair( sizeof(cl_mem), (void *)&dst.data )); - args.push_back( make_pair( sizeof(cl_mem), (void *)&src1.data )); - args.push_back( make_pair( sizeof(cl_mem), (void *)&src2.data )); - args.push_back( make_pair( sizeof(cl_int), (void *)&rows )); - args.push_back( make_pair( sizeof(cl_int), (void *)&cols )); - args.push_back( make_pair( sizeof(cl_int), (void *)&channels )); - args.push_back( make_pair( sizeof(cl_int), (void *)&whole_rows )); - args.push_back( make_pair( sizeof(cl_int), (void *)&whole_cols )); - args.push_back( make_pair( sizeof(cl_int), (void *)&src_offset )); - args.push_back( make_pair( sizeof(cl_int), (void *)&dst_offset )); - args.push_back( make_pair( sizeof(cl_int), (void *)&lut_offset )); - args.push_back( make_pair( sizeof(cl_int), (void *)&src_step )); - args.push_back( make_pair( sizeof(cl_int), (void *)&dst_step )); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&dst.data )); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&src1.data )); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&src2.data )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&rows )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&cols )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&channels )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&whole_rows )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&whole_cols )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src_offset )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dst_offset )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&lut_offset )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src_step )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dst_step )); openCLExecuteKernel(clCxt, &arithm_LUT, kernelName, globalSize, localSize, args, src1.oclchannels(), src1.depth()); } if(channels == 1 && (left_col != 0 || right_col != 0)) @@ -1082,19 +1081,19 @@ static void arithmetic_lut_run(const oclMat &src1, const oclMat &src2, oclMat &d globalSize[1] = (rows + localSize[1] - 1) / localSize[1] * localSize[1]; //kernel = openCLGetKernelFromSource(clCxt,&arithm_LUT,"LUT2"); args.clear(); - args.push_back( make_pair( sizeof(cl_mem), (void *)&dst.data )); - args.push_back( make_pair( sizeof(cl_mem), (void *)&src1.data )); - args.push_back( make_pair( sizeof(cl_mem), (void *)&src2.data )); - args.push_back( make_pair( sizeof(cl_int), (void *)&rows )); - args.push_back( make_pair( sizeof(cl_int), (void *)&left_col )); - args.push_back( make_pair( sizeof(cl_int), (void *)&channels )); - args.push_back( make_pair( sizeof(cl_int), (void *)&whole_rows )); - args.push_back( make_pair( sizeof(cl_int), (void *)&cols )); - args.push_back( make_pair( sizeof(cl_int), (void *)&src_offset )); - args.push_back( make_pair( sizeof(cl_int), (void *)&dst_offset )); - args.push_back( make_pair( sizeof(cl_int), (void *)&lut_offset )); - args.push_back( make_pair( sizeof(cl_int), (void *)&src_step )); - args.push_back( make_pair( sizeof(cl_int), (void *)&dst_step )); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&dst.data )); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&src1.data )); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&src2.data )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&rows )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&left_col )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&channels )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&whole_rows )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&cols )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src_offset )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dst_offset )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&lut_offset )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src_step )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dst_step )); openCLExecuteKernel(clCxt, &arithm_LUT, "LUT2", globalSize, localSize, args, src1.oclchannels(), src1.depth()); } } @@ -1106,14 +1105,14 @@ void cv::ocl::LUT(const oclMat &src, const oclMat &lut, oclMat &dst) CV_Assert((lut.oclchannels() == 1 || lut.oclchannels() == cn) && lut.rows == 1 && lut.cols == 256); dst.create(src.size(), CV_MAKETYPE(lut.depth(), cn)); //oclMat _lut(lut); - string kernelName = "LUT"; + std::string kernelName = "LUT"; arithmetic_lut_run(src, lut, dst, kernelName); } ////////////////////////////////////////////////////////////////////////////// //////////////////////////////// exp log ///////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// -static void arithmetic_exp_log_run(const oclMat &src, oclMat &dst, string kernelName, const char **kernelString) +static void arithmetic_exp_log_run(const oclMat &src, oclMat &dst, std::string kernelName, const char **kernelString) { dst.create(src.size(), src.type()); CV_Assert(src.cols == dst.cols && @@ -1137,15 +1136,15 @@ static void arithmetic_exp_log_run(const oclMat &src, oclMat &dst, string kernel 1 }; - vector > args; - args.push_back( make_pair( sizeof(cl_int), (void *)&src.rows )); - args.push_back( make_pair( sizeof(cl_int), (void *)&src.cols )); - args.push_back( make_pair( sizeof(cl_int), (void *)&src.step )); - args.push_back( make_pair( sizeof(cl_int), (void *)&dst.step )); - args.push_back( make_pair( sizeof(cl_int), (void *)&src.offset )); - args.push_back( make_pair( sizeof(cl_int), (void *)&dst.offset )); - args.push_back( make_pair( sizeof(cl_mem), (void *)&src.data )); - args.push_back( make_pair( sizeof(cl_mem), (void *)&dst.data )); + std::vector > args; + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src.rows )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src.cols )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src.step )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dst.step )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src.offset )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dst.offset )); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&src.data )); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&dst.data )); openCLExecuteKernel(clCxt, kernelString, kernelName, globalThreads, localThreads, args, -1, depth); } @@ -1162,7 +1161,7 @@ void cv::ocl::log(const oclMat &src, oclMat &dst) ////////////////////////////////////////////////////////////////////////////// ////////////////////////////// magnitude phase /////////////////////////////// ////////////////////////////////////////////////////////////////////////////// -static void arithmetic_magnitude_phase_run(const oclMat &src1, const oclMat &src2, oclMat &dst, string kernelName) +static void arithmetic_magnitude_phase_run(const oclMat &src1, const oclMat &src2, oclMat &dst, std::string kernelName) { if(src1.clCxt -> impl -> double_support == 0 && src1.type() == CV_64F) { @@ -1185,18 +1184,18 @@ static void arithmetic_magnitude_phase_run(const oclMat &src1, const oclMat &src 1 }; - vector > args; - args.push_back( make_pair( sizeof(cl_mem), (void *)&src1.data )); - args.push_back( make_pair( sizeof(cl_int), (void *)&src1.step )); - args.push_back( make_pair( sizeof(cl_int), (void *)&src1.offset )); - args.push_back( make_pair( sizeof(cl_mem), (void *)&src2.data )); - args.push_back( make_pair( sizeof(cl_int), (void *)&src2.step )); - args.push_back( make_pair( sizeof(cl_int), (void *)&src2.offset )); - args.push_back( make_pair( sizeof(cl_mem), (void *)&dst.data )); - args.push_back( make_pair( sizeof(cl_int), (void *)&dst.step )); - args.push_back( make_pair( sizeof(cl_int), (void *)&dst.offset )); - args.push_back( make_pair( sizeof(cl_int), (void *)&dst.rows )); - args.push_back( make_pair( sizeof(cl_int), (void *)&cols )); + std::vector > args; + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&src1.data )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src1.step )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src1.offset )); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&src2.data )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src2.step )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src2.offset )); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&dst.data )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dst.step )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dst.offset )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dst.rows )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&cols )); openCLExecuteKernel(clCxt, &arithm_magnitude, kernelName, globalThreads, localThreads, args, -1, depth); } @@ -1210,7 +1209,7 @@ void cv::ocl::magnitude(const oclMat &src1, const oclMat &src2, oclMat &dst) arithmetic_magnitude_phase_run(src1, src2, dst, "arithm_magnitude"); } -static void arithmetic_phase_run(const oclMat &src1, const oclMat &src2, oclMat &dst, string kernelName, const char **kernelString) +static void arithmetic_phase_run(const oclMat &src1, const oclMat &src2, oclMat &dst, std::string kernelName, const char **kernelString) { if(src1.clCxt -> impl -> double_support == 0 && src1.type() == CV_64F) { @@ -1237,19 +1236,19 @@ static void arithmetic_phase_run(const oclMat &src1, const oclMat &src2, oclMat }; int dst_step1 = dst.cols * dst.elemSize(); - vector > args; - args.push_back( make_pair( sizeof(cl_mem), (void *)&src1.data )); - args.push_back( make_pair( sizeof(cl_int), (void *)&src1.step )); - args.push_back( make_pair( sizeof(cl_int), (void *)&src1.offset )); - args.push_back( make_pair( sizeof(cl_mem), (void *)&src2.data )); - args.push_back( make_pair( sizeof(cl_int), (void *)&src2.step )); - args.push_back( make_pair( sizeof(cl_int), (void *)&src2.offset )); - args.push_back( make_pair( sizeof(cl_mem), (void *)&dst.data )); - args.push_back( make_pair( sizeof(cl_int), (void *)&dst.step )); - args.push_back( make_pair( sizeof(cl_int), (void *)&dst.offset )); - args.push_back( make_pair( sizeof(cl_int), (void *)&dst.rows )); - args.push_back( make_pair( sizeof(cl_int), (void *)&cols )); - args.push_back( make_pair( sizeof(cl_int), (void *)&dst_step1 )); + std::vector > args; + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&src1.data )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src1.step )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src1.offset )); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&src2.data )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src2.step )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src2.offset )); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&dst.data )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dst.step )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dst.offset )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dst.rows )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&cols )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dst_step1 )); openCLExecuteKernel(clCxt, kernelString, kernelName, globalThreads, localThreads, args, -1, depth); } @@ -1257,16 +1256,16 @@ void cv::ocl::phase(const oclMat &x, const oclMat &y, oclMat &Angle , bool angle { CV_Assert(x.type() == y.type() && x.size() == y.size() && (x.depth() == CV_32F || x.depth() == CV_64F)); Angle.create(x.size(), x.type()); - string kernelName = angleInDegrees ? "arithm_phase_indegrees" : "arithm_phase_inradians"; + std::string kernelName = angleInDegrees ? "arithm_phase_indegrees" : "arithm_phase_inradians"; if(angleInDegrees) { arithmetic_phase_run(x, y, Angle, kernelName, &arithm_phase); - //cout<<"1"< impl -> double_support == 0 && src1.type() == CV_64F) { @@ -1296,22 +1295,22 @@ static void arithmetic_cartToPolar_run(const oclMat &src1, const oclMat &src2, o }; int tmp = angleInDegrees ? 1 : 0; - vector > args; - args.push_back( make_pair( sizeof(cl_mem), (void *)&src1.data )); - args.push_back( make_pair( sizeof(cl_int), (void *)&src1.step )); - args.push_back( make_pair( sizeof(cl_int), (void *)&src1.offset )); - args.push_back( make_pair( sizeof(cl_mem), (void *)&src2.data )); - args.push_back( make_pair( sizeof(cl_int), (void *)&src2.step )); - args.push_back( make_pair( sizeof(cl_int), (void *)&src2.offset )); - args.push_back( make_pair( sizeof(cl_mem), (void *)&dst_mag.data )); - args.push_back( make_pair( sizeof(cl_int), (void *)&dst_mag.step )); - args.push_back( make_pair( sizeof(cl_int), (void *)&dst_mag.offset )); - args.push_back( make_pair( sizeof(cl_mem), (void *)&dst_cart.data )); - args.push_back( make_pair( sizeof(cl_int), (void *)&dst_cart.step )); - args.push_back( make_pair( sizeof(cl_int), (void *)&dst_cart.offset )); - args.push_back( make_pair( sizeof(cl_int), (void *)&rows )); - args.push_back( make_pair( sizeof(cl_int), (void *)&cols )); - args.push_back( make_pair( sizeof(cl_int), (void *)&tmp )); + std::vector > args; + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&src1.data )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src1.step )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src1.offset )); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&src2.data )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src2.step )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src2.offset )); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&dst_mag.data )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dst_mag.step )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dst_mag.offset )); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&dst_cart.data )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dst_cart.step )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dst_cart.offset )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&rows )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&cols )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&tmp )); openCLExecuteKernel(clCxt, &arithm_cartToPolar, kernelName, globalThreads, localThreads, args, -1, depth); } @@ -1329,7 +1328,7 @@ void cv::ocl::cartToPolar(const oclMat &x, const oclMat &y, oclMat &mag, oclMat ////////////////////////////////// polarToCart /////////////////////////////// ////////////////////////////////////////////////////////////////////////////// static void arithmetic_ptc_run(const oclMat &src1, const oclMat &src2, oclMat &dst1, oclMat &dst2, bool angleInDegrees, - string kernelName) + std::string kernelName) { if(src1.clCxt -> impl -> double_support == 0 && src1.type() == CV_64F) { @@ -1351,25 +1350,25 @@ static void arithmetic_ptc_run(const oclMat &src1, const oclMat &src2, oclMat &d }; int tmp = angleInDegrees ? 1 : 0; - vector > args; + std::vector > args; if(src1.data) { - args.push_back( make_pair( sizeof(cl_mem), (void *)&src1.data )); - args.push_back( make_pair( sizeof(cl_int), (void *)&src1.step )); - args.push_back( make_pair( sizeof(cl_int), (void *)&src1.offset )); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&src1.data )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src1.step )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src1.offset )); } - args.push_back( make_pair( sizeof(cl_mem), (void *)&src2.data )); - args.push_back( make_pair( sizeof(cl_int), (void *)&src2.step )); - args.push_back( make_pair( sizeof(cl_int), (void *)&src2.offset )); - args.push_back( make_pair( sizeof(cl_mem), (void *)&dst1.data )); - args.push_back( make_pair( sizeof(cl_int), (void *)&dst1.step )); - args.push_back( make_pair( sizeof(cl_int), (void *)&dst1.offset )); - args.push_back( make_pair( sizeof(cl_mem), (void *)&dst2.data )); - args.push_back( make_pair( sizeof(cl_int), (void *)&dst2.step )); - args.push_back( make_pair( sizeof(cl_int), (void *)&dst2.offset )); - args.push_back( make_pair( sizeof(cl_int), (void *)&rows )); - args.push_back( make_pair( sizeof(cl_int), (void *)&cols )); - args.push_back( make_pair( sizeof(cl_int), (void *)&tmp )); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&src2.data )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src2.step )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src2.offset )); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&dst1.data )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dst1.step )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dst1.offset )); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&dst2.data )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dst2.step )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dst2.offset )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&rows )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&cols )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&tmp )); openCLExecuteKernel(clCxt, &arithm_polarToCart, kernelName, globalThreads, localThreads, args, -1, depth); } @@ -1395,7 +1394,7 @@ void cv::ocl::polarToCart(const oclMat &magnitude, const oclMat &angle, oclMat & ////////////////////////////////////////////////////////////////////////////// static void arithmetic_minMaxLoc_run(const oclMat &src, cl_mem &dst, int vlen , int groupnum) { - vector > args; + std::vector > args; int all_cols = src.step / (vlen * src.elemSize1()); int pre_cols = (src.offset % src.step) / (vlen * src.elemSize1()); int sec_cols = all_cols - (src.offset % src.step + src.cols * src.elemSize1() - 1) / (vlen * src.elemSize1()) - 1; @@ -1404,13 +1403,13 @@ static void arithmetic_minMaxLoc_run(const oclMat &src, cl_mem &dst, int vlen , int offset = src.offset / (vlen * src.elemSize1()); int repeat_s = src.offset / src.elemSize1() - offset * vlen; int repeat_e = (offset + cols) * vlen - src.offset / src.elemSize1() - src.cols; - args.push_back( make_pair( sizeof(cl_int) , (void *)&cols )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&invalid_cols )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&offset)); - args.push_back( make_pair( sizeof(cl_int) , (void *)&elemnum)); - args.push_back( make_pair( sizeof(cl_int) , (void *)&groupnum)); - args.push_back( make_pair( sizeof(cl_mem) , (void *)&src.data)); - args.push_back( make_pair( sizeof(cl_mem) , (void *)&dst )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&cols )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&invalid_cols )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&offset)); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&elemnum)); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&groupnum)); + args.push_back( std::make_pair( sizeof(cl_mem) , (void *)&src.data)); + args.push_back( std::make_pair( sizeof(cl_mem) , (void *)&dst )); char build_options[50]; sprintf(build_options, "-D DEPTH_%d -D REPEAT_S%d -D REPEAT_E%d", src.depth(), repeat_s, repeat_e); size_t gt[3] = {groupnum * 256, 1, 1}, lt[3] = {256, 1, 1}; @@ -1419,7 +1418,7 @@ static void arithmetic_minMaxLoc_run(const oclMat &src, cl_mem &dst, int vlen , static void arithmetic_minMaxLoc_mask_run(const oclMat &src, const oclMat &mask, cl_mem &dst, int vlen, int groupnum) { - vector > args; + std::vector > args; size_t gt[3] = {groupnum * 256, 1, 1}, lt[3] = {256, 1, 1}; char build_options[50]; if(src.oclchannels() == 1) @@ -1432,16 +1431,16 @@ static void arithmetic_minMaxLoc_mask_run(const oclMat &src, const oclMat &mask, int moffset = mask.offset / mask.elemSize1(); int elemnum = cols * src.rows; sprintf(build_options, "-D DEPTH_%d -D REPEAT_E%d", src.depth(), repeat_me); - args.push_back( make_pair( sizeof(cl_int) , (void *)&cols )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&invalid_cols )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&offset)); - args.push_back( make_pair( sizeof(cl_int) , (void *)&elemnum)); - args.push_back( make_pair( sizeof(cl_int) , (void *)&groupnum)); - args.push_back( make_pair( sizeof(cl_mem) , (void *)&src.data)); - args.push_back( make_pair( sizeof(cl_int) , (void *)&minvalid_cols )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&moffset )); - args.push_back( make_pair( sizeof(cl_mem) , (void *)&mask.data )); - args.push_back( make_pair( sizeof(cl_mem) , (void *)&dst )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&cols )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&invalid_cols )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&offset)); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&elemnum)); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&groupnum)); + args.push_back( std::make_pair( sizeof(cl_mem) , (void *)&src.data)); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&minvalid_cols )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&moffset )); + args.push_back( std::make_pair( sizeof(cl_mem) , (void *)&mask.data )); + args.push_back( std::make_pair( sizeof(cl_mem) , (void *)&dst )); // printf("elemnum:%d,cols:%d,invalid_cols:%d,offset:%d,minvalid_cols:%d,moffset:%d,repeat_e:%d\r\n", // elemnum,cols,invalid_cols,offset,minvalid_cols,moffset,repeat_me); openCLExecuteKernel(src.clCxt, &arithm_minMaxLoc_mask, "arithm_op_minMaxLoc_mask", gt, lt, args, -1, -1, build_options); @@ -1531,9 +1530,9 @@ void cv::ocl::minMaxLoc(const oclMat &src, double *minVal, double *maxVal, ////////////////////////////////////////////////////////////////////////////// ///////////////////////////// countNonZero /////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// -static void arithmetic_countNonZero_run(const oclMat &src, cl_mem &dst, int vlen , int groupnum, string kernelName) +static void arithmetic_countNonZero_run(const oclMat &src, cl_mem &dst, int vlen , int groupnum, std::string kernelName) { - vector > args; + std::vector > args; int all_cols = src.step / (vlen * src.elemSize1()); int pre_cols = (src.offset % src.step) / (vlen * src.elemSize1()); int sec_cols = all_cols - (src.offset % src.step + src.cols * src.elemSize() - 1) / (vlen * src.elemSize1()) - 1; @@ -1546,13 +1545,13 @@ static void arithmetic_countNonZero_run(const oclMat &src, cl_mem &dst, int vlen char build_options[50]; sprintf(build_options, "-D DEPTH_%d -D REPEAT_S%d -D REPEAT_E%d", src.depth(), repeat_s, repeat_e); - args.push_back( make_pair( sizeof(cl_int) , (void *)&cols )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&invalid_cols )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&offset)); - args.push_back( make_pair( sizeof(cl_int) , (void *)&elemnum)); - args.push_back( make_pair( sizeof(cl_int) , (void *)&groupnum)); - args.push_back( make_pair( sizeof(cl_mem) , (void *)&src.data)); - args.push_back( make_pair( sizeof(cl_mem) , (void *)&dst )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&cols )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&invalid_cols )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&offset)); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&elemnum)); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&groupnum)); + args.push_back( std::make_pair( sizeof(cl_mem) , (void *)&src.data)); + args.push_back( std::make_pair( sizeof(cl_mem) , (void *)&dst )); size_t gt[3] = {groupnum * 256, 1, 1}, lt[3] = {256, 1, 1}; openCLExecuteKernel(src.clCxt, &arithm_nonzero, kernelName, gt, lt, args, -1, -1, build_options); } @@ -1569,7 +1568,7 @@ int cv::ocl::countNonZero(const oclMat &src) int vlen = 8 , dbsize = groupnum * vlen; //cl_ulong start, end; Context *clCxt = src.clCxt; - string kernelName = "arithm_op_nonzero"; + std::string kernelName = "arithm_op_nonzero"; int *p = new int[dbsize], nonzero = 0; cl_mem dstBuffer = openCLCreateBuffer(clCxt, CL_MEM_WRITE_ONLY, dbsize * sizeof(int)); arithmetic_countNonZero_run(src, dstBuffer, vlen, groupnum, kernelName); @@ -1588,7 +1587,7 @@ int cv::ocl::countNonZero(const oclMat &src) ////////////////////////////////////////////////////////////////////////////// ////////////////////////////////bitwise_op//////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// -static void bitwise_run(const oclMat &src1, oclMat &dst, string kernelName, const char **kernelString) +static void bitwise_run(const oclMat &src1, oclMat &dst, std::string kernelName, const char **kernelString) { dst.create(src1.size(), src1.type()); @@ -1614,23 +1613,23 @@ static void bitwise_run(const oclMat &src1, oclMat &dst, string kernelName, cons }; int dst_step1 = dst.cols * dst.elemSize(); - vector > args; - args.push_back( make_pair( sizeof(cl_mem), (void *)&src1.data )); - args.push_back( make_pair( sizeof(cl_int), (void *)&src1.step )); - args.push_back( make_pair( sizeof(cl_int), (void *)&src1.offset )); - args.push_back( make_pair( sizeof(cl_mem), (void *)&dst.data )); - args.push_back( make_pair( sizeof(cl_int), (void *)&dst.step )); - args.push_back( make_pair( sizeof(cl_int), (void *)&dst.offset )); - args.push_back( make_pair( sizeof(cl_int), (void *)&src1.rows )); - args.push_back( make_pair( sizeof(cl_int), (void *)&cols )); - args.push_back( make_pair( sizeof(cl_int), (void *)&dst_step1 )); + std::vector > args; + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&src1.data )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src1.step )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src1.offset )); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&dst.data )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dst.step )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dst.offset )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src1.rows )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&cols )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dst_step1 )); openCLExecuteKernel(clCxt, kernelString, kernelName, globalThreads, localThreads, args, -1, depth); } template -void bitwise_run(const oclMat &src1, const oclMat &src2, oclMat &dst, string kernelName, const char **kernelString, void *_scalar) +void bitwise_run(const oclMat &src1, const oclMat &src2, oclMat &dst, std::string kernelName, const char **kernelString, void *_scalar) { dst.create(src1.size(), src1.type()); CV_Assert(src1.cols == src2.cols && src2.cols == dst.cols && @@ -1659,34 +1658,34 @@ void bitwise_run(const oclMat &src1, const oclMat &src2, oclMat &dst, string ker }; int dst_step1 = dst.cols * dst.elemSize(); - vector > args; - args.push_back( make_pair( sizeof(cl_mem), (void *)&src1.data )); - args.push_back( make_pair( sizeof(cl_int), (void *)&src1.step )); - args.push_back( make_pair( sizeof(cl_int), (void *)&src1.offset )); - args.push_back( make_pair( sizeof(cl_mem), (void *)&src2.data )); - args.push_back( make_pair( sizeof(cl_int), (void *)&src2.step )); - args.push_back( make_pair( sizeof(cl_int), (void *)&src2.offset )); - args.push_back( make_pair( sizeof(cl_mem), (void *)&dst.data )); - args.push_back( make_pair( sizeof(cl_int), (void *)&dst.step )); - args.push_back( make_pair( sizeof(cl_int), (void *)&dst.offset )); - args.push_back( make_pair( sizeof(cl_int), (void *)&src1.rows )); - args.push_back( make_pair( sizeof(cl_int), (void *)&cols )); - args.push_back( make_pair( sizeof(cl_int), (void *)&dst_step1 )); + std::vector > args; + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&src1.data )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src1.step )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src1.offset )); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&src2.data )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src2.step )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src2.offset )); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&dst.data )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dst.step )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dst.offset )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src1.rows )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&cols )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dst_step1 )); if(_scalar != NULL) { double scalar1 = *((double *)_scalar); T scalar = (T)scalar1; - args.push_back( make_pair( sizeof(T), (void *)&scalar )); + args.push_back( std::make_pair( sizeof(T), (void *)&scalar )); } openCLExecuteKernel(clCxt, kernelString, kernelName, globalThreads, localThreads, args, -1, depth); } -static void bitwise_run(const oclMat &src1, const oclMat &src2, oclMat &dst, string kernelName, const char **kernelString) +static void bitwise_run(const oclMat &src1, const oclMat &src2, oclMat &dst, std::string kernelName, const char **kernelString) { bitwise_run(src1, src2, dst, kernelName, kernelString, (void *)NULL); } -static void bitwise_run(const oclMat &src1, const oclMat &src2, oclMat &dst, const oclMat &mask, string kernelName, const char **kernelString) +static void bitwise_run(const oclMat &src1, const oclMat &src2, oclMat &dst, const oclMat &mask, std::string kernelName, const char **kernelString) { dst.create(src1.size(), src1.type()); CV_Assert(src1.cols == src2.cols && src2.cols == dst.cols && @@ -1717,29 +1716,29 @@ static void bitwise_run(const oclMat &src1, const oclMat &src2, oclMat &dst, con }; int dst_step1 = dst.cols * dst.elemSize(); - vector > args; - args.push_back( make_pair( sizeof(cl_mem), (void *)&src1.data )); - args.push_back( make_pair( sizeof(cl_int), (void *)&src1.step )); - args.push_back( make_pair( sizeof(cl_int), (void *)&src1.offset )); - args.push_back( make_pair( sizeof(cl_mem), (void *)&src2.data )); - args.push_back( make_pair( sizeof(cl_int), (void *)&src2.step )); - args.push_back( make_pair( sizeof(cl_int), (void *)&src2.offset )); - args.push_back( make_pair( sizeof(cl_mem), (void *)&mask.data )); - args.push_back( make_pair( sizeof(cl_int), (void *)&mask.step )); - args.push_back( make_pair( sizeof(cl_int), (void *)&mask.offset )); - args.push_back( make_pair( sizeof(cl_mem), (void *)&dst.data )); - args.push_back( make_pair( sizeof(cl_int), (void *)&dst.step )); - args.push_back( make_pair( sizeof(cl_int), (void *)&dst.offset )); - args.push_back( make_pair( sizeof(cl_int), (void *)&src1.rows )); - args.push_back( make_pair( sizeof(cl_int), (void *)&cols )); - args.push_back( make_pair( sizeof(cl_int), (void *)&dst_step1 )); + std::vector > args; + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&src1.data )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src1.step )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src1.offset )); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&src2.data )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src2.step )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src2.offset )); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&mask.data )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&mask.step )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&mask.offset )); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&dst.data )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dst.step )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dst.offset )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src1.rows )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&cols )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dst_step1 )); openCLExecuteKernel(clCxt, kernelString, kernelName, globalThreads, localThreads, args, channels, depth); } template -void bitwise_scalar_run(const oclMat &src1, const Scalar &src2, oclMat &dst, const oclMat &mask, string kernelName, const char **kernelString, int isMatSubScalar) +void bitwise_scalar_run(const oclMat &src1, const Scalar &src2, oclMat &dst, const oclMat &mask, std::string kernelName, const char **kernelString, int isMatSubScalar) { dst.create(src1.size(), src1.type()); @@ -1777,38 +1776,38 @@ void bitwise_scalar_run(const oclMat &src1, const Scalar &src2, oclMat &dst, con }; int dst_step1 = dst.cols * dst.elemSize(); - vector > args; - args.push_back( make_pair( sizeof(cl_mem) , (void *)&src1.data )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&src1.step )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&src1.offset)); - args.push_back( make_pair( sizeof(cl_mem) , (void *)&dst.data )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&dst.step )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&dst.offset)); + std::vector > args; + args.push_back( std::make_pair( sizeof(cl_mem) , (void *)&src1.data )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&src1.step )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&src1.offset)); + args.push_back( std::make_pair( sizeof(cl_mem) , (void *)&dst.data )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&dst.step )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&dst.offset)); if(mask.data) { - args.push_back( make_pair( sizeof(cl_mem) , (void *)&mask.data )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&mask.step )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&mask.offset)); + args.push_back( std::make_pair( sizeof(cl_mem) , (void *)&mask.data )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&mask.step )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&mask.offset)); } - args.push_back( make_pair( sizeof(CL_WT) , (void *)&s )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&src1.rows )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&cols )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&dst_step1 )); + args.push_back( std::make_pair( sizeof(CL_WT) , (void *)&s )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&src1.rows )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&cols )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&dst_step1 )); if(isMatSubScalar != 0) { isMatSubScalar = isMatSubScalar > 0 ? 1 : 0; - args.push_back( make_pair( sizeof(cl_int) , (void *)&isMatSubScalar)); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&isMatSubScalar)); } openCLExecuteKernel(clCxt, kernelString, kernelName, globalThreads, localThreads, args, channels, depth); } -typedef void (*BitwiseFuncS)(const oclMat &src1, const Scalar &src2, oclMat &dst, const oclMat &mask, string kernelName, const char **kernelString, int isMatSubScalar); +typedef void (*BitwiseFuncS)(const oclMat &src1, const Scalar &src2, oclMat &dst, const oclMat &mask, std::string kernelName, const char **kernelString, int isMatSubScalar); -static void bitwise_scalar(const oclMat &src1, const Scalar &src2, oclMat &dst, const oclMat &mask, string kernelName, const char **kernelString, int isMatSubScalar) +static void bitwise_scalar(const oclMat &src1, const Scalar &src2, oclMat &dst, const oclMat &mask, std::string kernelName, const char **kernelString, int isMatSubScalar) { static BitwiseFuncS tab[8] = { @@ -1838,7 +1837,7 @@ static void bitwise_scalar(const oclMat &src1, const Scalar &src2, oclMat &dst, cv::ocl::error("Unsupported arithmetic operation", __FILE__, __LINE__); func(src1, src2, dst, mask, kernelName, kernelString, isMatSubScalar); } -static void bitwise_scalar(const oclMat &src1, const Scalar &src2, oclMat &dst, const oclMat &mask, string kernelName, const char **kernelString) +static void bitwise_scalar(const oclMat &src1, const Scalar &src2, oclMat &dst, const oclMat &mask, std::string kernelName, const char **kernelString) { bitwise_scalar(src1, src2, dst, mask, kernelName, kernelString, 0); } @@ -1847,11 +1846,11 @@ void cv::ocl::bitwise_not(const oclMat &src, oclMat &dst) { if(src.clCxt -> impl -> double_support == 0 && src.type() == CV_64F) { - cout << "Selected device do not support double" << endl; + std::cout << "Selected device do not support double" << std::endl; return; } dst.create(src.size(), src.type()); - string kernelName = "arithm_bitwise_not"; + std::string kernelName = "arithm_bitwise_not"; bitwise_run(src, dst, kernelName, &arithm_bitwise_not); } @@ -1860,11 +1859,11 @@ void cv::ocl::bitwise_or(const oclMat &src1, const oclMat &src2, oclMat &dst, co // dst.create(src1.size(),src1.type()); if(src1.clCxt -> impl -> double_support == 0 && src1.type() == CV_64F) { - cout << "Selected device do not support double" << endl; + std::cout << "Selected device do not support double" << std::endl; return; } oclMat emptyMat; - string kernelName = mask.empty() ? "arithm_bitwise_or" : "arithm_bitwise_or_with_mask"; + std::string kernelName = mask.empty() ? "arithm_bitwise_or" : "arithm_bitwise_or_with_mask"; if (mask.empty()) bitwise_run(src1, src2, dst, kernelName, &arithm_bitwise_or); else @@ -1876,10 +1875,10 @@ void cv::ocl::bitwise_or(const oclMat &src1, const Scalar &src2, oclMat &dst, co { if(src1.clCxt -> impl -> double_support == 0 && src1.type() == CV_64F) { - cout << "Selected device do not support double" << endl; + std::cout << "Selected device do not support double" << std::endl; return; } - string kernelName = mask.data ? "arithm_s_bitwise_or_with_mask" : "arithm_s_bitwise_or"; + std::string kernelName = mask.data ? "arithm_s_bitwise_or_with_mask" : "arithm_s_bitwise_or"; if (mask.data) bitwise_scalar( src1, src2, dst, mask, kernelName, &arithm_bitwise_or_scalar_mask); else @@ -1891,12 +1890,12 @@ void cv::ocl::bitwise_and(const oclMat &src1, const oclMat &src2, oclMat &dst, c // dst.create(src1.size(),src1.type()); if(src1.clCxt -> impl -> double_support == 0 && src1.type() == CV_64F) { - cout << "Selected device do not support double" << endl; + std::cout << "Selected device do not support double" << std::endl; return; } oclMat emptyMat; - string kernelName = mask.empty() ? "arithm_bitwise_and" : "arithm_bitwise_and_with_mask"; + std::string kernelName = mask.empty() ? "arithm_bitwise_and" : "arithm_bitwise_and_with_mask"; if (mask.empty()) bitwise_run(src1, src2, dst, kernelName, &arithm_bitwise_and); @@ -1908,10 +1907,10 @@ void cv::ocl::bitwise_and(const oclMat &src1, const Scalar &src2, oclMat &dst, c { if(src1.clCxt -> impl -> double_support == 0 && src1.type() == CV_64F) { - cout << "Selected device do not support double" << endl; + std::cout << "Selected device do not support double" << std::endl; return; } - string kernelName = mask.data ? "arithm_s_bitwise_and_with_mask" : "arithm_s_bitwise_and"; + std::string kernelName = mask.data ? "arithm_s_bitwise_and_with_mask" : "arithm_s_bitwise_and"; if (mask.data) bitwise_scalar(src1, src2, dst, mask, kernelName, &arithm_bitwise_and_scalar_mask); else @@ -1922,11 +1921,11 @@ void cv::ocl::bitwise_xor(const oclMat &src1, const oclMat &src2, oclMat &dst, c { if(src1.clCxt -> impl -> double_support == 0 && src1.type() == CV_64F) { - cout << "Selected device do not support double" << endl; + std::cout << "Selected device do not support double" << std::endl; return; } oclMat emptyMat; - string kernelName = mask.empty() ? "arithm_bitwise_xor" : "arithm_bitwise_xor_with_mask"; + std::string kernelName = mask.empty() ? "arithm_bitwise_xor" : "arithm_bitwise_xor_with_mask"; if (mask.empty()) @@ -1941,10 +1940,10 @@ void cv::ocl::bitwise_xor(const oclMat &src1, const Scalar &src2, oclMat &dst, c if(src1.clCxt -> impl -> double_support == 0 && src1.type() == CV_64F) { - cout << "Selected device do not support double" << endl; + std::cout << "Selected device do not support double" << std::endl; return; } - string kernelName = mask.data ? "arithm_s_bitwise_xor_with_mask" : "arithm_s_bitwise_xor"; + std::string kernelName = mask.data ? "arithm_s_bitwise_xor_with_mask" : "arithm_s_bitwise_xor"; if (mask.data) bitwise_scalar( src1, src2, dst, mask, kernelName, &arithm_bitwise_xor_scalar_mask); else @@ -2034,7 +2033,7 @@ oclMatExpr::operator oclMat() const ////////////////////////////////////////////////////////////////////////////// #define TILE_DIM (32) #define BLOCK_ROWS (256/TILE_DIM) -static void transpose_run(const oclMat &src, oclMat &dst, string kernelName) +static void transpose_run(const oclMat &src, oclMat &dst, std::string kernelName) { if(src.clCxt -> impl -> double_support == 0 && src.type() == CV_64F) { @@ -2064,15 +2063,15 @@ static void transpose_run(const oclMat &src, oclMat &dst, string kernelName) 1 }; - vector > args; - args.push_back( make_pair( sizeof(cl_mem), (void *)&src.data )); - args.push_back( make_pair( sizeof(cl_int), (void *)&src.step )); - args.push_back( make_pair( sizeof(cl_int), (void *)&src.offset )); - args.push_back( make_pair( sizeof(cl_mem), (void *)&dst.data )); - args.push_back( make_pair( sizeof(cl_int), (void *)&dst.step )); - args.push_back( make_pair( sizeof(cl_int), (void *)&dst.offset )); - args.push_back( make_pair( sizeof(cl_int), (void *)&src.rows )); - args.push_back( make_pair( sizeof(cl_int), (void *)&cols )); + std::vector > args; + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&src.data )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src.step )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src.offset )); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&dst.data )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dst.step )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dst.offset )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src.rows )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&cols )); openCLExecuteKernel(clCxt, &arithm_transpose, kernelName, globalThreads, localThreads, args, channels, depth); } @@ -2123,34 +2122,34 @@ void cv::ocl::addWeighted(const oclMat &src1, double alpha, const oclMat &src2, }; int dst_step1 = dst.cols * dst.elemSize(); - vector > args; - args.push_back( make_pair( sizeof(cl_mem), (void *)&src1.data )); - args.push_back( make_pair( sizeof(cl_int), (void *)&src1.step )); - args.push_back( make_pair( sizeof(cl_int), (void *)&src1.offset)); - args.push_back( make_pair( sizeof(cl_mem), (void *)&src2.data )); - args.push_back( make_pair( sizeof(cl_int), (void *)&src2.step )); - args.push_back( make_pair( sizeof(cl_int), (void *)&src2.offset)); + std::vector > args; + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&src1.data )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src1.step )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src1.offset)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&src2.data )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src2.step )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src2.offset)); if(src1.clCxt -> impl -> double_support != 0) { - args.push_back( make_pair( sizeof(cl_double), (void *)&alpha )); - args.push_back( make_pair( sizeof(cl_double), (void *)&beta )); - args.push_back( make_pair( sizeof(cl_double), (void *)&gama )); + args.push_back( std::make_pair( sizeof(cl_double), (void *)&alpha )); + args.push_back( std::make_pair( sizeof(cl_double), (void *)&beta )); + args.push_back( std::make_pair( sizeof(cl_double), (void *)&gama )); } else { float alpha_f = alpha, beta_f = beta, gama_f = gama; - args.push_back( make_pair( sizeof(cl_float), (void *)&alpha_f )); - args.push_back( make_pair( sizeof(cl_float), (void *)&beta_f )); - args.push_back( make_pair( sizeof(cl_float), (void *)&gama_f )); + args.push_back( std::make_pair( sizeof(cl_float), (void *)&alpha_f )); + args.push_back( std::make_pair( sizeof(cl_float), (void *)&beta_f )); + args.push_back( std::make_pair( sizeof(cl_float), (void *)&gama_f )); } - args.push_back( make_pair( sizeof(cl_mem), (void *)&dst.data )); - args.push_back( make_pair( sizeof(cl_int), (void *)&dst.step )); - args.push_back( make_pair( sizeof(cl_int), (void *)&dst.offset)); - args.push_back( make_pair( sizeof(cl_int), (void *)&src1.rows )); - args.push_back( make_pair( sizeof(cl_int), (void *)&cols )); - args.push_back( make_pair( sizeof(cl_int), (void *)&dst_step1 )); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&dst.data )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dst.step )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dst.offset)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src1.rows )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&cols )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dst_step1 )); openCLExecuteKernel(clCxt, &arithm_addWeighted, "addWeighted", globalThreads, localThreads, args, -1, depth); } @@ -2186,19 +2185,19 @@ void cv::ocl::magnitudeSqr(const oclMat &src1, const oclMat &src2, oclMat &dst) }; int dst_step1 = dst.cols * dst.elemSize(); - vector > args; - args.push_back( make_pair( sizeof(cl_mem), (void *)&src1.data )); - args.push_back( make_pair( sizeof(cl_int), (void *)&src1.step )); - args.push_back( make_pair( sizeof(cl_int), (void *)&src1.offset)); - args.push_back( make_pair( sizeof(cl_mem), (void *)&src2.data )); - args.push_back( make_pair( sizeof(cl_int), (void *)&src2.step )); - args.push_back( make_pair( sizeof(cl_int), (void *)&src2.offset)); - args.push_back( make_pair( sizeof(cl_mem), (void *)&dst.data )); - args.push_back( make_pair( sizeof(cl_int), (void *)&dst.step )); - args.push_back( make_pair( sizeof(cl_int), (void *)&dst.offset)); - args.push_back( make_pair( sizeof(cl_int), (void *)&src1.rows )); - args.push_back( make_pair( sizeof(cl_int), (void *)&cols )); - args.push_back( make_pair( sizeof(cl_int), (void *)&dst_step1 )); + std::vector > args; + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&src1.data )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src1.step )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src1.offset)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&src2.data )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src2.step )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src2.offset)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&dst.data )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dst.step )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dst.offset)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src1.rows )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&cols )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dst_step1 )); openCLExecuteKernel(clCxt, &arithm_magnitudeSqr, "magnitudeSqr", globalThreads, localThreads, args, 1, depth); } @@ -2234,21 +2233,21 @@ void cv::ocl::magnitudeSqr(const oclMat &src1, oclMat &dst) }; int dst_step1 = dst.cols * dst.elemSize(); - vector > args; - args.push_back( make_pair( sizeof(cl_mem), (void *)&src1.data )); - args.push_back( make_pair( sizeof(cl_int), (void *)&src1.step )); - args.push_back( make_pair( sizeof(cl_int), (void *)&src1.offset)); - args.push_back( make_pair( sizeof(cl_mem), (void *)&dst.data )); - args.push_back( make_pair( sizeof(cl_int), (void *)&dst.step )); - args.push_back( make_pair( sizeof(cl_int), (void *)&dst.offset)); - args.push_back( make_pair( sizeof(cl_int), (void *)&src1.rows )); - args.push_back( make_pair( sizeof(cl_int), (void *)&cols )); - args.push_back( make_pair( sizeof(cl_int), (void *)&dst_step1 )); + std::vector > args; + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&src1.data )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src1.step )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src1.offset)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&dst.data )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dst.step )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dst.offset)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src1.rows )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&cols )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dst_step1 )); openCLExecuteKernel(clCxt, &arithm_magnitudeSqr, "magnitudeSqr", globalThreads, localThreads, args, 2, depth); } -static void arithmetic_pow_run(const oclMat &src1, double p, oclMat &dst, string kernelName, const char **kernelString) +static void arithmetic_pow_run(const oclMat &src1, double p, oclMat &dst, std::string kernelName, const char **kernelString) { CV_Assert(src1.cols == dst.cols && src1.rows == dst.rows); CV_Assert(src1.type() == dst.type()); @@ -2269,23 +2268,23 @@ static void arithmetic_pow_run(const oclMat &src1, double p, oclMat &dst, string }; int dst_step1 = dst.cols * dst.elemSize(); - vector > args; - args.push_back( make_pair( sizeof(cl_mem), (void *)&src1.data )); - args.push_back( make_pair( sizeof(cl_int), (void *)&src1.step )); - args.push_back( make_pair( sizeof(cl_int), (void *)&src1.offset )); - args.push_back( make_pair( sizeof(cl_mem), (void *)&dst.data )); - args.push_back( make_pair( sizeof(cl_int), (void *)&dst.step )); - args.push_back( make_pair( sizeof(cl_int), (void *)&dst.offset )); - args.push_back( make_pair( sizeof(cl_int), (void *)&dst.rows )); - args.push_back( make_pair( sizeof(cl_int), (void *)&cols )); - args.push_back( make_pair( sizeof(cl_int), (void *)&dst_step1 )); + std::vector > args; + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&src1.data )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src1.step )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src1.offset )); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&dst.data )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dst.step )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dst.offset )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dst.rows )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&cols )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dst_step1 )); if(src1.clCxt -> impl -> double_support == 0) { float pf = p; - args.push_back( make_pair( sizeof(cl_float), (void *)&pf )); + args.push_back( std::make_pair( sizeof(cl_float), (void *)&pf )); } else - args.push_back( make_pair( sizeof(cl_double), (void *)&p )); + args.push_back( std::make_pair( sizeof(cl_double), (void *)&p )); openCLExecuteKernel(clCxt, kernelString, kernelName, globalThreads, localThreads, args, -1, depth); } @@ -2293,13 +2292,13 @@ void cv::ocl::pow(const oclMat &x, double p, oclMat &y) { if(x.clCxt -> impl -> double_support == 0 && x.type() == CV_64F) { - cout << "Selected device do not support double" << endl; + std::cout << "Selected device do not support double" << std::endl; return; } CV_Assert((x.type() == y.type() && x.size() == y.size() && x.depth() == CV_32F) || x.depth() == CV_64F); y.create(x.size(), x.type()); - string kernelName = "arithm_pow"; + std::string kernelName = "arithm_pow"; arithmetic_pow_run(x, p, y, kernelName, &arithm_pow); } diff --git a/modules/ocl/src/binarycaching.hpp b/modules/ocl/src/binarycaching.hpp index 0ec565f88..6c7bee94d 100644 --- a/modules/ocl/src/binarycaching.hpp +++ b/modules/ocl/src/binarycaching.hpp @@ -46,9 +46,6 @@ using namespace cv; using namespace cv::ocl; -using namespace std; -using std::cout; -using std::endl; namespace cv { @@ -58,8 +55,8 @@ namespace cv { protected: ProgramCache(); - friend class auto_ptr; - static auto_ptr programCache; + friend class std::auto_ptr; + static std::auto_ptr programCache; public: ~ProgramCache(); @@ -71,13 +68,13 @@ namespace cv } //lookup the binary given the file name - cl_program progLookup(string srcsign); + cl_program progLookup(std::string srcsign); //add program to the cache - void addProgram(string srcsign, cl_program program); + void addProgram(std::string srcsign, cl_program program); void releaseProgram(); - map codeCache; + std::map codeCache; unsigned int cacheSize; //The presumed watermark for the cache volume (256MB). Is it enough? //We may need more delicate algorithms when necessary later. diff --git a/modules/ocl/src/blend.cpp b/modules/ocl/src/blend.cpp index 5eead4766..3dfff323b 100644 --- a/modules/ocl/src/blend.cpp +++ b/modules/ocl/src/blend.cpp @@ -48,7 +48,6 @@ using namespace cv; using namespace cv::ocl; -using namespace std; namespace cv { @@ -73,19 +72,19 @@ void cv::ocl::blendLinear(const oclMat &img1, const oclMat &img2, const oclMat & size_t globalSize[] = {cols * channels / 4, rows, 1}; size_t localSize[] = {256, 1, 1}; - vector< pair > args; + std::vector< std::pair > args; if(globalSize[0] != 0) { - args.push_back( make_pair( sizeof(cl_mem), (void *)&result.data )); - args.push_back( make_pair( sizeof(cl_mem), (void *)&img1.data )); - args.push_back( make_pair( sizeof(cl_mem), (void *)&img2.data )); - args.push_back( make_pair( sizeof(cl_mem), (void *)&weights1.data )); - args.push_back( make_pair( sizeof(cl_mem), (void *)&weights2.data )); - args.push_back( make_pair( sizeof(cl_int), (void *)&rows )); - args.push_back( make_pair( sizeof(cl_int), (void *)&cols )); - args.push_back( make_pair( sizeof(cl_int), (void *)&istep )); - args.push_back( make_pair( sizeof(cl_int), (void *)&wstep )); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&result.data )); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&img1.data )); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&img2.data )); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&weights1.data )); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&weights2.data )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&rows )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&cols )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&istep )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&wstep )); std::string kernelName = "BlendLinear"; openCLExecuteKernel(ctx, &blend_linear, kernelName, globalSize, localSize, args, channels, depth); diff --git a/modules/ocl/src/brute_force_matcher.cpp b/modules/ocl/src/brute_force_matcher.cpp index c81e342d3..7654496f8 100644 --- a/modules/ocl/src/brute_force_matcher.cpp +++ b/modules/ocl/src/brute_force_matcher.cpp @@ -49,9 +49,7 @@ #include using namespace cv; using namespace cv::ocl; -using namespace std; -using namespace std; namespace cv { namespace ocl @@ -71,24 +69,24 @@ void matchUnrolledCached(const oclMat &query, const oclMat &train, const oclMat const size_t smemSize = (BLOCK_SIZE * (MAX_DESC_LEN >= 2 * BLOCK_SIZE ? MAX_DESC_LEN : 2 * BLOCK_SIZE) + BLOCK_SIZE * BLOCK_SIZE) * sizeof(int); int block_size = BLOCK_SIZE; int m_size = MAX_DESC_LEN; - vector< pair > args; + std::vector< std::pair > args; if(globalSize[0] != 0) { - args.push_back( make_pair( sizeof(cl_mem), (void *)&query.data )); - args.push_back( make_pair( sizeof(cl_mem), (void *)&train.data )); - args.push_back( make_pair( sizeof(cl_mem), (void *)&mask.data )); - args.push_back( make_pair( sizeof(cl_mem), (void *)&trainIdx.data )); - args.push_back( make_pair( sizeof(cl_mem), (void *)&distance.data )); - args.push_back( make_pair( smemSize, (void *)NULL)); - args.push_back( make_pair( sizeof(cl_int), (void *)&block_size )); - args.push_back( make_pair( sizeof(cl_int), (void *)&m_size )); - args.push_back( make_pair( sizeof(cl_int), (void *)&query.rows )); - args.push_back( make_pair( sizeof(cl_int), (void *)&query.cols )); - args.push_back( make_pair( sizeof(cl_int), (void *)&train.rows )); - args.push_back( make_pair( sizeof(cl_int), (void *)&train.cols )); - args.push_back( make_pair( sizeof(cl_int), (void *)&query.step )); - args.push_back( make_pair( sizeof(cl_int), (void *)&distType )); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&query.data )); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&train.data )); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&mask.data )); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&trainIdx.data )); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&distance.data )); + args.push_back( std::make_pair( smemSize, (void *)NULL)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&block_size )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&m_size )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&query.rows )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&query.cols )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&train.rows )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&train.cols )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&query.step )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&distType )); std::string kernelName = "BruteForceMatch_UnrollMatch"; @@ -111,23 +109,23 @@ void match(const oclMat &query, const oclMat &train, const oclMat &mask, size_t localSize[] = {BLOCK_SIZE, BLOCK_SIZE, 1}; const size_t smemSize = (2 * BLOCK_SIZE * BLOCK_SIZE) * sizeof(int); int block_size = BLOCK_SIZE; - vector< pair > args; + std::vector< std::pair > args; if(globalSize[0] != 0) { - args.push_back( make_pair( sizeof(cl_mem), (void *)&query.data )); - args.push_back( make_pair( sizeof(cl_mem), (void *)&train.data )); - args.push_back( make_pair( sizeof(cl_mem), (void *)&mask.data )); - args.push_back( make_pair( sizeof(cl_mem), (void *)&trainIdx.data )); - args.push_back( make_pair( sizeof(cl_mem), (void *)&distance.data )); - args.push_back( make_pair( smemSize, (void *)NULL)); - args.push_back( make_pair( sizeof(cl_int), (void *)&block_size )); - args.push_back( make_pair( sizeof(cl_int), (void *)&query.rows )); - args.push_back( make_pair( sizeof(cl_int), (void *)&query.cols )); - args.push_back( make_pair( sizeof(cl_int), (void *)&train.rows )); - args.push_back( make_pair( sizeof(cl_int), (void *)&train.cols )); - args.push_back( make_pair( sizeof(cl_int), (void *)&query.step )); - args.push_back( make_pair( sizeof(cl_int), (void *)&distType )); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&query.data )); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&train.data )); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&mask.data )); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&trainIdx.data )); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&distance.data )); + args.push_back( std::make_pair( smemSize, (void *)NULL)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&block_size )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&query.rows )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&query.cols )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&train.rows )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&train.cols )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&query.step )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&distType )); std::string kernelName = "BruteForceMatch_Match"; @@ -152,28 +150,28 @@ void matchUnrolledCached(const oclMat &query, const oclMat &train, float maxDist const size_t smemSize = (2 * BLOCK_SIZE * BLOCK_SIZE) * sizeof(int); int block_size = BLOCK_SIZE; int m_size = MAX_DESC_LEN; - vector< pair > args; + std::vector< std::pair > args; if(globalSize[0] != 0) { - args.push_back( make_pair( sizeof(cl_mem), (void *)&query.data )); - args.push_back( make_pair( sizeof(cl_mem), (void *)&train.data )); - args.push_back( make_pair( sizeof(cl_float), (void *)&maxDistance )); - args.push_back( make_pair( sizeof(cl_mem), (void *)&mask.data )); - args.push_back( make_pair( sizeof(cl_mem), (void *)&trainIdx.data )); - args.push_back( make_pair( sizeof(cl_mem), (void *)&distance.data )); - args.push_back( make_pair( sizeof(cl_mem), (void *)&nMatches.data )); - args.push_back( make_pair( smemSize, (void *)NULL)); - args.push_back( make_pair( sizeof(cl_int), (void *)&block_size )); - args.push_back( make_pair( sizeof(cl_int), (void *)&m_size )); - args.push_back( make_pair( sizeof(cl_int), (void *)&query.rows )); - args.push_back( make_pair( sizeof(cl_int), (void *)&query.cols )); - args.push_back( make_pair( sizeof(cl_int), (void *)&train.rows )); - args.push_back( make_pair( sizeof(cl_int), (void *)&train.cols )); - args.push_back( make_pair( sizeof(cl_int), (void *)&trainIdx.cols )); - args.push_back( make_pair( sizeof(cl_int), (void *)&query.step )); - args.push_back( make_pair( sizeof(cl_int), (void *)&trainIdx.step )); - args.push_back( make_pair( sizeof(cl_int), (void *)&distType )); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&query.data )); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&train.data )); + args.push_back( std::make_pair( sizeof(cl_float), (void *)&maxDistance )); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&mask.data )); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&trainIdx.data )); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&distance.data )); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&nMatches.data )); + args.push_back( std::make_pair( smemSize, (void *)NULL)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&block_size )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&m_size )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&query.rows )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&query.cols )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&train.rows )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&train.cols )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&trainIdx.cols )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&query.step )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&trainIdx.step )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&distType )); std::string kernelName = "BruteForceMatch_RadiusUnrollMatch"; @@ -191,27 +189,27 @@ void radius_match(const oclMat &query, const oclMat &train, float maxDistance, c size_t localSize[] = {BLOCK_SIZE, BLOCK_SIZE, 1}; const size_t smemSize = (2 * BLOCK_SIZE * BLOCK_SIZE) * sizeof(int); int block_size = BLOCK_SIZE; - vector< pair > args; + std::vector< std::pair > args; if(globalSize[0] != 0) { - args.push_back( make_pair( sizeof(cl_mem), (void *)&query.data )); - args.push_back( make_pair( sizeof(cl_mem), (void *)&train.data )); - args.push_back( make_pair( sizeof(cl_float), (void *)&maxDistance )); - args.push_back( make_pair( sizeof(cl_mem), (void *)&mask.data )); - args.push_back( make_pair( sizeof(cl_mem), (void *)&trainIdx.data )); - args.push_back( make_pair( sizeof(cl_mem), (void *)&distance.data )); - args.push_back( make_pair( sizeof(cl_mem), (void *)&nMatches.data )); - args.push_back( make_pair( smemSize, (void *)NULL)); - args.push_back( make_pair( sizeof(cl_int), (void *)&block_size )); - args.push_back( make_pair( sizeof(cl_int), (void *)&query.rows )); - args.push_back( make_pair( sizeof(cl_int), (void *)&query.cols )); - args.push_back( make_pair( sizeof(cl_int), (void *)&train.rows )); - args.push_back( make_pair( sizeof(cl_int), (void *)&train.cols )); - args.push_back( make_pair( sizeof(cl_int), (void *)&trainIdx.cols )); - args.push_back( make_pair( sizeof(cl_int), (void *)&query.step )); - args.push_back( make_pair( sizeof(cl_int), (void *)&trainIdx.step )); - args.push_back( make_pair( sizeof(cl_int), (void *)&distType )); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&query.data )); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&train.data )); + args.push_back( std::make_pair( sizeof(cl_float), (void *)&maxDistance )); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&mask.data )); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&trainIdx.data )); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&distance.data )); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&nMatches.data )); + args.push_back( std::make_pair( smemSize, (void *)NULL)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&block_size )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&query.rows )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&query.cols )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&train.rows )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&train.cols )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&trainIdx.cols )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&query.step )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&trainIdx.step )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&distType )); std::string kernelName = "BruteForceMatch_RadiusMatch"; @@ -481,24 +479,24 @@ void knn_matchUnrolledCached(const oclMat &query, const oclMat &train, const ocl const size_t smemSize = (BLOCK_SIZE * (MAX_DESC_LEN >= BLOCK_SIZE ? MAX_DESC_LEN : BLOCK_SIZE) + BLOCK_SIZE * BLOCK_SIZE) * sizeof(int); int block_size = BLOCK_SIZE; int m_size = MAX_DESC_LEN; - vector< pair > args; + std::vector< std::pair > args; if(globalSize[0] != 0) { - args.push_back( make_pair( sizeof(cl_mem), (void *)&query.data )); - args.push_back( make_pair( sizeof(cl_mem), (void *)&train.data )); - args.push_back( make_pair( sizeof(cl_mem), (void *)&mask.data )); - args.push_back( make_pair( sizeof(cl_mem), (void *)&trainIdx.data )); - args.push_back( make_pair( sizeof(cl_mem), (void *)&distance.data )); - args.push_back( make_pair( smemSize, (void *)NULL)); - args.push_back( make_pair( sizeof(cl_int), (void *)&block_size )); - args.push_back( make_pair( sizeof(cl_int), (void *)&m_size )); - args.push_back( make_pair( sizeof(cl_int), (void *)&query.rows )); - args.push_back( make_pair( sizeof(cl_int), (void *)&query.cols )); - args.push_back( make_pair( sizeof(cl_int), (void *)&train.rows )); - args.push_back( make_pair( sizeof(cl_int), (void *)&train.cols )); - args.push_back( make_pair( sizeof(cl_int), (void *)&query.step )); - args.push_back( make_pair( sizeof(cl_int), (void *)&distType )); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&query.data )); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&train.data )); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&mask.data )); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&trainIdx.data )); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&distance.data )); + args.push_back( std::make_pair( smemSize, (void *)NULL)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&block_size )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&m_size )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&query.rows )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&query.cols )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&train.rows )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&train.cols )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&query.step )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&distType )); std::string kernelName = "BruteForceMatch_knnUnrollMatch"; @@ -515,23 +513,23 @@ void knn_match(const oclMat &query, const oclMat &train, const oclMat &mask, size_t localSize[] = {BLOCK_SIZE, BLOCK_SIZE, 1}; const size_t smemSize = (2 * BLOCK_SIZE * BLOCK_SIZE) * sizeof(int); int block_size = BLOCK_SIZE; - vector< pair > args; + std::vector< std::pair > args; if(globalSize[0] != 0) { - args.push_back( make_pair( sizeof(cl_mem), (void *)&query.data )); - args.push_back( make_pair( sizeof(cl_mem), (void *)&train.data )); - args.push_back( make_pair( sizeof(cl_mem), (void *)&mask.data )); - args.push_back( make_pair( sizeof(cl_mem), (void *)&trainIdx.data )); - args.push_back( make_pair( sizeof(cl_mem), (void *)&distance.data )); - args.push_back( make_pair( smemSize, (void *)NULL)); - args.push_back( make_pair( sizeof(cl_int), (void *)&block_size )); - args.push_back( make_pair( sizeof(cl_int), (void *)&query.rows )); - args.push_back( make_pair( sizeof(cl_int), (void *)&query.cols )); - args.push_back( make_pair( sizeof(cl_int), (void *)&train.rows )); - args.push_back( make_pair( sizeof(cl_int), (void *)&train.cols )); - args.push_back( make_pair( sizeof(cl_int), (void *)&query.step )); - args.push_back( make_pair( sizeof(cl_int), (void *)&distType )); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&query.data )); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&train.data )); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&mask.data )); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&trainIdx.data )); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&distance.data )); + args.push_back( std::make_pair( smemSize, (void *)NULL)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&block_size )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&query.rows )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&query.cols )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&train.rows )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&train.cols )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&query.step )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&distType )); std::string kernelName = "BruteForceMatch_knnMatch"; @@ -548,23 +546,23 @@ void calcDistanceUnrolled(const oclMat &query, const oclMat &train, const oclMat const size_t smemSize = (2 * BLOCK_SIZE * BLOCK_SIZE) * sizeof(int); int block_size = BLOCK_SIZE; int m_size = MAX_DESC_LEN; - vector< pair > args; + std::vector< std::pair > args; if(globalSize[0] != 0) { - args.push_back( make_pair( sizeof(cl_mem), (void *)&query.data )); - args.push_back( make_pair( sizeof(cl_mem), (void *)&train.data )); - args.push_back( make_pair( sizeof(cl_mem), (void *)&mask.data )); - args.push_back( make_pair( sizeof(cl_mem), (void *)&allDist.data )); - args.push_back( make_pair( smemSize, (void *)NULL)); - args.push_back( make_pair( sizeof(cl_int), (void *)&block_size )); - args.push_back( make_pair( sizeof(cl_int), (void *)&m_size )); - args.push_back( make_pair( sizeof(cl_int), (void *)&query.rows )); - args.push_back( make_pair( sizeof(cl_int), (void *)&query.cols )); - args.push_back( make_pair( sizeof(cl_int), (void *)&train.rows )); - args.push_back( make_pair( sizeof(cl_int), (void *)&train.cols )); - args.push_back( make_pair( sizeof(cl_int), (void *)&query.step )); - args.push_back( make_pair( sizeof(cl_int), (void *)&distType )); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&query.data )); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&train.data )); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&mask.data )); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&allDist.data )); + args.push_back( std::make_pair( smemSize, (void *)NULL)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&block_size )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&m_size )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&query.rows )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&query.cols )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&train.rows )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&train.cols )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&query.step )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&distType )); std::string kernelName = "BruteForceMatch_calcDistanceUnrolled"; @@ -580,22 +578,22 @@ void calcDistance(const oclMat &query, const oclMat &train, const oclMat &mask, size_t localSize[] = {BLOCK_SIZE, BLOCK_SIZE, 1}; const size_t smemSize = (2 * BLOCK_SIZE * BLOCK_SIZE) * sizeof(int); int block_size = BLOCK_SIZE; - vector< pair > args; + std::vector< std::pair > args; if(globalSize[0] != 0) { - args.push_back( make_pair( sizeof(cl_mem), (void *)&query.data )); - args.push_back( make_pair( sizeof(cl_mem), (void *)&train.data )); - args.push_back( make_pair( sizeof(cl_mem), (void *)&mask.data )); - args.push_back( make_pair( sizeof(cl_mem), (void *)&allDist.data )); - args.push_back( make_pair( smemSize, (void *)NULL)); - args.push_back( make_pair( sizeof(cl_int), (void *)&block_size )); - args.push_back( make_pair( sizeof(cl_int), (void *)&query.rows )); - args.push_back( make_pair( sizeof(cl_int), (void *)&query.cols )); - args.push_back( make_pair( sizeof(cl_int), (void *)&train.rows )); - args.push_back( make_pair( sizeof(cl_int), (void *)&train.cols )); - args.push_back( make_pair( sizeof(cl_int), (void *)&query.step )); - args.push_back( make_pair( sizeof(cl_int), (void *)&distType )); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&query.data )); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&train.data )); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&mask.data )); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&allDist.data )); + args.push_back( std::make_pair( smemSize, (void *)NULL)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&block_size )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&query.rows )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&query.cols )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&train.rows )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&train.cols )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&query.step )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&distType )); std::string kernelName = "BruteForceMatch_calcDistance"; @@ -676,16 +674,16 @@ void findKnnMatch(int k, const oclMat &trainIdx, const oclMat &distance, const o for (int i = 0; i < k; ++i) { - vector< pair > args; + std::vector< std::pair > args; - args.push_back( make_pair( sizeof(cl_mem), (void *)&allDist.data )); - args.push_back( make_pair( sizeof(cl_mem), (void *)&trainIdx.data )); - args.push_back( make_pair( sizeof(cl_mem), (void *)&distance.data )); - args.push_back( make_pair( sizeof(cl_mem), (void *)&i)); - args.push_back( make_pair( sizeof(cl_int), (void *)&block_size )); - //args.push_back( make_pair( sizeof(cl_int), (void *)&train.rows )); - //args.push_back( make_pair( sizeof(cl_int), (void *)&train.cols )); - //args.push_back( make_pair( sizeof(cl_int), (void *)&query.step )); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&allDist.data )); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&trainIdx.data )); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&distance.data )); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&i)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&block_size )); + //args.push_back( std::make_pair( sizeof(cl_int), (void *)&train.rows )); + //args.push_back( std::make_pair( sizeof(cl_int), (void *)&train.cols )); + //args.push_back( std::make_pair( sizeof(cl_int), (void *)&query.step )); openCLExecuteKernel(ctx, &brute_force_match, kernelName, globalSize, localSize, args, -1, -1); } @@ -900,12 +898,12 @@ cv::ocl::BruteForceMatcher_OCL_base::BruteForceMatcher_OCL_base(DistType distTyp { } -void cv::ocl::BruteForceMatcher_OCL_base::add(const vector &descCollection) +void cv::ocl::BruteForceMatcher_OCL_base::add(const std::vector &descCollection) { trainDescCollection.insert(trainDescCollection.end(), descCollection.begin(), descCollection.end()); } -const vector &cv::ocl::BruteForceMatcher_OCL_base::getTrainDescriptors() const +const std::vector &cv::ocl::BruteForceMatcher_OCL_base::getTrainDescriptors() const { return trainDescCollection; } @@ -964,7 +962,7 @@ void cv::ocl::BruteForceMatcher_OCL_base::matchSingle(const oclMat &query, const func(query, train, mask, trainIdx, distance); } -void cv::ocl::BruteForceMatcher_OCL_base::matchDownload(const oclMat &trainIdx, const oclMat &distance, vector &matches) +void cv::ocl::BruteForceMatcher_OCL_base::matchDownload(const oclMat &trainIdx, const oclMat &distance, std::vector &matches) { if (trainIdx.empty() || distance.empty()) return; @@ -975,7 +973,7 @@ void cv::ocl::BruteForceMatcher_OCL_base::matchDownload(const oclMat &trainIdx, matchConvert(trainIdxCPU, distanceCPU, matches); } -void cv::ocl::BruteForceMatcher_OCL_base::matchConvert(const Mat &trainIdx, const Mat &distance, vector &matches) +void cv::ocl::BruteForceMatcher_OCL_base::matchConvert(const Mat &trainIdx, const Mat &distance, std::vector &matches) { if (trainIdx.empty() || distance.empty()) return; @@ -1005,14 +1003,14 @@ void cv::ocl::BruteForceMatcher_OCL_base::matchConvert(const Mat &trainIdx, cons } } -void cv::ocl::BruteForceMatcher_OCL_base::match(const oclMat &query, const oclMat &train, vector &matches, const oclMat &mask) +void cv::ocl::BruteForceMatcher_OCL_base::match(const oclMat &query, const oclMat &train, std::vector &matches, const oclMat &mask) { oclMat trainIdx, distance; matchSingle(query, train, trainIdx, distance, mask); matchDownload(trainIdx, distance, matches); } -void cv::ocl::BruteForceMatcher_OCL_base::makeGpuCollection(oclMat &trainCollection, oclMat &maskCollection, const vector &masks) +void cv::ocl::BruteForceMatcher_OCL_base::makeGpuCollection(oclMat &trainCollection, oclMat &maskCollection, const std::vector &masks) { if (empty()) @@ -1098,7 +1096,7 @@ void cv::ocl::BruteForceMatcher_OCL_base::matchCollection(const oclMat &query, c func(query, trainCollection, masks, trainIdx, imgIdx, distance); } -void cv::ocl::BruteForceMatcher_OCL_base::matchDownload(const oclMat &trainIdx, const oclMat &imgIdx, const oclMat &distance, vector &matches) +void cv::ocl::BruteForceMatcher_OCL_base::matchDownload(const oclMat &trainIdx, const oclMat &imgIdx, const oclMat &distance, std::vector &matches) { if (trainIdx.empty() || imgIdx.empty() || distance.empty()) return; @@ -1110,7 +1108,7 @@ void cv::ocl::BruteForceMatcher_OCL_base::matchDownload(const oclMat &trainIdx, matchConvert(trainIdxCPU, imgIdxCPU, distanceCPU, matches); } -void cv::ocl::BruteForceMatcher_OCL_base::matchConvert(const Mat &trainIdx, const Mat &imgIdx, const Mat &distance, vector &matches) +void cv::ocl::BruteForceMatcher_OCL_base::matchConvert(const Mat &trainIdx, const Mat &imgIdx, const Mat &distance, std::vector &matches) { if (trainIdx.empty() || imgIdx.empty() || distance.empty()) return; @@ -1144,7 +1142,7 @@ void cv::ocl::BruteForceMatcher_OCL_base::matchConvert(const Mat &trainIdx, cons } } -void cv::ocl::BruteForceMatcher_OCL_base::match(const oclMat &query, vector &matches, const vector &masks) +void cv::ocl::BruteForceMatcher_OCL_base::match(const oclMat &query, std::vector &matches, const std::vector &masks) { oclMat trainCollection; oclMat maskCollection; @@ -1212,7 +1210,7 @@ void cv::ocl::BruteForceMatcher_OCL_base::knnMatchSingle(const oclMat &query, co func(query, train, k, mask, trainIdx, distance, allDist); } -void cv::ocl::BruteForceMatcher_OCL_base::knnMatchDownload(const oclMat &trainIdx, const oclMat &distance, vector< vector > &matches, bool compactResult) +void cv::ocl::BruteForceMatcher_OCL_base::knnMatchDownload(const oclMat &trainIdx, const oclMat &distance, std::vector< std::vector > &matches, bool compactResult) { if (trainIdx.empty() || distance.empty()) return; @@ -1223,7 +1221,7 @@ void cv::ocl::BruteForceMatcher_OCL_base::knnMatchDownload(const oclMat &trainId knnMatchConvert(trainIdxCPU, distanceCPU, matches, compactResult); } -void cv::ocl::BruteForceMatcher_OCL_base::knnMatchConvert(const Mat &trainIdx, const Mat &distance, vector< vector > &matches, bool compactResult) +void cv::ocl::BruteForceMatcher_OCL_base::knnMatchConvert(const Mat &trainIdx, const Mat &distance, std::vector< std::vector > &matches, bool compactResult) { if (trainIdx.empty() || distance.empty()) return; @@ -1244,8 +1242,8 @@ void cv::ocl::BruteForceMatcher_OCL_base::knnMatchConvert(const Mat &trainIdx, c for (int queryIdx = 0; queryIdx < nQuery; ++queryIdx) { - matches.push_back(vector()); - vector &curMatches = matches.back(); + matches.push_back(std::vector()); + std::vector &curMatches = matches.back(); curMatches.reserve(k); for (int i = 0; i < k; ++i, ++trainIdx_ptr, ++distance_ptr) @@ -1267,7 +1265,7 @@ void cv::ocl::BruteForceMatcher_OCL_base::knnMatchConvert(const Mat &trainIdx, c } } -void cv::ocl::BruteForceMatcher_OCL_base::knnMatch(const oclMat &query, const oclMat &train, vector< vector > &matches +void cv::ocl::BruteForceMatcher_OCL_base::knnMatch(const oclMat &query, const oclMat &train, std::vector< std::vector > &matches , int k, const oclMat &mask, bool compactResult) { oclMat trainIdx, distance, allDist; @@ -1320,7 +1318,7 @@ void cv::ocl::BruteForceMatcher_OCL_base::knnMatch2Collection(const oclMat &quer } void cv::ocl::BruteForceMatcher_OCL_base::knnMatch2Download(const oclMat &trainIdx, const oclMat &imgIdx, - const oclMat &distance, vector< vector > &matches, bool compactResult) + const oclMat &distance, std::vector< std::vector > &matches, bool compactResult) { if (trainIdx.empty() || imgIdx.empty() || distance.empty()) return; @@ -1333,7 +1331,7 @@ void cv::ocl::BruteForceMatcher_OCL_base::knnMatch2Download(const oclMat &trainI } void cv::ocl::BruteForceMatcher_OCL_base::knnMatch2Convert(const Mat &trainIdx, const Mat &imgIdx, const Mat &distance, - vector< vector > &matches, bool compactResult) + std::vector< std::vector > &matches, bool compactResult) { if (trainIdx.empty() || imgIdx.empty() || distance.empty()) return; @@ -1353,8 +1351,8 @@ void cv::ocl::BruteForceMatcher_OCL_base::knnMatch2Convert(const Mat &trainIdx, for (int queryIdx = 0; queryIdx < nQuery; ++queryIdx) { - matches.push_back(vector()); - vector &curMatches = matches.back(); + matches.push_back(std::vector()); + std::vector &curMatches = matches.back(); curMatches.reserve(2); for (int i = 0; i < 2; ++i, ++trainIdx_ptr, ++imgIdx_ptr, ++distance_ptr) @@ -1391,8 +1389,8 @@ namespace }; } -void cv::ocl::BruteForceMatcher_OCL_base::knnMatch(const oclMat &query, vector< vector > &matches, int k, - const vector &masks, bool compactResult) +void cv::ocl::BruteForceMatcher_OCL_base::knnMatch(const oclMat &query, std::vector< std::vector > &matches, int k, + const std::vector &masks, bool compactResult) { @@ -1413,12 +1411,12 @@ void cv::ocl::BruteForceMatcher_OCL_base::knnMatch(const oclMat &query, vector< if (query.empty() || empty()) return; - vector< vector > curMatches; - vector temp; + std::vector< std::vector > curMatches; + std::vector temp; temp.reserve(2 * k); matches.resize(query.rows); - for_each(matches.begin(), matches.end(), bind2nd(mem_fun_ref(&vector::reserve), k)); + std::for_each(matches.begin(), matches.end(), std::bind2nd(std::mem_fun_ref(&std::vector::reserve), k)); for (size_t imgIdx = 0, size = trainDescCollection.size(); imgIdx < size; ++imgIdx) { @@ -1426,8 +1424,8 @@ void cv::ocl::BruteForceMatcher_OCL_base::knnMatch(const oclMat &query, vector< for (int queryIdx = 0; queryIdx < query.rows; ++queryIdx) { - vector &localMatch = curMatches[queryIdx]; - vector &globalMatch = matches[queryIdx]; + std::vector &localMatch = curMatches[queryIdx]; + std::vector &globalMatch = matches[queryIdx]; for_each(localMatch.begin(), localMatch.end(), ImgIdxSetter(static_cast(imgIdx))); @@ -1442,7 +1440,7 @@ void cv::ocl::BruteForceMatcher_OCL_base::knnMatch(const oclMat &query, vector< if (compactResult) { - vector< vector >::iterator new_end = remove_if(matches.begin(), matches.end(), mem_fun_ref(&vector::empty)); + std::vector< std::vector >::iterator new_end = std::remove_if(matches.begin(), matches.end(), std::mem_fun_ref(&std::vector::empty)); matches.erase(new_end, matches.end()); } } @@ -1502,7 +1500,7 @@ void cv::ocl::BruteForceMatcher_OCL_base::radiusMatchSingle(const oclMat &query, } void cv::ocl::BruteForceMatcher_OCL_base::radiusMatchDownload(const oclMat &trainIdx, const oclMat &distance, const oclMat &nMatches, - vector< vector > &matches, bool compactResult) + std::vector< std::vector > &matches, bool compactResult) { if (trainIdx.empty() || distance.empty() || nMatches.empty()) return; @@ -1515,7 +1513,7 @@ void cv::ocl::BruteForceMatcher_OCL_base::radiusMatchDownload(const oclMat &trai } void cv::ocl::BruteForceMatcher_OCL_base::radiusMatchConvert(const Mat &trainIdx, const Mat &distance, const Mat &nMatches, - vector< vector > &matches, bool compactResult) + std::vector< std::vector > &matches, bool compactResult) { if (trainIdx.empty() || distance.empty() || nMatches.empty()) return; @@ -1541,12 +1539,12 @@ void cv::ocl::BruteForceMatcher_OCL_base::radiusMatchConvert(const Mat &trainIdx if (nMatches == 0) { if (!compactResult) - matches.push_back(vector()); + matches.push_back(std::vector()); continue; } - matches.push_back(vector(nMatches)); - vector &curMatches = matches.back(); + matches.push_back(std::vector(nMatches)); + std::vector &curMatches = matches.back(); for (int i = 0; i < nMatches; ++i, ++trainIdx_ptr, ++distance_ptr) { @@ -1563,7 +1561,7 @@ void cv::ocl::BruteForceMatcher_OCL_base::radiusMatchConvert(const Mat &trainIdx } } -void cv::ocl::BruteForceMatcher_OCL_base::radiusMatch(const oclMat &query, const oclMat &train, vector< vector > &matches, +void cv::ocl::BruteForceMatcher_OCL_base::radiusMatch(const oclMat &query, const oclMat &train, std::vector< std::vector > &matches, float maxDistance, const oclMat &mask, bool compactResult) { oclMat trainIdx, distance, nMatches; @@ -1572,7 +1570,7 @@ void cv::ocl::BruteForceMatcher_OCL_base::radiusMatch(const oclMat &query, const } void cv::ocl::BruteForceMatcher_OCL_base::radiusMatchCollection(const oclMat &query, oclMat &trainIdx, oclMat &imgIdx, oclMat &distance, - oclMat &nMatches, float /*maxDistance*/, const vector &masks) + oclMat &nMatches, float /*maxDistance*/, const std::vector &masks) { if (query.empty() || empty()) return; @@ -1617,15 +1615,15 @@ void cv::ocl::BruteForceMatcher_OCL_base::radiusMatchCollection(const oclMat &qu //caller_t func = callers[distType][query.depth()]; //CV_Assert(func != 0); - vector trains_(trainDescCollection.begin(), trainDescCollection.end()); - vector masks_(masks.begin(), masks.end()); + std::vector trains_(trainDescCollection.begin(), trainDescCollection.end()); + std::vector masks_(masks.begin(), masks.end()); /* func(query, &trains_[0], static_cast(trains_.size()), maxDistance, masks_.size() == 0 ? 0 : &masks_[0], trainIdx, imgIdx, distance, nMatches));*/ } void cv::ocl::BruteForceMatcher_OCL_base::radiusMatchDownload(const oclMat &trainIdx, const oclMat &imgIdx, const oclMat &distance, - const oclMat &nMatches, vector< vector > &matches, bool compactResult) + const oclMat &nMatches, std::vector< std::vector > &matches, bool compactResult) { if (trainIdx.empty() || imgIdx.empty() || distance.empty() || nMatches.empty()) return; @@ -1639,7 +1637,7 @@ void cv::ocl::BruteForceMatcher_OCL_base::radiusMatchDownload(const oclMat &trai } void cv::ocl::BruteForceMatcher_OCL_base::radiusMatchConvert(const Mat &trainIdx, const Mat &imgIdx, const Mat &distance, const Mat &nMatches, - vector< vector > &matches, bool compactResult) + std::vector< std::vector > &matches, bool compactResult) { if (trainIdx.empty() || imgIdx.empty() || distance.empty() || nMatches.empty()) return; @@ -1667,12 +1665,12 @@ void cv::ocl::BruteForceMatcher_OCL_base::radiusMatchConvert(const Mat &trainIdx if (nMatches == 0) { if (!compactResult) - matches.push_back(vector()); + matches.push_back(std::vector()); continue; } - matches.push_back(vector()); - vector &curMatches = matches.back(); + matches.push_back(std::vector()); + std::vector &curMatches = matches.back(); curMatches.reserve(nMatches); for (int i = 0; i < nMatches; ++i, ++trainIdx_ptr, ++imgIdx_ptr, ++distance_ptr) @@ -1690,8 +1688,8 @@ void cv::ocl::BruteForceMatcher_OCL_base::radiusMatchConvert(const Mat &trainIdx } } -void cv::ocl::BruteForceMatcher_OCL_base::radiusMatch(const oclMat &query, vector< vector > &matches, float maxDistance, - const vector &masks, bool compactResult) +void cv::ocl::BruteForceMatcher_OCL_base::radiusMatch(const oclMat &query, std::vector< std::vector > &matches, float maxDistance, + const std::vector &masks, bool compactResult) { oclMat trainIdx, imgIdx, distance, nMatches; radiusMatchCollection(query, trainIdx, imgIdx, distance, nMatches, maxDistance, masks); diff --git a/modules/ocl/src/build_warps.cpp b/modules/ocl/src/build_warps.cpp index c4a092993..9c9e7e7e0 100644 --- a/modules/ocl/src/build_warps.cpp +++ b/modules/ocl/src/build_warps.cpp @@ -47,7 +47,6 @@ using namespace cv; using namespace cv::ocl; -using namespace std; namespace cv { @@ -84,19 +83,19 @@ void cv::ocl::buildWarpPlaneMaps(Size /*src_size*/, Rect dst_roi, const Mat &K, int tl_v = dst_roi.tl().y; Context *clCxt = Context::getContext(); - string kernelName = "buildWarpPlaneMaps"; - vector< pair > args; + std::string kernelName = "buildWarpPlaneMaps"; + std::vector< std::pair > args; - args.push_back( make_pair( sizeof(cl_mem), (void *)&map_x.data)); - args.push_back( make_pair( sizeof(cl_mem), (void *)&map_y.data)); - args.push_back( make_pair( sizeof(cl_mem), (void *)&KRT_mat.data)); - args.push_back( make_pair( sizeof(cl_int), (void *)&tl_u)); - args.push_back( make_pair( sizeof(cl_int), (void *)&tl_v)); - args.push_back( make_pair( sizeof(cl_int), (void *)&map_x.cols)); - args.push_back( make_pair( sizeof(cl_int), (void *)&map_x.rows)); - args.push_back( make_pair( sizeof(cl_int), (void *)&map_x.step)); - args.push_back( make_pair( sizeof(cl_int), (void *)&map_y.step)); - args.push_back( make_pair( sizeof(cl_float), (void *)&scale)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&map_x.data)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&map_y.data)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&KRT_mat.data)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&tl_u)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&tl_v)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&map_x.cols)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&map_x.rows)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&map_x.step)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&map_y.step)); + args.push_back( std::make_pair( sizeof(cl_float), (void *)&scale)); size_t globalThreads[3] = {map_x.cols, map_x.rows, 1}; size_t localThreads[3] = {32, 8, 1}; @@ -124,19 +123,19 @@ void cv::ocl::buildWarpCylindricalMaps(Size /*src_size*/, Rect dst_roi, const Ma int tl_v = dst_roi.tl().y; Context *clCxt = Context::getContext(); - string kernelName = "buildWarpCylindricalMaps"; - vector< pair > args; + std::string kernelName = "buildWarpCylindricalMaps"; + std::vector< std::pair > args; - args.push_back( make_pair( sizeof(cl_mem), (void *)&map_x.data)); - args.push_back( make_pair( sizeof(cl_mem), (void *)&map_y.data)); - args.push_back( make_pair( sizeof(cl_mem), (void *)&KR_oclMat.data)); - args.push_back( make_pair( sizeof(cl_int), (void *)&tl_u)); - args.push_back( make_pair( sizeof(cl_int), (void *)&tl_v)); - args.push_back( make_pair( sizeof(cl_int), (void *)&map_x.cols)); - args.push_back( make_pair( sizeof(cl_int), (void *)&map_x.rows)); - args.push_back( make_pair( sizeof(cl_int), (void *)&map_x.step)); - args.push_back( make_pair( sizeof(cl_int), (void *)&map_y.step)); - args.push_back( make_pair( sizeof(cl_float), (void *)&scale)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&map_x.data)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&map_y.data)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&KR_oclMat.data)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&tl_u)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&tl_v)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&map_x.cols)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&map_x.rows)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&map_x.step)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&map_y.step)); + args.push_back( std::make_pair( sizeof(cl_float), (void *)&scale)); size_t globalThreads[3] = {map_x.cols, map_x.rows, 1}; size_t localThreads[3] = {32, 8, 1}; @@ -163,19 +162,19 @@ void cv::ocl::buildWarpSphericalMaps(Size /*src_size*/, Rect dst_roi, const Mat int tl_v = dst_roi.tl().y; Context *clCxt = Context::getContext(); - string kernelName = "buildWarpSphericalMaps"; - vector< pair > args; + std::string kernelName = "buildWarpSphericalMaps"; + std::vector< std::pair > args; - args.push_back( make_pair( sizeof(cl_mem), (void *)&map_x.data)); - args.push_back( make_pair( sizeof(cl_mem), (void *)&map_y.data)); - args.push_back( make_pair( sizeof(cl_mem), (void *)&KR_oclMat.data)); - args.push_back( make_pair( sizeof(cl_int), (void *)&tl_u)); - args.push_back( make_pair( sizeof(cl_int), (void *)&tl_v)); - args.push_back( make_pair( sizeof(cl_int), (void *)&map_x.cols)); - args.push_back( make_pair( sizeof(cl_int), (void *)&map_x.rows)); - args.push_back( make_pair( sizeof(cl_int), (void *)&map_x.step)); - args.push_back( make_pair( sizeof(cl_int), (void *)&map_y.step)); - args.push_back( make_pair( sizeof(cl_float), (void *)&scale)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&map_x.data)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&map_y.data)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&KR_oclMat.data)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&tl_u)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&tl_v)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&map_x.cols)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&map_x.rows)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&map_x.step)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&map_y.step)); + args.push_back( std::make_pair( sizeof(cl_float), (void *)&scale)); size_t globalThreads[3] = {map_x.cols, map_x.rows, 1}; size_t localThreads[3] = {32, 8, 1}; @@ -206,16 +205,16 @@ void cv::ocl::buildWarpAffineMaps(const Mat &M, bool inverse, Size dsize, oclMat oclMat coeffsOclMat(coeffsMat.reshape(1, 1)); Context *clCxt = Context::getContext(); - string kernelName = "buildWarpAffineMaps"; - vector< pair > args; + std::string kernelName = "buildWarpAffineMaps"; + std::vector< std::pair > args; - args.push_back( make_pair( sizeof(cl_mem), (void *)&xmap.data)); - args.push_back( make_pair( sizeof(cl_mem), (void *)&ymap.data)); - args.push_back( make_pair( sizeof(cl_mem), (void *)&coeffsOclMat.data)); - args.push_back( make_pair( sizeof(cl_int), (void *)&xmap.cols)); - args.push_back( make_pair( sizeof(cl_int), (void *)&xmap.rows)); - args.push_back( make_pair( sizeof(cl_int), (void *)&xmap.step)); - args.push_back( make_pair( sizeof(cl_int), (void *)&ymap.step)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&xmap.data)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&ymap.data)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&coeffsOclMat.data)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&xmap.cols)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&xmap.rows)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&xmap.step)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&ymap.step)); size_t globalThreads[3] = {xmap.cols, xmap.rows, 1}; size_t localThreads[3] = {32, 8, 1}; @@ -245,16 +244,16 @@ void cv::ocl::buildWarpPerspectiveMaps(const Mat &M, bool inverse, Size dsize, o oclMat coeffsOclMat(coeffsMat.reshape(1, 1)); Context *clCxt = Context::getContext(); - string kernelName = "buildWarpPerspectiveMaps"; - vector< pair > args; + std::string kernelName = "buildWarpPerspectiveMaps"; + std::vector< std::pair > args; - args.push_back( make_pair( sizeof(cl_mem), (void *)&xmap.data)); - args.push_back( make_pair( sizeof(cl_mem), (void *)&ymap.data)); - args.push_back( make_pair( sizeof(cl_mem), (void *)&coeffsOclMat.data)); - args.push_back( make_pair( sizeof(cl_int), (void *)&xmap.cols)); - args.push_back( make_pair( sizeof(cl_int), (void *)&xmap.rows)); - args.push_back( make_pair( sizeof(cl_int), (void *)&xmap.step)); - args.push_back( make_pair( sizeof(cl_int), (void *)&ymap.step)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&xmap.data)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&ymap.data)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&coeffsOclMat.data)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&xmap.cols)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&xmap.rows)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&xmap.step)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&ymap.step)); size_t globalThreads[3] = {xmap.cols, xmap.rows, 1}; size_t localThreads[3] = {32, 8, 1}; diff --git a/modules/ocl/src/canny.cpp b/modules/ocl/src/canny.cpp index 4b872a1bc..a7871d4a3 100644 --- a/modules/ocl/src/canny.cpp +++ b/modules/ocl/src/canny.cpp @@ -49,7 +49,6 @@ using namespace cv; using namespace cv::ocl; -using namespace std; namespace cv { @@ -219,20 +218,20 @@ void cv::ocl::Canny(const oclMat &dx, const oclMat &dy, CannyBuf &buf, oclMat &d void canny::calcSobelRowPass_gpu(const oclMat &src, oclMat &dx_buf, oclMat &dy_buf, int rows, int cols) { Context *clCxt = src.clCxt; - string kernelName = "calcSobelRowPass"; - vector< pair > args; + std::string kernelName = "calcSobelRowPass"; + std::vector< std::pair > args; - args.push_back( make_pair( sizeof(cl_mem), (void *)&src.data)); - args.push_back( make_pair( sizeof(cl_mem), (void *)&dx_buf.data)); - args.push_back( make_pair( sizeof(cl_mem), (void *)&dy_buf.data)); - args.push_back( make_pair( sizeof(cl_int), (void *)&rows)); - args.push_back( make_pair( sizeof(cl_int), (void *)&cols)); - args.push_back( make_pair( sizeof(cl_int), (void *)&src.step)); - args.push_back( make_pair( sizeof(cl_int), (void *)&src.offset)); - args.push_back( make_pair( sizeof(cl_int), (void *)&dx_buf.step)); - args.push_back( make_pair( sizeof(cl_int), (void *)&dx_buf.offset)); - args.push_back( make_pair( sizeof(cl_int), (void *)&dy_buf.step)); - args.push_back( make_pair( sizeof(cl_int), (void *)&dy_buf.offset)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&src.data)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&dx_buf.data)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&dy_buf.data)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&rows)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&cols)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src.step)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src.offset)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dx_buf.step)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dx_buf.offset)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dy_buf.step)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dy_buf.offset)); size_t globalThreads[3] = {cols, rows, 1}; size_t localThreads[3] = {16, 16, 1}; @@ -242,26 +241,26 @@ void canny::calcSobelRowPass_gpu(const oclMat &src, oclMat &dx_buf, oclMat &dy_b void canny::calcMagnitude_gpu(const oclMat &dx_buf, const oclMat &dy_buf, oclMat &dx, oclMat &dy, oclMat &mag, int rows, int cols, bool L2Grad) { Context *clCxt = dx_buf.clCxt; - string kernelName = "calcMagnitude_buf"; - vector< pair > args; + std::string kernelName = "calcMagnitude_buf"; + std::vector< std::pair > args; - args.push_back( make_pair( sizeof(cl_mem), (void *)&dx_buf.data)); - args.push_back( make_pair( sizeof(cl_mem), (void *)&dy_buf.data)); - args.push_back( make_pair( sizeof(cl_mem), (void *)&dx.data)); - args.push_back( make_pair( sizeof(cl_mem), (void *)&dy.data)); - args.push_back( make_pair( sizeof(cl_mem), (void *)&mag.data)); - args.push_back( make_pair( sizeof(cl_int), (void *)&rows)); - args.push_back( make_pair( sizeof(cl_int), (void *)&cols)); - args.push_back( make_pair( sizeof(cl_int), (void *)&dx_buf.step)); - args.push_back( make_pair( sizeof(cl_int), (void *)&dx_buf.offset)); - args.push_back( make_pair( sizeof(cl_int), (void *)&dy_buf.step)); - args.push_back( make_pair( sizeof(cl_int), (void *)&dy_buf.offset)); - args.push_back( make_pair( sizeof(cl_int), (void *)&dx.step)); - args.push_back( make_pair( sizeof(cl_int), (void *)&dx.offset)); - args.push_back( make_pair( sizeof(cl_int), (void *)&dy.step)); - args.push_back( make_pair( sizeof(cl_int), (void *)&dy.offset)); - args.push_back( make_pair( sizeof(cl_int), (void *)&mag.step)); - args.push_back( make_pair( sizeof(cl_int), (void *)&mag.offset)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&dx_buf.data)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&dy_buf.data)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&dx.data)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&dy.data)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&mag.data)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&rows)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&cols)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dx_buf.step)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dx_buf.offset)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dy_buf.step)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dy_buf.offset)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dx.step)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dx.offset)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dy.step)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dy.offset)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&mag.step)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&mag.offset)); size_t globalThreads[3] = {cols, rows, 1}; size_t localThreads[3] = {16, 16, 1}; @@ -276,20 +275,20 @@ void canny::calcMagnitude_gpu(const oclMat &dx_buf, const oclMat &dy_buf, oclMat void canny::calcMagnitude_gpu(const oclMat &dx, const oclMat &dy, oclMat &mag, int rows, int cols, bool L2Grad) { Context *clCxt = dx.clCxt; - string kernelName = "calcMagnitude"; - vector< pair > args; + std::string kernelName = "calcMagnitude"; + std::vector< std::pair > args; - args.push_back( make_pair( sizeof(cl_mem), (void *)&dx.data)); - args.push_back( make_pair( sizeof(cl_mem), (void *)&dy.data)); - args.push_back( make_pair( sizeof(cl_mem), (void *)&mag.data)); - args.push_back( make_pair( sizeof(cl_int), (void *)&rows)); - args.push_back( make_pair( sizeof(cl_int), (void *)&cols)); - args.push_back( make_pair( sizeof(cl_int), (void *)&dx.step)); - args.push_back( make_pair( sizeof(cl_int), (void *)&dx.offset)); - args.push_back( make_pair( sizeof(cl_int), (void *)&dy.step)); - args.push_back( make_pair( sizeof(cl_int), (void *)&dy.offset)); - args.push_back( make_pair( sizeof(cl_int), (void *)&mag.step)); - args.push_back( make_pair( sizeof(cl_int), (void *)&mag.offset)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&dx.data)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&dy.data)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&mag.data)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&rows)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&cols)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dx.step)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dx.offset)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dy.step)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dy.offset)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&mag.step)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&mag.offset)); size_t globalThreads[3] = {cols, rows, 1}; size_t localThreads[3] = {16, 16, 1}; @@ -306,28 +305,28 @@ void canny::calcMap_gpu(oclMat &dx, oclMat &dy, oclMat &mag, oclMat &map, int ro { Context *clCxt = dx.clCxt; - vector< pair > args; + std::vector< std::pair > args; - args.push_back( make_pair( sizeof(cl_mem), (void *)&dx.data)); - args.push_back( make_pair( sizeof(cl_mem), (void *)&dy.data)); - args.push_back( make_pair( sizeof(cl_mem), (void *)&mag.data)); - args.push_back( make_pair( sizeof(cl_mem), (void *)&map.data)); - args.push_back( make_pair( sizeof(cl_int), (void *)&rows)); - args.push_back( make_pair( sizeof(cl_int), (void *)&cols)); - args.push_back( make_pair( sizeof(cl_float), (void *)&low_thresh)); - args.push_back( make_pair( sizeof(cl_float), (void *)&high_thresh)); - args.push_back( make_pair( sizeof(cl_int), (void *)&dx.step)); - args.push_back( make_pair( sizeof(cl_int), (void *)&dx.offset)); - args.push_back( make_pair( sizeof(cl_int), (void *)&dy.step)); - args.push_back( make_pair( sizeof(cl_int), (void *)&dy.offset)); - args.push_back( make_pair( sizeof(cl_int), (void *)&mag.step)); - args.push_back( make_pair( sizeof(cl_int), (void *)&mag.offset)); - args.push_back( make_pair( sizeof(cl_int), (void *)&map.step)); - args.push_back( make_pair( sizeof(cl_int), (void *)&map.offset)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&dx.data)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&dy.data)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&mag.data)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&map.data)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&rows)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&cols)); + args.push_back( std::make_pair( sizeof(cl_float), (void *)&low_thresh)); + args.push_back( std::make_pair( sizeof(cl_float), (void *)&high_thresh)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dx.step)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dx.offset)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dy.step)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dy.offset)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&mag.step)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&mag.offset)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&map.step)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&map.offset)); size_t globalThreads[3] = {cols, rows, 1}; - string kernelName = "calcMap"; + std::string kernelName = "calcMap"; size_t localThreads[3] = {16, 16, 1}; openCLExecuteKernel2(clCxt, &imgproc_canny, kernelName, globalThreads, localThreads, args, -1, -1); @@ -336,16 +335,16 @@ void canny::calcMap_gpu(oclMat &dx, oclMat &dy, oclMat &mag, oclMat &map, int ro void canny::edgesHysteresisLocal_gpu(oclMat &map, oclMat &st1, void *counter, int rows, int cols) { Context *clCxt = map.clCxt; - string kernelName = "edgesHysteresisLocal"; - vector< pair > args; + std::string kernelName = "edgesHysteresisLocal"; + std::vector< std::pair > args; - args.push_back( make_pair( sizeof(cl_mem), (void *)&map.data)); - args.push_back( make_pair( sizeof(cl_mem), (void *)&st1.data)); - args.push_back( make_pair( sizeof(cl_mem), (void *)&counter)); - args.push_back( make_pair( sizeof(cl_int), (void *)&rows)); - args.push_back( make_pair( sizeof(cl_int), (void *)&cols)); - args.push_back( make_pair( sizeof(cl_int), (void *)&map.step)); - args.push_back( make_pair( sizeof(cl_int), (void *)&map.offset)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&map.data)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&st1.data)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&counter)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&rows)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&cols)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&map.step)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&map.offset)); size_t globalThreads[3] = {cols, rows, 1}; size_t localThreads[3] = {16, 16, 1}; @@ -358,8 +357,8 @@ void canny::edgesHysteresisGlobal_gpu(oclMat &map, oclMat &st1, oclMat &st2, voi unsigned int count; openCLSafeCall(clEnqueueReadBuffer(Context::getContext()->impl->clCmdQueue, (cl_mem)counter, 1, 0, sizeof(float), &count, 0, NULL, NULL)); Context *clCxt = map.clCxt; - string kernelName = "edgesHysteresisGlobal"; - vector< pair > args; + std::string kernelName = "edgesHysteresisGlobal"; + std::vector< std::pair > args; size_t localThreads[3] = {128, 1, 1}; #define DIVUP(a, b) ((a)+(b)-1)/(b) @@ -370,15 +369,15 @@ void canny::edgesHysteresisGlobal_gpu(oclMat &map, oclMat &st1, oclMat &st2, voi args.clear(); size_t globalThreads[3] = {std::min(count, 65535u) * 128, DIVUP(count, 65535), 1}; - args.push_back( make_pair( sizeof(cl_mem), (void *)&map.data)); - args.push_back( make_pair( sizeof(cl_mem), (void *)&st1.data)); - args.push_back( make_pair( sizeof(cl_mem), (void *)&st2.data)); - args.push_back( make_pair( sizeof(cl_mem), (void *)&counter)); - args.push_back( make_pair( sizeof(cl_int), (void *)&rows)); - args.push_back( make_pair( sizeof(cl_int), (void *)&cols)); - args.push_back( make_pair( sizeof(cl_int), (void *)&count)); - args.push_back( make_pair( sizeof(cl_int), (void *)&map.step)); - args.push_back( make_pair( sizeof(cl_int), (void *)&map.offset)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&map.data)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&st1.data)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&st2.data)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&counter)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&rows)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&cols)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&count)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&map.step)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&map.offset)); openCLExecuteKernel2(clCxt, &imgproc_canny, kernelName, globalThreads, localThreads, args, -1, -1, DISABLE); openCLSafeCall(clEnqueueReadBuffer(Context::getContext()->impl->clCmdQueue, (cl_mem)counter, 1, 0, sizeof(int), &count, 0, NULL, NULL)); @@ -390,17 +389,17 @@ void canny::edgesHysteresisGlobal_gpu(oclMat &map, oclMat &st1, oclMat &st2, voi void canny::getEdges_gpu(oclMat &map, oclMat &dst, int rows, int cols) { Context *clCxt = map.clCxt; - string kernelName = "getEdges"; - vector< pair > args; + std::string kernelName = "getEdges"; + std::vector< std::pair > args; - args.push_back( make_pair( sizeof(cl_mem), (void *)&map.data)); - args.push_back( make_pair( sizeof(cl_mem), (void *)&dst.data)); - args.push_back( make_pair( sizeof(cl_int), (void *)&rows)); - args.push_back( make_pair( sizeof(cl_int), (void *)&cols)); - args.push_back( make_pair( sizeof(cl_int), (void *)&map.step)); - args.push_back( make_pair( sizeof(cl_int), (void *)&map.offset)); - args.push_back( make_pair( sizeof(cl_int), (void *)&dst.step)); - args.push_back( make_pair( sizeof(cl_int), (void *)&dst.offset)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&map.data)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&dst.data)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&rows)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&cols)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&map.step)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&map.offset)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dst.step)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dst.offset)); size_t globalThreads[3] = {cols, rows, 1}; size_t localThreads[3] = {16, 16, 1}; diff --git a/modules/ocl/src/color.cpp b/modules/ocl/src/color.cpp index e14bd2756..a98549c40 100644 --- a/modules/ocl/src/color.cpp +++ b/modules/ocl/src/color.cpp @@ -69,106 +69,106 @@ namespace { void RGB2Gray_caller(const oclMat &src, oclMat &dst, int bidx) { - vector > args; + std::vector > args; int channels = src.oclchannels(); char build_options[50]; sprintf(build_options, "-D DEPTH_%d", src.depth()); //printf("depth:%d,channels:%d,bidx:%d\n",src.depth(),src.oclchannels(),bidx); - args.push_back( make_pair( sizeof(cl_int) , (void *)&src.cols)); - args.push_back( make_pair( sizeof(cl_int) , (void *)&src.rows)); - args.push_back( make_pair( sizeof(cl_int) , (void *)&src.step)); - args.push_back( make_pair( sizeof(cl_int) , (void *)&dst.step)); - args.push_back( make_pair( sizeof(cl_int) , (void *)&channels)); - args.push_back( make_pair( sizeof(cl_int) , (void *)&bidx)); - args.push_back( make_pair( sizeof(cl_mem) , (void *)&src.data)); - args.push_back( make_pair( sizeof(cl_mem) , (void *)&dst.data)); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&src.cols)); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&src.rows)); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&src.step)); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&dst.step)); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&channels)); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&bidx)); + args.push_back( std::make_pair( sizeof(cl_mem) , (void *)&src.data)); + args.push_back( std::make_pair( sizeof(cl_mem) , (void *)&dst.data)); size_t gt[3] = {src.cols, src.rows, 1}, lt[3] = {16, 16, 1}; openCLExecuteKernel(src.clCxt, &cvt_color, "RGB2Gray", gt, lt, args, -1, -1, build_options); } void Gray2RGB_caller(const oclMat &src, oclMat &dst) { - vector > args; + std::vector > args; char build_options[50]; sprintf(build_options, "-D DEPTH_%d", src.depth()); //printf("depth:%d,channels:%d,bidx:%d\n",src.depth(),src.oclchannels(),bidx); - args.push_back( make_pair( sizeof(cl_int) , (void *)&src.cols)); - args.push_back( make_pair( sizeof(cl_int) , (void *)&src.rows)); - args.push_back( make_pair( sizeof(cl_int) , (void *)&src.step)); - args.push_back( make_pair( sizeof(cl_int) , (void *)&dst.step)); - args.push_back( make_pair( sizeof(cl_mem) , (void *)&src.data)); - args.push_back( make_pair( sizeof(cl_mem) , (void *)&dst.data)); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&src.cols)); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&src.rows)); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&src.step)); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&dst.step)); + args.push_back( std::make_pair( sizeof(cl_mem) , (void *)&src.data)); + args.push_back( std::make_pair( sizeof(cl_mem) , (void *)&dst.data)); size_t gt[3] = {src.cols, src.rows, 1}, lt[3] = {16, 16, 1}; openCLExecuteKernel(src.clCxt, &cvt_color, "Gray2RGB", gt, lt, args, -1, -1, build_options); } void RGB2YUV_caller(const oclMat &src, oclMat &dst, int bidx) { - vector > args; + std::vector > args; int channels = src.oclchannels(); char build_options[50]; sprintf(build_options, "-D DEPTH_%d", src.depth()); //printf("depth:%d,channels:%d,bidx:%d\n",src.depth(),src.oclchannels(),bidx); - args.push_back( make_pair( sizeof(cl_int) , (void *)&src.cols)); - args.push_back( make_pair( sizeof(cl_int) , (void *)&src.rows)); - args.push_back( make_pair( sizeof(cl_int) , (void *)&src.step)); - args.push_back( make_pair( sizeof(cl_int) , (void *)&dst.step)); - args.push_back( make_pair( sizeof(cl_int) , (void *)&channels)); - args.push_back( make_pair( sizeof(cl_int) , (void *)&bidx)); - args.push_back( make_pair( sizeof(cl_mem) , (void *)&src.data)); - args.push_back( make_pair( sizeof(cl_mem) , (void *)&dst.data)); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&src.cols)); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&src.rows)); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&src.step)); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&dst.step)); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&channels)); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&bidx)); + args.push_back( std::make_pair( sizeof(cl_mem) , (void *)&src.data)); + args.push_back( std::make_pair( sizeof(cl_mem) , (void *)&dst.data)); size_t gt[3] = {src.cols, src.rows, 1}, lt[3] = {16, 16, 1}; openCLExecuteKernel(src.clCxt, &cvt_color, "RGB2YUV", gt, lt, args, -1, -1, build_options); } void YUV2RGB_caller(const oclMat &src, oclMat &dst, int bidx) { - vector > args; + std::vector > args; int channels = src.oclchannels(); char build_options[50]; sprintf(build_options, "-D DEPTH_%d", src.depth()); //printf("depth:%d,channels:%d,bidx:%d\n",src.depth(),src.oclchannels(),bidx); - args.push_back( make_pair( sizeof(cl_int) , (void *)&src.cols)); - args.push_back( make_pair( sizeof(cl_int) , (void *)&src.rows)); - args.push_back( make_pair( sizeof(cl_int) , (void *)&src.step)); - args.push_back( make_pair( sizeof(cl_int) , (void *)&dst.step)); - args.push_back( make_pair( sizeof(cl_int) , (void *)&channels)); - args.push_back( make_pair( sizeof(cl_int) , (void *)&bidx)); - args.push_back( make_pair( sizeof(cl_mem) , (void *)&src.data)); - args.push_back( make_pair( sizeof(cl_mem) , (void *)&dst.data)); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&src.cols)); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&src.rows)); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&src.step)); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&dst.step)); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&channels)); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&bidx)); + args.push_back( std::make_pair( sizeof(cl_mem) , (void *)&src.data)); + args.push_back( std::make_pair( sizeof(cl_mem) , (void *)&dst.data)); size_t gt[3] = {src.cols, src.rows, 1}, lt[3] = {16, 16, 1}; openCLExecuteKernel(src.clCxt, &cvt_color, "YUV2RGB", gt, lt, args, -1, -1, build_options); } void YUV2RGB_NV12_caller(const oclMat &src, oclMat &dst, int bidx) { - vector > args; + std::vector > args; char build_options[50]; sprintf(build_options, "-D DEPTH_%d", src.depth()); //printf("depth:%d,channels:%d,bidx:%d\n",src.depth(),src.oclchannels(),bidx); - args.push_back( make_pair( sizeof(cl_int) , (void *)&src.cols)); - args.push_back( make_pair( sizeof(cl_int) , (void *)&src.rows)); - args.push_back( make_pair( sizeof(cl_int) , (void *)&src.step)); - args.push_back( make_pair( sizeof(cl_int) , (void *)&dst.step)); - args.push_back( make_pair( sizeof(cl_int) , (void *)&bidx)); - args.push_back( make_pair( sizeof(cl_int) , (void *)&dst.cols)); - args.push_back( make_pair( sizeof(cl_int) , (void *)&dst.rows)); - args.push_back( make_pair( sizeof(cl_mem) , (void *)&src.data)); - args.push_back( make_pair( sizeof(cl_mem) , (void *)&dst.data)); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&src.cols)); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&src.rows)); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&src.step)); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&dst.step)); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&bidx)); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&dst.cols)); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&dst.rows)); + args.push_back( std::make_pair( sizeof(cl_mem) , (void *)&src.data)); + args.push_back( std::make_pair( sizeof(cl_mem) , (void *)&dst.data)); size_t gt[3] = {dst.cols / 2, dst.rows / 2, 1}, lt[3] = {16, 16, 1}; openCLExecuteKernel(src.clCxt, &cvt_color, "YUV2RGBA_NV12", gt, lt, args, -1, -1, build_options); } void RGB2YCrCb_caller(const oclMat &src, oclMat &dst, int bidx) { - vector > args; + std::vector > args; int channels = src.oclchannels(); char build_options[50]; sprintf(build_options, "-D DEPTH_%d", src.depth()); //printf("depth:%d,channels:%d,bidx:%d\n",src.depth(),src.oclchannels(),bidx); - args.push_back( make_pair( sizeof(cl_int) , (void *)&src.cols)); - args.push_back( make_pair( sizeof(cl_int) , (void *)&src.rows)); - args.push_back( make_pair( sizeof(cl_int) , (void *)&src.step)); - args.push_back( make_pair( sizeof(cl_int) , (void *)&dst.step)); - args.push_back( make_pair( sizeof(cl_int) , (void *)&channels)); - args.push_back( make_pair( sizeof(cl_int) , (void *)&bidx)); - args.push_back( make_pair( sizeof(cl_mem) , (void *)&src.data)); - args.push_back( make_pair( sizeof(cl_mem) , (void *)&dst.data)); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&src.cols)); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&src.rows)); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&src.step)); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&dst.step)); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&channels)); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&bidx)); + args.push_back( std::make_pair( sizeof(cl_mem) , (void *)&src.data)); + args.push_back( std::make_pair( sizeof(cl_mem) , (void *)&dst.data)); size_t gt[3] = {src.cols, src.rows, 1}, lt[3] = {16, 16, 1}; openCLExecuteKernel(src.clCxt, &cvt_color, "RGB2YCrCb", gt, lt, args, -1, -1, build_options); } diff --git a/modules/ocl/src/columnsum.cpp b/modules/ocl/src/columnsum.cpp index 037ff234e..397c5356a 100644 --- a/modules/ocl/src/columnsum.cpp +++ b/modules/ocl/src/columnsum.cpp @@ -48,7 +48,6 @@ using namespace cv; using namespace cv::ocl; -using namespace std; namespace cv { @@ -68,14 +67,14 @@ void cv::ocl::columnSum(const oclMat &src, oclMat &dst) const std::string kernelName = "columnSum"; - std::vector< pair > args; + std::vector< std::pair > args; - args.push_back( make_pair( sizeof(cl_mem), (void *)&src.data)); - args.push_back( make_pair( sizeof(cl_mem), (void *)&dst.data)); - args.push_back( make_pair( sizeof(cl_int), (void *)&src.cols)); - args.push_back( make_pair( sizeof(cl_int), (void *)&src.rows)); - args.push_back( make_pair( sizeof(cl_int), (void *)&src.step)); - args.push_back( make_pair( sizeof(cl_int), (void *)&dst.step)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&src.data)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&dst.data)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src.cols)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src.rows)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src.step)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dst.step)); size_t globalThreads[3] = {dst.cols, 1, 1}; size_t localThreads[3] = {256, 1, 1}; diff --git a/modules/ocl/src/fft.cpp b/modules/ocl/src/fft.cpp index 300ae60a7..b246639fb 100644 --- a/modules/ocl/src/fft.cpp +++ b/modules/ocl/src/fft.cpp @@ -47,7 +47,6 @@ using namespace cv; using namespace cv::ocl; -using namespace std; #if !defined HAVE_CLAMDFFT void cv::ocl::dft(const oclMat&, oclMat&, Size, int) @@ -88,11 +87,11 @@ namespace cv protected: PlanCache(); ~PlanCache(); - friend class auto_ptr; - static auto_ptr planCache; + friend class std::auto_ptr; + static std::auto_ptr planCache; bool started; - vector planStore; + std::vector planStore; clAmdFftSetupData *setupData; public: friend void fft_setup(); @@ -116,7 +115,7 @@ namespace cv }; } } -auto_ptr PlanCache::planCache; +std::auto_ptr PlanCache::planCache; void cv::ocl::fft_setup() { @@ -194,8 +193,8 @@ cv::ocl::FftPlan::FftPlan(Size _dft_size, int _src_step, int _dst_step, int _fla break; default: //std::runtime_error("does not support this convertion!"); - cout << "Does not support this convertion!" << endl; - throw exception(); + std::cout << "Does not support this convertion!" << std::endl; + throw std::exception(); break; } @@ -225,7 +224,7 @@ cv::ocl::FftPlan::~FftPlan() cv::ocl::PlanCache::PlanCache() : started(false), - planStore(vector()), + planStore(std::vector()), setupData(NULL) { } @@ -238,7 +237,7 @@ cv::ocl::PlanCache::~PlanCache() FftPlan* cv::ocl::PlanCache::getPlan(Size _dft_size, int _src_step, int _dst_step, int _flags, FftType _type) { PlanCache& pCache = *PlanCache::getPlanCache(); - vector& pStore = pCache.planStore; + std::vector& pStore = pCache.planStore; // go through search for(size_t i = 0; i < pStore.size(); i ++) { @@ -264,7 +263,7 @@ FftPlan* cv::ocl::PlanCache::getPlan(Size _dft_size, int _src_step, int _dst_ste bool cv::ocl::PlanCache::removePlan(clAmdFftPlanHandle plHandle) { PlanCache& pCache = *PlanCache::getPlanCache(); - vector& pStore = pCache.planStore; + std::vector& pStore = pCache.planStore; for(size_t i = 0; i < pStore.size(); i ++) { if(pStore[i]->getPlanHandle() == plHandle) @@ -318,8 +317,8 @@ void cv::ocl::dft(const oclMat &src, oclMat &dst, Size dft_size, int flags) break; default: //std::runtime_error("does not support this convertion!"); - cout << "Does not support this convertion!" << endl; - throw exception(); + std::cout << "Does not support this convertion!" << std::endl; + throw std::exception(); break; } clAmdFftPlanHandle plHandle = PlanCache::getPlan(dft_size, src.step, dst.step, flags, type)->getPlanHandle(); diff --git a/modules/ocl/src/filtering.cpp b/modules/ocl/src/filtering.cpp index 5173dba37..61e899c17 100644 --- a/modules/ocl/src/filtering.cpp +++ b/modules/ocl/src/filtering.cpp @@ -50,7 +50,6 @@ #include "precomp.hpp" #include "mcwutil.hpp" #include -using namespace std; using namespace cv; using namespace cv::ocl; @@ -237,7 +236,7 @@ static void GPUErode(const oclMat &src, oclMat &dst, oclMat &mat_kernel, int srcOffset_x = srcOffset % srcStep; int srcOffset_y = srcOffset / srcStep; Context *clCxt = src.clCxt; - string kernelName; + std::string kernelName; size_t localThreads[3] = {16, 16, 1}; size_t globalThreads[3] = {(src.cols + localThreads[0] - 1) / localThreads[0] *localThreads[0], (src.rows + localThreads[1] - 1) / localThreads[1] *localThreads[1], 1}; @@ -281,19 +280,19 @@ static void GPUErode(const oclMat &src, oclMat &dst, oclMat &mat_kernel, rectKernel?"-D RECTKERNEL":"", useROI?"-D USEROI":"", s); - vector< pair > args; - args.push_back(make_pair(sizeof(cl_mem), (void *)&src.data)); - args.push_back(make_pair(sizeof(cl_mem), (void *)&dst.data)); - args.push_back(make_pair(sizeof(cl_int), (void *)&srcOffset_x)); - args.push_back(make_pair(sizeof(cl_int), (void *)&srcOffset_y)); - args.push_back(make_pair(sizeof(cl_int), (void *)&src.cols)); - args.push_back(make_pair(sizeof(cl_int), (void *)&src.rows)); - args.push_back(make_pair(sizeof(cl_int), (void *)&srcStep)); - args.push_back(make_pair(sizeof(cl_int), (void *)&dstStep)); - args.push_back(make_pair(sizeof(cl_mem), (void *)&mat_kernel.data)); - args.push_back(make_pair(sizeof(cl_int), (void *)&src.wholecols)); - args.push_back(make_pair(sizeof(cl_int), (void *)&src.wholerows)); - args.push_back(make_pair(sizeof(cl_int), (void *)&dstOffset)); + std::vector< std::pair > args; + args.push_back(std::make_pair(sizeof(cl_mem), (void *)&src.data)); + args.push_back(std::make_pair(sizeof(cl_mem), (void *)&dst.data)); + args.push_back(std::make_pair(sizeof(cl_int), (void *)&srcOffset_x)); + args.push_back(std::make_pair(sizeof(cl_int), (void *)&srcOffset_y)); + args.push_back(std::make_pair(sizeof(cl_int), (void *)&src.cols)); + args.push_back(std::make_pair(sizeof(cl_int), (void *)&src.rows)); + args.push_back(std::make_pair(sizeof(cl_int), (void *)&srcStep)); + args.push_back(std::make_pair(sizeof(cl_int), (void *)&dstStep)); + args.push_back(std::make_pair(sizeof(cl_mem), (void *)&mat_kernel.data)); + args.push_back(std::make_pair(sizeof(cl_int), (void *)&src.wholecols)); + args.push_back(std::make_pair(sizeof(cl_int), (void *)&src.wholerows)); + args.push_back(std::make_pair(sizeof(cl_int), (void *)&dstOffset)); openCLExecuteKernel(clCxt, &filtering_morph, kernelName, globalThreads, localThreads, args, -1, -1, compile_option); } @@ -317,7 +316,7 @@ static void GPUDilate(const oclMat &src, oclMat &dst, oclMat &mat_kernel, int srcOffset_x = srcOffset % srcStep; int srcOffset_y = srcOffset / srcStep; Context *clCxt = src.clCxt; - string kernelName; + std::string kernelName; size_t localThreads[3] = {16, 16, 1}; size_t globalThreads[3] = {(src.cols + localThreads[0] - 1) / localThreads[0] *localThreads[0], (src.rows + localThreads[1] - 1) / localThreads[1] *localThreads[1], 1}; @@ -362,19 +361,19 @@ static void GPUDilate(const oclMat &src, oclMat &dst, oclMat &mat_kernel, rectKernel?"-D RECTKERNEL":"", useROI?"-D USEROI":"", s); - vector< pair > args; - args.push_back(make_pair(sizeof(cl_mem), (void *)&src.data)); - args.push_back(make_pair(sizeof(cl_mem), (void *)&dst.data)); - args.push_back(make_pair(sizeof(cl_int), (void *)&srcOffset_x)); - args.push_back(make_pair(sizeof(cl_int), (void *)&srcOffset_y)); - args.push_back(make_pair(sizeof(cl_int), (void *)&src.cols)); - args.push_back(make_pair(sizeof(cl_int), (void *)&src.rows)); - args.push_back(make_pair(sizeof(cl_int), (void *)&srcStep)); - args.push_back(make_pair(sizeof(cl_int), (void *)&dstStep)); - args.push_back(make_pair(sizeof(cl_mem), (void *)&mat_kernel.data)); - args.push_back(make_pair(sizeof(cl_int), (void *)&src.wholecols)); - args.push_back(make_pair(sizeof(cl_int), (void *)&src.wholerows)); - args.push_back(make_pair(sizeof(cl_int), (void *)&dstOffset)); + std::vector< std::pair > args; + args.push_back(std::make_pair(sizeof(cl_mem), (void *)&src.data)); + args.push_back(std::make_pair(sizeof(cl_mem), (void *)&dst.data)); + args.push_back(std::make_pair(sizeof(cl_int), (void *)&srcOffset_x)); + args.push_back(std::make_pair(sizeof(cl_int), (void *)&srcOffset_y)); + args.push_back(std::make_pair(sizeof(cl_int), (void *)&src.cols)); + args.push_back(std::make_pair(sizeof(cl_int), (void *)&src.rows)); + args.push_back(std::make_pair(sizeof(cl_int), (void *)&srcStep)); + args.push_back(std::make_pair(sizeof(cl_int), (void *)&dstStep)); + args.push_back(std::make_pair(sizeof(cl_mem), (void *)&mat_kernel.data)); + args.push_back(std::make_pair(sizeof(cl_int), (void *)&src.wholecols)); + args.push_back(std::make_pair(sizeof(cl_int), (void *)&src.wholerows)); + args.push_back(std::make_pair(sizeof(cl_int), (void *)&dstOffset)); openCLExecuteKernel(clCxt, &filtering_morph, kernelName, globalThreads, localThreads, args, -1, -1, compile_option); } @@ -610,7 +609,7 @@ static void GPUFilter2D(const oclMat &src, oclMat &dst, oclMat &mat_kernel, int cn = src.oclchannels(); int depth = src.depth(); - string kernelName = "filter2D"; + std::string kernelName = "filter2D"; size_t src_offset_x = (src.offset % src.step) / src.elemSize(); size_t src_offset_y = src.offset / src.step; @@ -634,21 +633,21 @@ static void GPUFilter2D(const oclMat &src, oclMat &dst, oclMat &mat_kernel, divUp(rows, localThreads[1]) *localThreads[1], 1 }; - vector< pair > args; - args.push_back(make_pair(sizeof(cl_mem), (void *)&src.data)); - args.push_back(make_pair(sizeof(cl_int), (void *)&src.step)); - args.push_back(make_pair(sizeof(cl_int), (void *)&src_offset_x)); - args.push_back(make_pair(sizeof(cl_int), (void *)&src_offset_y)); - args.push_back(make_pair(sizeof(cl_mem), (void *)&dst.data)); - args.push_back(make_pair(sizeof(cl_int), (void *)&dst.step)); - args.push_back(make_pair(sizeof(cl_int), (void *)&dst_offset_x)); - args.push_back(make_pair(sizeof(cl_int), (void *)&dst_offset_y)); - args.push_back(make_pair(sizeof(cl_mem), (void *)&mat_kernel.data)); - args.push_back(make_pair(sizeof(cl_int), (void *)&src.cols)); - args.push_back(make_pair(sizeof(cl_int), (void *)&src.rows)); - args.push_back(make_pair(sizeof(cl_int), (void *)&cols)); - args.push_back(make_pair(sizeof(cl_int), (void *)&src.wholecols)); - args.push_back(make_pair(sizeof(cl_int), (void *)&src.wholerows)); + std::vector< std::pair > args; + args.push_back(std::make_pair(sizeof(cl_mem), (void *)&src.data)); + args.push_back(std::make_pair(sizeof(cl_int), (void *)&src.step)); + args.push_back(std::make_pair(sizeof(cl_int), (void *)&src_offset_x)); + args.push_back(std::make_pair(sizeof(cl_int), (void *)&src_offset_y)); + args.push_back(std::make_pair(sizeof(cl_mem), (void *)&dst.data)); + args.push_back(std::make_pair(sizeof(cl_int), (void *)&dst.step)); + args.push_back(std::make_pair(sizeof(cl_int), (void *)&dst_offset_x)); + args.push_back(std::make_pair(sizeof(cl_int), (void *)&dst_offset_y)); + args.push_back(std::make_pair(sizeof(cl_mem), (void *)&mat_kernel.data)); + args.push_back(std::make_pair(sizeof(cl_int), (void *)&src.cols)); + args.push_back(std::make_pair(sizeof(cl_int), (void *)&src.rows)); + args.push_back(std::make_pair(sizeof(cl_int), (void *)&cols)); + args.push_back(std::make_pair(sizeof(cl_int), (void *)&src.wholecols)); + args.push_back(std::make_pair(sizeof(cl_int), (void *)&src.wholerows)); openCLExecuteKernel(clCxt, &filtering_laplacian, kernelName, globalThreads, localThreads, args, cn, depth); } @@ -766,7 +765,7 @@ static void GPUFilterBox_8u_C1R(const oclMat &src, oclMat &dst, (src.rows == dst.rows)); Context *clCxt = src.clCxt; - string kernelName = "boxFilter_C1_D0"; + std::string kernelName = "boxFilter_C1_D0"; char btype[30]; @@ -801,18 +800,18 @@ static void GPUFilterBox_8u_C1R(const oclMat &src, oclMat &dst, size_t globalThreads[3] = { globalSizeX, globalSizeY, 1 }; size_t localThreads[3] = { blockSizeX, blockSizeY, 1 }; - vector > args; - args.push_back(make_pair(sizeof(cl_mem), &src.data)); - args.push_back(make_pair(sizeof(cl_mem), &dst.data)); - args.push_back(make_pair(sizeof(cl_float), (void *)&alpha)); - args.push_back(make_pair(sizeof(cl_int), (void *)&src.offset)); - args.push_back(make_pair(sizeof(cl_int), (void *)&src.wholerows)); - args.push_back(make_pair(sizeof(cl_int), (void *)&src.wholecols)); - args.push_back(make_pair(sizeof(cl_int), (void *)&src.step)); - args.push_back(make_pair(sizeof(cl_int), (void *)&dst.offset)); - args.push_back(make_pair(sizeof(cl_int), (void *)&dst.rows)); - args.push_back(make_pair(sizeof(cl_int), (void *)&dst.cols)); - args.push_back(make_pair(sizeof(cl_int), (void *)&dst.step)); + std::vector > args; + args.push_back(std::make_pair(sizeof(cl_mem), &src.data)); + args.push_back(std::make_pair(sizeof(cl_mem), &dst.data)); + args.push_back(std::make_pair(sizeof(cl_float), (void *)&alpha)); + args.push_back(std::make_pair(sizeof(cl_int), (void *)&src.offset)); + args.push_back(std::make_pair(sizeof(cl_int), (void *)&src.wholerows)); + args.push_back(std::make_pair(sizeof(cl_int), (void *)&src.wholecols)); + args.push_back(std::make_pair(sizeof(cl_int), (void *)&src.step)); + args.push_back(std::make_pair(sizeof(cl_int), (void *)&dst.offset)); + args.push_back(std::make_pair(sizeof(cl_int), (void *)&dst.rows)); + args.push_back(std::make_pair(sizeof(cl_int), (void *)&dst.cols)); + args.push_back(std::make_pair(sizeof(cl_int), (void *)&dst.step)); openCLExecuteKernel(clCxt, &filtering_boxFilter, kernelName, globalThreads, localThreads, args, -1, -1, build_options); } @@ -828,7 +827,7 @@ static void GPUFilterBox_8u_C4R(const oclMat &src, oclMat &dst, (src.rows == dst.rows)); Context *clCxt = src.clCxt; - string kernelName = "boxFilter_C4_D0"; + std::string kernelName = "boxFilter_C4_D0"; char btype[30]; @@ -863,18 +862,18 @@ static void GPUFilterBox_8u_C4R(const oclMat &src, oclMat &dst, size_t globalThreads[3] = { globalSizeX, globalSizeY, 1}; size_t localThreads[3] = { blockSizeX, blockSizeY, 1}; - vector > args; - args.push_back(make_pair(sizeof(cl_mem), &src.data)); - args.push_back(make_pair(sizeof(cl_mem), &dst.data)); - args.push_back(make_pair(sizeof(cl_float), (void *)&alpha)); - args.push_back(make_pair(sizeof(cl_int), (void *)&src.offset)); - args.push_back(make_pair(sizeof(cl_int), (void *)&src.wholerows)); - args.push_back(make_pair(sizeof(cl_int), (void *)&src.wholecols)); - args.push_back(make_pair(sizeof(cl_int), (void *)&src.step)); - args.push_back(make_pair(sizeof(cl_int), (void *)&dst.offset)); - args.push_back(make_pair(sizeof(cl_int), (void *)&dst.rows)); - args.push_back(make_pair(sizeof(cl_int), (void *)&dst.cols)); - args.push_back(make_pair(sizeof(cl_int), (void *)&dst.step)); + std::vector > args; + args.push_back(std::make_pair(sizeof(cl_mem), &src.data)); + args.push_back(std::make_pair(sizeof(cl_mem), &dst.data)); + args.push_back(std::make_pair(sizeof(cl_float), (void *)&alpha)); + args.push_back(std::make_pair(sizeof(cl_int), (void *)&src.offset)); + args.push_back(std::make_pair(sizeof(cl_int), (void *)&src.wholerows)); + args.push_back(std::make_pair(sizeof(cl_int), (void *)&src.wholecols)); + args.push_back(std::make_pair(sizeof(cl_int), (void *)&src.step)); + args.push_back(std::make_pair(sizeof(cl_int), (void *)&dst.offset)); + args.push_back(std::make_pair(sizeof(cl_int), (void *)&dst.rows)); + args.push_back(std::make_pair(sizeof(cl_int), (void *)&dst.cols)); + args.push_back(std::make_pair(sizeof(cl_int), (void *)&dst.step)); openCLExecuteKernel(clCxt, &filtering_boxFilter, kernelName, globalThreads, localThreads, args, -1, -1, build_options); } @@ -890,7 +889,7 @@ static void GPUFilterBox_32F_C1R(const oclMat &src, oclMat &dst, (src.rows == dst.rows)); Context *clCxt = src.clCxt; - string kernelName = "boxFilter_C1_D5"; + std::string kernelName = "boxFilter_C1_D5"; char btype[30]; @@ -926,18 +925,18 @@ static void GPUFilterBox_32F_C1R(const oclMat &src, oclMat &dst, size_t globalThreads[3] = { globalSizeX, globalSizeY, 1}; size_t localThreads[3] = { blockSizeX, blockSizeY, 1}; - vector > args; - args.push_back(make_pair(sizeof(cl_mem), &src.data)); - args.push_back(make_pair(sizeof(cl_mem), &dst.data)); - args.push_back(make_pair(sizeof(cl_float), (void *)&alpha)); - args.push_back(make_pair(sizeof(cl_int), (void *)&src.offset)); - args.push_back(make_pair(sizeof(cl_int), (void *)&src.wholerows)); - args.push_back(make_pair(sizeof(cl_int), (void *)&src.wholecols)); - args.push_back(make_pair(sizeof(cl_int), (void *)&src.step)); - args.push_back(make_pair(sizeof(cl_int), (void *)&dst.offset)); - args.push_back(make_pair(sizeof(cl_int), (void *)&dst.rows)); - args.push_back(make_pair(sizeof(cl_int), (void *)&dst.cols)); - args.push_back(make_pair(sizeof(cl_int), (void *)&dst.step)); + std::vector > args; + args.push_back(std::make_pair(sizeof(cl_mem), &src.data)); + args.push_back(std::make_pair(sizeof(cl_mem), &dst.data)); + args.push_back(std::make_pair(sizeof(cl_float), (void *)&alpha)); + args.push_back(std::make_pair(sizeof(cl_int), (void *)&src.offset)); + args.push_back(std::make_pair(sizeof(cl_int), (void *)&src.wholerows)); + args.push_back(std::make_pair(sizeof(cl_int), (void *)&src.wholecols)); + args.push_back(std::make_pair(sizeof(cl_int), (void *)&src.step)); + args.push_back(std::make_pair(sizeof(cl_int), (void *)&dst.offset)); + args.push_back(std::make_pair(sizeof(cl_int), (void *)&dst.rows)); + args.push_back(std::make_pair(sizeof(cl_int), (void *)&dst.cols)); + args.push_back(std::make_pair(sizeof(cl_int), (void *)&dst.step)); openCLExecuteKernel(clCxt, &filtering_boxFilter, kernelName, globalThreads, localThreads, args, -1, -1, build_options); } @@ -953,7 +952,7 @@ static void GPUFilterBox_32F_C4R(const oclMat &src, oclMat &dst, (src.rows == dst.rows)); Context *clCxt = src.clCxt; - string kernelName = "boxFilter_C4_D5"; + std::string kernelName = "boxFilter_C4_D5"; char btype[30]; @@ -989,18 +988,18 @@ static void GPUFilterBox_32F_C4R(const oclMat &src, oclMat &dst, size_t globalThreads[3] = { globalSizeX, globalSizeY, 1}; size_t localThreads[3] = { blockSizeX, blockSizeY, 1}; - vector > args; - args.push_back(make_pair(sizeof(cl_mem), &src.data)); - args.push_back(make_pair(sizeof(cl_mem), &dst.data)); - args.push_back(make_pair(sizeof(cl_float), (void *)&alpha)); - args.push_back(make_pair(sizeof(cl_int), (void *)&src.offset)); - args.push_back(make_pair(sizeof(cl_int), (void *)&src.wholerows)); - args.push_back(make_pair(sizeof(cl_int), (void *)&src.wholecols)); - args.push_back(make_pair(sizeof(cl_int), (void *)&src.step)); - args.push_back(make_pair(sizeof(cl_int), (void *)&dst.offset)); - args.push_back(make_pair(sizeof(cl_int), (void *)&dst.rows)); - args.push_back(make_pair(sizeof(cl_int), (void *)&dst.cols)); - args.push_back(make_pair(sizeof(cl_int), (void *)&dst.step)); + std::vector > args; + args.push_back(std::make_pair(sizeof(cl_mem), &src.data)); + args.push_back(std::make_pair(sizeof(cl_mem), &dst.data)); + args.push_back(std::make_pair(sizeof(cl_float), (void *)&alpha)); + args.push_back(std::make_pair(sizeof(cl_int), (void *)&src.offset)); + args.push_back(std::make_pair(sizeof(cl_int), (void *)&src.wholerows)); + args.push_back(std::make_pair(sizeof(cl_int), (void *)&src.wholecols)); + args.push_back(std::make_pair(sizeof(cl_int), (void *)&src.step)); + args.push_back(std::make_pair(sizeof(cl_int), (void *)&dst.offset)); + args.push_back(std::make_pair(sizeof(cl_int), (void *)&dst.rows)); + args.push_back(std::make_pair(sizeof(cl_int), (void *)&dst.cols)); + args.push_back(std::make_pair(sizeof(cl_int), (void *)&dst.step)); openCLExecuteKernel(clCxt, &filtering_boxFilter, kernelName, globalThreads, localThreads, args, -1, -1, build_options); } @@ -1099,7 +1098,7 @@ void linearRowFilter_gpu(const oclMat &src, const oclMat &dst, oclMat mat_kernel int channels = src.oclchannels(); size_t localThreads[3] = {16, 16, 1}; - string kernelName = "row_filter"; + std::string kernelName = "row_filter"; char btype[30]; @@ -1163,19 +1162,19 @@ void linearRowFilter_gpu(const oclMat &src, const oclMat &dst, oclMat mat_kernel dst_pix_per_row = dst.step / dst.elemSize(); //dst_offset_in_pixel = dst.offset / dst.elemSize(); int ridusy = (dst.rows - src.rows) >> 1; - vector > args; - args.push_back(make_pair(sizeof(cl_mem), &src.data)); - args.push_back(make_pair(sizeof(cl_mem), &dst.data)); - args.push_back(make_pair(sizeof(cl_int), (void *)&dst.cols)); - args.push_back(make_pair(sizeof(cl_int), (void *)&dst.rows)); - args.push_back(make_pair(sizeof(cl_int), (void *)&src.wholecols)); - args.push_back(make_pair(sizeof(cl_int), (void *)&src.wholerows)); - args.push_back(make_pair(sizeof(cl_int), (void *)&src_pix_per_row)); - args.push_back(make_pair(sizeof(cl_int), (void *)&src_offset_x)); - args.push_back(make_pair(sizeof(cl_int), (void *)&src_offset_y)); - args.push_back(make_pair(sizeof(cl_int), (void *)&dst_pix_per_row)); - args.push_back(make_pair(sizeof(cl_int), (void *)&ridusy)); - args.push_back(make_pair(sizeof(cl_mem), (void *)&mat_kernel.data)); + std::vector > args; + args.push_back(std::make_pair(sizeof(cl_mem), &src.data)); + args.push_back(std::make_pair(sizeof(cl_mem), &dst.data)); + args.push_back(std::make_pair(sizeof(cl_int), (void *)&dst.cols)); + args.push_back(std::make_pair(sizeof(cl_int), (void *)&dst.rows)); + args.push_back(std::make_pair(sizeof(cl_int), (void *)&src.wholecols)); + args.push_back(std::make_pair(sizeof(cl_int), (void *)&src.wholerows)); + args.push_back(std::make_pair(sizeof(cl_int), (void *)&src_pix_per_row)); + args.push_back(std::make_pair(sizeof(cl_int), (void *)&src_offset_x)); + args.push_back(std::make_pair(sizeof(cl_int), (void *)&src_offset_y)); + args.push_back(std::make_pair(sizeof(cl_int), (void *)&dst_pix_per_row)); + args.push_back(std::make_pair(sizeof(cl_int), (void *)&ridusy)); + args.push_back(std::make_pair(sizeof(cl_mem), (void *)&mat_kernel.data)); openCLExecuteKernel2(clCxt, &filter_sep_row, kernelName, globalThreads, localThreads, args, channels, src.depth(), compile_option, CLFLUSH); } @@ -1231,7 +1230,7 @@ void linearColumnFilter_gpu(const oclMat &src, const oclMat &dst, oclMat mat_ker int channels = src.oclchannels(); size_t localThreads[3] = {16, 16, 1}; - string kernelName = "col_filter"; + std::string kernelName = "col_filter"; char btype[30]; @@ -1324,19 +1323,19 @@ void linearColumnFilter_gpu(const oclMat &src, const oclMat &dst, oclMat mat_ker dst_pix_per_row = dst.step / dst.elemSize(); dst_offset_in_pixel = dst.offset / dst.elemSize(); - vector > args; - args.push_back(make_pair(sizeof(cl_mem), &src.data)); - args.push_back(make_pair(sizeof(cl_mem), &dst.data)); - args.push_back(make_pair(sizeof(cl_int), (void *)&dst.cols)); - args.push_back(make_pair(sizeof(cl_int), (void *)&dst.rows)); - args.push_back(make_pair(sizeof(cl_int), (void *)&src.wholecols)); - args.push_back(make_pair(sizeof(cl_int), (void *)&src.wholerows)); - args.push_back(make_pair(sizeof(cl_int), (void *)&src_pix_per_row)); - //args.push_back(make_pair(sizeof(cl_int),(void*)&src_offset_x)); - //args.push_back(make_pair(sizeof(cl_int),(void*)&src_offset_y)); - args.push_back(make_pair(sizeof(cl_int), (void *)&dst_pix_per_row)); - args.push_back(make_pair(sizeof(cl_int), (void *)&dst_offset_in_pixel)); - args.push_back(make_pair(sizeof(cl_mem), (void *)&mat_kernel.data)); + std::vector > args; + args.push_back(std::make_pair(sizeof(cl_mem), &src.data)); + args.push_back(std::make_pair(sizeof(cl_mem), &dst.data)); + args.push_back(std::make_pair(sizeof(cl_int), (void *)&dst.cols)); + args.push_back(std::make_pair(sizeof(cl_int), (void *)&dst.rows)); + args.push_back(std::make_pair(sizeof(cl_int), (void *)&src.wholecols)); + args.push_back(std::make_pair(sizeof(cl_int), (void *)&src.wholerows)); + args.push_back(std::make_pair(sizeof(cl_int), (void *)&src_pix_per_row)); + //args.push_back(std::make_pair(sizeof(cl_int),(void*)&src_offset_x)); + //args.push_back(std::make_pair(sizeof(cl_int),(void*)&src_offset_y)); + args.push_back(std::make_pair(sizeof(cl_int), (void *)&dst_pix_per_row)); + args.push_back(std::make_pair(sizeof(cl_int), (void *)&dst_offset_in_pixel)); + args.push_back(std::make_pair(sizeof(cl_mem), (void *)&mat_kernel.data)); openCLExecuteKernel(clCxt, &filter_sep_col, kernelName, globalThreads, localThreads, args, -1, -1, compile_option); } diff --git a/modules/ocl/src/haar.cpp b/modules/ocl/src/haar.cpp index 506dc6b0c..31da6ec2d 100644 --- a/modules/ocl/src/haar.cpp +++ b/modules/ocl/src/haar.cpp @@ -53,8 +53,6 @@ using namespace cv; using namespace cv::ocl; -using namespace std; - namespace cv { @@ -930,8 +928,8 @@ CvSeq *cv::ocl::OclCascadeClassifier::oclHaarDetectObjects( oclMat &gimg, CvMemS int indexy = 0; CvSize sz; //t = (double)cvGetTickCount(); - vector sizev; - vector scalev; + std::vector sizev; + std::vector scalev; for(factor = 1.f;; factor *= scaleFactor) { CvSize winSize = { cvRound(winSize0.width * factor), cvRound(winSize0.height * factor) }; @@ -1092,23 +1090,23 @@ CvSeq *cv::ocl::OclCascadeClassifier::oclHaarDetectObjects( oclMat &gimg, CvMemS // openCLVerifyKernel(gsum.clCxt, kernel, &blocksize, globalThreads, localThreads); //openCLSafeCall(clSetKernelArg(kernel,argcount++,sizeof(cl_mem),(void*)&cascadebuffer)); - vector > args; - args.push_back ( make_pair(sizeof(cl_mem) , (void *)&stagebuffer )); - args.push_back ( make_pair(sizeof(cl_mem) , (void *)&scaleinfobuffer )); - args.push_back ( make_pair(sizeof(cl_mem) , (void *)&nodebuffer )); - args.push_back ( make_pair(sizeof(cl_mem) , (void *)&gsum.data )); - args.push_back ( make_pair(sizeof(cl_mem) , (void *)&gsqsum.data )); - args.push_back ( make_pair(sizeof(cl_mem) , (void *)&candidatebuffer )); - args.push_back ( make_pair(sizeof(cl_int) , (void *)&pixelstep )); - args.push_back ( make_pair(sizeof(cl_int) , (void *)&loopcount )); - args.push_back ( make_pair(sizeof(cl_int) , (void *)&startstage )); - args.push_back ( make_pair(sizeof(cl_int) , (void *)&splitstage )); - args.push_back ( make_pair(sizeof(cl_int) , (void *)&endstage )); - args.push_back ( make_pair(sizeof(cl_int) , (void *)&startnode )); - args.push_back ( make_pair(sizeof(cl_int) , (void *)&splitnode )); - args.push_back ( make_pair(sizeof(cl_int4) , (void *)&p )); - args.push_back ( make_pair(sizeof(cl_int4) , (void *)&pq )); - args.push_back ( make_pair(sizeof(cl_float) , (void *)&correction )); + std::vector > args; + args.push_back ( std::make_pair(sizeof(cl_mem) , (void *)&stagebuffer )); + args.push_back ( std::make_pair(sizeof(cl_mem) , (void *)&scaleinfobuffer )); + args.push_back ( std::make_pair(sizeof(cl_mem) , (void *)&nodebuffer )); + args.push_back ( std::make_pair(sizeof(cl_mem) , (void *)&gsum.data )); + args.push_back ( std::make_pair(sizeof(cl_mem) , (void *)&gsqsum.data )); + args.push_back ( std::make_pair(sizeof(cl_mem) , (void *)&candidatebuffer )); + args.push_back ( std::make_pair(sizeof(cl_int) , (void *)&pixelstep )); + args.push_back ( std::make_pair(sizeof(cl_int) , (void *)&loopcount )); + args.push_back ( std::make_pair(sizeof(cl_int) , (void *)&startstage )); + args.push_back ( std::make_pair(sizeof(cl_int) , (void *)&splitstage )); + args.push_back ( std::make_pair(sizeof(cl_int) , (void *)&endstage )); + args.push_back ( std::make_pair(sizeof(cl_int) , (void *)&startnode )); + args.push_back ( std::make_pair(sizeof(cl_int) , (void *)&splitnode )); + args.push_back ( std::make_pair(sizeof(cl_int4) , (void *)&p )); + args.push_back ( std::make_pair(sizeof(cl_int4) , (void *)&pq )); + args.push_back ( std::make_pair(sizeof(cl_float) , (void *)&correction )); openCLExecuteKernel(gsum.clCxt, &haarobjectdetect, "gpuRunHaarClassifierCascade", globalThreads, localThreads, args, -1, -1); //t = (double)cvGetTickCount() - t; @@ -1142,8 +1140,8 @@ CvSeq *cv::ocl::OclCascadeClassifier::oclHaarDetectObjects( oclMat &gimg, CvMemS oclMat gsqsum; cv::ocl::integral(gimg, gsum, gsqsum); CvSize sz; - vector sizev; - vector scalev; + std::vector sizev; + std::vector scalev; gpuSetHaarClassifierCascade(cascade); gcascade = (GpuHidHaarClassifierCascade *)cascade->hid_cascade; stage = (GpuHidHaarStageClassifier *)(gcascade + 1); @@ -1177,7 +1175,7 @@ CvSeq *cv::ocl::OclCascadeClassifier::oclHaarDetectObjects( oclMat &gimg, CvMemS loopcount = 1; n_factors = 1; sizev.push_back(minSize); - scalev.push_back( min(cvRound(minSize.width / winsize0.width), cvRound(minSize.height / winsize0.height)) ); + scalev.push_back( std::min(cvRound(minSize.width / winsize0.width), cvRound(minSize.height / winsize0.height)) ); } detect_piramid_info *scaleinfo = (detect_piramid_info *)malloc(sizeof(detect_piramid_info) * loopcount); @@ -1231,12 +1229,12 @@ CvSeq *cv::ocl::OclCascadeClassifier::oclHaarDetectObjects( oclMat &gimg, CvMemS int startnodenum = nodenum * i; float factor2 = (float)factor; - vector > args1; - args1.push_back ( make_pair(sizeof(cl_mem) , (void *)&nodebuffer )); - args1.push_back ( make_pair(sizeof(cl_mem) , (void *)&newnodebuffer )); - args1.push_back ( make_pair(sizeof(cl_float) , (void *)&factor2 )); - args1.push_back ( make_pair(sizeof(cl_float) , (void *)&correction[i] )); - args1.push_back ( make_pair(sizeof(cl_int) , (void *)&startnodenum )); + std::vector > args1; + args1.push_back ( std::make_pair(sizeof(cl_mem) , (void *)&nodebuffer )); + args1.push_back ( std::make_pair(sizeof(cl_mem) , (void *)&newnodebuffer )); + args1.push_back ( std::make_pair(sizeof(cl_float) , (void *)&factor2 )); + args1.push_back ( std::make_pair(sizeof(cl_float) , (void *)&correction[i] )); + args1.push_back ( std::make_pair(sizeof(cl_int) , (void *)&startnodenum )); size_t globalThreads2[3] = {nodenum, 1, 1}; @@ -1264,23 +1262,23 @@ CvSeq *cv::ocl::OclCascadeClassifier::oclHaarDetectObjects( oclMat &gimg, CvMemS openCLSafeCall(clEnqueueWriteBuffer(gsum.clCxt->impl->clCmdQueue, correctionbuffer, 1, 0, sizeof(cl_float)*loopcount, correction, 0, NULL, NULL)); //int argcount = 0; - vector > args; - args.push_back ( make_pair(sizeof(cl_mem) , (void *)&stagebuffer )); - args.push_back ( make_pair(sizeof(cl_mem) , (void *)&scaleinfobuffer )); - args.push_back ( make_pair(sizeof(cl_mem) , (void *)&newnodebuffer )); - args.push_back ( make_pair(sizeof(cl_mem) , (void *)&gsum.data )); - args.push_back ( make_pair(sizeof(cl_mem) , (void *)&gsqsum.data )); - args.push_back ( make_pair(sizeof(cl_mem) , (void *)&candidatebuffer )); - args.push_back ( make_pair(sizeof(cl_int) , (void *)&step )); - args.push_back ( make_pair(sizeof(cl_int) , (void *)&loopcount )); - args.push_back ( make_pair(sizeof(cl_int) , (void *)&startstage )); - args.push_back ( make_pair(sizeof(cl_int) , (void *)&splitstage )); - args.push_back ( make_pair(sizeof(cl_int) , (void *)&endstage )); - args.push_back ( make_pair(sizeof(cl_int) , (void *)&startnode )); - args.push_back ( make_pair(sizeof(cl_int) , (void *)&splitnode )); - args.push_back ( make_pair(sizeof(cl_mem) , (void *)&pbuffer )); - args.push_back ( make_pair(sizeof(cl_mem) , (void *)&correctionbuffer )); - args.push_back ( make_pair(sizeof(cl_int) , (void *)&nodenum )); + std::vector > args; + args.push_back ( std::make_pair(sizeof(cl_mem) , (void *)&stagebuffer )); + args.push_back ( std::make_pair(sizeof(cl_mem) , (void *)&scaleinfobuffer )); + args.push_back ( std::make_pair(sizeof(cl_mem) , (void *)&newnodebuffer )); + args.push_back ( std::make_pair(sizeof(cl_mem) , (void *)&gsum.data )); + args.push_back ( std::make_pair(sizeof(cl_mem) , (void *)&gsqsum.data )); + args.push_back ( std::make_pair(sizeof(cl_mem) , (void *)&candidatebuffer )); + args.push_back ( std::make_pair(sizeof(cl_int) , (void *)&step )); + args.push_back ( std::make_pair(sizeof(cl_int) , (void *)&loopcount )); + args.push_back ( std::make_pair(sizeof(cl_int) , (void *)&startstage )); + args.push_back ( std::make_pair(sizeof(cl_int) , (void *)&splitstage )); + args.push_back ( std::make_pair(sizeof(cl_int) , (void *)&endstage )); + args.push_back ( std::make_pair(sizeof(cl_int) , (void *)&startnode )); + args.push_back ( std::make_pair(sizeof(cl_int) , (void *)&splitnode )); + args.push_back ( std::make_pair(sizeof(cl_mem) , (void *)&pbuffer )); + args.push_back ( std::make_pair(sizeof(cl_mem) , (void *)&correctionbuffer )); + args.push_back ( std::make_pair(sizeof(cl_int) , (void *)&nodenum )); openCLExecuteKernel(gsum.clCxt, &haarobjectdetect_scaled2, "gpuRunHaarClassifierCascade_scaled2", globalThreads, localThreads, args, -1, -1); @@ -1412,7 +1410,7 @@ struct gpuHaarDetectObjects_ScaleImage_Invoker { Size winSize0 = cascade->orig_window_size; Size winSize(cvRound(winSize0.width * factor), cvRound(winSize0.height * factor)); - int y1 = range.begin() * stripSize, y2 = min(range.end() * stripSize, sum1.rows - 1 - winSize0.height); + int y1 = range.begin() * stripSize, y2 = std::min(range.end() * stripSize, sum1.rows - 1 - winSize0.height); Size ssz(sum1.cols - 1 - winSize0.width, y2 - y1); int x, y, ystep = factor > 2 ? 1 : 2; diff --git a/modules/ocl/src/hog.cpp b/modules/ocl/src/hog.cpp index 59062ae49..db9220583 100644 --- a/modules/ocl/src/hog.cpp +++ b/modules/ocl/src/hog.cpp @@ -47,7 +47,6 @@ #include "mcwutil.hpp" using namespace cv; using namespace cv::ocl; -using namespace std; #define CELL_WIDTH 8 @@ -171,7 +170,7 @@ bool cv::ocl::HOGDescriptor::checkDetectorSize() const return detector_size == 0 || detector_size == descriptor_size || detector_size == descriptor_size + 1; } -void cv::ocl::HOGDescriptor::setSVMDetector(const vector &_detector) +void cv::ocl::HOGDescriptor::setSVMDetector(const std::vector &_detector) { std::vector detector_reordered(_detector.size()); @@ -273,7 +272,7 @@ void cv::ocl::HOGDescriptor::getDescriptors(const oclMat &img, Size win_stride, } -void cv::ocl::HOGDescriptor::detect(const oclMat &img, vector &hits, double hit_threshold, Size win_stride, Size padding) +void cv::ocl::HOGDescriptor::detect(const oclMat &img, std::vector &hits, double hit_threshold, Size win_stride, Size padding) { CV_Assert(img.type() == CV_8UC1 || img.type() == CV_8UC4); CV_Assert(padding == Size(0, 0)); @@ -308,13 +307,13 @@ void cv::ocl::HOGDescriptor::detect(const oclMat &img, vector &hits, doub -void cv::ocl::HOGDescriptor::detectMultiScale(const oclMat &img, vector &found_locations, double hit_threshold, +void cv::ocl::HOGDescriptor::detectMultiScale(const oclMat &img, std::vector &found_locations, double hit_threshold, Size win_stride, Size padding, double scale0, int group_threshold) { CV_Assert(img.type() == CV_8UC1 || img.type() == CV_8UC4); CV_Assert(scale0 > 1); - vector level_scale; + std::vector level_scale; double scale = 1.; int levels = 0; @@ -330,7 +329,7 @@ void cv::ocl::HOGDescriptor::detectMultiScale(const oclMat &img, vector &f level_scale.resize(levels); std::vector all_candidates; - vector locations; + std::vector locations; if (win_stride == Size()) win_stride = block_stride; @@ -712,7 +711,7 @@ std::vector cv::ocl::HOGDescriptor::getPeopleDetector48x96() -0.035372f, -0.233209f, -0.049869f, -0.039151f, -0.022279f, -0.065380f, -9.063785f }; - return vector(detector, detector + sizeof(detector) / sizeof(detector[0])); + return std::vector(detector, detector + sizeof(detector) / sizeof(detector[0])); } @@ -1528,7 +1527,7 @@ std::vector cv::ocl::HOGDescriptor::getPeopleDetector64x128() -0.03250246f, 3.38630192e-003f, 2.64779478e-003f, 0.03359732f, -0.02411991f, -0.04229729f, 0.10666174f, -6.66579151f }; - return vector(detector, detector + sizeof(detector) / sizeof(detector[0])); + return std::vector(detector, detector + sizeof(detector) / sizeof(detector[0])); } /* Returns the nearest upper power of two, works only for @@ -1576,8 +1575,8 @@ void cv::ocl::device::hog::compute_hists(int nbins, int block_stride_x, int bloc const cv::ocl::oclMat &qangle, float sigma, cv::ocl::oclMat &block_hists) { Context *clCxt = Context::getContext(); - string kernelName = "compute_hists_kernel"; - vector< pair > args; + std::string kernelName = "compute_hists_kernel"; + std::vector< std::pair > args; int img_block_width = (width - CELLS_PER_BLOCK_X * CELL_WIDTH + block_stride_x) / block_stride_x; int img_block_height = (height - CELLS_PER_BLOCK_Y * CELL_HEIGHT + block_stride_y) / block_stride_y; @@ -1595,19 +1594,19 @@ void cv::ocl::device::hog::compute_hists(int nbins, int block_stride_x, int bloc int final_hists_size = (nbins * CELLS_PER_BLOCK_X * CELLS_PER_BLOCK_Y) * sizeof(float); int smem = hists_size + final_hists_size; - args.push_back( make_pair( sizeof(cl_int), (void *)&width)); - args.push_back( make_pair( sizeof(cl_int), (void *)&cblock_stride_x)); - args.push_back( make_pair( sizeof(cl_int), (void *)&cblock_stride_y)); - args.push_back( make_pair( sizeof(cl_int), (void *)&cnbins)); - args.push_back( make_pair( sizeof(cl_int), (void *)&cblock_hist_size)); - args.push_back( make_pair( sizeof(cl_int), (void *)&img_block_width)); - args.push_back( make_pair( sizeof(cl_int), (void *)&grad_quadstep)); - args.push_back( make_pair( sizeof(cl_int), (void *)&qangle_step)); - args.push_back( make_pair( sizeof(cl_mem), (void *)&grad.data)); - args.push_back( make_pair( sizeof(cl_mem), (void *)&qangle.data)); - args.push_back( make_pair( sizeof(cl_float), (void *)&scale)); - args.push_back( make_pair( sizeof(cl_mem), (void *)&block_hists.data)); - args.push_back( make_pair( smem, (void *)NULL)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&width)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&cblock_stride_x)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&cblock_stride_y)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&cnbins)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&cblock_hist_size)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&img_block_width)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&grad_quadstep)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&qangle_step)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&grad.data)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&qangle.data)); + args.push_back( std::make_pair( sizeof(cl_float), (void *)&scale)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&block_hists.data)); + args.push_back( std::make_pair( smem, (void *)NULL)); openCLExecuteKernel2(clCxt, &objdetect_hog, kernelName, globalThreads, localThreads, args, -1, -1); } @@ -1616,8 +1615,8 @@ void cv::ocl::device::hog::normalize_hists(int nbins, int block_stride_x, int bl int height, int width, cv::ocl::oclMat &block_hists, float threshold) { Context *clCxt = Context::getContext(); - string kernelName = "normalize_hists_kernel"; - vector< pair > args; + std::string kernelName = "normalize_hists_kernel"; + std::vector< std::pair > args; int block_hist_size = nbins * CELLS_PER_BLOCK_X * CELLS_PER_BLOCK_Y; int nthreads = power_2up(block_hist_size); @@ -1630,12 +1629,12 @@ void cv::ocl::device::hog::normalize_hists(int nbins, int block_stride_x, int bl if ((nthreads < 32) || (nthreads > 512) ) cv::ocl::error("normalize_hists: histogram's size is too small or too big", __FILE__, __LINE__, "normalize_hists"); - args.push_back( make_pair( sizeof(cl_int), (void *)&nthreads)); - args.push_back( make_pair( sizeof(cl_int), (void *)&block_hist_size)); - args.push_back( make_pair( sizeof(cl_int), (void *)&img_block_width)); - args.push_back( make_pair( sizeof(cl_mem), (void *)&block_hists.data)); - args.push_back( make_pair( sizeof(cl_float), (void *)&threshold)); - args.push_back( make_pair( nthreads * sizeof(float), (void *)NULL)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&nthreads)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&block_hist_size)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&img_block_width)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&block_hists.data)); + args.push_back( std::make_pair( sizeof(cl_float), (void *)&threshold)); + args.push_back( std::make_pair( nthreads * sizeof(float), (void *)NULL)); openCLExecuteKernel2(clCxt, &objdetect_hog, kernelName, globalThreads, localThreads, args, -1, -1); } @@ -1646,8 +1645,8 @@ void cv::ocl::device::hog::classify_hists(int win_height, int win_width, int blo float threshold, cv::ocl::oclMat &labels) { Context *clCxt = Context::getContext(); - string kernelName = "classify_hists_kernel"; - vector< pair > args; + std::string kernelName = "classify_hists_kernel"; + std::vector< std::pair > args; int win_block_stride_x = win_stride_x / block_stride_x; int win_block_stride_y = win_stride_y / block_stride_y; @@ -1658,18 +1657,18 @@ void cv::ocl::device::hog::classify_hists(int win_height, int win_width, int blo size_t globalThreads[3] = { img_win_width * NTHREADS, img_win_height, 1 }; size_t localThreads[3] = { NTHREADS, 1, 1 }; - args.push_back( make_pair( sizeof(cl_int), (void *)&cblock_hist_size)); - args.push_back( make_pair( sizeof(cl_int), (void *)&cdescr_size)); - args.push_back( make_pair( sizeof(cl_int), (void *)&cdescr_width)); - args.push_back( make_pair( sizeof(cl_int), (void *)&img_win_width)); - args.push_back( make_pair( sizeof(cl_int), (void *)&img_block_width)); - args.push_back( make_pair( sizeof(cl_int), (void *)&win_block_stride_x)); - args.push_back( make_pair( sizeof(cl_int), (void *)&win_block_stride_y)); - args.push_back( make_pair( sizeof(cl_mem), (void *)&block_hists.data)); - args.push_back( make_pair( sizeof(cl_mem), (void *)&coefs.data)); - args.push_back( make_pair( sizeof(cl_float), (void *)&free_coef)); - args.push_back( make_pair( sizeof(cl_float), (void *)&threshold)); - args.push_back( make_pair( sizeof(cl_mem), (void *)&labels.data)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&cblock_hist_size)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&cdescr_size)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&cdescr_width)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&img_win_width)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&img_block_width)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&win_block_stride_x)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&win_block_stride_y)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&block_hists.data)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&coefs.data)); + args.push_back( std::make_pair( sizeof(cl_float), (void *)&free_coef)); + args.push_back( std::make_pair( sizeof(cl_float), (void *)&threshold)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&labels.data)); openCLExecuteKernel2(clCxt, &objdetect_hog, kernelName, globalThreads, localThreads, args, -1, -1); } @@ -1679,8 +1678,8 @@ void cv::ocl::device::hog::extract_descrs_by_rows(int win_height, int win_width, const cv::ocl::oclMat &block_hists, cv::ocl::oclMat &descriptors) { Context *clCxt = Context::getContext(); - string kernelName = "extract_descrs_by_rows_kernel"; - vector< pair > args; + std::string kernelName = "extract_descrs_by_rows_kernel"; + std::vector< std::pair > args; int win_block_stride_x = win_stride_x / block_stride_x; int win_block_stride_y = win_stride_y / block_stride_y; @@ -1692,15 +1691,15 @@ void cv::ocl::device::hog::extract_descrs_by_rows(int win_height, int win_width, size_t globalThreads[3] = { img_win_width * NTHREADS, img_win_height, 1 }; size_t localThreads[3] = { NTHREADS, 1, 1 }; - args.push_back( make_pair( sizeof(cl_int), (void *)&cblock_hist_size)); - args.push_back( make_pair( sizeof(cl_int), (void *)&descriptors_quadstep)); - args.push_back( make_pair( sizeof(cl_int), (void *)&cdescr_size)); - args.push_back( make_pair( sizeof(cl_int), (void *)&cdescr_width)); - args.push_back( make_pair( sizeof(cl_int), (void *)&img_block_width)); - args.push_back( make_pair( sizeof(cl_int), (void *)&win_block_stride_x)); - args.push_back( make_pair( sizeof(cl_int), (void *)&win_block_stride_y)); - args.push_back( make_pair( sizeof(cl_mem), (void *)&block_hists.data)); - args.push_back( make_pair( sizeof(cl_mem), (void *)&descriptors.data)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&cblock_hist_size)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&descriptors_quadstep)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&cdescr_size)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&cdescr_width)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&img_block_width)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&win_block_stride_x)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&win_block_stride_y)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&block_hists.data)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&descriptors.data)); openCLExecuteKernel2(clCxt, &objdetect_hog, kernelName, globalThreads, localThreads, args, -1, -1); } @@ -1710,8 +1709,8 @@ void cv::ocl::device::hog::extract_descrs_by_cols(int win_height, int win_width, const cv::ocl::oclMat &block_hists, cv::ocl::oclMat &descriptors) { Context *clCxt = Context::getContext(); - string kernelName = "extract_descrs_by_cols_kernel"; - vector< pair > args; + std::string kernelName = "extract_descrs_by_cols_kernel"; + std::vector< std::pair > args; int win_block_stride_x = win_stride_x / block_stride_x; int win_block_stride_y = win_stride_y / block_stride_y; @@ -1723,16 +1722,16 @@ void cv::ocl::device::hog::extract_descrs_by_cols(int win_height, int win_width, size_t globalThreads[3] = { img_win_width * NTHREADS, img_win_height, 1 }; size_t localThreads[3] = { NTHREADS, 1, 1 }; - args.push_back( make_pair( sizeof(cl_int), (void *)&cblock_hist_size)); - args.push_back( make_pair( sizeof(cl_int), (void *)&descriptors_quadstep)); - args.push_back( make_pair( sizeof(cl_int), (void *)&cdescr_size)); - args.push_back( make_pair( sizeof(cl_int), (void *)&cnblocks_win_x)); - args.push_back( make_pair( sizeof(cl_int), (void *)&cnblocks_win_y)); - args.push_back( make_pair( sizeof(cl_int), (void *)&img_block_width)); - args.push_back( make_pair( sizeof(cl_int), (void *)&win_block_stride_x)); - args.push_back( make_pair( sizeof(cl_int), (void *)&win_block_stride_y)); - args.push_back( make_pair( sizeof(cl_mem), (void *)&block_hists.data)); - args.push_back( make_pair( sizeof(cl_mem), (void *)&descriptors.data)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&cblock_hist_size)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&descriptors_quadstep)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&cdescr_size)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&cnblocks_win_x)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&cnblocks_win_y)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&img_block_width)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&win_block_stride_x)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&win_block_stride_y)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&block_hists.data)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&descriptors.data)); openCLExecuteKernel2(clCxt, &objdetect_hog, kernelName, globalThreads, localThreads, args, -1, -1); } @@ -1746,8 +1745,8 @@ void cv::ocl::device::hog::compute_gradients_8UC1(int height, int width, const c float angle_scale, cv::ocl::oclMat &grad, cv::ocl::oclMat &qangle, bool correct_gamma) { Context *clCxt = Context::getContext(); - string kernelName = "compute_gradients_8UC1_kernel"; - vector< pair > args; + std::string kernelName = "compute_gradients_8UC1_kernel"; + std::vector< std::pair > args; size_t localThreads[3] = { NTHREADS, 1, 1 }; size_t globalThreads[3] = { width, height, 1 }; @@ -1756,17 +1755,17 @@ void cv::ocl::device::hog::compute_gradients_8UC1(int height, int width, const c int grad_quadstep = grad.step >> 3; int qangle_step = qangle.step >> 1; - args.push_back( make_pair( sizeof(cl_int), (void *)&height)); - args.push_back( make_pair( sizeof(cl_int), (void *)&width)); - args.push_back( make_pair( sizeof(cl_int), (void *)&img_step)); - args.push_back( make_pair( sizeof(cl_int), (void *)&grad_quadstep)); - args.push_back( make_pair( sizeof(cl_int), (void *)&qangle_step)); - args.push_back( make_pair( sizeof(cl_mem), (void *)&img.data)); - args.push_back( make_pair( sizeof(cl_mem), (void *)&grad.data)); - args.push_back( make_pair( sizeof(cl_mem), (void *)&qangle.data)); - args.push_back( make_pair( sizeof(cl_float), (void *)&angle_scale)); - args.push_back( make_pair( sizeof(cl_char), (void *)&correctGamma)); - args.push_back( make_pair( sizeof(cl_int), (void *)&cnbins)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&height)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&width)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&img_step)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&grad_quadstep)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&qangle_step)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&img.data)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&grad.data)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&qangle.data)); + args.push_back( std::make_pair( sizeof(cl_float), (void *)&angle_scale)); + args.push_back( std::make_pair( sizeof(cl_char), (void *)&correctGamma)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&cnbins)); openCLExecuteKernel2(clCxt, &objdetect_hog, kernelName, globalThreads, localThreads, args, -1, -1); } @@ -1775,8 +1774,8 @@ void cv::ocl::device::hog::compute_gradients_8UC4(int height, int width, const c float angle_scale, cv::ocl::oclMat &grad, cv::ocl::oclMat &qangle, bool correct_gamma) { Context *clCxt = Context::getContext(); - string kernelName = "compute_gradients_8UC4_kernel"; - vector< pair > args; + std::string kernelName = "compute_gradients_8UC4_kernel"; + std::vector< std::pair > args; size_t localThreads[3] = { NTHREADS, 1, 1 }; size_t globalThreads[3] = { width, height, 1 }; @@ -1786,17 +1785,17 @@ void cv::ocl::device::hog::compute_gradients_8UC4(int height, int width, const c int grad_quadstep = grad.step >> 3; int qangle_step = qangle.step >> 1; - args.push_back( make_pair( sizeof(cl_int), (void *)&height)); - args.push_back( make_pair( sizeof(cl_int), (void *)&width)); - args.push_back( make_pair( sizeof(cl_int), (void *)&img_step)); - args.push_back( make_pair( sizeof(cl_int), (void *)&grad_quadstep)); - args.push_back( make_pair( sizeof(cl_int), (void *)&qangle_step)); - args.push_back( make_pair( sizeof(cl_mem), (void *)&img.data)); - args.push_back( make_pair( sizeof(cl_mem), (void *)&grad.data)); - args.push_back( make_pair( sizeof(cl_mem), (void *)&qangle.data)); - args.push_back( make_pair( sizeof(cl_float), (void *)&angle_scale)); - args.push_back( make_pair( sizeof(cl_char), (void *)&correctGamma)); - args.push_back( make_pair( sizeof(cl_int), (void *)&cnbins)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&height)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&width)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&img_step)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&grad_quadstep)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&qangle_step)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&img.data)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&grad.data)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&qangle.data)); + args.push_back( std::make_pair( sizeof(cl_float), (void *)&angle_scale)); + args.push_back( std::make_pair( sizeof(cl_char), (void *)&correctGamma)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&cnbins)); openCLExecuteKernel2(clCxt, &objdetect_hog, kernelName, globalThreads, localThreads, args, -1, -1); } @@ -1806,7 +1805,7 @@ void cv::ocl::device::hog::resize( const oclMat &src, oclMat &dst, const Size sz CV_Assert( (src.channels() == dst.channels()) ); Context *clCxt = Context::getContext(); - string kernelName = (src.type() == CV_8UC1) ? "resize_8UC1_kernel" : "resize_8UC4_kernel"; + std::string kernelName = (src.type() == CV_8UC1) ? "resize_8UC1_kernel" : "resize_8UC4_kernel"; size_t blkSizeX = 16, blkSizeY = 16; size_t glbSizeX = sz.width % blkSizeX == 0 ? sz.width : (sz.width / blkSizeX + 1) * blkSizeX; size_t glbSizeY = sz.height % blkSizeY == 0 ? sz.height : (sz.height / blkSizeY + 1) * blkSizeY; @@ -1816,19 +1815,19 @@ void cv::ocl::device::hog::resize( const oclMat &src, oclMat &dst, const Size sz float ifx = (float)src.cols / sz.width; float ify = (float)src.rows / sz.height; - vector< pair > args; - args.push_back( make_pair(sizeof(cl_mem), (void *)&dst.data)); - args.push_back( make_pair(sizeof(cl_mem), (void *)&src.data)); - args.push_back( make_pair(sizeof(cl_int), (void *)&dst.offset)); - args.push_back( make_pair(sizeof(cl_int), (void *)&src.offset)); - args.push_back( make_pair(sizeof(cl_int), (void *)&dst.step)); - args.push_back( make_pair(sizeof(cl_int), (void *)&src.step)); - args.push_back( make_pair(sizeof(cl_int), (void *)&src.cols)); - args.push_back( make_pair(sizeof(cl_int), (void *)&src.rows)); - args.push_back( make_pair(sizeof(cl_int), (void *)&sz.width)); - args.push_back( make_pair(sizeof(cl_int), (void *)&sz.height)); - args.push_back( make_pair(sizeof(cl_float), (void *)&ifx)); - args.push_back( make_pair(sizeof(cl_float), (void *)&ify)); + std::vector< std::pair > args; + args.push_back( std::make_pair(sizeof(cl_mem), (void *)&dst.data)); + args.push_back( std::make_pair(sizeof(cl_mem), (void *)&src.data)); + args.push_back( std::make_pair(sizeof(cl_int), (void *)&dst.offset)); + args.push_back( std::make_pair(sizeof(cl_int), (void *)&src.offset)); + args.push_back( std::make_pair(sizeof(cl_int), (void *)&dst.step)); + args.push_back( std::make_pair(sizeof(cl_int), (void *)&src.step)); + args.push_back( std::make_pair(sizeof(cl_int), (void *)&src.cols)); + args.push_back( std::make_pair(sizeof(cl_int), (void *)&src.rows)); + args.push_back( std::make_pair(sizeof(cl_int), (void *)&sz.width)); + args.push_back( std::make_pair(sizeof(cl_int), (void *)&sz.height)); + args.push_back( std::make_pair(sizeof(cl_float), (void *)&ifx)); + args.push_back( std::make_pair(sizeof(cl_float), (void *)&ify)); openCLExecuteKernel2(clCxt, &objdetect_hog, kernelName, globalThreads, localThreads, args, -1, -1); } diff --git a/modules/ocl/src/hough.cpp b/modules/ocl/src/hough.cpp index a263e22ae..f5d770c95 100644 --- a/modules/ocl/src/hough.cpp +++ b/modules/ocl/src/hough.cpp @@ -42,7 +42,6 @@ #include "precomp.hpp" -using namespace std; using namespace cv; using namespace cv::ocl; @@ -90,13 +89,13 @@ namespace const size_t glbSizeY = src.rows % blkSizeY == 0 ? src.rows : MUL_UP(src.rows, blkSizeY); size_t globalThreads[3] = { glbSizeX, glbSizeY, 1 }; - vector > args; - args.push_back( make_pair( sizeof(cl_mem) , (void *)&src.data )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&src.cols )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&src.rows )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&src.step )); - args.push_back( make_pair( sizeof(cl_mem) , (void *)&list.data )); - args.push_back( make_pair( sizeof(cl_mem) , (void *)&counter )); + std::vector > args; + args.push_back( std::make_pair( sizeof(cl_mem) , (void *)&src.data )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&src.cols )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&src.rows )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&src.step )); + args.push_back( std::make_pair( sizeof(cl_mem) , (void *)&list.data )); + args.push_back( std::make_pair( sizeof(cl_mem) , (void *)&counter )); openCLExecuteKernel(src.clCxt, &imgproc_hough, "buildPointList", globalThreads, localThreads, args, -1, -1); openCLSafeCall(clEnqueueReadBuffer(src.clCxt->impl->clCmdQueue, counter, CL_TRUE, 0, sizeof(int), &totalCount, 0, NULL, NULL)); @@ -122,20 +121,20 @@ namespace const int width = accum.cols - 2; const int height = accum.rows - 2; - vector > args; - args.push_back( make_pair( sizeof(cl_mem) , (void *)&list.data )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&count )); - args.push_back( make_pair( sizeof(cl_mem) , (void *)&dx.data )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&dx.step )); - args.push_back( make_pair( sizeof(cl_mem) , (void *)&dy.data )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&dy.step )); - args.push_back( make_pair( sizeof(cl_mem) , (void *)&accum.data )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&accum.step )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&width )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&height )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&minRadius)); - args.push_back( make_pair( sizeof(cl_int) , (void *)&maxRadius)); - args.push_back( make_pair( sizeof(cl_float), (void *)&idp)); + std::vector > args; + args.push_back( std::make_pair( sizeof(cl_mem) , (void *)&list.data )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&count )); + args.push_back( std::make_pair( sizeof(cl_mem) , (void *)&dx.data )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&dx.step )); + args.push_back( std::make_pair( sizeof(cl_mem) , (void *)&dy.data )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&dy.step )); + args.push_back( std::make_pair( sizeof(cl_mem) , (void *)&accum.data )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&accum.step )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&width )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&height )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&minRadius)); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&maxRadius)); + args.push_back( std::make_pair( sizeof(cl_float), (void *)&idp)); openCLExecuteKernel(accum.clCxt, &imgproc_hough, "circlesAccumCenters", globalThreads, localThreads, args, -1, -1); } @@ -159,14 +158,14 @@ namespace const size_t glbSizeY = (accum.rows - 2) % blkSizeY == 0 ? accum.rows - 2 : MUL_UP(accum.rows - 2, blkSizeY); size_t globalThreads[3] = { glbSizeX, glbSizeY, 1 }; - vector > args; - args.push_back( make_pair( sizeof(cl_mem) , (void *)&accum.data )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&accum.cols )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&accum.rows )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&accum.step )); - args.push_back( make_pair( sizeof(cl_mem) , (void *)¢ers.data )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&threshold )); - args.push_back( make_pair( sizeof(cl_mem) , (void *)&counter )); + std::vector > args; + args.push_back( std::make_pair( sizeof(cl_mem) , (void *)&accum.data )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&accum.cols )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&accum.rows )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&accum.step )); + args.push_back( std::make_pair( sizeof(cl_mem) , (void *)¢ers.data )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&threshold )); + args.push_back( std::make_pair( sizeof(cl_mem) , (void *)&counter )); openCLExecuteKernel(accum.clCxt, &imgproc_hough, "buildCentersList", globalThreads, localThreads, args, -1, -1); @@ -199,19 +198,19 @@ namespace const int histSize = maxRadius - minRadius + 1; size_t smemSize = (histSize + 2) * sizeof(int); - vector > args; - args.push_back( make_pair( sizeof(cl_mem) , (void *)¢ers.data )); - args.push_back( make_pair( sizeof(cl_mem) , (void *)&list.data )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&count )); - args.push_back( make_pair( sizeof(cl_mem) , (void *)&circles.data )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&maxCircles )); - args.push_back( make_pair( sizeof(cl_float), (void *)&dp )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&minRadius )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&maxRadius )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&histSize )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&threshold )); - args.push_back( make_pair( smemSize , (void *)NULL )); - args.push_back( make_pair( sizeof(cl_mem) , (void *)&counter )); + std::vector > args; + args.push_back( std::make_pair( sizeof(cl_mem) , (void *)¢ers.data )); + args.push_back( std::make_pair( sizeof(cl_mem) , (void *)&list.data )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&count )); + args.push_back( std::make_pair( sizeof(cl_mem) , (void *)&circles.data )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&maxCircles )); + args.push_back( std::make_pair( sizeof(cl_float), (void *)&dp )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&minRadius )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&maxRadius )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&histSize )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&threshold )); + args.push_back( std::make_pair( smemSize , (void *)NULL )); + args.push_back( std::make_pair( sizeof(cl_mem) , (void *)&counter )); CV_Assert(circles.offset == 0); @@ -221,7 +220,7 @@ namespace openCLSafeCall(clReleaseMemObject(counter)); - totalCount = ::min(totalCount, maxCircles); + totalCount = std::min(totalCount, maxCircles); return totalCount; } @@ -329,7 +328,7 @@ void cv::ocl::HoughCircles(const oclMat& src, oclMat& circles, HoughCirclesBuf& { for (int xx = x1; xx <= x2; ++xx) { - vector& m = grid[yy * gridWidth + xx]; + std::vector& m = grid[yy * gridWidth + xx]; for(size_t j = 0; j < m.size(); ++j) { diff --git a/modules/ocl/src/imgproc.cpp b/modules/ocl/src/imgproc.cpp index 8fbada1d3..003830ccc 100644 --- a/modules/ocl/src/imgproc.cpp +++ b/modules/ocl/src/imgproc.cpp @@ -57,7 +57,6 @@ using namespace cv; using namespace cv::ocl; -using namespace std; namespace cv { @@ -124,7 +123,7 @@ namespace cv uchar thresh_uchar = cvFloor(thresh); uchar max_val = cvRound(maxVal); - string kernelName = "threshold"; + std::string kernelName = "threshold"; size_t cols = (dst.cols + (dst.offset % 16) + 15) / 16; size_t bSizeX = 16, bSizeY = 16; @@ -133,18 +132,18 @@ namespace cv size_t globalThreads[3] = {gSizeX, gSizeY, 1}; size_t localThreads[3] = {bSizeX, bSizeY, 1}; - vector< pair > args; - args.push_back( make_pair(sizeof(cl_mem), &src.data)); - args.push_back( make_pair(sizeof(cl_mem), &dst.data)); - args.push_back( make_pair(sizeof(cl_int), (void *)&src.offset)); - args.push_back( make_pair(sizeof(cl_int), (void *)&src.step)); - args.push_back( make_pair(sizeof(cl_int), (void *)&dst.offset)); - args.push_back( make_pair(sizeof(cl_int), (void *)&dst.rows)); - args.push_back( make_pair(sizeof(cl_int), (void *)&dst.cols)); - args.push_back( make_pair(sizeof(cl_int), (void *)&dst.step)); - args.push_back( make_pair(sizeof(cl_uchar), (void *)&thresh_uchar)); - args.push_back( make_pair(sizeof(cl_uchar), (void *)&max_val)); - args.push_back( make_pair(sizeof(cl_int), (void *)&type)); + std::vector< std::pair > args; + args.push_back( std::make_pair(sizeof(cl_mem), &src.data)); + args.push_back( std::make_pair(sizeof(cl_mem), &dst.data)); + args.push_back( std::make_pair(sizeof(cl_int), (void *)&src.offset)); + args.push_back( std::make_pair(sizeof(cl_int), (void *)&src.step)); + args.push_back( std::make_pair(sizeof(cl_int), (void *)&dst.offset)); + args.push_back( std::make_pair(sizeof(cl_int), (void *)&dst.rows)); + args.push_back( std::make_pair(sizeof(cl_int), (void *)&dst.cols)); + args.push_back( std::make_pair(sizeof(cl_int), (void *)&dst.step)); + args.push_back( std::make_pair(sizeof(cl_uchar), (void *)&thresh_uchar)); + args.push_back( std::make_pair(sizeof(cl_uchar), (void *)&max_val)); + args.push_back( std::make_pair(sizeof(cl_int), (void *)&type)); openCLExecuteKernel(clCxt, &imgproc_threshold, kernelName, globalThreads, localThreads, args, src.oclchannels(), src.depth()); } @@ -160,7 +159,7 @@ namespace cv int src_offset = (src.offset >> 2); int src_step = (src.step >> 2); - string kernelName = "threshold"; + std::string kernelName = "threshold"; size_t cols = (dst.cols + (dst_offset & 3) + 3) / 4; //size_t cols = dst.cols; @@ -170,18 +169,18 @@ namespace cv size_t globalThreads[3] = {gSizeX, gSizeY, 1}; size_t localThreads[3] = {bSizeX, bSizeY, 1}; - vector< pair > args; - args.push_back( make_pair(sizeof(cl_mem), &src.data)); - args.push_back( make_pair(sizeof(cl_mem), &dst.data)); - args.push_back( make_pair(sizeof(cl_int), (void *)&src_offset)); - args.push_back( make_pair(sizeof(cl_int), (void *)&src_step)); - args.push_back( make_pair(sizeof(cl_int), (void *)&dst_offset)); - args.push_back( make_pair(sizeof(cl_int), (void *)&dst.rows)); - args.push_back( make_pair(sizeof(cl_int), (void *)&dst.cols)); - args.push_back( make_pair(sizeof(cl_int), (void *)&dst_step)); - args.push_back( make_pair(sizeof(cl_float), (void *)&thresh_f)); - args.push_back( make_pair(sizeof(cl_float), (void *)&max_val)); - args.push_back( make_pair(sizeof(cl_int), (void *)&type)); + std::vector< std::pair > args; + args.push_back( std::make_pair(sizeof(cl_mem), &src.data)); + args.push_back( std::make_pair(sizeof(cl_mem), &dst.data)); + args.push_back( std::make_pair(sizeof(cl_int), (void *)&src_offset)); + args.push_back( std::make_pair(sizeof(cl_int), (void *)&src_step)); + args.push_back( std::make_pair(sizeof(cl_int), (void *)&dst_offset)); + args.push_back( std::make_pair(sizeof(cl_int), (void *)&dst.rows)); + args.push_back( std::make_pair(sizeof(cl_int), (void *)&dst.cols)); + args.push_back( std::make_pair(sizeof(cl_int), (void *)&dst_step)); + args.push_back( std::make_pair(sizeof(cl_float), (void *)&thresh_f)); + args.push_back( std::make_pair(sizeof(cl_float), (void *)&max_val)); + args.push_back( std::make_pair(sizeof(cl_int), (void *)&type)); openCLExecuteKernel(clCxt, &imgproc_threshold, kernelName, globalThreads, localThreads, args, src.oclchannels(), src.depth()); } @@ -217,7 +216,7 @@ namespace cv dst.create(map1.size(), src.type()); - string kernelName; + std::string kernelName; if( map1.type() == CV_32FC2 && !map2.data ) { @@ -270,62 +269,62 @@ namespace cv size_t localThreads[3] = {blkSizeX, blkSizeY, 1}; - vector< pair > args; + std::vector< std::pair > args; if(map1.channels() == 2) { - args.push_back( make_pair(sizeof(cl_mem), (void *)&dst.data)); - args.push_back( make_pair(sizeof(cl_mem), (void *)&src.data)); - args.push_back( make_pair(sizeof(cl_mem), (void *)&map1.data)); - args.push_back( make_pair(sizeof(cl_int), (void *)&dst.offset)); - args.push_back( make_pair(sizeof(cl_int), (void *)&src.offset)); - args.push_back( make_pair(sizeof(cl_int), (void *)&map1.offset)); - args.push_back( make_pair(sizeof(cl_int), (void *)&dst.step)); - args.push_back( make_pair(sizeof(cl_int), (void *)&src.step)); - args.push_back( make_pair(sizeof(cl_int), (void *)&map1.step)); - args.push_back( make_pair(sizeof(cl_int), (void *)&src.cols)); - args.push_back( make_pair(sizeof(cl_int), (void *)&src.rows)); - args.push_back( make_pair(sizeof(cl_int), (void *)&dst.cols)); - args.push_back( make_pair(sizeof(cl_int), (void *)&dst.rows)); - args.push_back( make_pair(sizeof(cl_int), (void *)&map1.cols)); - args.push_back( make_pair(sizeof(cl_int), (void *)&map1.rows)); - args.push_back( make_pair(sizeof(cl_int), (void *)&cols)); + args.push_back( std::make_pair(sizeof(cl_mem), (void *)&dst.data)); + args.push_back( std::make_pair(sizeof(cl_mem), (void *)&src.data)); + args.push_back( std::make_pair(sizeof(cl_mem), (void *)&map1.data)); + args.push_back( std::make_pair(sizeof(cl_int), (void *)&dst.offset)); + args.push_back( std::make_pair(sizeof(cl_int), (void *)&src.offset)); + args.push_back( std::make_pair(sizeof(cl_int), (void *)&map1.offset)); + args.push_back( std::make_pair(sizeof(cl_int), (void *)&dst.step)); + args.push_back( std::make_pair(sizeof(cl_int), (void *)&src.step)); + args.push_back( std::make_pair(sizeof(cl_int), (void *)&map1.step)); + args.push_back( std::make_pair(sizeof(cl_int), (void *)&src.cols)); + args.push_back( std::make_pair(sizeof(cl_int), (void *)&src.rows)); + args.push_back( std::make_pair(sizeof(cl_int), (void *)&dst.cols)); + args.push_back( std::make_pair(sizeof(cl_int), (void *)&dst.rows)); + args.push_back( std::make_pair(sizeof(cl_int), (void *)&map1.cols)); + args.push_back( std::make_pair(sizeof(cl_int), (void *)&map1.rows)); + args.push_back( std::make_pair(sizeof(cl_int), (void *)&cols)); if(src.clCxt -> impl -> double_support != 0) { - args.push_back( make_pair(sizeof(cl_double4), (void *)&borderValue)); + args.push_back( std::make_pair(sizeof(cl_double4), (void *)&borderValue)); } else { float borderFloat[4] = {(float)borderValue[0], (float)borderValue[1], (float)borderValue[2], (float)borderValue[3]}; - args.push_back( make_pair(sizeof(cl_float4), (void *)&borderFloat)); + args.push_back( std::make_pair(sizeof(cl_float4), (void *)&borderFloat)); } } if(map1.channels() == 1) { - args.push_back( make_pair(sizeof(cl_mem), (void *)&dst.data)); - args.push_back( make_pair(sizeof(cl_mem), (void *)&src.data)); - args.push_back( make_pair(sizeof(cl_mem), (void *)&map1.data)); - args.push_back( make_pair(sizeof(cl_mem), (void *)&map2.data)); - args.push_back( make_pair(sizeof(cl_int), (void *)&dst.offset)); - args.push_back( make_pair(sizeof(cl_int), (void *)&src.offset)); - args.push_back( make_pair(sizeof(cl_int), (void *)&map1.offset)); - args.push_back( make_pair(sizeof(cl_int), (void *)&dst.step)); - args.push_back( make_pair(sizeof(cl_int), (void *)&src.step)); - args.push_back( make_pair(sizeof(cl_int), (void *)&map1.step)); - args.push_back( make_pair(sizeof(cl_int), (void *)&src.cols)); - args.push_back( make_pair(sizeof(cl_int), (void *)&src.rows)); - args.push_back( make_pair(sizeof(cl_int), (void *)&dst.cols)); - args.push_back( make_pair(sizeof(cl_int), (void *)&dst.rows)); - args.push_back( make_pair(sizeof(cl_int), (void *)&map1.cols)); - args.push_back( make_pair(sizeof(cl_int), (void *)&map1.rows)); - args.push_back( make_pair(sizeof(cl_int), (void *)&cols)); + args.push_back( std::make_pair(sizeof(cl_mem), (void *)&dst.data)); + args.push_back( std::make_pair(sizeof(cl_mem), (void *)&src.data)); + args.push_back( std::make_pair(sizeof(cl_mem), (void *)&map1.data)); + args.push_back( std::make_pair(sizeof(cl_mem), (void *)&map2.data)); + args.push_back( std::make_pair(sizeof(cl_int), (void *)&dst.offset)); + args.push_back( std::make_pair(sizeof(cl_int), (void *)&src.offset)); + args.push_back( std::make_pair(sizeof(cl_int), (void *)&map1.offset)); + args.push_back( std::make_pair(sizeof(cl_int), (void *)&dst.step)); + args.push_back( std::make_pair(sizeof(cl_int), (void *)&src.step)); + args.push_back( std::make_pair(sizeof(cl_int), (void *)&map1.step)); + args.push_back( std::make_pair(sizeof(cl_int), (void *)&src.cols)); + args.push_back( std::make_pair(sizeof(cl_int), (void *)&src.rows)); + args.push_back( std::make_pair(sizeof(cl_int), (void *)&dst.cols)); + args.push_back( std::make_pair(sizeof(cl_int), (void *)&dst.rows)); + args.push_back( std::make_pair(sizeof(cl_int), (void *)&map1.cols)); + args.push_back( std::make_pair(sizeof(cl_int), (void *)&map1.rows)); + args.push_back( std::make_pair(sizeof(cl_int), (void *)&cols)); if(src.clCxt -> impl -> double_support != 0) { - args.push_back( make_pair(sizeof(cl_double4), (void *)&borderValue)); + args.push_back( std::make_pair(sizeof(cl_double4), (void *)&borderValue)); } else { float borderFloat[4] = {(float)borderValue[0], (float)borderValue[1], (float)borderValue[2], (float)borderValue[3]}; - args.push_back( make_pair(sizeof(cl_float4), (void *)&borderFloat)); + args.push_back( std::make_pair(sizeof(cl_float4), (void *)&borderFloat)); } } openCLExecuteKernel(clCxt, &imgproc_remap, kernelName, globalThreads, localThreads, args, src.oclchannels(), src.depth()); @@ -347,7 +346,7 @@ namespace cv int dstStep_in_pixel = dst.step1() / dst.oclchannels(); int dstoffset_in_pixel = dst.offset / dst.elemSize(); //printf("%d %d\n",src.step1() , dst.elemSize()); - string kernelName; + std::string kernelName; if(interpolation == INTER_LINEAR) kernelName = "resizeLN"; else if(interpolation == INTER_NEAREST) @@ -369,44 +368,44 @@ namespace cv size_t globalThreads[3] = {glbSizeX, glbSizeY, 1}; size_t localThreads[3] = {blkSizeX, blkSizeY, 1}; - vector< pair > args; + std::vector< std::pair > args; if(interpolation == INTER_NEAREST) { - args.push_back( make_pair(sizeof(cl_mem), (void *)&dst.data)); - args.push_back( make_pair(sizeof(cl_mem), (void *)&src.data)); - args.push_back( make_pair(sizeof(cl_int), (void *)&dstoffset_in_pixel)); - args.push_back( make_pair(sizeof(cl_int), (void *)&srcoffset_in_pixel)); - args.push_back( make_pair(sizeof(cl_int), (void *)&dstStep_in_pixel)); - args.push_back( make_pair(sizeof(cl_int), (void *)&srcStep_in_pixel)); - args.push_back( make_pair(sizeof(cl_int), (void *)&src.cols)); - args.push_back( make_pair(sizeof(cl_int), (void *)&src.rows)); - args.push_back( make_pair(sizeof(cl_int), (void *)&dst.cols)); - args.push_back( make_pair(sizeof(cl_int), (void *)&dst.rows)); + args.push_back( std::make_pair(sizeof(cl_mem), (void *)&dst.data)); + args.push_back( std::make_pair(sizeof(cl_mem), (void *)&src.data)); + args.push_back( std::make_pair(sizeof(cl_int), (void *)&dstoffset_in_pixel)); + args.push_back( std::make_pair(sizeof(cl_int), (void *)&srcoffset_in_pixel)); + args.push_back( std::make_pair(sizeof(cl_int), (void *)&dstStep_in_pixel)); + args.push_back( std::make_pair(sizeof(cl_int), (void *)&srcStep_in_pixel)); + args.push_back( std::make_pair(sizeof(cl_int), (void *)&src.cols)); + args.push_back( std::make_pair(sizeof(cl_int), (void *)&src.rows)); + args.push_back( std::make_pair(sizeof(cl_int), (void *)&dst.cols)); + args.push_back( std::make_pair(sizeof(cl_int), (void *)&dst.rows)); if(src.clCxt -> impl -> double_support != 0) { - args.push_back( make_pair(sizeof(cl_double), (void *)&ifx_d)); - args.push_back( make_pair(sizeof(cl_double), (void *)&ify_d)); + args.push_back( std::make_pair(sizeof(cl_double), (void *)&ifx_d)); + args.push_back( std::make_pair(sizeof(cl_double), (void *)&ify_d)); } else { - args.push_back( make_pair(sizeof(cl_float), (void *)&ifx)); - args.push_back( make_pair(sizeof(cl_float), (void *)&ify)); + args.push_back( std::make_pair(sizeof(cl_float), (void *)&ifx)); + args.push_back( std::make_pair(sizeof(cl_float), (void *)&ify)); } } else { - args.push_back( make_pair(sizeof(cl_mem), (void *)&dst.data)); - args.push_back( make_pair(sizeof(cl_mem), (void *)&src.data)); - args.push_back( make_pair(sizeof(cl_int), (void *)&dstoffset_in_pixel)); - args.push_back( make_pair(sizeof(cl_int), (void *)&srcoffset_in_pixel)); - args.push_back( make_pair(sizeof(cl_int), (void *)&dstStep_in_pixel)); - args.push_back( make_pair(sizeof(cl_int), (void *)&srcStep_in_pixel)); - args.push_back( make_pair(sizeof(cl_int), (void *)&src.cols)); - args.push_back( make_pair(sizeof(cl_int), (void *)&src.rows)); - args.push_back( make_pair(sizeof(cl_int), (void *)&dst.cols)); - args.push_back( make_pair(sizeof(cl_int), (void *)&dst.rows)); - args.push_back( make_pair(sizeof(cl_float), (void *)&ifx)); - args.push_back( make_pair(sizeof(cl_float), (void *)&ify)); + args.push_back( std::make_pair(sizeof(cl_mem), (void *)&dst.data)); + args.push_back( std::make_pair(sizeof(cl_mem), (void *)&src.data)); + args.push_back( std::make_pair(sizeof(cl_int), (void *)&dstoffset_in_pixel)); + args.push_back( std::make_pair(sizeof(cl_int), (void *)&srcoffset_in_pixel)); + args.push_back( std::make_pair(sizeof(cl_int), (void *)&dstStep_in_pixel)); + args.push_back( std::make_pair(sizeof(cl_int), (void *)&srcStep_in_pixel)); + args.push_back( std::make_pair(sizeof(cl_int), (void *)&src.cols)); + args.push_back( std::make_pair(sizeof(cl_int), (void *)&src.rows)); + args.push_back( std::make_pair(sizeof(cl_int), (void *)&dst.cols)); + args.push_back( std::make_pair(sizeof(cl_int), (void *)&dst.rows)); + args.push_back( std::make_pair(sizeof(cl_float), (void *)&ifx)); + args.push_back( std::make_pair(sizeof(cl_float), (void *)&ify)); } openCLExecuteKernel(clCxt, &imgproc_resize, kernelName, globalThreads, localThreads, args, src.oclchannels(), src.depth()); @@ -471,37 +470,37 @@ namespace cv int dstOffset = dst.offset / dst.oclchannels() / dst.elemSize1(); Context *clCxt = src.clCxt; - string kernelName = "medianFilter"; + std::string kernelName = "medianFilter"; - vector< pair > args; - args.push_back( make_pair( sizeof(cl_mem), (void *)&src.data)); - args.push_back( make_pair( sizeof(cl_mem), (void *)&dst.data)); - args.push_back( make_pair( sizeof(cl_int), (void *)&srcOffset)); - args.push_back( make_pair( sizeof(cl_int), (void *)&dstOffset)); - args.push_back( make_pair( sizeof(cl_int), (void *)&src.cols)); - args.push_back( make_pair( sizeof(cl_int), (void *)&src.rows)); - args.push_back( make_pair( sizeof(cl_int), (void *)&srcStep)); - args.push_back( make_pair( sizeof(cl_int), (void *)&dstStep)); + std::vector< std::pair > args; + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&src.data)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&dst.data)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&srcOffset)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dstOffset)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src.cols)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src.rows)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&srcStep)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dstStep)); size_t globalThreads[3] = {(src.cols + 18) / 16 * 16, (src.rows + 15) / 16 * 16, 1}; size_t localThreads[3] = {16, 16, 1}; if(m == 3) { - string kernelName = "medianFilter3"; + std::string kernelName = "medianFilter3"; openCLExecuteKernel(clCxt, &imgproc_median, kernelName, globalThreads, localThreads, args, src.oclchannels(), src.depth()); } else if(m == 5) { - string kernelName = "medianFilter5"; + std::string kernelName = "medianFilter5"; openCLExecuteKernel(clCxt, &imgproc_median, kernelName, globalThreads, localThreads, args, src.oclchannels(), src.depth()); } else { CV_Error(CV_StsUnsupportedFormat, "Non-supported filter length"); - //string kernelName = "medianFilter"; - //args.push_back( make_pair( sizeof(cl_int),(void*)&m)); + //std::string kernelName = "medianFilter"; + //args.push_back( std::make_pair( sizeof(cl_int),(void*)&m)); //openCLExecuteKernel(clCxt,&imgproc_median,kernelName,globalThreads,localThreads,args,src.oclchannels(),-1); } @@ -549,25 +548,25 @@ namespace cv { CV_Error(CV_StsBadArg, "unsupported border type"); } - string kernelName = "copymakeborder"; + std::string kernelName = "copymakeborder"; size_t localThreads[3] = {16, 16, 1}; size_t globalThreads[3] = {(dst.cols + localThreads[0] - 1) / localThreads[0] *localThreads[0], (dst.rows + localThreads[1] - 1) / localThreads[1] *localThreads[1], 1 }; - vector< pair > args; - args.push_back( make_pair( sizeof(cl_mem), (void *)&src.data)); - args.push_back( make_pair( sizeof(cl_mem), (void *)&dst.data)); - args.push_back( make_pair( sizeof(cl_int), (void *)&dst.cols)); - args.push_back( make_pair( sizeof(cl_int), (void *)&dst.rows)); - args.push_back( make_pair( sizeof(cl_int), (void *)&src.cols)); - args.push_back( make_pair( sizeof(cl_int), (void *)&src.rows)); - args.push_back( make_pair( sizeof(cl_int), (void *)&srcStep)); - args.push_back( make_pair( sizeof(cl_int), (void *)&srcOffset)); - args.push_back( make_pair( sizeof(cl_int), (void *)&dstStep)); - args.push_back( make_pair( sizeof(cl_int), (void *)&dstOffset)); - args.push_back( make_pair( sizeof(cl_int), (void *)&top)); - args.push_back( make_pair( sizeof(cl_int), (void *)&left)); + std::vector< std::pair > args; + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&src.data)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&dst.data)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dst.cols)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dst.rows)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src.cols)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src.rows)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&srcStep)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&srcOffset)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dstStep)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dstOffset)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&top)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&left)); char compile_option[64]; union sc { @@ -590,7 +589,7 @@ namespace cv { case 1: sprintf(compile_option, "-D GENTYPE=uchar -D %s", borderstr[bordertype_index]); - args.push_back( make_pair( sizeof(cl_uchar) , (void *)&val.uval.s[0] )); + args.push_back( std::make_pair( sizeof(cl_uchar) , (void *)&val.uval.s[0] )); if(((dst.offset & 3) == 0) && ((dst.cols & 3) == 0)) { kernelName = "copymakeborder_C1_D0"; @@ -599,7 +598,7 @@ namespace cv break; case 4: sprintf(compile_option, "-D GENTYPE=uchar4 -D %s", borderstr[bordertype_index]); - args.push_back( make_pair( sizeof(cl_uchar4) , (void *)&val.uval )); + args.push_back( std::make_pair( sizeof(cl_uchar4) , (void *)&val.uval )); break; default: CV_Error(CV_StsUnsupportedFormat, "unsupported channels"); @@ -614,11 +613,11 @@ namespace cv { case 1: sprintf(compile_option, "-D GENTYPE=char -D %s", borderstr[bordertype_index]); - args.push_back( make_pair( sizeof(cl_char) , (void *)&val.cval.s[0] )); + args.push_back( std::make_pair( sizeof(cl_char) , (void *)&val.cval.s[0] )); break; case 4: sprintf(compile_option, "-D GENTYPE=char4 -D %s", borderstr[bordertype_index]); - args.push_back( make_pair( sizeof(cl_char4) , (void *)&val.cval )); + args.push_back( std::make_pair( sizeof(cl_char4) , (void *)&val.cval )); break; default: CV_Error(CV_StsUnsupportedFormat, "unsupported channels"); @@ -633,11 +632,11 @@ namespace cv { case 1: sprintf(compile_option, "-D GENTYPE=ushort -D %s", borderstr[bordertype_index]); - args.push_back( make_pair( sizeof(cl_ushort) , (void *)&val.usval.s[0] )); + args.push_back( std::make_pair( sizeof(cl_ushort) , (void *)&val.usval.s[0] )); break; case 4: sprintf(compile_option, "-D GENTYPE=ushort4 -D %s", borderstr[bordertype_index]); - args.push_back( make_pair( sizeof(cl_ushort4) , (void *)&val.usval )); + args.push_back( std::make_pair( sizeof(cl_ushort4) , (void *)&val.usval )); break; default: CV_Error(CV_StsUnsupportedFormat, "unsupported channels"); @@ -652,11 +651,11 @@ namespace cv { case 1: sprintf(compile_option, "-D GENTYPE=short -D %s", borderstr[bordertype_index]); - args.push_back( make_pair( sizeof(cl_short) , (void *)&val.shval.s[0] )); + args.push_back( std::make_pair( sizeof(cl_short) , (void *)&val.shval.s[0] )); break; case 4: sprintf(compile_option, "-D GENTYPE=short4 -D %s", borderstr[bordertype_index]); - args.push_back( make_pair( sizeof(cl_short4) , (void *)&val.shval )); + args.push_back( std::make_pair( sizeof(cl_short4) , (void *)&val.shval )); break; default: CV_Error(CV_StsUnsupportedFormat, "unsupported channels"); @@ -671,18 +670,18 @@ namespace cv { case 1: sprintf(compile_option, "-D GENTYPE=int -D %s", borderstr[bordertype_index]); - args.push_back( make_pair( sizeof(cl_int) , (void *)&val.ival.s[0] )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&val.ival.s[0] )); break; case 2: sprintf(compile_option, "-D GENTYPE=int2 -D %s", borderstr[bordertype_index]); cl_int2 i2val; i2val.s[0] = val.ival.s[0]; i2val.s[1] = val.ival.s[1]; - args.push_back( make_pair( sizeof(cl_int2) , (void *)&i2val )); + args.push_back( std::make_pair( sizeof(cl_int2) , (void *)&i2val )); break; case 4: sprintf(compile_option, "-D GENTYPE=int4 -D %s", borderstr[bordertype_index]); - args.push_back( make_pair( sizeof(cl_int4) , (void *)&val.ival )); + args.push_back( std::make_pair( sizeof(cl_int4) , (void *)&val.ival )); break; default: CV_Error(CV_StsUnsupportedFormat, "unsupported channels"); @@ -697,11 +696,11 @@ namespace cv { case 1: sprintf(compile_option, "-D GENTYPE=float -D %s", borderstr[bordertype_index]); - args.push_back( make_pair( sizeof(cl_float) , (void *)&val.fval.s[0] )); + args.push_back( std::make_pair( sizeof(cl_float) , (void *)&val.fval.s[0] )); break; case 4: sprintf(compile_option, "-D GENTYPE=float4 -D %s", borderstr[bordertype_index]); - args.push_back( make_pair( sizeof(cl_float4) , (void *)&val.fval )); + args.push_back( std::make_pair( sizeof(cl_float4) , (void *)&val.fval )); break; default: CV_Error(CV_StsUnsupportedFormat, "unsupported channels"); @@ -716,11 +715,11 @@ namespace cv { case 1: sprintf(compile_option, "-D GENTYPE=double -D %s", borderstr[bordertype_index]); - args.push_back( make_pair( sizeof(cl_double) , (void *)&val.dval.s[0] )); + args.push_back( std::make_pair( sizeof(cl_double) , (void *)&val.dval.s[0] )); break; case 4: sprintf(compile_option, "-D GENTYPE=double4 -D %s", borderstr[bordertype_index]); - args.push_back( make_pair( sizeof(cl_double4) , (void *)&val.dval )); + args.push_back( std::make_pair( sizeof(cl_double4) , (void *)&val.dval )); break; default: CV_Error(CV_StsUnsupportedFormat, "unsupported channels"); @@ -739,9 +738,9 @@ namespace cv //{ // for(int j=0;j impl -> double_support != 0) @@ -861,20 +860,20 @@ namespace cv size_t globalThreads[3] = {glbSizeX, glbSizeY, 1}; size_t localThreads[3] = {blkSizeX, blkSizeY, 1}; - vector< pair > args; + std::vector< std::pair > args; - args.push_back(make_pair(sizeof(cl_mem), (void *)&src.data)); - args.push_back(make_pair(sizeof(cl_mem), (void *)&dst.data)); - args.push_back(make_pair(sizeof(cl_int), (void *)&src.cols)); - args.push_back(make_pair(sizeof(cl_int), (void *)&src.rows)); - args.push_back(make_pair(sizeof(cl_int), (void *)&dst.cols)); - args.push_back(make_pair(sizeof(cl_int), (void *)&dst.rows)); - args.push_back(make_pair(sizeof(cl_int), (void *)&srcStep)); - args.push_back(make_pair(sizeof(cl_int), (void *)&dstStep)); - args.push_back(make_pair(sizeof(cl_int), (void *)&src.offset)); - args.push_back(make_pair(sizeof(cl_int), (void *)&dst.offset)); - args.push_back(make_pair(sizeof(cl_mem), (void *)&coeffs_cm)); - args.push_back(make_pair(sizeof(cl_int), (void *)&cols)); + args.push_back(std::make_pair(sizeof(cl_mem), (void *)&src.data)); + args.push_back(std::make_pair(sizeof(cl_mem), (void *)&dst.data)); + args.push_back(std::make_pair(sizeof(cl_int), (void *)&src.cols)); + args.push_back(std::make_pair(sizeof(cl_int), (void *)&src.rows)); + args.push_back(std::make_pair(sizeof(cl_int), (void *)&dst.cols)); + args.push_back(std::make_pair(sizeof(cl_int), (void *)&dst.rows)); + args.push_back(std::make_pair(sizeof(cl_int), (void *)&srcStep)); + args.push_back(std::make_pair(sizeof(cl_int), (void *)&dstStep)); + args.push_back(std::make_pair(sizeof(cl_int), (void *)&src.offset)); + args.push_back(std::make_pair(sizeof(cl_int), (void *)&dst.offset)); + args.push_back(std::make_pair(sizeof(cl_mem), (void *)&coeffs_cm)); + args.push_back(std::make_pair(sizeof(cl_int), (void *)&cols)); openCLExecuteKernel(clCxt, &imgproc_warpAffine, kernelName, globalThreads, localThreads, args, src.oclchannels(), src.depth()); openCLSafeCall(clReleaseMemObject(coeffs_cm)); @@ -890,8 +889,8 @@ namespace cv cl_mem coeffs_cm; Context *clCxt = src.clCxt; - string s[3] = {"NN", "Linear", "Cubic"}; - string kernelName = "warpPerspective" + s[interpolation]; + std::string s[3] = {"NN", "Linear", "Cubic"}; + std::string kernelName = "warpPerspective" + s[interpolation]; if(src.clCxt -> impl -> double_support != 0) { @@ -931,20 +930,20 @@ namespace cv size_t globalThreads[3] = {glbSizeX, glbSizeY, 1}; size_t localThreads[3] = {blkSizeX, blkSizeY, 1}; - vector< pair > args; + std::vector< std::pair > args; - args.push_back(make_pair(sizeof(cl_mem), (void *)&src.data)); - args.push_back(make_pair(sizeof(cl_mem), (void *)&dst.data)); - args.push_back(make_pair(sizeof(cl_int), (void *)&src.cols)); - args.push_back(make_pair(sizeof(cl_int), (void *)&src.rows)); - args.push_back(make_pair(sizeof(cl_int), (void *)&dst.cols)); - args.push_back(make_pair(sizeof(cl_int), (void *)&dst.rows)); - args.push_back(make_pair(sizeof(cl_int), (void *)&srcStep)); - args.push_back(make_pair(sizeof(cl_int), (void *)&dstStep)); - args.push_back(make_pair(sizeof(cl_int), (void *)&src.offset)); - args.push_back(make_pair(sizeof(cl_int), (void *)&dst.offset)); - args.push_back(make_pair(sizeof(cl_mem), (void *)&coeffs_cm)); - args.push_back(make_pair(sizeof(cl_int), (void *)&cols)); + args.push_back(std::make_pair(sizeof(cl_mem), (void *)&src.data)); + args.push_back(std::make_pair(sizeof(cl_mem), (void *)&dst.data)); + args.push_back(std::make_pair(sizeof(cl_int), (void *)&src.cols)); + args.push_back(std::make_pair(sizeof(cl_int), (void *)&src.rows)); + args.push_back(std::make_pair(sizeof(cl_int), (void *)&dst.cols)); + args.push_back(std::make_pair(sizeof(cl_int), (void *)&dst.rows)); + args.push_back(std::make_pair(sizeof(cl_int), (void *)&srcStep)); + args.push_back(std::make_pair(sizeof(cl_int), (void *)&dstStep)); + args.push_back(std::make_pair(sizeof(cl_int), (void *)&src.offset)); + args.push_back(std::make_pair(sizeof(cl_int), (void *)&dst.offset)); + args.push_back(std::make_pair(sizeof(cl_mem), (void *)&coeffs_cm)); + args.push_back(std::make_pair(sizeof(cl_int), (void *)&cols)); openCLExecuteKernel(clCxt, &imgproc_warpPerspective, kernelName, globalThreads, localThreads, args, src.oclchannels(), src.depth()); openCLSafeCall(clReleaseMemObject(coeffs_cm)); @@ -1035,33 +1034,33 @@ namespace cv sqsum.create(h, w, CV_32FC1); int sum_offset = sum.offset / vlen, sqsum_offset = sqsum.offset / vlen; - vector > args; - args.push_back( make_pair( sizeof(cl_mem) , (void *)&src.data )); - args.push_back( make_pair( sizeof(cl_mem) , (void *)&t_sum.data )); - args.push_back( make_pair( sizeof(cl_mem) , (void *)&t_sqsum.data )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&offset )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&pre_invalid )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&src.rows )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&src.cols )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&src.step )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&t_sum.step)); + std::vector > args; + args.push_back( std::make_pair( sizeof(cl_mem) , (void *)&src.data )); + args.push_back( std::make_pair( sizeof(cl_mem) , (void *)&t_sum.data )); + args.push_back( std::make_pair( sizeof(cl_mem) , (void *)&t_sqsum.data )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&offset )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&pre_invalid )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&src.rows )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&src.cols )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&src.step )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&t_sum.step)); size_t gt[3] = {((vcols + 1) / 2) * 256, 1, 1}, lt[3] = {256, 1, 1}; openCLExecuteKernel(src.clCxt, &imgproc_integral, "integral_cols", gt, lt, args, -1, -1); args.clear(); - args.push_back( make_pair( sizeof(cl_mem) , (void *)&t_sum.data )); - args.push_back( make_pair( sizeof(cl_mem) , (void *)&t_sqsum.data )); - args.push_back( make_pair( sizeof(cl_mem) , (void *)&sum.data )); - args.push_back( make_pair( sizeof(cl_mem) , (void *)&sqsum.data )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&t_sum.rows )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&t_sum.cols )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&t_sum.step )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&sum.step)); - args.push_back( make_pair( sizeof(cl_int) , (void *)&sqsum.step)); - args.push_back( make_pair( sizeof(cl_int) , (void *)&sum_offset)); - args.push_back( make_pair( sizeof(cl_int) , (void *)&sqsum_offset)); + args.push_back( std::make_pair( sizeof(cl_mem) , (void *)&t_sum.data )); + args.push_back( std::make_pair( sizeof(cl_mem) , (void *)&t_sqsum.data )); + args.push_back( std::make_pair( sizeof(cl_mem) , (void *)&sum.data )); + args.push_back( std::make_pair( sizeof(cl_mem) , (void *)&sqsum.data )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&t_sum.rows )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&t_sum.cols )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&t_sum.step )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&sum.step)); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&sqsum.step)); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&sum_offset)); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&sqsum_offset)); size_t gt2[3] = {t_sum.cols * 32, 1, 1}, lt2[3] = {256, 1, 1}; openCLExecuteKernel(src.clCxt, &imgproc_integral, "integral_rows", gt2, lt2, args, -1, -1); - //cout << "tested" << endl; + //std::cout << "tested" << std::endl; } void integral(const oclMat &src, oclMat &sum) { @@ -1078,28 +1077,28 @@ namespace cv sum.create(h, w, CV_32SC1); int sum_offset = sum.offset / vlen; - vector > args; - args.push_back( make_pair( sizeof(cl_mem) , (void *)&src.data )); - args.push_back( make_pair( sizeof(cl_mem) , (void *)&t_sum.data )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&offset )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&pre_invalid )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&src.rows )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&src.cols )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&src.step )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&t_sum.step)); + std::vector > args; + args.push_back( std::make_pair( sizeof(cl_mem) , (void *)&src.data )); + args.push_back( std::make_pair( sizeof(cl_mem) , (void *)&t_sum.data )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&offset )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&pre_invalid )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&src.rows )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&src.cols )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&src.step )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&t_sum.step)); size_t gt[3] = {((vcols + 1) / 2) * 256, 1, 1}, lt[3] = {256, 1, 1}; openCLExecuteKernel(src.clCxt, &imgproc_integral_sum, "integral_sum_cols", gt, lt, args, -1, -1); args.clear(); - args.push_back( make_pair( sizeof(cl_mem) , (void *)&t_sum.data )); - args.push_back( make_pair( sizeof(cl_mem) , (void *)&sum.data )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&t_sum.rows )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&t_sum.cols )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&t_sum.step )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&sum.step)); - args.push_back( make_pair( sizeof(cl_int) , (void *)&sum_offset)); + args.push_back( std::make_pair( sizeof(cl_mem) , (void *)&t_sum.data )); + args.push_back( std::make_pair( sizeof(cl_mem) , (void *)&sum.data )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&t_sum.rows )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&t_sum.cols )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&t_sum.step )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&sum.step)); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&sum_offset)); size_t gt2[3] = {t_sum.cols * 32, 1, 1}, lt2[3] = {256, 1, 1}; openCLExecuteKernel(src.clCxt, &imgproc_integral_sum, "integral_sum_rows", gt2, lt2, args, -1, -1); - //cout << "tested" << endl; + //std::cout << "tested" << std::endl; } /////////////////////// corner ////////////////////////////// @@ -1133,7 +1132,7 @@ namespace cv CV_Assert(Dx.offset == 0 && Dy.offset == 0); } - static void corner_ocl(const char *src_str, string kernelName, int block_size, float k, oclMat &Dx, oclMat &Dy, + static void corner_ocl(const char *src_str, std::string kernelName, int block_size, float k, oclMat &Dx, oclMat &Dy, oclMat &dst, int border_type) { char borderType[30]; @@ -1152,7 +1151,7 @@ namespace cv sprintf(borderType, "BORDER_REPLICATE"); break; default: - cout << "BORDER type is not supported!" << endl; + std::cout << "BORDER type is not supported!" << std::endl; } char build_options[150]; sprintf(build_options, "-D anX=%d -D anY=%d -D ksX=%d -D ksY=%d -D %s", @@ -1168,23 +1167,23 @@ namespace cv size_t gt[3] = { globalSizeX, globalSizeY, 1 }; size_t lt[3] = { blockSizeX, blockSizeY, 1 }; - vector > args; - args.push_back( make_pair( sizeof(cl_mem) , (void *)&Dx.data )); - args.push_back( make_pair( sizeof(cl_mem) , (void *)&Dy.data)); - args.push_back( make_pair( sizeof(cl_mem) , (void *)&dst.data)); - args.push_back( make_pair( sizeof(cl_int) , (void *)&Dx.offset )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&Dx.wholerows )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&Dx.wholecols )); - args.push_back( make_pair(sizeof(cl_int), (void *)&Dx.step)); - args.push_back( make_pair( sizeof(cl_int) , (void *)&Dy.offset )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&Dy.wholerows )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&Dy.wholecols )); - args.push_back( make_pair(sizeof(cl_int), (void *)&Dy.step)); - args.push_back( make_pair(sizeof(cl_int), (void *)&dst.offset)); - args.push_back( make_pair(sizeof(cl_int), (void *)&dst.rows)); - args.push_back( make_pair(sizeof(cl_int), (void *)&dst.cols)); - args.push_back( make_pair(sizeof(cl_int), (void *)&dst.step)); - args.push_back( make_pair( sizeof(cl_float) , (void *)&k)); + std::vector > args; + args.push_back( std::make_pair( sizeof(cl_mem) , (void *)&Dx.data )); + args.push_back( std::make_pair( sizeof(cl_mem) , (void *)&Dy.data)); + args.push_back( std::make_pair( sizeof(cl_mem) , (void *)&dst.data)); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&Dx.offset )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&Dx.wholerows )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&Dx.wholecols )); + args.push_back( std::make_pair(sizeof(cl_int), (void *)&Dx.step)); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&Dy.offset )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&Dy.wholerows )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&Dy.wholecols )); + args.push_back( std::make_pair(sizeof(cl_int), (void *)&Dy.step)); + args.push_back( std::make_pair(sizeof(cl_int), (void *)&dst.offset)); + args.push_back( std::make_pair(sizeof(cl_int), (void *)&dst.rows)); + args.push_back( std::make_pair(sizeof(cl_int), (void *)&dst.cols)); + args.push_back( std::make_pair(sizeof(cl_int), (void *)&dst.step)); + args.push_back( std::make_pair( sizeof(cl_float) , (void *)&k)); openCLExecuteKernel(dst.clCxt, &src_str, kernelName, gt, lt, args, -1, -1, build_options); } @@ -1235,19 +1234,19 @@ namespace cv size_t localThreads[3] = {ltx, lty, 1}; //set args - vector > args; - args.push_back( make_pair( sizeof(cl_mem) , (void *)&dst.data )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&dst.step )); - args.push_back( make_pair( sizeof(cl_mem) , (void *)&src.data )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&src.step )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&dst.offset )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&src.offset )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&dst.cols )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&dst.rows )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&sp )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&sr )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&maxIter )); - args.push_back( make_pair( sizeof(cl_float) , (void *)&eps )); + std::vector > args; + args.push_back( std::make_pair( sizeof(cl_mem) , (void *)&dst.data )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&dst.step )); + args.push_back( std::make_pair( sizeof(cl_mem) , (void *)&src.data )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&src.step )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&dst.offset )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&src.offset )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&dst.cols )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&dst.rows )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&sp )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&sr )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&maxIter )); + args.push_back( std::make_pair( sizeof(cl_float) , (void *)&eps )); openCLExecuteKernel(clCxt, &meanShift, "meanshift_kernel", globalThreads, localThreads, args, -1, -1); } @@ -1300,22 +1299,22 @@ namespace cv size_t localThreads[3] = {ltx, lty, 1}; //set args - vector > args; - args.push_back( make_pair( sizeof(cl_mem) , (void *)&src.data )); - args.push_back( make_pair( sizeof(cl_mem) , (void *)&dstr.data )); - args.push_back( make_pair( sizeof(cl_mem) , (void *)&dstsp.data )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&src.step )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&dstr.step )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&dstsp.step )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&src.offset )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&dstr.offset )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&dstsp.offset )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&dstr.cols )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&dstr.rows )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&sp )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&sr )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&maxIter )); - args.push_back( make_pair( sizeof(cl_float) , (void *)&eps )); + std::vector > args; + args.push_back( std::make_pair( sizeof(cl_mem) , (void *)&src.data )); + args.push_back( std::make_pair( sizeof(cl_mem) , (void *)&dstr.data )); + args.push_back( std::make_pair( sizeof(cl_mem) , (void *)&dstsp.data )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&src.step )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&dstr.step )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&dstsp.step )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&src.offset )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&dstr.offset )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&dstsp.offset )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&dstr.cols )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&dstr.rows )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&sp )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&sr )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&maxIter )); + args.push_back( std::make_pair( sizeof(cl_float) , (void *)&eps )); openCLExecuteKernel(clCxt, &meanShift, "meanshiftproc_kernel", globalThreads, localThreads, args, -1, -1); } @@ -1364,7 +1363,7 @@ namespace cv Context *clCxt = mat_src.clCxt; int depth = mat_src.depth(); - string kernelName = "calc_sub_hist"; + std::string kernelName = "calc_sub_hist"; size_t localThreads[3] = { HISTOGRAM256_BIN_COUNT, 1, 1 }; size_t globalThreads[3] = { PARTIAL_HISTOGRAM256_COUNT *localThreads[0], 1, 1}; @@ -1395,7 +1394,7 @@ namespace cv globalThreads[0] = 0; } - vector > args; + std::vector > args; if(globalThreads[0] != 0) { int tempcols = cols >> dataWidth_bits; @@ -1404,15 +1403,15 @@ namespace cv src_offset >>= dataWidth_bits; int src_step = mat_src.step >> dataWidth_bits; int datacount = tempcols * mat_src.rows; - args.push_back( make_pair( sizeof(cl_mem), (void *)&mat_src.data)); - args.push_back( make_pair( sizeof(cl_int), (void *)&src_step)); - args.push_back( make_pair( sizeof(cl_int), (void *)&src_offset)); - args.push_back( make_pair( sizeof(cl_mem), (void *)&mat_sub_hist.data)); - args.push_back( make_pair( sizeof(cl_int), (void *)&datacount)); - args.push_back( make_pair( sizeof(cl_int), (void *)&tempcols)); - args.push_back( make_pair( sizeof(cl_int), (void *)&inc_x)); - args.push_back( make_pair( sizeof(cl_int), (void *)&inc_y)); - args.push_back( make_pair( sizeof(cl_int), (void *)&hist_step)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&mat_src.data)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src_step)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src_offset)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&mat_sub_hist.data)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&datacount)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&tempcols)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&inc_x)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&inc_y)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&hist_step)); openCLExecuteKernel(clCxt, &imgproc_histogram, kernelName, globalThreads, localThreads, args, -1, depth); } if(left_col != 0 || right_col != 0) @@ -1425,14 +1424,14 @@ namespace cv globalThreads[1] = (mat_src.rows + localThreads[1] - 1) / localThreads[1] * localThreads[1]; args.clear(); - args.push_back( make_pair( sizeof(cl_mem), (void *)&mat_src.data)); - args.push_back( make_pair( sizeof(cl_int), (void *)&mat_src.step)); - args.push_back( make_pair( sizeof(cl_int), (void *)&src_offset)); - args.push_back( make_pair( sizeof(cl_mem), (void *)&mat_sub_hist.data)); - args.push_back( make_pair( sizeof(cl_int), (void *)&left_col)); - args.push_back( make_pair( sizeof(cl_int), (void *)&cols)); - args.push_back( make_pair( sizeof(cl_int), (void *)&mat_src.rows)); - args.push_back( make_pair( sizeof(cl_int), (void *)&hist_step)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&mat_src.data)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&mat_src.step)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src_offset)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&mat_sub_hist.data)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&left_col)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&cols)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&mat_src.rows)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&hist_step)); openCLExecuteKernel(clCxt, &imgproc_histogram, kernelName, globalThreads, localThreads, args, -1, depth); } } @@ -1441,15 +1440,15 @@ namespace cv using namespace histograms; Context *clCxt = sub_hist.clCxt; - string kernelName = "merge_hist"; + std::string kernelName = "merge_hist"; size_t localThreads[3] = { 256, 1, 1 }; size_t globalThreads[3] = { HISTOGRAM256_BIN_COUNT *localThreads[0], 1, 1}; int src_step = sub_hist.step >> 2; - vector > args; - args.push_back( make_pair( sizeof(cl_mem), (void *)&sub_hist.data)); - args.push_back( make_pair( sizeof(cl_mem), (void *)&mat_hist.data)); - args.push_back( make_pair( sizeof(cl_int), (void *)&src_step)); + std::vector > args; + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&sub_hist.data)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&mat_hist.data)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src_step)); openCLExecuteKernel(clCxt, &imgproc_histogram, kernelName, globalThreads, localThreads, args, -1, -1); } void calcHist(const oclMat &mat_src, oclMat &mat_hist) @@ -1474,15 +1473,15 @@ namespace cv calcHist(mat_src, mat_hist); Context *clCxt = mat_src.clCxt; - string kernelName = "calLUT"; + std::string kernelName = "calLUT"; size_t localThreads[3] = { 256, 1, 1}; size_t globalThreads[3] = { 256, 1, 1}; oclMat lut(1, 256, CV_8UC1); - vector > args; + std::vector > args; int total = mat_src.rows * mat_src.cols; - args.push_back( make_pair( sizeof(cl_mem), (void *)&lut.data)); - args.push_back( make_pair( sizeof(cl_mem), (void *)&mat_hist.data)); - args.push_back( make_pair( sizeof(int), (void *)&total)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&lut.data)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&mat_hist.data)); + args.push_back( std::make_pair( sizeof(int), (void *)&total)); openCLExecuteKernel(clCxt, &imgproc_histogram, kernelName, globalThreads, localThreads, args, -1, -1); LUT(mat_src, lut, mat_dst); } @@ -1517,9 +1516,9 @@ namespace cv oclMat temp; copyMakeBorder( src, temp, radius, radius, radius, radius, borderType ); - vector _color_weight(cn * 256); - vector _space_weight(d * d); - vector _space_ofs(d * d); + std::vector _color_weight(cn * 256); + std::vector _space_weight(d * d); + std::vector _space_ofs(d * d); float *color_weight = &_color_weight[0]; float *space_weight = &_space_weight[0]; int *space_ofs = &_space_ofs[0]; @@ -1544,7 +1543,7 @@ namespace cv oclMat oclspace_weight(1, d * d, CV_32FC1, space_weight); oclMat oclspace_ofs(1, d * d, CV_32SC1, space_ofs); - string kernelName = "bilateral"; + std::string kernelName = "bilateral"; size_t localThreads[3] = { 16, 16, 1 }; size_t globalThreads[3] = { (dst.cols + localThreads[0] - 1) / localThreads[0] *localThreads[0], (dst.rows + localThreads[1] - 1) / localThreads[1] *localThreads[1], @@ -1555,21 +1554,21 @@ namespace cv kernelName = "bilateral2"; globalThreads[0] = (dst.cols / 4 + localThreads[0] - 1) / localThreads[0] * localThreads[0]; } - vector > args; - args.push_back( make_pair( sizeof(cl_mem), (void *)&dst.data )); - args.push_back( make_pair( sizeof(cl_mem), (void *)&temp.data )); - args.push_back( make_pair( sizeof(cl_int), (void *)&dst.rows )); - args.push_back( make_pair( sizeof(cl_int), (void *)&dst.cols )); - args.push_back( make_pair( sizeof(cl_int), (void *)&maxk )); - args.push_back( make_pair( sizeof(cl_int), (void *)&radius )); - args.push_back( make_pair( sizeof(cl_int), (void *)&dst_step_in_pixel )); - args.push_back( make_pair( sizeof(cl_int), (void *)&dst_offset_in_pixel )); - args.push_back( make_pair( sizeof(cl_int), (void *)&temp_step_in_pixel )); - args.push_back( make_pair( sizeof(cl_int), (void *)&temp.rows )); - args.push_back( make_pair( sizeof(cl_int), (void *)&temp.cols )); - args.push_back( make_pair( sizeof(cl_mem), (void *)&oclcolor_weight.data )); - args.push_back( make_pair( sizeof(cl_mem), (void *)&oclspace_weight.data )); - args.push_back( make_pair( sizeof(cl_mem), (void *)&oclspace_ofs.data )); + std::vector > args; + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&dst.data )); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&temp.data )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dst.rows )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dst.cols )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&maxk )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&radius )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dst_step_in_pixel )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dst_offset_in_pixel )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&temp_step_in_pixel )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&temp.rows )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&temp.cols )); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&oclcolor_weight.data )); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&oclspace_weight.data )); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&oclspace_ofs.data )); openCLExecuteKernel(src.clCxt, &imgproc_bilateral, kernelName, globalThreads, localThreads, args, dst.oclchannels(), dst.depth()); } void bilateralFilter(const oclMat &src, oclMat &dst, int radius, double sigmaclr, double sigmaspc, int borderType) @@ -1590,7 +1589,7 @@ inline int divUp(int total, int grain) { return (total + grain - 1) / grain; } -static void convolve_run(const oclMat &src, const oclMat &temp1, oclMat &dst, string kernelName, const char **kernelString) +static void convolve_run(const oclMat &src, const oclMat &temp1, oclMat &dst, std::string kernelName, const char **kernelString) { CV_Assert(src.depth() == CV_32FC1); CV_Assert(temp1.depth() == CV_32F); @@ -1616,17 +1615,17 @@ static void convolve_run(const oclMat &src, const oclMat &temp1, oclMat &dst, st 1 }; - vector > args; - args.push_back( make_pair( sizeof(cl_mem), (void *)&src.data )); - args.push_back( make_pair( sizeof(cl_mem), (void *)&temp1.data )); - args.push_back( make_pair( sizeof(cl_mem), (void *)&dst.data )); - args.push_back( make_pair( sizeof(cl_int), (void *)&src.rows )); - args.push_back( make_pair( sizeof(cl_int), (void *)&cols )); - args.push_back( make_pair( sizeof(cl_int), (void *)&src.step )); - args.push_back( make_pair( sizeof(cl_int), (void *)&dst.step )); - args.push_back( make_pair( sizeof(cl_int), (void *)&temp1.step )); - args.push_back( make_pair( sizeof(cl_int), (void *)&temp1.rows )); - args.push_back( make_pair( sizeof(cl_int), (void *)&temp1.cols )); + std::vector > args; + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&src.data )); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&temp1.data )); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&dst.data )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src.rows )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&cols )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src.step )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dst.step )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&temp1.step )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&temp1.rows )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&temp1.cols )); openCLExecuteKernel(clCxt, kernelString, kernelName, globalThreads, localThreads, args, -1, depth); } @@ -1636,7 +1635,7 @@ void cv::ocl::convolve(const oclMat &x, const oclMat &t, oclMat &y) CV_Assert(t.depth() == CV_32F); CV_Assert(x.type() == y.type() && x.size() == y.size()); y.create(x.size(), x.type()); - string kernelName = "convolve"; + std::string kernelName = "convolve"; convolve_run(x, t, y, kernelName, &imgproc_convolve); } diff --git a/modules/ocl/src/initialization.cpp b/modules/ocl/src/initialization.cpp index 5d4adfceb..7abc89f64 100644 --- a/modules/ocl/src/initialization.cpp +++ b/modules/ocl/src/initialization.cpp @@ -52,9 +52,6 @@ using namespace cv; using namespace cv::ocl; -using namespace std; -using std::cout; -using std::endl; //#define PRINT_KERNEL_RUN_TIME #define RUN_TIMES 100 @@ -70,7 +67,7 @@ namespace cv * Strictly, this is not a cache because we do not implement evictions right now. * We shall add such features to trade-off memory consumption and performance when necessary. */ - auto_ptr ProgramCache::programCache; + std::auto_ptr ProgramCache::programCache; ProgramCache *programCache = NULL; ProgramCache::ProgramCache() { @@ -83,9 +80,9 @@ namespace cv releaseProgram(); } - cl_program ProgramCache::progLookup(string srcsign) + cl_program ProgramCache::progLookup(std::string srcsign) { - map::iterator iter; + std::map::iterator iter; iter = codeCache.find(srcsign); if(iter != codeCache.end()) return iter->second; @@ -93,17 +90,17 @@ namespace cv return NULL; } - void ProgramCache::addProgram(string srcsign , cl_program program) + void ProgramCache::addProgram(std::string srcsign , cl_program program) { if(!progLookup(srcsign)) { - codeCache.insert(map::value_type(srcsign, program)); + codeCache.insert(std::map::value_type(srcsign, program)); } } void ProgramCache::releaseProgram() { - map::iterator iter; + std::map::iterator iter; for(iter = codeCache.begin(); iter != codeCache.end(); iter++) { openCLSafeCall(clReleaseProgram(iter->second)); @@ -246,7 +243,7 @@ namespace cv extends_set[EXT_LEN - 1] = 0; memset(oclinfo.impl->extra_options, 0, 512); oclinfo.impl->double_support = 0; - int fp64_khr = string(extends_set).find("cl_khr_fp64"); + int fp64_khr = std::string(extends_set).find("cl_khr_fp64"); if(fp64_khr >= 0 && fp64_khr < EXT_LEN) { @@ -379,7 +376,7 @@ namespace cv { openCLSafeCall(clReleaseMemObject((cl_mem)devPtr)); } - cl_kernel openCLGetKernelFromSource(const Context *clCxt, const char **source, string kernelName) + cl_kernel openCLGetKernelFromSource(const Context *clCxt, const char **source, std::string kernelName) { return openCLGetKernelFromSource(clCxt, source, kernelName, NULL); } @@ -419,15 +416,15 @@ namespace cv return 1; } - cl_kernel openCLGetKernelFromSource(const Context *clCxt, const char **source, string kernelName, + cl_kernel openCLGetKernelFromSource(const Context *clCxt, const char **source, std::string kernelName, const char *build_options) { cl_kernel kernel; cl_program program ; cl_int status = 0; - stringstream src_sign; - string srcsign; - string filename; + std::stringstream src_sign; + std::string srcsign; + std::string filename; CV_Assert(programCache != NULL); if(NULL != build_options) @@ -508,14 +505,14 @@ namespace cv clCxt->impl->devices, CL_PROGRAM_BUILD_LOG, buildLogSize, buildLog, &buildLogSize); if(logStatus != CL_SUCCESS) - cout << "Failed to build the program and get the build info." << endl; + std::cout << "Failed to build the program and get the build info." << std::endl; buildLog = new char[buildLogSize]; CV_DbgAssert(!!buildLog); memset(buildLog, 0, buildLogSize); openCLSafeCall(clGetProgramBuildInfo(program, clCxt->impl->devices, CL_PROGRAM_BUILD_LOG, buildLogSize, buildLog, NULL)); - cout << "\n\t\t\tBUILD LOG\n"; - cout << buildLog << endl; + std::cout << "\n\t\t\tBUILD LOG\n"; + std::cout << buildLog << std::endl; delete [] buildLog; } openCLVerifyCall(status); @@ -524,7 +521,7 @@ namespace cv if( (programCache->cacheSize += 1) < programCache->MAX_PROG_CACHE_SIZE) programCache->addProgram(srcsign, program); else - cout << "Warning: code cache has been full.\n"; + std::cout << "Warning: code cache has been full.\n"; } kernel = clCreateKernel(program, kernelName.c_str(), &status); openCLVerifyCall(status); @@ -547,14 +544,14 @@ namespace cv static double total_execute_time = 0; static double total_kernel_time = 0; #endif - void openCLExecuteKernel_(Context *clCxt , const char **source, string kernelName, size_t globalThreads[3], - size_t localThreads[3], vector< pair > &args, int channels, + void openCLExecuteKernel_(Context *clCxt , const char **source, std::string kernelName, size_t globalThreads[3], + size_t localThreads[3], std::vector< std::pair > &args, int channels, int depth, const char *build_options) { //construct kernel name //The rule is functionName_Cn_Dn, C represent Channels, D Represent DataType Depth, n represent an integer number //for exmaple split_C2_D2, represent the split kernel with channels =2 and dataType Depth = 2(Data type is char) - stringstream idxStr; + std::stringstream idxStr; if(channels != -1) idxStr << "_C" << channels; if(depth != -1) @@ -601,9 +598,9 @@ namespace cv execute_time = (double)(end_time - start_time) / (1000 * 1000); total_time = (double)(end_time - queue_time) / (1000 * 1000); - // cout << setiosflags(ios::left) << setw(15) << execute_time; - // cout << setiosflags(ios::left) << setw(15) << total_time - execute_time; - // cout << setiosflags(ios::left) << setw(15) << total_time << endl; + // std::cout << setiosflags(ios::left) << setw(15) << execute_time; + // std::cout << setiosflags(ios::left) << setw(15) << total_time - execute_time; + // std::cout << setiosflags(ios::left) << setw(15) << total_time << std::endl; total_execute_time += execute_time; total_kernel_time += total_time; @@ -614,57 +611,57 @@ namespace cv openCLSafeCall(clReleaseKernel(kernel)); } - void openCLExecuteKernel(Context *clCxt , const char **source, string kernelName, + void openCLExecuteKernel(Context *clCxt , const char **source, std::string kernelName, size_t globalThreads[3], size_t localThreads[3], - vector< pair > &args, int channels, int depth) + std::vector< std::pair > &args, int channels, int depth) { openCLExecuteKernel(clCxt, source, kernelName, globalThreads, localThreads, args, channels, depth, NULL); } - void openCLExecuteKernel(Context *clCxt , const char **source, string kernelName, + void openCLExecuteKernel(Context *clCxt , const char **source, std::string kernelName, size_t globalThreads[3], size_t localThreads[3], - vector< pair > &args, int channels, int depth, const char *build_options) + std::vector< std::pair > &args, int channels, int depth, const char *build_options) { #ifndef PRINT_KERNEL_RUN_TIME openCLExecuteKernel_(clCxt, source, kernelName, globalThreads, localThreads, args, channels, depth, build_options); #else - string data_type[] = { "uchar", "char", "ushort", "short", "int", "float", "double"}; - cout << endl; - cout << "Function Name: " << kernelName; + std::string data_type[] = { "uchar", "char", "ushort", "short", "int", "float", "double"}; + std::cout << std::endl; + std::cout << "Function Name: " << kernelName; if(depth >= 0) - cout << " |data type: " << data_type[depth]; - cout << " |channels: " << channels; - cout << " |Time Unit: " << "ms" << endl; + std::cout << " |data type: " << data_type[depth]; + std::cout << " |channels: " << channels; + std::cout << " |Time Unit: " << "ms" << std::endl; total_execute_time = 0; total_kernel_time = 0; - cout << "-------------------------------------" << endl; + std::cout << "-------------------------------------" << std::endl; - cout << setiosflags(ios::left) << setw(15) << "excute time"; - cout << setiosflags(ios::left) << setw(15) << "lauch time"; - cout << setiosflags(ios::left) << setw(15) << "kernel time" << endl; + std::cout << setiosflags(ios::left) << setw(15) << "excute time"; + std::cout << setiosflags(ios::left) << setw(15) << "lauch time"; + std::cout << setiosflags(ios::left) << setw(15) << "kernel time" << std::endl; int i = 0; for(i = 0; i < RUN_TIMES; i++) openCLExecuteKernel_(clCxt, source, kernelName, globalThreads, localThreads, args, channels, depth, build_options); - cout << "average kernel excute time: " << total_execute_time / RUN_TIMES << endl; // "ms" << endl; - cout << "average kernel total time: " << total_kernel_time / RUN_TIMES << endl; // "ms" << endl; + std::cout << "average kernel excute time: " << total_execute_time / RUN_TIMES << std::endl; // "ms" << std::endl; + std::cout << "average kernel total time: " << total_kernel_time / RUN_TIMES << std::endl; // "ms" << std::endl; #endif } - double openCLExecuteKernelInterop(Context *clCxt , const char **source, string kernelName, + double openCLExecuteKernelInterop(Context *clCxt , const char **source, std::string kernelName, size_t globalThreads[3], size_t localThreads[3], - vector< pair > &args, int channels, int depth, const char *build_options, + std::vector< std::pair > &args, int channels, int depth, const char *build_options, bool finish, bool measureKernelTime, bool cleanUp) { //construct kernel name //The rule is functionName_Cn_Dn, C represent Channels, D Represent DataType Depth, n represent an integer number //for exmaple split_C2_D2, represent the split kernel with channels =2 and dataType Depth = 2(Data type is char) - stringstream idxStr; + std::stringstream idxStr; if(channels != -1) idxStr << "_C" << channels; if(depth != -1) @@ -763,9 +760,9 @@ namespace cv return -1; } - double openCLExecuteKernelInterop(Context *clCxt , const char **fileName, const int numFiles, string kernelName, + double openCLExecuteKernelInterop(Context *clCxt , const char **fileName, const int numFiles, std::string kernelName, size_t globalThreads[3], size_t localThreads[3], - vector< pair > &args, int channels, int depth, const char *build_options, + std::vector< std::pair > &args, int channels, int depth, const char *build_options, bool finish, bool measureKernelTime, bool cleanUp) { @@ -803,7 +800,7 @@ namespace cv } /////////////////////////////OpenCL initialization///////////////// - auto_ptr Context::clCxt; + std::auto_ptr Context::clCxt; int Context::val = 0; Mutex cs; Context *Context::getContext() diff --git a/modules/ocl/src/interpolate_frames.cpp b/modules/ocl/src/interpolate_frames.cpp index 6b9f53b85..4a7c43652 100644 --- a/modules/ocl/src/interpolate_frames.cpp +++ b/modules/ocl/src/interpolate_frames.cpp @@ -46,7 +46,6 @@ #include #include "precomp.hpp" -using namespace std; using namespace cv; using namespace cv::ocl; @@ -133,17 +132,17 @@ void cv::ocl::interpolateFrames(const oclMat &frame0, const oclMat &frame1, void interpolate::memsetKernel(float val, oclMat &img, int height, int offset) { Context *clCxt = Context::getContext(); - string kernelName = "memsetKernel"; - vector< pair > args; + std::string kernelName = "memsetKernel"; + std::vector< std::pair > args; int step = img.step / sizeof(float); offset = step * height * offset; - args.push_back( make_pair( sizeof(cl_float), (void *)&val)); - args.push_back( make_pair( sizeof(cl_mem), (void *)&img.data)); - args.push_back( make_pair( sizeof(cl_int), (void *)&img.cols)); - args.push_back( make_pair( sizeof(cl_int), (void *)&height)); - args.push_back( make_pair( sizeof(cl_int), (void *)&step)); - args.push_back( make_pair( sizeof(cl_int), (void *)&offset)); + args.push_back( std::make_pair( sizeof(cl_float), (void *)&val)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&img.data)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&img.cols)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&height)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&step)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&offset)); size_t globalThreads[3] = {img.cols, height, 1}; size_t localThreads[3] = {16, 16, 1}; @@ -152,18 +151,18 @@ void interpolate::memsetKernel(float val, oclMat &img, int height, int offset) void interpolate::normalizeKernel(oclMat &buffer, int height, int factor_offset, int dst_offset) { Context *clCxt = Context::getContext(); - string kernelName = "normalizeKernel"; - vector< pair > args; + std::string kernelName = "normalizeKernel"; + std::vector< std::pair > args; int step = buffer.step / sizeof(float); factor_offset = step * height * factor_offset; dst_offset = step * height * dst_offset; - args.push_back( make_pair( sizeof(cl_mem), (void *)&buffer.data)); - args.push_back( make_pair( sizeof(cl_int), (void *)&buffer.cols)); - args.push_back( make_pair( sizeof(cl_int), (void *)&height)); - args.push_back( make_pair( sizeof(cl_int), (void *)&step)); - args.push_back( make_pair( sizeof(cl_int), (void *)&factor_offset)); - args.push_back( make_pair( sizeof(cl_int), (void *)&dst_offset)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&buffer.data)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&buffer.cols)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&height)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&step)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&factor_offset)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dst_offset)); size_t globalThreads[3] = {buffer.cols, height, 1}; size_t localThreads[3] = {16, 16, 1}; @@ -174,25 +173,25 @@ void interpolate::forwardWarpKernel(const oclMat &src, oclMat &buffer, const ocl int b_offset, int d_offset) { Context *clCxt = Context::getContext(); - string kernelName = "forwardWarpKernel"; - vector< pair > args; + std::string kernelName = "forwardWarpKernel"; + std::vector< std::pair > args; int f_step = u.step / sizeof(float); // flow step int b_step = buffer.step / sizeof(float); b_offset = b_step * src.rows * b_offset; d_offset = b_step * src.rows * d_offset; - args.push_back( make_pair( sizeof(cl_mem), (void *)&src.data)); - args.push_back( make_pair( sizeof(cl_mem), (void *)&buffer.data)); - args.push_back( make_pair( sizeof(cl_mem), (void *)&u.data)); - args.push_back( make_pair( sizeof(cl_mem), (void *)&v.data)); - args.push_back( make_pair( sizeof(cl_int), (void *)&src.cols)); - args.push_back( make_pair( sizeof(cl_int), (void *)&src.rows)); - args.push_back( make_pair( sizeof(cl_int), (void *)&f_step)); - args.push_back( make_pair( sizeof(cl_int), (void *)&b_step)); - args.push_back( make_pair( sizeof(cl_int), (void *)&b_offset)); - args.push_back( make_pair( sizeof(cl_int), (void *)&d_offset)); - args.push_back( make_pair( sizeof(cl_float), (void *)&time_scale)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&src.data)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&buffer.data)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&u.data)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&v.data)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src.cols)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src.rows)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&f_step)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&b_step)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&b_offset)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&d_offset)); + args.push_back( std::make_pair( sizeof(cl_float), (void *)&time_scale)); size_t globalThreads[3] = {src.cols, src.rows, 1}; size_t localThreads[3] = {16, 16, 1}; @@ -212,17 +211,17 @@ void interpolate::blendFrames(const oclMat &frame0, const oclMat &/*frame1*/, co int step = buffer.step / sizeof(float); Context *clCxt = Context::getContext(); - string kernelName = "blendFramesKernel"; - vector< pair > args; + std::string kernelName = "blendFramesKernel"; + std::vector< std::pair > args; - args.push_back( make_pair( sizeof(cl_mem), (void *)&tex_src0)); - args.push_back( make_pair( sizeof(cl_mem), (void *)&tex_src1)); - args.push_back( make_pair( sizeof(cl_mem), (void *)&buffer.data)); - args.push_back( make_pair( sizeof(cl_mem), (void *)&newFrame.data)); - args.push_back( make_pair( sizeof(cl_int), (void *)&frame0.cols)); - args.push_back( make_pair( sizeof(cl_int), (void *)&frame0.rows)); - args.push_back( make_pair( sizeof(cl_int), (void *)&step)); - args.push_back( make_pair( sizeof(cl_float), (void *)&pos)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&tex_src0)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&tex_src1)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&buffer.data)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&newFrame.data)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&frame0.cols)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&frame0.rows)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&step)); + args.push_back( std::make_pair( sizeof(cl_float), (void *)&pos)); size_t globalThreads[3] = {frame0.cols, frame0.rows, 1}; size_t localThreads[3] = {16, 16, 1}; diff --git a/modules/ocl/src/match_template.cpp b/modules/ocl/src/match_template.cpp index ab867d4d3..9d20f5204 100644 --- a/modules/ocl/src/match_template.cpp +++ b/modules/ocl/src/match_template.cpp @@ -49,7 +49,6 @@ using namespace cv; using namespace cv::ocl; -using namespace std; //helper routines namespace cv @@ -140,20 +139,20 @@ namespace cv unsigned long long templ_sqsum = (unsigned long long)sqrSum(templ.reshape(1))[0]; Context *clCxt = image.clCxt; - string kernelName = "matchTemplate_Prepared_SQDIFF_NORMED"; - vector< pair > args; + std::string kernelName = "matchTemplate_Prepared_SQDIFF_NORMED"; + std::vector< std::pair > args; - args.push_back( make_pair( sizeof(cl_mem), (void *)&buf.image_sums[0].data)); - args.push_back( make_pair( sizeof(cl_mem), (void *)&result.data)); - args.push_back( make_pair( sizeof(cl_ulong), (void *)&templ_sqsum)); - args.push_back( make_pair( sizeof(cl_int), (void *)&result.rows)); - args.push_back( make_pair( sizeof(cl_int), (void *)&result.cols)); - args.push_back( make_pair( sizeof(cl_int), (void *)&templ.rows)); - args.push_back( make_pair( sizeof(cl_int), (void *)&templ.cols)); - args.push_back( make_pair( sizeof(cl_int), (void *)&buf.image_sums[0].offset)); - args.push_back( make_pair( sizeof(cl_int), (void *)&buf.image_sums[0].step)); - args.push_back( make_pair( sizeof(cl_int), (void *)&result.offset)); - args.push_back( make_pair( sizeof(cl_int), (void *)&result.step)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&buf.image_sums[0].data)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&result.data)); + args.push_back( std::make_pair( sizeof(cl_ulong), (void *)&templ_sqsum)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&result.rows)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&result.cols)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&templ.rows)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&templ.cols)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&buf.image_sums[0].offset)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&buf.image_sums[0].step)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&result.offset)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&result.step)); size_t globalThreads[3] = {result.cols, result.rows, 1}; size_t localThreads[3] = {32, 8, 1}; @@ -170,25 +169,25 @@ namespace cv CV_Assert(result.rows == image.rows - templ.rows + 1 && result.cols == image.cols - templ.cols + 1); Context *clCxt = image.clCxt; - string kernelName = "matchTemplate_Naive_SQDIFF"; + std::string kernelName = "matchTemplate_Naive_SQDIFF"; - vector< pair > args; + std::vector< std::pair > args; - args.push_back( make_pair( sizeof(cl_mem), (void *)&image.data)); - args.push_back( make_pair( sizeof(cl_mem), (void *)&templ.data)); - args.push_back( make_pair( sizeof(cl_mem), (void *)&result.data)); - args.push_back( make_pair( sizeof(cl_int), (void *)&image.rows)); - args.push_back( make_pair( sizeof(cl_int), (void *)&image.cols)); - args.push_back( make_pair( sizeof(cl_int), (void *)&templ.rows)); - args.push_back( make_pair( sizeof(cl_int), (void *)&templ.cols)); - args.push_back( make_pair( sizeof(cl_int), (void *)&result.rows)); - args.push_back( make_pair( sizeof(cl_int), (void *)&result.cols)); - args.push_back( make_pair( sizeof(cl_int), (void *)&image.offset)); - args.push_back( make_pair( sizeof(cl_int), (void *)&templ.offset)); - args.push_back( make_pair( sizeof(cl_int), (void *)&result.offset)); - args.push_back( make_pair( sizeof(cl_int), (void *)&image.step)); - args.push_back( make_pair( sizeof(cl_int), (void *)&templ.step)); - args.push_back( make_pair( sizeof(cl_int), (void *)&result.step)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&image.data)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&templ.data)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&result.data)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&image.rows)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&image.cols)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&templ.rows)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&templ.cols)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&result.rows)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&result.cols)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&image.offset)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&templ.offset)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&result.offset)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&image.step)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&templ.step)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&result.step)); size_t globalThreads[3] = {result.cols, result.rows, 1}; size_t localThreads[3] = {32, 8, 1}; @@ -233,20 +232,20 @@ namespace cv unsigned long long templ_sqsum = (unsigned long long)sqrSum(templ.reshape(1))[0]; Context *clCxt = image.clCxt; - string kernelName = "normalizeKernel"; - vector< pair > args; + std::string kernelName = "normalizeKernel"; + std::vector< std::pair > args; - args.push_back( make_pair( sizeof(cl_mem), (void *)&buf.image_sqsums[0].data)); - args.push_back( make_pair( sizeof(cl_mem), (void *)&result.data)); - args.push_back( make_pair( sizeof(cl_ulong), (void *)&templ_sqsum)); - args.push_back( make_pair( sizeof(cl_int), (void *)&result.rows)); - args.push_back( make_pair( sizeof(cl_int), (void *)&result.cols)); - args.push_back( make_pair( sizeof(cl_int), (void *)&templ.rows)); - args.push_back( make_pair( sizeof(cl_int), (void *)&templ.cols)); - args.push_back( make_pair( sizeof(cl_int), (void *)&buf.image_sqsums[0].offset)); - args.push_back( make_pair( sizeof(cl_int), (void *)&buf.image_sqsums[0].step)); - args.push_back( make_pair( sizeof(cl_int), (void *)&result.offset)); - args.push_back( make_pair( sizeof(cl_int), (void *)&result.step)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&buf.image_sqsums[0].data)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&result.data)); + args.push_back( std::make_pair( sizeof(cl_ulong), (void *)&templ_sqsum)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&result.rows)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&result.cols)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&templ.rows)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&templ.cols)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&buf.image_sqsums[0].offset)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&buf.image_sqsums[0].step)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&result.offset)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&result.step)); size_t globalThreads[3] = {result.cols, result.rows, 1}; size_t localThreads[3] = {32, 8, 1}; @@ -263,25 +262,25 @@ namespace cv CV_Assert(result.rows == image.rows - templ.rows + 1 && result.cols == image.cols - templ.cols + 1); Context *clCxt = image.clCxt; - string kernelName = "matchTemplate_Naive_CCORR"; + std::string kernelName = "matchTemplate_Naive_CCORR"; - vector< pair > args; + std::vector< std::pair > args; - args.push_back( make_pair( sizeof(cl_mem), (void *)&image.data)); - args.push_back( make_pair( sizeof(cl_mem), (void *)&templ.data)); - args.push_back( make_pair( sizeof(cl_mem), (void *)&result.data)); - args.push_back( make_pair( sizeof(cl_int), (void *)&image.rows)); - args.push_back( make_pair( sizeof(cl_int), (void *)&image.cols)); - args.push_back( make_pair( sizeof(cl_int), (void *)&templ.rows)); - args.push_back( make_pair( sizeof(cl_int), (void *)&templ.cols)); - args.push_back( make_pair( sizeof(cl_int), (void *)&result.rows)); - args.push_back( make_pair( sizeof(cl_int), (void *)&result.cols)); - args.push_back( make_pair( sizeof(cl_int), (void *)&image.offset)); - args.push_back( make_pair( sizeof(cl_int), (void *)&templ.offset)); - args.push_back( make_pair( sizeof(cl_int), (void *)&result.offset)); - args.push_back( make_pair( sizeof(cl_int), (void *)&image.step)); - args.push_back( make_pair( sizeof(cl_int), (void *)&templ.step)); - args.push_back( make_pair( sizeof(cl_int), (void *)&result.step)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&image.data)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&templ.data)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&result.data)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&image.rows)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&image.cols)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&templ.rows)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&templ.cols)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&result.rows)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&result.cols)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&image.offset)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&templ.offset)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&result.offset)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&image.step)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&templ.step)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&result.step)); size_t globalThreads[3] = {result.cols, result.rows, 1}; size_t localThreads[3] = {32, 8, 1}; @@ -297,22 +296,22 @@ namespace cv matchTemplate_CCORR(image, templ, result, buf); Context *clCxt = image.clCxt; - string kernelName; + std::string kernelName; kernelName = "matchTemplate_Prepared_CCOFF"; size_t globalThreads[3] = {result.cols, result.rows, 1}; size_t localThreads[3] = {32, 8, 1}; - vector< pair > args; - args.push_back( make_pair( sizeof(cl_mem), (void *)&result.data) ); - args.push_back( make_pair( sizeof(cl_int), (void *)&image.rows) ); - args.push_back( make_pair( sizeof(cl_int), (void *)&image.cols) ); - args.push_back( make_pair( sizeof(cl_int), (void *)&templ.rows) ); - args.push_back( make_pair( sizeof(cl_int), (void *)&templ.cols) ); - args.push_back( make_pair( sizeof(cl_int), (void *)&result.rows) ); - args.push_back( make_pair( sizeof(cl_int), (void *)&result.cols) ); - args.push_back( make_pair( sizeof(cl_int), (void *)&result.offset)); - args.push_back( make_pair( sizeof(cl_int), (void *)&result.step)); + std::vector< std::pair > args; + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&result.data) ); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&image.rows) ); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&image.cols) ); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&templ.rows) ); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&templ.cols) ); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&result.rows) ); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&result.cols) ); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&result.offset)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&result.step)); // to be continued in the following section if(image.oclchannels() == 1) { @@ -321,10 +320,10 @@ namespace cv float templ_sum = 0; templ_sum = (float)sum(templ)[0] / templ.size().area(); - args.push_back( make_pair( sizeof(cl_mem), (void *)&buf.image_sums[0].data) ); - args.push_back( make_pair( sizeof(cl_int), (void *)&buf.image_sums[0].offset) ); - args.push_back( make_pair( sizeof(cl_int), (void *)&buf.image_sums[0].step) ); - args.push_back( make_pair( sizeof(cl_float), (void *)&templ_sum) ); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&buf.image_sums[0].data) ); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&buf.image_sums[0].offset) ); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&buf.image_sums[0].step) ); + args.push_back( std::make_pair( sizeof(cl_float), (void *)&templ_sum) ); } else { @@ -341,16 +340,16 @@ namespace cv switch(image.oclchannels()) { case 4: - args.push_back( make_pair( sizeof(cl_mem), (void *)&buf.image_sums[0].data) ); - args.push_back( make_pair( sizeof(cl_mem), (void *)&buf.image_sums[1].data) ); - args.push_back( make_pair( sizeof(cl_mem), (void *)&buf.image_sums[2].data) ); - args.push_back( make_pair( sizeof(cl_mem), (void *)&buf.image_sums[3].data) ); - args.push_back( make_pair( sizeof(cl_int), (void *)&buf.image_sums[0].offset) ); - args.push_back( make_pair( sizeof(cl_int), (void *)&buf.image_sums[0].step) ); - args.push_back( make_pair( sizeof(cl_float), (void *)&templ_sum[0]) ); - args.push_back( make_pair( sizeof(cl_float), (void *)&templ_sum[1]) ); - args.push_back( make_pair( sizeof(cl_float), (void *)&templ_sum[2]) ); - args.push_back( make_pair( sizeof(cl_float), (void *)&templ_sum[3]) ); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&buf.image_sums[0].data) ); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&buf.image_sums[1].data) ); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&buf.image_sums[2].data) ); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&buf.image_sums[3].data) ); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&buf.image_sums[0].offset) ); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&buf.image_sums[0].step) ); + args.push_back( std::make_pair( sizeof(cl_float), (void *)&templ_sum[0]) ); + args.push_back( std::make_pair( sizeof(cl_float), (void *)&templ_sum[1]) ); + args.push_back( std::make_pair( sizeof(cl_float), (void *)&templ_sum[2]) ); + args.push_back( std::make_pair( sizeof(cl_float), (void *)&templ_sum[3]) ); break; default: CV_Error(CV_StsBadArg, "matchTemplate: unsupported number of channels"); @@ -370,23 +369,23 @@ namespace cv float scale = 1.f / templ.size().area(); Context *clCxt = image.clCxt; - string kernelName; + std::string kernelName; kernelName = "matchTemplate_Prepared_CCOFF_NORMED"; size_t globalThreads[3] = {result.cols, result.rows, 1}; size_t localThreads[3] = {32, 8, 1}; - vector< pair > args; - args.push_back( make_pair( sizeof(cl_mem), (void *)&result.data) ); - args.push_back( make_pair( sizeof(cl_int), (void *)&image.rows) ); - args.push_back( make_pair( sizeof(cl_int), (void *)&image.cols) ); - args.push_back( make_pair( sizeof(cl_int), (void *)&templ.rows) ); - args.push_back( make_pair( sizeof(cl_int), (void *)&templ.cols) ); - args.push_back( make_pair( sizeof(cl_int), (void *)&result.rows) ); - args.push_back( make_pair( sizeof(cl_int), (void *)&result.cols) ); - args.push_back( make_pair( sizeof(cl_int), (void *)&result.offset)); - args.push_back( make_pair( sizeof(cl_int), (void *)&result.step)); - args.push_back( make_pair( sizeof(cl_float), (void *)&scale) ); + std::vector< std::pair > args; + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&result.data) ); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&image.rows) ); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&image.cols) ); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&templ.rows) ); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&templ.cols) ); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&result.rows) ); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&result.cols) ); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&result.offset)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&result.step)); + args.push_back( std::make_pair( sizeof(cl_float), (void *)&scale) ); // to be continued in the following section if(image.oclchannels() == 1) { @@ -402,14 +401,14 @@ namespace cv templ_sqsum -= scale * templ_sum * templ_sum; templ_sum *= scale; - args.push_back( make_pair( sizeof(cl_mem), (void *)&buf.image_sums[0].data) ); - args.push_back( make_pair( sizeof(cl_int), (void *)&buf.image_sums[0].offset) ); - args.push_back( make_pair( sizeof(cl_int), (void *)&buf.image_sums[0].step) ); - args.push_back( make_pair( sizeof(cl_mem), (void *)&buf.image_sqsums[0].data) ); - args.push_back( make_pair( sizeof(cl_int), (void *)&buf.image_sqsums[0].offset) ); - args.push_back( make_pair( sizeof(cl_int), (void *)&buf.image_sqsums[0].step) ); - args.push_back( make_pair( sizeof(cl_float), (void *)&templ_sum) ); - args.push_back( make_pair( sizeof(cl_float), (void *)&templ_sqsum) ); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&buf.image_sums[0].data) ); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&buf.image_sums[0].offset) ); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&buf.image_sums[0].step) ); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&buf.image_sqsums[0].data) ); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&buf.image_sqsums[0].offset) ); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&buf.image_sqsums[0].step) ); + args.push_back( std::make_pair( sizeof(cl_float), (void *)&templ_sum) ); + args.push_back( std::make_pair( sizeof(cl_float), (void *)&templ_sqsum) ); } else { @@ -440,23 +439,23 @@ namespace cv switch(image.oclchannels()) { case 4: - args.push_back( make_pair( sizeof(cl_mem), (void *)&buf.image_sums[0].data) ); - args.push_back( make_pair( sizeof(cl_mem), (void *)&buf.image_sums[1].data) ); - args.push_back( make_pair( sizeof(cl_mem), (void *)&buf.image_sums[2].data) ); - args.push_back( make_pair( sizeof(cl_mem), (void *)&buf.image_sums[3].data) ); - args.push_back( make_pair( sizeof(cl_int), (void *)&buf.image_sums[0].offset) ); - args.push_back( make_pair( sizeof(cl_int), (void *)&buf.image_sums[0].step) ); - args.push_back( make_pair( sizeof(cl_mem), (void *)&buf.image_sqsums[0].data) ); - args.push_back( make_pair( sizeof(cl_mem), (void *)&buf.image_sqsums[1].data) ); - args.push_back( make_pair( sizeof(cl_mem), (void *)&buf.image_sqsums[2].data) ); - args.push_back( make_pair( sizeof(cl_mem), (void *)&buf.image_sqsums[3].data) ); - args.push_back( make_pair( sizeof(cl_int), (void *)&buf.image_sqsums[0].offset) ); - args.push_back( make_pair( sizeof(cl_int), (void *)&buf.image_sqsums[0].step) ); - args.push_back( make_pair( sizeof(cl_float), (void *)&templ_sum[0]) ); - args.push_back( make_pair( sizeof(cl_float), (void *)&templ_sum[1]) ); - args.push_back( make_pair( sizeof(cl_float), (void *)&templ_sum[2]) ); - args.push_back( make_pair( sizeof(cl_float), (void *)&templ_sum[3]) ); - args.push_back( make_pair( sizeof(cl_float), (void *)&templ_sqsum_sum) ); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&buf.image_sums[0].data) ); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&buf.image_sums[1].data) ); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&buf.image_sums[2].data) ); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&buf.image_sums[3].data) ); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&buf.image_sums[0].offset) ); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&buf.image_sums[0].step) ); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&buf.image_sqsums[0].data) ); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&buf.image_sqsums[1].data) ); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&buf.image_sqsums[2].data) ); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&buf.image_sqsums[3].data) ); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&buf.image_sqsums[0].offset) ); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&buf.image_sqsums[0].step) ); + args.push_back( std::make_pair( sizeof(cl_float), (void *)&templ_sum[0]) ); + args.push_back( std::make_pair( sizeof(cl_float), (void *)&templ_sum[1]) ); + args.push_back( std::make_pair( sizeof(cl_float), (void *)&templ_sum[2]) ); + args.push_back( std::make_pair( sizeof(cl_float), (void *)&templ_sum[3]) ); + args.push_back( std::make_pair( sizeof(cl_float), (void *)&templ_sqsum_sum) ); break; default: CV_Error(CV_StsBadArg, "matchTemplate: unsupported number of channels"); diff --git a/modules/ocl/src/matrix_operations.cpp b/modules/ocl/src/matrix_operations.cpp index f0e65f9cc..9fdf9c60e 100644 --- a/modules/ocl/src/matrix_operations.cpp +++ b/modules/ocl/src/matrix_operations.cpp @@ -52,7 +52,6 @@ using namespace cv; using namespace cv::ocl; -using namespace std; //////////////////////////////////////////////////////////////////////// //////////////////////////////// oclMat //////////////////////////////// @@ -79,7 +78,7 @@ static void convert_C3C4(const cl_mem &src, oclMat &dst) int dstStep_in_pixel = dst.step1() / dst.oclchannels(); int pixel_end = dst.wholecols * dst.wholerows - 1; Context *clCxt = dst.clCxt; - string kernelName = "convertC3C4"; + std::string kernelName = "convertC3C4"; char compile_option[32]; switch(dst.depth()) { @@ -107,13 +106,13 @@ static void convert_C3C4(const cl_mem &src, oclMat &dst) default: CV_Error(CV_StsUnsupportedFormat, "unknown depth"); } - vector< pair > args; - args.push_back( make_pair( sizeof(cl_mem), (void *)&src)); - args.push_back( make_pair( sizeof(cl_mem), (void *)&dst.data)); - args.push_back( make_pair( sizeof(cl_int), (void *)&dst.wholecols)); - args.push_back( make_pair( sizeof(cl_int), (void *)&dst.wholerows)); - args.push_back( make_pair( sizeof(cl_int), (void *)&dstStep_in_pixel)); - args.push_back( make_pair( sizeof(cl_int), (void *)&pixel_end)); + std::vector< std::pair > args; + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&src)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&dst.data)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dst.wholecols)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dst.wholerows)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dstStep_in_pixel)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&pixel_end)); size_t globalThreads[3] = {((dst.wholecols * dst.wholerows + 3) / 4 + 255) / 256 * 256, 1, 1}; size_t localThreads[3] = {256, 1, 1}; @@ -127,7 +126,7 @@ static void convert_C4C3(const oclMat &src, cl_mem &dst) int srcStep_in_pixel = src.step1() / src.oclchannels(); int pixel_end = src.wholecols * src.wholerows - 1; Context *clCxt = src.clCxt; - string kernelName = "convertC4C3"; + std::string kernelName = "convertC4C3"; char compile_option[32]; switch(src.depth()) { @@ -156,13 +155,13 @@ static void convert_C4C3(const oclMat &src, cl_mem &dst) CV_Error(CV_StsUnsupportedFormat, "unknown depth"); } - vector< pair > args; - args.push_back( make_pair( sizeof(cl_mem), (void *)&src.data)); - args.push_back( make_pair( sizeof(cl_mem), (void *)&dst)); - args.push_back( make_pair( sizeof(cl_int), (void *)&src.wholecols)); - args.push_back( make_pair( sizeof(cl_int), (void *)&src.wholerows)); - args.push_back( make_pair( sizeof(cl_int), (void *)&srcStep_in_pixel)); - args.push_back( make_pair( sizeof(cl_int), (void *)&pixel_end)); + std::vector< std::pair > args; + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&src.data)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&dst)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src.wholecols)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src.wholerows)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&srcStep_in_pixel)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&pixel_end)); size_t globalThreads[3] = {((src.wholecols * src.wholerows + 3) / 4 + 255) / 256 * 256, 1, 1}; size_t localThreads[3] = {256, 1, 1}; @@ -284,13 +283,13 @@ inline int divUp(int total, int grain) /////////////////////////////////////////////////////////////////////////// ////////////////////////////////// CopyTo ///////////////////////////////// /////////////////////////////////////////////////////////////////////////// -static void copy_to_with_mask(const oclMat &src, oclMat &dst, const oclMat &mask, string kernelName) +static void copy_to_with_mask(const oclMat &src, oclMat &dst, const oclMat &mask, std::string kernelName) { CV_DbgAssert( dst.rows == mask.rows && dst.cols == mask.cols && src.rows == dst.rows && src.cols == dst.cols && mask.type() == CV_8UC1); - vector > args; + std::vector > args; std::string string_types[4][7] = {{"uchar", "char", "ushort", "short", "int", "float", "double"}, {"uchar2", "char2", "ushort2", "short2", "int2", "float2", "double2"}, @@ -309,17 +308,17 @@ static void copy_to_with_mask(const oclMat &src, oclMat &dst, const oclMat &mask int dststep_in_pixel = dst.step / dst.elemSize(), dstoffset_in_pixel = dst.offset / dst.elemSize(); int srcstep_in_pixel = src.step / src.elemSize(), srcoffset_in_pixel = src.offset / src.elemSize(); - args.push_back( make_pair( sizeof(cl_mem) , (void *)&src.data )); - args.push_back( make_pair( sizeof(cl_mem) , (void *)&dst.data )); - args.push_back( make_pair( sizeof(cl_mem) , (void *)&mask.data )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&src.cols )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&src.rows )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&srcstep_in_pixel )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&srcoffset_in_pixel )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&dststep_in_pixel )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&dstoffset_in_pixel )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&mask.step )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&mask.offset )); + args.push_back( std::make_pair( sizeof(cl_mem) , (void *)&src.data )); + args.push_back( std::make_pair( sizeof(cl_mem) , (void *)&dst.data )); + args.push_back( std::make_pair( sizeof(cl_mem) , (void *)&mask.data )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&src.cols )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&src.rows )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&srcstep_in_pixel )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&srcoffset_in_pixel )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&dststep_in_pixel )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&dstoffset_in_pixel )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&mask.step )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&mask.offset )); openCLExecuteKernel(dst.clCxt , &operator_copyToM, kernelName, globalThreads, localThreads, args, -1, -1, compile_option); @@ -351,13 +350,13 @@ void cv::ocl::oclMat::copyTo( oclMat &mat, const oclMat &mask) const /////////////////////////////////////////////////////////////////////////// static void convert_run(const oclMat &src, oclMat &dst, double alpha, double beta) { - string kernelName = "convert_to_S"; - stringstream idxStr; + std::string kernelName = "convert_to_S"; + std::stringstream idxStr; idxStr << src.depth(); kernelName += idxStr.str(); float alpha_f = alpha, beta_f = beta; CV_DbgAssert(src.rows == dst.rows && src.cols == dst.cols); - vector > args; + std::vector > args; size_t localThreads[3] = {16, 16, 1}; size_t globalThreads[3]; globalThreads[0] = (dst.cols + localThreads[0] - 1) / localThreads[0] * localThreads[0]; @@ -369,16 +368,16 @@ static void convert_run(const oclMat &src, oclMat &dst, double alpha, double bet { globalThreads[0] = ((dst.cols + 4) / 4 + localThreads[0]) / localThreads[0] * localThreads[0]; } - args.push_back( make_pair( sizeof(cl_mem) , (void *)&src.data )); - args.push_back( make_pair( sizeof(cl_mem) , (void *)&dst.data )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&src.cols )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&src.rows )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&srcstep_in_pixel )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&srcoffset_in_pixel )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&dststep_in_pixel )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&dstoffset_in_pixel )); - args.push_back( make_pair( sizeof(cl_float) , (void *)&alpha_f )); - args.push_back( make_pair( sizeof(cl_float) , (void *)&beta_f )); + args.push_back( std::make_pair( sizeof(cl_mem) , (void *)&src.data )); + args.push_back( std::make_pair( sizeof(cl_mem) , (void *)&dst.data )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&src.cols )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&src.rows )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&srcstep_in_pixel )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&srcoffset_in_pixel )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&dststep_in_pixel )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&dstoffset_in_pixel )); + args.push_back( std::make_pair( sizeof(cl_float) , (void *)&alpha_f )); + args.push_back( std::make_pair( sizeof(cl_float) , (void *)&beta_f )); openCLExecuteKernel(dst.clCxt , &operator_convertTo, kernelName, globalThreads, localThreads, args, dst.oclchannels(), dst.depth()); } @@ -420,9 +419,9 @@ oclMat &cv::ocl::oclMat::operator = (const Scalar &s) setTo(s); return *this; } -static void set_to_withoutmask_run(const oclMat &dst, const Scalar &scalar, string kernelName) +static void set_to_withoutmask_run(const oclMat &dst, const Scalar &scalar, std::string kernelName) { - vector > args; + std::vector > args; size_t localThreads[3] = {16, 16, 1}; size_t globalThreads[3]; @@ -456,11 +455,11 @@ static void set_to_withoutmask_run(const oclMat &dst, const Scalar &scalar, stri { case 1: sprintf(compile_option, "-D GENTYPE=uchar"); - args.push_back( make_pair( sizeof(cl_uchar) , (void *)&val.uval.s[0] )); + args.push_back( std::make_pair( sizeof(cl_uchar) , (void *)&val.uval.s[0] )); break; case 4: sprintf(compile_option, "-D GENTYPE=uchar4"); - args.push_back( make_pair( sizeof(cl_uchar4) , (void *)&val.uval )); + args.push_back( std::make_pair( sizeof(cl_uchar4) , (void *)&val.uval )); break; default: CV_Error(CV_StsUnsupportedFormat, "unsupported channels"); @@ -475,11 +474,11 @@ static void set_to_withoutmask_run(const oclMat &dst, const Scalar &scalar, stri { case 1: sprintf(compile_option, "-D GENTYPE=char"); - args.push_back( make_pair( sizeof(cl_char) , (void *)&val.cval.s[0] )); + args.push_back( std::make_pair( sizeof(cl_char) , (void *)&val.cval.s[0] )); break; case 4: sprintf(compile_option, "-D GENTYPE=char4"); - args.push_back( make_pair( sizeof(cl_char4) , (void *)&val.cval )); + args.push_back( std::make_pair( sizeof(cl_char4) , (void *)&val.cval )); break; default: CV_Error(CV_StsUnsupportedFormat, "unsupported channels"); @@ -494,11 +493,11 @@ static void set_to_withoutmask_run(const oclMat &dst, const Scalar &scalar, stri { case 1: sprintf(compile_option, "-D GENTYPE=ushort"); - args.push_back( make_pair( sizeof(cl_ushort) , (void *)&val.usval.s[0] )); + args.push_back( std::make_pair( sizeof(cl_ushort) , (void *)&val.usval.s[0] )); break; case 4: sprintf(compile_option, "-D GENTYPE=ushort4"); - args.push_back( make_pair( sizeof(cl_ushort4) , (void *)&val.usval )); + args.push_back( std::make_pair( sizeof(cl_ushort4) , (void *)&val.usval )); break; default: CV_Error(CV_StsUnsupportedFormat, "unsupported channels"); @@ -513,11 +512,11 @@ static void set_to_withoutmask_run(const oclMat &dst, const Scalar &scalar, stri { case 1: sprintf(compile_option, "-D GENTYPE=short"); - args.push_back( make_pair( sizeof(cl_short) , (void *)&val.shval.s[0] )); + args.push_back( std::make_pair( sizeof(cl_short) , (void *)&val.shval.s[0] )); break; case 4: sprintf(compile_option, "-D GENTYPE=short4"); - args.push_back( make_pair( sizeof(cl_short4) , (void *)&val.shval )); + args.push_back( std::make_pair( sizeof(cl_short4) , (void *)&val.shval )); break; default: CV_Error(CV_StsUnsupportedFormat, "unsupported channels"); @@ -532,18 +531,18 @@ static void set_to_withoutmask_run(const oclMat &dst, const Scalar &scalar, stri { case 1: sprintf(compile_option, "-D GENTYPE=int"); - args.push_back( make_pair( sizeof(cl_int) , (void *)&val.ival.s[0] )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&val.ival.s[0] )); break; case 2: sprintf(compile_option, "-D GENTYPE=int2"); cl_int2 i2val; i2val.s[0] = val.ival.s[0]; i2val.s[1] = val.ival.s[1]; - args.push_back( make_pair( sizeof(cl_int2) , (void *)&i2val )); + args.push_back( std::make_pair( sizeof(cl_int2) , (void *)&i2val )); break; case 4: sprintf(compile_option, "-D GENTYPE=int4"); - args.push_back( make_pair( sizeof(cl_int4) , (void *)&val.ival )); + args.push_back( std::make_pair( sizeof(cl_int4) , (void *)&val.ival )); break; default: CV_Error(CV_StsUnsupportedFormat, "unsupported channels"); @@ -558,11 +557,11 @@ static void set_to_withoutmask_run(const oclMat &dst, const Scalar &scalar, stri { case 1: sprintf(compile_option, "-D GENTYPE=float"); - args.push_back( make_pair( sizeof(cl_float) , (void *)&val.fval.s[0] )); + args.push_back( std::make_pair( sizeof(cl_float) , (void *)&val.fval.s[0] )); break; case 4: sprintf(compile_option, "-D GENTYPE=float4"); - args.push_back( make_pair( sizeof(cl_float4) , (void *)&val.fval )); + args.push_back( std::make_pair( sizeof(cl_float4) , (void *)&val.fval )); break; default: CV_Error(CV_StsUnsupportedFormat, "unsupported channels"); @@ -577,11 +576,11 @@ static void set_to_withoutmask_run(const oclMat &dst, const Scalar &scalar, stri { case 1: sprintf(compile_option, "-D GENTYPE=double"); - args.push_back( make_pair( sizeof(cl_double) , (void *)&val.dval.s[0] )); + args.push_back( std::make_pair( sizeof(cl_double) , (void *)&val.dval.s[0] )); break; case 4: sprintf(compile_option, "-D GENTYPE=double4"); - args.push_back( make_pair( sizeof(cl_double4) , (void *)&val.dval )); + args.push_back( std::make_pair( sizeof(cl_double4) , (void *)&val.dval )); break; default: CV_Error(CV_StsUnsupportedFormat, "unsupported channels"); @@ -597,29 +596,29 @@ static void set_to_withoutmask_run(const oclMat &dst, const Scalar &scalar, stri } else { - args.push_back( make_pair( sizeof(cl_mem) , (void *)&dst.data )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&dst.cols )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&dst.rows )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&step_in_pixel )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&offset_in_pixel)); + args.push_back( std::make_pair( sizeof(cl_mem) , (void *)&dst.data )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&dst.cols )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&dst.rows )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&step_in_pixel )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&offset_in_pixel)); openCLExecuteKernel(dst.clCxt , &operator_setTo, kernelName, globalThreads, localThreads, args, -1, -1, compile_option); } #else - args.push_back( make_pair( sizeof(cl_mem) , (void *)&dst.data )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&dst.cols )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&dst.rows )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&step_in_pixel )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&offset_in_pixel)); + args.push_back( std::make_pair( sizeof(cl_mem) , (void *)&dst.data )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&dst.cols )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&dst.rows )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&step_in_pixel )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&offset_in_pixel)); openCLExecuteKernel(dst.clCxt , &operator_setTo, kernelName, globalThreads, localThreads, args, -1, -1, compile_option); #endif } -static void set_to_withmask_run(const oclMat &dst, const Scalar &scalar, const oclMat &mask, string kernelName) +static void set_to_withmask_run(const oclMat &dst, const Scalar &scalar, const oclMat &mask, std::string kernelName) { CV_DbgAssert( dst.rows == mask.rows && dst.cols == mask.cols); - vector > args; + std::vector > args; size_t localThreads[3] = {16, 16, 1}; size_t globalThreads[3]; globalThreads[0] = (dst.cols + localThreads[0] - 1) / localThreads[0] * localThreads[0]; @@ -648,11 +647,11 @@ static void set_to_withmask_run(const oclMat &dst, const Scalar &scalar, const o { case 1: sprintf(compile_option, "-D GENTYPE=uchar"); - args.push_back( make_pair( sizeof(cl_uchar) , (void *)&val.uval.s[0] )); + args.push_back( std::make_pair( sizeof(cl_uchar) , (void *)&val.uval.s[0] )); break; case 4: sprintf(compile_option, "-D GENTYPE=uchar4"); - args.push_back( make_pair( sizeof(cl_uchar4) , (void *)&val.uval )); + args.push_back( std::make_pair( sizeof(cl_uchar4) , (void *)&val.uval )); break; default: CV_Error(CV_StsUnsupportedFormat, "unsupported channels"); @@ -667,11 +666,11 @@ static void set_to_withmask_run(const oclMat &dst, const Scalar &scalar, const o { case 1: sprintf(compile_option, "-D GENTYPE=char"); - args.push_back( make_pair( sizeof(cl_char) , (void *)&val.cval.s[0] )); + args.push_back( std::make_pair( sizeof(cl_char) , (void *)&val.cval.s[0] )); break; case 4: sprintf(compile_option, "-D GENTYPE=char4"); - args.push_back( make_pair( sizeof(cl_char4) , (void *)&val.cval )); + args.push_back( std::make_pair( sizeof(cl_char4) , (void *)&val.cval )); break; default: CV_Error(CV_StsUnsupportedFormat, "unsupported channels"); @@ -686,11 +685,11 @@ static void set_to_withmask_run(const oclMat &dst, const Scalar &scalar, const o { case 1: sprintf(compile_option, "-D GENTYPE=ushort"); - args.push_back( make_pair( sizeof(cl_ushort) , (void *)&val.usval.s[0] )); + args.push_back( std::make_pair( sizeof(cl_ushort) , (void *)&val.usval.s[0] )); break; case 4: sprintf(compile_option, "-D GENTYPE=ushort4"); - args.push_back( make_pair( sizeof(cl_ushort4) , (void *)&val.usval )); + args.push_back( std::make_pair( sizeof(cl_ushort4) , (void *)&val.usval )); break; default: CV_Error(CV_StsUnsupportedFormat, "unsupported channels"); @@ -705,11 +704,11 @@ static void set_to_withmask_run(const oclMat &dst, const Scalar &scalar, const o { case 1: sprintf(compile_option, "-D GENTYPE=short"); - args.push_back( make_pair( sizeof(cl_short) , (void *)&val.shval.s[0] )); + args.push_back( std::make_pair( sizeof(cl_short) , (void *)&val.shval.s[0] )); break; case 4: sprintf(compile_option, "-D GENTYPE=short4"); - args.push_back( make_pair( sizeof(cl_short4) , (void *)&val.shval )); + args.push_back( std::make_pair( sizeof(cl_short4) , (void *)&val.shval )); break; default: CV_Error(CV_StsUnsupportedFormat, "unsupported channels"); @@ -724,11 +723,11 @@ static void set_to_withmask_run(const oclMat &dst, const Scalar &scalar, const o { case 1: sprintf(compile_option, "-D GENTYPE=int"); - args.push_back( make_pair( sizeof(cl_int) , (void *)&val.ival.s[0] )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&val.ival.s[0] )); break; case 4: sprintf(compile_option, "-D GENTYPE=int4"); - args.push_back( make_pair( sizeof(cl_int4) , (void *)&val.ival )); + args.push_back( std::make_pair( sizeof(cl_int4) , (void *)&val.ival )); break; default: CV_Error(CV_StsUnsupportedFormat, "unsupported channels"); @@ -743,11 +742,11 @@ static void set_to_withmask_run(const oclMat &dst, const Scalar &scalar, const o { case 1: sprintf(compile_option, "-D GENTYPE=float"); - args.push_back( make_pair( sizeof(cl_float) , (void *)&val.fval.s[0] )); + args.push_back( std::make_pair( sizeof(cl_float) , (void *)&val.fval.s[0] )); break; case 4: sprintf(compile_option, "-D GENTYPE=float4"); - args.push_back( make_pair( sizeof(cl_float4) , (void *)&val.fval )); + args.push_back( std::make_pair( sizeof(cl_float4) , (void *)&val.fval )); break; default: CV_Error(CV_StsUnsupportedFormat, "unsupported channels"); @@ -762,11 +761,11 @@ static void set_to_withmask_run(const oclMat &dst, const Scalar &scalar, const o { case 1: sprintf(compile_option, "-D GENTYPE=double"); - args.push_back( make_pair( sizeof(cl_double) , (void *)&val.dval.s[0] )); + args.push_back( std::make_pair( sizeof(cl_double) , (void *)&val.dval.s[0] )); break; case 4: sprintf(compile_option, "-D GENTYPE=double4"); - args.push_back( make_pair( sizeof(cl_double4) , (void *)&val.dval )); + args.push_back( std::make_pair( sizeof(cl_double4) , (void *)&val.dval )); break; default: CV_Error(CV_StsUnsupportedFormat, "unsupported channels"); @@ -775,14 +774,14 @@ static void set_to_withmask_run(const oclMat &dst, const Scalar &scalar, const o default: CV_Error(CV_StsUnsupportedFormat, "unknown depth"); } - args.push_back( make_pair( sizeof(cl_mem) , (void *)&dst.data )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&dst.cols )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&dst.rows )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&step_in_pixel )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&offset_in_pixel )); - args.push_back( make_pair( sizeof(cl_mem) , (void *)&mask.data )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&mask.step )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&mask.offset )); + args.push_back( std::make_pair( sizeof(cl_mem) , (void *)&dst.data )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&dst.cols )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&dst.rows )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&step_in_pixel )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&offset_in_pixel )); + args.push_back( std::make_pair( sizeof(cl_mem) , (void *)&mask.data )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&mask.step )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&mask.offset )); openCLExecuteKernel(dst.clCxt , &operator_setToM, kernelName, globalThreads, localThreads, args, -1, -1, compile_option); } diff --git a/modules/ocl/src/mcwutil.cpp b/modules/ocl/src/mcwutil.cpp index 32bb8f678..85686029d 100644 --- a/modules/ocl/src/mcwutil.cpp +++ b/modules/ocl/src/mcwutil.cpp @@ -50,10 +50,6 @@ #define CL_VERSION_1_2 0 #endif -using namespace std; - - - namespace cv { namespace ocl @@ -65,14 +61,14 @@ namespace cv } // provide additional methods for the user to interact with the command queue after a task is fired - static void openCLExecuteKernel_2(Context *clCxt , const char **source, string kernelName, size_t globalThreads[3], - size_t localThreads[3], vector< pair > &args, int channels, + static void openCLExecuteKernel_2(Context *clCxt , const char **source, std::string kernelName, size_t globalThreads[3], + size_t localThreads[3], std::vector< std::pair > &args, int channels, int depth, char *build_options, FLUSH_MODE finish_mode) { //construct kernel name //The rule is functionName_Cn_Dn, C represent Channels, D Represent DataType Depth, n represent an integer number //for exmaple split_C2_D2, represent the split kernel with channels =2 and dataType Depth = 2(Data type is char) - stringstream idxStr; + std::stringstream idxStr; if(channels != -1) idxStr << "_C" << channels; if(depth != -1) @@ -111,16 +107,16 @@ namespace cv openCLSafeCall(clReleaseKernel(kernel)); } - void openCLExecuteKernel2(Context *clCxt , const char **source, string kernelName, + void openCLExecuteKernel2(Context *clCxt , const char **source, std::string kernelName, size_t globalThreads[3], size_t localThreads[3], - vector< pair > &args, int channels, int depth, FLUSH_MODE finish_mode) + std::vector< std::pair > &args, int channels, int depth, FLUSH_MODE finish_mode) { openCLExecuteKernel2(clCxt, source, kernelName, globalThreads, localThreads, args, channels, depth, NULL, finish_mode); } - void openCLExecuteKernel2(Context *clCxt , const char **source, string kernelName, + void openCLExecuteKernel2(Context *clCxt , const char **source, std::string kernelName, size_t globalThreads[3], size_t localThreads[3], - vector< pair > &args, int channels, int depth, char *build_options, FLUSH_MODE finish_mode) + std::vector< std::pair > &args, int channels, int depth, char *build_options, FLUSH_MODE finish_mode) { openCLExecuteKernel_2(clCxt, source, kernelName, globalThreads, localThreads, args, channels, depth, diff --git a/modules/ocl/src/mcwutil.hpp b/modules/ocl/src/mcwutil.hpp index d1986b93b..91b08db7f 100644 --- a/modules/ocl/src/mcwutil.hpp +++ b/modules/ocl/src/mcwutil.hpp @@ -47,7 +47,6 @@ #define _OPENCV_MCWUTIL_ #include "precomp.hpp" -using namespace std; namespace cv { @@ -59,10 +58,10 @@ namespace cv CLFLUSH, DISABLE }; - void openCLExecuteKernel2(Context *clCxt , const char **source, string kernelName, size_t globalThreads[3], - size_t localThreads[3], vector< pair > &args, int channels, int depth, FLUSH_MODE finish_mode = DISABLE); - void openCLExecuteKernel2(Context *clCxt , const char **source, string kernelName, size_t globalThreads[3], - size_t localThreads[3], vector< pair > &args, int channels, + void openCLExecuteKernel2(Context *clCxt , const char **source, std::string kernelName, size_t globalThreads[3], + size_t localThreads[3], std::vector< std::pair > &args, int channels, int depth, FLUSH_MODE finish_mode = DISABLE); + void openCLExecuteKernel2(Context *clCxt , const char **source, std::string kernelName, size_t globalThreads[3], + size_t localThreads[3], std::vector< std::pair > &args, int channels, int depth, char *build_options, FLUSH_MODE finish_mode = DISABLE); // bind oclMat to OpenCL image textures // note: diff --git a/modules/ocl/src/mssegmentation.cpp b/modules/ocl/src/mssegmentation.cpp index 300265bc2..83248a1a6 100644 --- a/modules/ocl/src/mssegmentation.cpp +++ b/modules/ocl/src/mssegmentation.cpp @@ -44,8 +44,6 @@ #include "precomp.hpp" -using namespace std; - // Auxiliray stuff namespace { @@ -61,9 +59,9 @@ namespace int find(int elem); int merge(int set1, int set2); - vector parent; - vector rank; - vector size; + std::vector parent; + std::vector rank; + std::vector size; private: DjSets(const DjSets &) {} DjSets operator =(const DjSets &); @@ -90,8 +88,8 @@ namespace void addEdge(int from, int to, const T &val = T()); - vector start; - vector edges; + std::vector start; + std::vector edges; int numv; int nume_max; @@ -330,7 +328,7 @@ namespace cv } } - vector edges; + std::vector edges; edges.reserve(g.numv); // Prepare edges connecting differnet components @@ -359,7 +357,7 @@ namespace cv // Compute sum of the pixel's colors which are in the same segment Mat h_src = src; - vector sumcols(nrows * ncols, Vec4i(0, 0, 0, 0)); + std::vector sumcols(nrows * ncols, Vec4i(0, 0, 0, 0)); for (int y = 0; y < nrows; ++y) { Vec4b *h_srcy = h_src.ptr(y); diff --git a/modules/ocl/src/precomp.hpp b/modules/ocl/src/precomp.hpp index f65621f41..085f00b4b 100644 --- a/modules/ocl/src/precomp.hpp +++ b/modules/ocl/src/precomp.hpp @@ -86,8 +86,6 @@ #include "safe_call.hpp" -using namespace std; - namespace cv { namespace ocl @@ -105,19 +103,19 @@ namespace cv cl_mem openCLCreateBuffer(Context *clCxt, size_t flag, size_t size); void openCLReadBuffer(Context *clCxt, cl_mem dst_buffer, void *host_buffer, size_t size); cl_kernel openCLGetKernelFromSource(const Context *clCxt, - const char **source, string kernelName); + const char **source, std::string kernelName); cl_kernel openCLGetKernelFromSource(const Context *clCxt, - const char **source, string kernelName, const char *build_options); + const char **source, std::string kernelName, const char *build_options); void openCLVerifyKernel(const Context *clCxt, cl_kernel kernel, size_t *localThreads); - void openCLExecuteKernel(Context *clCxt , const char **source, string kernelName, vector< std::pair > &args, + void openCLExecuteKernel(Context *clCxt , const char **source, std::string kernelName, std::vector< std::pair > &args, int globalcols , int globalrows, size_t blockSize = 16, int kernel_expand_depth = -1, int kernel_expand_channel = -1); - void openCLExecuteKernel_(Context *clCxt , const char **source, string kernelName, + void openCLExecuteKernel_(Context *clCxt , const char **source, std::string kernelName, size_t globalThreads[3], size_t localThreads[3], - vector< pair > &args, int channels, int depth, const char *build_options); - void openCLExecuteKernel(Context *clCxt , const char **source, string kernelName, size_t globalThreads[3], - size_t localThreads[3], vector< pair > &args, int channels, int depth); - void openCLExecuteKernel(Context *clCxt , const char **source, string kernelName, size_t globalThreads[3], - size_t localThreads[3], vector< pair > &args, int channels, + std::vector< std::pair > &args, int channels, int depth, const char *build_options); + void openCLExecuteKernel(Context *clCxt , const char **source, std::string kernelName, size_t globalThreads[3], + size_t localThreads[3], std::vector< std::pair > &args, int channels, int depth); + void openCLExecuteKernel(Context *clCxt , const char **source, std::string kernelName, size_t globalThreads[3], + size_t localThreads[3], std::vector< std::pair > &args, int channels, int depth, const char *build_options); cl_mem load_constant(cl_context context, cl_command_queue command_queue, const void *value, @@ -134,7 +132,7 @@ namespace cv cl_context clContext; cl_command_queue clCmdQueue; cl_device_id devices; - string devName; + std::string devName; cl_uint maxDimensions; size_t maxWorkGroupSize; size_t maxWorkItemSizes[4]; @@ -142,7 +140,7 @@ namespace cv int double_support; //extra options to recognize vendor specific fp64 extensions char extra_options[512]; - string Binpath; + std::string Binpath; }; } } diff --git a/modules/ocl/src/pyrdown.cpp b/modules/ocl/src/pyrdown.cpp index 96be69b45..6cd7cf5d4 100644 --- a/modules/ocl/src/pyrdown.cpp +++ b/modules/ocl/src/pyrdown.cpp @@ -48,10 +48,6 @@ using namespace cv; using namespace cv::ocl; -using namespace std; - -using std::cout; -using std::endl; namespace cv { @@ -76,7 +72,7 @@ static void pyrdown_run(const oclMat &src, const oclMat &dst) //int channels = dst.channels(); //int depth = dst.depth(); - string kernelName = "pyrDown"; + std::string kernelName = "pyrDown"; //int vector_lengths[4][7] = {{4, 0, 4, 4, 1, 1, 1}, // {4, 0, 4, 4, 1, 1, 1}, @@ -91,14 +87,14 @@ static void pyrdown_run(const oclMat &src, const oclMat &dst) size_t globalThreads[3] = { src.cols, dst.rows, 1}; //int dst_step1 = dst.cols * dst.elemSize(); - vector > args; - args.push_back( make_pair( sizeof(cl_mem), (void *)&src.data )); - args.push_back( make_pair( sizeof(cl_int), (void *)&src.step )); - args.push_back( make_pair( sizeof(cl_int), (void *)&src.rows)); - args.push_back( make_pair( sizeof(cl_int), (void *)&src.cols)); - args.push_back( make_pair( sizeof(cl_mem), (void *)&dst.data )); - args.push_back( make_pair( sizeof(cl_int), (void *)&dst.step )); - args.push_back( make_pair( sizeof(cl_int), (void *)&dst.cols)); + std::vector > args; + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&src.data )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src.step )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src.rows)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src.cols)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&dst.data )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dst.step )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dst.cols)); openCLExecuteKernel(clCxt, &pyr_down, kernelName, globalThreads, localThreads, args, src.oclchannels(), src.depth()); } diff --git a/modules/ocl/src/pyrlk.cpp b/modules/ocl/src/pyrlk.cpp index d4dbfd506..a42e696a7 100644 --- a/modules/ocl/src/pyrlk.cpp +++ b/modules/ocl/src/pyrlk.cpp @@ -48,7 +48,6 @@ #include "precomp.hpp" #include "mcwutil.hpp" -using namespace std; using namespace cv; using namespace cv::ocl; @@ -116,13 +115,13 @@ inline int divUp(int total, int grain) /////////////////////////////////////////////////////////////////////////// static void convert_run_cus(const oclMat &src, oclMat &dst, double alpha, double beta) { - string kernelName = "convert_to_S"; - stringstream idxStr; + std::string kernelName = "convert_to_S"; + std::stringstream idxStr; idxStr << src.depth(); kernelName += idxStr.str(); float alpha_f = (float)alpha, beta_f = (float)beta; CV_DbgAssert(src.rows == dst.rows && src.cols == dst.cols); - vector > args; + std::vector > args; size_t localThreads[3] = {16, 16, 1}; size_t globalThreads[3]; globalThreads[0] = (dst.cols + localThreads[0] - 1) / localThreads[0] * localThreads[0]; @@ -134,16 +133,16 @@ static void convert_run_cus(const oclMat &src, oclMat &dst, double alpha, double { globalThreads[0] = ((dst.cols + 4) / 4 + localThreads[0]) / localThreads[0] * localThreads[0]; } - args.push_back( make_pair( sizeof(cl_mem) , (void *)&src.data )); - args.push_back( make_pair( sizeof(cl_mem) , (void *)&dst.data )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&src.cols )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&src.rows )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&srcstep_in_pixel )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&srcoffset_in_pixel )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&dststep_in_pixel )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&dstoffset_in_pixel )); - args.push_back( make_pair( sizeof(cl_float) , (void *)&alpha_f )); - args.push_back( make_pair( sizeof(cl_float) , (void *)&beta_f )); + args.push_back( std::make_pair( sizeof(cl_mem) , (void *)&src.data )); + args.push_back( std::make_pair( sizeof(cl_mem) , (void *)&dst.data )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&src.cols )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&src.rows )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&srcstep_in_pixel )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&srcoffset_in_pixel )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&dststep_in_pixel )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&dstoffset_in_pixel )); + args.push_back( std::make_pair( sizeof(cl_float) , (void *)&alpha_f )); + args.push_back( std::make_pair( sizeof(cl_float) , (void *)&beta_f )); openCLExecuteKernel2(dst.clCxt , &operator_convertTo, kernelName, globalThreads, localThreads, args, dst.oclchannels(), dst.depth(), CLFLUSH); } @@ -185,9 +184,9 @@ void convertTo( const oclMat &src, oclMat &dst, int rtype, double alpha, double // setTo(s); // return *this; //} -static void set_to_withoutmask_run_cus(const oclMat &dst, const Scalar &scalar, string kernelName) +static void set_to_withoutmask_run_cus(const oclMat &dst, const Scalar &scalar, std::string kernelName) { - vector > args; + std::vector > args; size_t localThreads[3] = {16, 16, 1}; size_t globalThreads[3]; @@ -221,11 +220,11 @@ static void set_to_withoutmask_run_cus(const oclMat &dst, const Scalar &scalar, { case 1: sprintf(compile_option, "-D GENTYPE=uchar"); - args.push_back( make_pair( sizeof(cl_uchar) , (void *)&val.uval.s[0] )); + args.push_back( std::make_pair( sizeof(cl_uchar) , (void *)&val.uval.s[0] )); break; case 4: sprintf(compile_option, "-D GENTYPE=uchar4"); - args.push_back( make_pair( sizeof(cl_uchar4) , (void *)&val.uval )); + args.push_back( std::make_pair( sizeof(cl_uchar4) , (void *)&val.uval )); break; default: CV_Error(CV_StsUnsupportedFormat, "unsupported channels"); @@ -240,11 +239,11 @@ static void set_to_withoutmask_run_cus(const oclMat &dst, const Scalar &scalar, { case 1: sprintf(compile_option, "-D GENTYPE=char"); - args.push_back( make_pair( sizeof(cl_char) , (void *)&val.cval.s[0] )); + args.push_back( std::make_pair( sizeof(cl_char) , (void *)&val.cval.s[0] )); break; case 4: sprintf(compile_option, "-D GENTYPE=char4"); - args.push_back( make_pair( sizeof(cl_char4) , (void *)&val.cval )); + args.push_back( std::make_pair( sizeof(cl_char4) , (void *)&val.cval )); break; default: CV_Error(CV_StsUnsupportedFormat, "unsupported channels"); @@ -259,11 +258,11 @@ static void set_to_withoutmask_run_cus(const oclMat &dst, const Scalar &scalar, { case 1: sprintf(compile_option, "-D GENTYPE=ushort"); - args.push_back( make_pair( sizeof(cl_ushort) , (void *)&val.usval.s[0] )); + args.push_back( std::make_pair( sizeof(cl_ushort) , (void *)&val.usval.s[0] )); break; case 4: sprintf(compile_option, "-D GENTYPE=ushort4"); - args.push_back( make_pair( sizeof(cl_ushort4) , (void *)&val.usval )); + args.push_back( std::make_pair( sizeof(cl_ushort4) , (void *)&val.usval )); break; default: CV_Error(CV_StsUnsupportedFormat, "unsupported channels"); @@ -278,11 +277,11 @@ static void set_to_withoutmask_run_cus(const oclMat &dst, const Scalar &scalar, { case 1: sprintf(compile_option, "-D GENTYPE=short"); - args.push_back( make_pair( sizeof(cl_short) , (void *)&val.shval.s[0] )); + args.push_back( std::make_pair( sizeof(cl_short) , (void *)&val.shval.s[0] )); break; case 4: sprintf(compile_option, "-D GENTYPE=short4"); - args.push_back( make_pair( sizeof(cl_short4) , (void *)&val.shval )); + args.push_back( std::make_pair( sizeof(cl_short4) , (void *)&val.shval )); break; default: CV_Error(CV_StsUnsupportedFormat, "unsupported channels"); @@ -297,18 +296,18 @@ static void set_to_withoutmask_run_cus(const oclMat &dst, const Scalar &scalar, { case 1: sprintf(compile_option, "-D GENTYPE=int"); - args.push_back( make_pair( sizeof(cl_int) , (void *)&val.ival.s[0] )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&val.ival.s[0] )); break; case 2: sprintf(compile_option, "-D GENTYPE=int2"); cl_int2 i2val; i2val.s[0] = val.ival.s[0]; i2val.s[1] = val.ival.s[1]; - args.push_back( make_pair( sizeof(cl_int2) , (void *)&i2val )); + args.push_back( std::make_pair( sizeof(cl_int2) , (void *)&i2val )); break; case 4: sprintf(compile_option, "-D GENTYPE=int4"); - args.push_back( make_pair( sizeof(cl_int4) , (void *)&val.ival )); + args.push_back( std::make_pair( sizeof(cl_int4) , (void *)&val.ival )); break; default: CV_Error(CV_StsUnsupportedFormat, "unsupported channels"); @@ -323,11 +322,11 @@ static void set_to_withoutmask_run_cus(const oclMat &dst, const Scalar &scalar, { case 1: sprintf(compile_option, "-D GENTYPE=float"); - args.push_back( make_pair( sizeof(cl_float) , (void *)&val.fval.s[0] )); + args.push_back( std::make_pair( sizeof(cl_float) , (void *)&val.fval.s[0] )); break; case 4: sprintf(compile_option, "-D GENTYPE=float4"); - args.push_back( make_pair( sizeof(cl_float4) , (void *)&val.fval )); + args.push_back( std::make_pair( sizeof(cl_float4) , (void *)&val.fval )); break; default: CV_Error(CV_StsUnsupportedFormat, "unsupported channels"); @@ -342,11 +341,11 @@ static void set_to_withoutmask_run_cus(const oclMat &dst, const Scalar &scalar, { case 1: sprintf(compile_option, "-D GENTYPE=double"); - args.push_back( make_pair( sizeof(cl_double) , (void *)&val.dval.s[0] )); + args.push_back( std::make_pair( sizeof(cl_double) , (void *)&val.dval.s[0] )); break; case 4: sprintf(compile_option, "-D GENTYPE=double4"); - args.push_back( make_pair( sizeof(cl_double4) , (void *)&val.dval )); + args.push_back( std::make_pair( sizeof(cl_double4) , (void *)&val.dval )); break; default: CV_Error(CV_StsUnsupportedFormat, "unsupported channels"); @@ -362,20 +361,20 @@ static void set_to_withoutmask_run_cus(const oclMat &dst, const Scalar &scalar, } else { - args.push_back( make_pair( sizeof(cl_mem) , (void *)&dst.data )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&dst.cols )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&dst.rows )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&step_in_pixel )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&offset_in_pixel)); + args.push_back( std::make_pair( sizeof(cl_mem) , (void *)&dst.data )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&dst.cols )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&dst.rows )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&step_in_pixel )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&offset_in_pixel)); openCLExecuteKernel2(dst.clCxt , &operator_setTo, kernelName, globalThreads, localThreads, args, -1, -1, compile_option, CLFLUSH); } #else - args.push_back( make_pair( sizeof(cl_mem) , (void *)&dst.data )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&dst.cols )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&dst.rows )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&step_in_pixel )); - args.push_back( make_pair( sizeof(cl_int) , (void *)&offset_in_pixel)); + args.push_back( std::make_pair( sizeof(cl_mem) , (void *)&dst.data )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&dst.cols )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&dst.rows )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&step_in_pixel )); + args.push_back( std::make_pair( sizeof(cl_int) , (void *)&offset_in_pixel)); openCLExecuteKernel2(dst.clCxt , &operator_setTo, kernelName, globalThreads, localThreads, args, -1, -1, compile_option, CLFLUSH); #endif @@ -401,13 +400,13 @@ static oclMat &setTo(oclMat &src, const Scalar &scalar) /////////////////////////////////////////////////////////////////////////// ////////////////////////////////// CopyTo ///////////////////////////////// /////////////////////////////////////////////////////////////////////////// -// static void copy_to_with_mask_cus(const oclMat &src, oclMat &dst, const oclMat &mask, string kernelName) +// static void copy_to_with_mask_cus(const oclMat &src, oclMat &dst, const oclMat &mask, std::string kernelName) // { // CV_DbgAssert( dst.rows == mask.rows && dst.cols == mask.cols && // src.rows == dst.rows && src.cols == dst.cols // && mask.type() == CV_8UC1); -// vector > args; +// std::vector > args; // std::string string_types[4][7] = {{"uchar", "char", "ushort", "short", "int", "float", "double"}, // {"uchar2", "char2", "ushort2", "short2", "int2", "float2", "double2"}, @@ -426,17 +425,17 @@ static oclMat &setTo(oclMat &src, const Scalar &scalar) // int dststep_in_pixel = dst.step / dst.elemSize(), dstoffset_in_pixel = dst.offset / dst.elemSize(); // int srcstep_in_pixel = src.step / src.elemSize(), srcoffset_in_pixel = src.offset / src.elemSize(); -// args.push_back( make_pair( sizeof(cl_mem) , (void *)&src.data )); -// args.push_back( make_pair( sizeof(cl_mem) , (void *)&dst.data )); -// args.push_back( make_pair( sizeof(cl_mem) , (void *)&mask.data )); -// args.push_back( make_pair( sizeof(cl_int) , (void *)&src.cols )); -// args.push_back( make_pair( sizeof(cl_int) , (void *)&src.rows )); -// args.push_back( make_pair( sizeof(cl_int) , (void *)&srcstep_in_pixel )); -// args.push_back( make_pair( sizeof(cl_int) , (void *)&srcoffset_in_pixel )); -// args.push_back( make_pair( sizeof(cl_int) , (void *)&dststep_in_pixel )); -// args.push_back( make_pair( sizeof(cl_int) , (void *)&dstoffset_in_pixel )); -// args.push_back( make_pair( sizeof(cl_int) , (void *)&mask.step )); -// args.push_back( make_pair( sizeof(cl_int) , (void *)&mask.offset )); +// args.push_back( std::make_pair( sizeof(cl_mem) , (void *)&src.data )); +// args.push_back( std::make_pair( sizeof(cl_mem) , (void *)&dst.data )); +// args.push_back( std::make_pair( sizeof(cl_mem) , (void *)&mask.data )); +// args.push_back( std::make_pair( sizeof(cl_int) , (void *)&src.cols )); +// args.push_back( std::make_pair( sizeof(cl_int) , (void *)&src.rows )); +// args.push_back( std::make_pair( sizeof(cl_int) , (void *)&srcstep_in_pixel )); +// args.push_back( std::make_pair( sizeof(cl_int) , (void *)&srcoffset_in_pixel )); +// args.push_back( std::make_pair( sizeof(cl_int) , (void *)&dststep_in_pixel )); +// args.push_back( std::make_pair( sizeof(cl_int) , (void *)&dstoffset_in_pixel )); +// args.push_back( std::make_pair( sizeof(cl_int) , (void *)&mask.step )); +// args.push_back( std::make_pair( sizeof(cl_int) , (void *)&mask.offset )); // openCLExecuteKernel2(dst.clCxt , &operator_copyToM, kernelName, globalThreads, // localThreads, args, -1, -1, compile_option, CLFLUSH); @@ -463,7 +462,7 @@ static void copyTo(const oclMat &src, oclMat &m ) // } // } -static void arithmetic_run(const oclMat &src1, oclMat &dst, string kernelName, const char **kernelString, void *_scalar) +static void arithmetic_run(const oclMat &src1, oclMat &dst, std::string kernelName, const char **kernelString, void *_scalar) { if(src1.clCxt -> impl -> double_support == 0 && src1.type() == CV_64F) { @@ -505,24 +504,24 @@ static void arithmetic_run(const oclMat &src1, oclMat &dst, string kernelName, c }; int dst_step1 = dst.cols * dst.elemSize(); - vector > args; - args.push_back( make_pair( sizeof(cl_mem), (void *)&src1.data )); - args.push_back( make_pair( sizeof(cl_int), (void *)&src1.step )); - args.push_back( make_pair( sizeof(cl_int), (void *)&src1.offset )); - //args.push_back( make_pair( sizeof(cl_mem), (void *)&src2.data )); - //args.push_back( make_pair( sizeof(cl_int), (void *)&src2.step )); - //args.push_back( make_pair( sizeof(cl_int), (void *)&src2.offset )); - args.push_back( make_pair( sizeof(cl_mem), (void *)&dst.data )); - args.push_back( make_pair( sizeof(cl_int), (void *)&dst.step )); - args.push_back( make_pair( sizeof(cl_int), (void *)&dst.offset )); - args.push_back( make_pair( sizeof(cl_int), (void *)&src1.rows )); - args.push_back( make_pair( sizeof(cl_int), (void *)&src1.cols )); - args.push_back( make_pair( sizeof(cl_int), (void *)&dst_step1 )); + std::vector > args; + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&src1.data )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src1.step )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src1.offset )); + //args.push_back( std::make_pair( sizeof(cl_mem), (void *)&src2.data )); + //args.push_back( std::make_pair( sizeof(cl_int), (void *)&src2.step )); + //args.push_back( std::make_pair( sizeof(cl_int), (void *)&src2.offset )); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&dst.data )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dst.step )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dst.offset )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src1.rows )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src1.cols )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dst_step1 )); //if(_scalar != NULL) //{ float scalar1 = *((float *)_scalar); - args.push_back( make_pair( sizeof(float), (float *)&scalar1 )); + args.push_back( std::make_pair( sizeof(float), (float *)&scalar1 )); //} openCLExecuteKernel2(clCxt, kernelString, kernelName, globalThreads, localThreads, args, -1, src1.depth(), CLFLUSH); @@ -541,19 +540,19 @@ static void pyrdown_run_cus(const oclMat &src, const oclMat &dst) Context *clCxt = src.clCxt; - string kernelName = "pyrDown"; + std::string kernelName = "pyrDown"; size_t localThreads[3] = { 256, 1, 1 }; size_t globalThreads[3] = { src.cols, dst.rows, 1}; - vector > args; - args.push_back( make_pair( sizeof(cl_mem), (void *)&src.data )); - args.push_back( make_pair( sizeof(cl_int), (void *)&src.step )); - args.push_back( make_pair( sizeof(cl_int), (void *)&src.rows)); - args.push_back( make_pair( sizeof(cl_int), (void *)&src.cols)); - args.push_back( make_pair( sizeof(cl_mem), (void *)&dst.data )); - args.push_back( make_pair( sizeof(cl_int), (void *)&dst.step )); - args.push_back( make_pair( sizeof(cl_int), (void *)&dst.cols)); + std::vector > args; + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&src.data )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src.step )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src.rows)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src.cols)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&dst.data )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dst.step )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dst.cols)); openCLExecuteKernel2(clCxt, &pyr_down, kernelName, globalThreads, localThreads, args, src.oclchannels(), src.depth(), CLFLUSH); } @@ -573,7 +572,7 @@ static void lkSparse_run(oclMat &I, oclMat &J, { Context *clCxt = I.clCxt; int elemCntPerRow = I.step / I.elemSize(); - string kernelName = "lkSparse"; + std::string kernelName = "lkSparse"; size_t localThreads[3] = { 8, 8, 1 }; size_t globalThreads[3] = { 8 * ptcount, 8, 1}; int cn = I.oclchannels(); @@ -587,28 +586,28 @@ static void lkSparse_run(oclMat &I, oclMat &J, calcErr = 0; } - vector > args; + std::vector > args; cl_mem ITex = bindTexture(I); cl_mem JTex = bindTexture(J); - args.push_back( make_pair( sizeof(cl_mem), (void *)&ITex )); - args.push_back( make_pair( sizeof(cl_mem), (void *)&JTex )); - args.push_back( make_pair( sizeof(cl_mem), (void *)&prevPts.data )); - args.push_back( make_pair( sizeof(cl_int), (void *)&prevPts.step )); - args.push_back( make_pair( sizeof(cl_mem), (void *)&nextPts.data )); - args.push_back( make_pair( sizeof(cl_int), (void *)&nextPts.step )); - args.push_back( make_pair( sizeof(cl_mem), (void *)&status.data )); - args.push_back( make_pair( sizeof(cl_mem), (void *)&err.data )); - args.push_back( make_pair( sizeof(cl_int), (void *)&level )); - args.push_back( make_pair( sizeof(cl_int), (void *)&I.rows )); - args.push_back( make_pair( sizeof(cl_int), (void *)&I.cols )); - args.push_back( make_pair( sizeof(cl_int), (void *)&patch.x )); - args.push_back( make_pair( sizeof(cl_int), (void *)&patch.y )); - args.push_back( make_pair( sizeof(cl_int), (void *)&cn )); - args.push_back( make_pair( sizeof(cl_int), (void *)&winSize.width )); - args.push_back( make_pair( sizeof(cl_int), (void *)&winSize.height )); - args.push_back( make_pair( sizeof(cl_int), (void *)&iters )); - args.push_back( make_pair( sizeof(cl_char), (void *)&calcErr )); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&ITex )); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&JTex )); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&prevPts.data )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&prevPts.step )); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&nextPts.data )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&nextPts.step )); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&status.data )); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&err.data )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&level )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&I.rows )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&I.cols )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&patch.x )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&patch.y )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&cn )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&winSize.width )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&winSize.height )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&iters )); + args.push_back( std::make_pair( sizeof(cl_char), (void *)&calcErr )); try { @@ -622,7 +621,7 @@ static void lkSparse_run(oclMat &I, oclMat &J, ITex = (cl_mem)I.data; JTex = (cl_mem)J.data; localThreads[1] = globalThreads[1] = 32; - args.insert( args.begin()+11, make_pair( sizeof(cl_int), (void *)&elemCntPerRow ) ); + args.insert( args.begin()+11, std::make_pair( sizeof(cl_int), (void *)&elemCntPerRow ) ); openCLExecuteKernel2(clCxt, &pyrlk_no_image, kernelName, globalThreads, localThreads, args, I.oclchannels(), I.depth(), CLFLUSH); } } @@ -724,10 +723,10 @@ static void lkDense_run(oclMat &I, oclMat &J, oclMat &u, oclMat &v, oclMat &prevU, oclMat &prevV, oclMat *err, Size winSize, int iters) { Context *clCxt = I.clCxt; - bool isImageSupported = clCxt->impl->devName.find("Intel(R) HD Graphics") == string::npos; + bool isImageSupported = clCxt->impl->devName.find("Intel(R) HD Graphics") == std::string::npos; int elemCntPerRow = I.step / I.elemSize(); - string kernelName = "lkDense"; + std::string kernelName = "lkDense"; size_t localThreads[3] = { 16, 16, 1 }; size_t globalThreads[3] = { I.cols, I.rows, 1}; @@ -761,31 +760,31 @@ static void lkDense_run(oclMat &I, oclMat &J, oclMat &u, oclMat &v, //const int patchHeight = 16 + 2 * halfWin.y; //size_t smem_size = 3 * patchWidth * patchHeight * sizeof(int); - vector > args; + std::vector > args; - args.push_back( make_pair( sizeof(cl_mem), (void *)&ITex )); - args.push_back( make_pair( sizeof(cl_mem), (void *)&JTex )); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&ITex )); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&JTex )); - args.push_back( make_pair( sizeof(cl_mem), (void *)&u.data )); - args.push_back( make_pair( sizeof(cl_int), (void *)&u.step )); - args.push_back( make_pair( sizeof(cl_mem), (void *)&v.data )); - args.push_back( make_pair( sizeof(cl_int), (void *)&v.step )); - args.push_back( make_pair( sizeof(cl_mem), (void *)&prevU.data )); - args.push_back( make_pair( sizeof(cl_int), (void *)&prevU.step )); - args.push_back( make_pair( sizeof(cl_mem), (void *)&prevV.data )); - args.push_back( make_pair( sizeof(cl_int), (void *)&prevV.step )); - args.push_back( make_pair( sizeof(cl_int), (void *)&I.rows )); - args.push_back( make_pair( sizeof(cl_int), (void *)&I.cols )); - //args.push_back( make_pair( sizeof(cl_mem), (void *)&(*err).data )); - //args.push_back( make_pair( sizeof(cl_int), (void *)&(*err).step )); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&u.data )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&u.step )); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&v.data )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&v.step )); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&prevU.data )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&prevU.step )); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&prevV.data )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&prevV.step )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&I.rows )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&I.cols )); + //args.push_back( std::make_pair( sizeof(cl_mem), (void *)&(*err).data )); + //args.push_back( std::make_pair( sizeof(cl_int), (void *)&(*err).step )); if (!isImageSupported) { - args.push_back( make_pair( sizeof(cl_int), (void *)&elemCntPerRow ) ); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&elemCntPerRow ) ); } - args.push_back( make_pair( sizeof(cl_int), (void *)&winSize.width )); - args.push_back( make_pair( sizeof(cl_int), (void *)&winSize.height )); - args.push_back( make_pair( sizeof(cl_int), (void *)&iters )); - args.push_back( make_pair( sizeof(cl_char), (void *)&calcErr )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&winSize.width )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&winSize.height )); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&iters )); + args.push_back( std::make_pair( sizeof(cl_char), (void *)&calcErr )); if (isImageSupported) { diff --git a/modules/ocl/src/pyrup.cpp b/modules/ocl/src/pyrup.cpp index fa7f73d4c..5cec5ba27 100644 --- a/modules/ocl/src/pyrup.cpp +++ b/modules/ocl/src/pyrup.cpp @@ -52,7 +52,6 @@ using namespace cv; using namespace cv::ocl; -using namespace std; namespace cv { @@ -67,17 +66,17 @@ namespace cv const std::string kernelName = "pyrUp"; - std::vector< pair > args; - args.push_back( make_pair( sizeof(cl_mem), (void *)&src.data)); - args.push_back( make_pair( sizeof(cl_mem), (void *)&dst.data)); - args.push_back( make_pair( sizeof(cl_int), (void *)&src.rows)); - args.push_back( make_pair( sizeof(cl_int), (void *)&dst.rows)); - args.push_back( make_pair( sizeof(cl_int), (void *)&src.cols)); - args.push_back( make_pair( sizeof(cl_int), (void *)&dst.cols)); - args.push_back( make_pair( sizeof(cl_int), (void *)&src.offset)); - args.push_back( make_pair( sizeof(cl_int), (void *)&dst.offset)); - args.push_back( make_pair( sizeof(cl_int), (void *)&src.step)); - args.push_back( make_pair( sizeof(cl_int), (void *)&dst.step)); + std::vector< std::pair > args; + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&src.data)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&dst.data)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src.rows)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dst.rows)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src.cols)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dst.cols)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src.offset)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dst.offset)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&src.step)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dst.step)); size_t globalThreads[3] = {dst.cols, dst.rows, 1}; size_t localThreads[3] = {16, 16, 1}; diff --git a/modules/ocl/src/split_merge.cpp b/modules/ocl/src/split_merge.cpp index e7aad4382..1916f50df 100644 --- a/modules/ocl/src/split_merge.cpp +++ b/modules/ocl/src/split_merge.cpp @@ -48,11 +48,6 @@ using namespace cv; using namespace cv::ocl; -using namespace std; - - -using std::cout; -using std::endl; //////////////////////////////////////////////////////////////////////// ///////////////// oclMat merge and split /////////////////////////////// @@ -89,7 +84,7 @@ namespace cv // int channels = mat_dst.oclchannels(); // int depth = mat_dst.depth(); - // string kernelName = "merge_vector"; + // std::string kernelName = "merge_vector"; // int indexes[4][7] = {{0, 0, 0, 0, 0, 0, 0}, // {4, 4, 2, 2, 1, 1, 1}, @@ -105,24 +100,24 @@ namespace cv // 1 // }; - // vector > args; - // args.push_back( make_pair( sizeof(cl_int), (void *)&mat_dst.rows)); - // args.push_back( make_pair( sizeof(cl_int), (void *)&cols)); - // args.push_back( make_pair( sizeof(cl_mem), (void *)&mat_dst.data)); - // args.push_back( make_pair( sizeof(cl_int), (void *)&mat_dst.step)); - // args.push_back( make_pair( sizeof(cl_mem), (void *)&mat_src[0].data)); - // args.push_back( make_pair( sizeof(cl_int), (void *)&mat_src[0].step)); - // args.push_back( make_pair( sizeof(cl_mem), (void *)&mat_src[1].data)); - // args.push_back( make_pair( sizeof(cl_int), (void *)&mat_src[1].step)); + // std::vector > args; + // args.push_back( std::make_pair( sizeof(cl_int), (void *)&mat_dst.rows)); + // args.push_back( std::make_pair( sizeof(cl_int), (void *)&cols)); + // args.push_back( std::make_pair( sizeof(cl_mem), (void *)&mat_dst.data)); + // args.push_back( std::make_pair( sizeof(cl_int), (void *)&mat_dst.step)); + // args.push_back( std::make_pair( sizeof(cl_mem), (void *)&mat_src[0].data)); + // args.push_back( std::make_pair( sizeof(cl_int), (void *)&mat_src[0].step)); + // args.push_back( std::make_pair( sizeof(cl_mem), (void *)&mat_src[1].data)); + // args.push_back( std::make_pair( sizeof(cl_int), (void *)&mat_src[1].step)); // if(n >= 3) // { - // args.push_back( make_pair( sizeof(cl_mem), (void *)&mat_src[2].data)); - // args.push_back( make_pair( sizeof(cl_int), (void *)&mat_src[2].step)); + // args.push_back( std::make_pair( sizeof(cl_mem), (void *)&mat_src[2].data)); + // args.push_back( std::make_pair( sizeof(cl_int), (void *)&mat_src[2].step)); // } // if(n >= 4) // { - // args.push_back( make_pair( sizeof(cl_mem), (void *)&mat_src[3].data)); - // args.push_back( make_pair( sizeof(cl_int), (void *)&mat_src[3].step)); + // args.push_back( std::make_pair( sizeof(cl_mem), (void *)&mat_src[3].data)); + // args.push_back( std::make_pair( sizeof(cl_int), (void *)&mat_src[3].step)); // } // openCLExecuteKernel(clCxt, &merge_mat, kernelName, globalThreads, localThreads, args, channels, depth); @@ -140,7 +135,7 @@ namespace cv int channels = mat_dst.oclchannels(); int depth = mat_dst.depth(); - string kernelName = "merge_vector"; + std::string kernelName = "merge_vector"; int vector_lengths[4][7] = {{0, 0, 0, 0, 0, 0, 0}, {2, 2, 1, 1, 1, 1, 1}, @@ -159,44 +154,44 @@ namespace cv }; int dst_step1 = mat_dst.cols * mat_dst.elemSize(); - vector > args; - args.push_back( make_pair( sizeof(cl_mem), (void *)&mat_dst.data)); - args.push_back( make_pair( sizeof(cl_int), (void *)&mat_dst.step)); - args.push_back( make_pair( sizeof(cl_int), (void *)&mat_dst.offset)); - args.push_back( make_pair( sizeof(cl_mem), (void *)&mat_src[0].data)); - args.push_back( make_pair( sizeof(cl_int), (void *)&mat_src[0].step)); - args.push_back( make_pair( sizeof(cl_int), (void *)&mat_src[0].offset)); - args.push_back( make_pair( sizeof(cl_mem), (void *)&mat_src[1].data)); - args.push_back( make_pair( sizeof(cl_int), (void *)&mat_src[1].step)); - args.push_back( make_pair( sizeof(cl_int), (void *)&mat_src[1].offset)); + std::vector > args; + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&mat_dst.data)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&mat_dst.step)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&mat_dst.offset)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&mat_src[0].data)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&mat_src[0].step)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&mat_src[0].offset)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&mat_src[1].data)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&mat_src[1].step)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&mat_src[1].offset)); if(channels == 4) { - args.push_back( make_pair( sizeof(cl_mem), (void *)&mat_src[2].data)); - args.push_back( make_pair( sizeof(cl_int), (void *)&mat_src[2].step)); - args.push_back( make_pair( sizeof(cl_int), (void *)&mat_src[2].offset)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&mat_src[2].data)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&mat_src[2].step)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&mat_src[2].offset)); // if channel == 3, then the matrix will convert to channel =4 //if(n == 3) - // args.push_back( make_pair( sizeof(cl_int), (void *)&offset_cols)); + // args.push_back( std::make_pair( sizeof(cl_int), (void *)&offset_cols)); if(n == 3) { - args.push_back( make_pair( sizeof(cl_mem), (void *)&mat_src[2].data)); - args.push_back( make_pair( sizeof(cl_int), (void *)&mat_src[2].step)); - args.push_back( make_pair( sizeof(cl_int), (void *)&mat_src[2].offset)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&mat_src[2].data)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&mat_src[2].step)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&mat_src[2].offset)); } else if( n == 4) { - args.push_back( make_pair( sizeof(cl_mem), (void *)&mat_src[3].data)); - args.push_back( make_pair( sizeof(cl_int), (void *)&mat_src[3].step)); - args.push_back( make_pair( sizeof(cl_int), (void *)&mat_src[3].offset)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&mat_src[3].data)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&mat_src[3].step)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&mat_src[3].offset)); } } - args.push_back( make_pair( sizeof(cl_int), (void *)&mat_dst.rows)); - args.push_back( make_pair( sizeof(cl_int), (void *)&cols)); - args.push_back( make_pair( sizeof(cl_int), (void *)&dst_step1)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&mat_dst.rows)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&cols)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dst_step1)); openCLExecuteKernel(clCxt, &merge_mat, kernelName, globalThreads, localThreads, args, channels, depth); } @@ -238,7 +233,7 @@ namespace cv // int channels = mat_src.oclchannels(); // int depth = mat_src.depth(); - // string kernelName = "split_vector"; + // std::string kernelName = "split_vector"; // int indexes[4][7] = {{0, 0, 0, 0, 0, 0, 0}, // {8, 8, 8, 8, 4, 4, 2}, @@ -254,24 +249,24 @@ namespace cv // 1 // }; - // vector > args; - // args.push_back( make_pair( sizeof(cl_mem), (void *)&mat_src.data)); - // args.push_back( make_pair( sizeof(cl_int), (void *)&mat_src.step)); - // args.push_back( make_pair( sizeof(cl_int), (void *)&mat_src.rows)); - // args.push_back( make_pair( sizeof(cl_int), (void *)&cols)); - // args.push_back( make_pair( sizeof(cl_mem), (void *)&mat_dst[0].data)); - // args.push_back( make_pair( sizeof(cl_int), (void *)&mat_dst[0].step)); - // args.push_back( make_pair( sizeof(cl_mem), (void *)&mat_dst[1].data)); - // args.push_back( make_pair( sizeof(cl_int), (void *)&mat_dst[1].step)); + // std::vector > args; + // args.push_back( std::make_pair( sizeof(cl_mem), (void *)&mat_src.data)); + // args.push_back( std::make_pair( sizeof(cl_int), (void *)&mat_src.step)); + // args.push_back( std::make_pair( sizeof(cl_int), (void *)&mat_src.rows)); + // args.push_back( std::make_pair( sizeof(cl_int), (void *)&cols)); + // args.push_back( std::make_pair( sizeof(cl_mem), (void *)&mat_dst[0].data)); + // args.push_back( std::make_pair( sizeof(cl_int), (void *)&mat_dst[0].step)); + // args.push_back( std::make_pair( sizeof(cl_mem), (void *)&mat_dst[1].data)); + // args.push_back( std::make_pair( sizeof(cl_int), (void *)&mat_dst[1].step)); // if(channels >= 3) // { - // args.push_back( make_pair( sizeof(cl_mem), (void *)&mat_dst[2].data)); - // args.push_back( make_pair( sizeof(cl_int), (void *)&mat_dst[2].step)); + // args.push_back( std::make_pair( sizeof(cl_mem), (void *)&mat_dst[2].data)); + // args.push_back( std::make_pair( sizeof(cl_int), (void *)&mat_dst[2].step)); // } // if(channels >= 4) // { - // args.push_back( make_pair( sizeof(cl_mem), (void *)&mat_dst[3].data)); - // args.push_back( make_pair( sizeof(cl_int), (void *)&mat_dst[3].step)); + // args.push_back( std::make_pair( sizeof(cl_mem), (void *)&mat_dst[3].data)); + // args.push_back( std::make_pair( sizeof(cl_int), (void *)&mat_dst[3].step)); // } // openCLExecuteKernel(clCxt, &split_mat, kernelName, globalThreads, localThreads, args, channels, depth); @@ -289,7 +284,7 @@ namespace cv int channels = mat_src.oclchannels(); int depth = mat_src.depth(); - string kernelName = "split_vector"; + std::string kernelName = "split_vector"; int vector_lengths[4][7] = {{0, 0, 0, 0, 0, 0, 0}, {4, 4, 2, 2, 1, 1, 1}, @@ -316,33 +311,33 @@ namespace cv }; int dst_step1 = mat_dst[0].cols * mat_dst[0].elemSize(); - vector > args; - args.push_back( make_pair( sizeof(cl_mem), (void *)&mat_src.data)); - args.push_back( make_pair( sizeof(cl_int), (void *)&mat_src.step)); - args.push_back( make_pair( sizeof(cl_int), (void *)&mat_src.offset)); - args.push_back( make_pair( sizeof(cl_mem), (void *)&mat_dst[0].data)); - args.push_back( make_pair( sizeof(cl_int), (void *)&mat_dst[0].step)); - args.push_back( make_pair( sizeof(cl_int), (void *)&mat_dst[0].offset)); - args.push_back( make_pair( sizeof(cl_mem), (void *)&mat_dst[1].data)); - args.push_back( make_pair( sizeof(cl_int), (void *)&mat_dst[1].step)); - args.push_back( make_pair( sizeof(cl_int), (void *)&mat_dst[1].offset)); + std::vector > args; + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&mat_src.data)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&mat_src.step)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&mat_src.offset)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&mat_dst[0].data)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&mat_dst[0].step)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&mat_dst[0].offset)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&mat_dst[1].data)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&mat_dst[1].step)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&mat_dst[1].offset)); if(channels >= 3) { - args.push_back( make_pair( sizeof(cl_mem), (void *)&mat_dst[2].data)); - args.push_back( make_pair( sizeof(cl_int), (void *)&mat_dst[2].step)); - args.push_back( make_pair( sizeof(cl_int), (void *)&mat_dst[2].offset)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&mat_dst[2].data)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&mat_dst[2].step)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&mat_dst[2].offset)); } if(channels >= 4) { - args.push_back( make_pair( sizeof(cl_mem), (void *)&mat_dst[3].data)); - args.push_back( make_pair( sizeof(cl_int), (void *)&mat_dst[3].step)); - args.push_back( make_pair( sizeof(cl_int), (void *)&mat_dst[3].offset)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&mat_dst[3].data)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&mat_dst[3].step)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&mat_dst[3].offset)); } - args.push_back( make_pair( sizeof(cl_int), (void *)&mat_src.rows)); - args.push_back( make_pair( sizeof(cl_int), (void *)&cols)); - args.push_back( make_pair( sizeof(cl_int), (void *)&dst_step1)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&mat_src.rows)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&cols)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&dst_step1)); openCLExecuteKernel(clCxt, &split_mat, kernelName, globalThreads, localThreads, args, channels, depth); } @@ -374,7 +369,7 @@ void cv::ocl::merge(const oclMat *src, size_t n, oclMat &dst) { split_merge::merge(src, n, dst); } -void cv::ocl::merge(const vector &src, oclMat &dst) +void cv::ocl::merge(const std::vector &src, oclMat &dst) { split_merge::merge(&src[0], src.size(), dst); } @@ -383,7 +378,7 @@ void cv::ocl::split(const oclMat &src, oclMat *dst) { split_merge::split(src, dst); } -void cv::ocl::split(const oclMat &src, vector &dst) +void cv::ocl::split(const oclMat &src, std::vector &dst) { dst.resize(src.oclchannels()); if(src.oclchannels() > 0) diff --git a/modules/ocl/src/surf.cpp b/modules/ocl/src/surf.cpp index 65dc86d16..320302226 100644 --- a/modules/ocl/src/surf.cpp +++ b/modules/ocl/src/surf.cpp @@ -48,7 +48,6 @@ using namespace cv; using namespace cv::ocl; -using namespace std; namespace cv { @@ -276,7 +275,7 @@ int cv::ocl::SURF_OCL::descriptorSize() const return extended ? 128 : 64; } -void cv::ocl::SURF_OCL::uploadKeypoints(const vector &keypoints, oclMat &keypointsGPU) +void cv::ocl::SURF_OCL::uploadKeypoints(const std::vector &keypoints, oclMat &keypointsGPU) { if (keypoints.empty()) keypointsGPU.release(); @@ -308,7 +307,7 @@ void cv::ocl::SURF_OCL::uploadKeypoints(const vector &keypoints, oclMa } } -void cv::ocl::SURF_OCL::downloadKeypoints(const oclMat &keypointsGPU, vector &keypoints) +void cv::ocl::SURF_OCL::downloadKeypoints(const oclMat &keypointsGPU, std::vector &keypoints) { const int nFeatures = keypointsGPU.cols; @@ -344,7 +343,7 @@ void cv::ocl::SURF_OCL::downloadKeypoints(const oclMat &keypointsGPU, vector &descriptors) +void cv::ocl::SURF_OCL::downloadDescriptors(const oclMat &descriptorsGPU, std::vector &descriptors) { if (descriptorsGPU.empty()) descriptors.clear(); @@ -362,9 +361,9 @@ void cv::ocl::SURF_OCL::operator()(const oclMat &img, const oclMat &mask, oclMat { if (!img.empty()) { - if (img.clCxt->impl->devName.find("Intel(R) HD Graphics") != string::npos) + if (img.clCxt->impl->devName.find("Intel(R) HD Graphics") != std::string::npos) { - cout << " Intel HD GPU device unsupported " << endl; + std::cout << " Intel HD GPU device unsupported " << std::endl; return; } SURF_OCL_Invoker surf(*this, img, mask); @@ -378,9 +377,9 @@ void cv::ocl::SURF_OCL::operator()(const oclMat &img, const oclMat &mask, oclMat { if (!img.empty()) { - if (img.clCxt->impl->devName.find("Intel(R) HD Graphics") != string::npos) + if (img.clCxt->impl->devName.find("Intel(R) HD Graphics") != std::string::npos) { - cout << " Intel HD GPU device unsupported " << endl; + std::cout << " Intel HD GPU device unsupported " << std::endl; return; } SURF_OCL_Invoker surf(*this, img, mask); @@ -396,7 +395,7 @@ void cv::ocl::SURF_OCL::operator()(const oclMat &img, const oclMat &mask, oclMat } } -void cv::ocl::SURF_OCL::operator()(const oclMat &img, const oclMat &mask, vector &keypoints) +void cv::ocl::SURF_OCL::operator()(const oclMat &img, const oclMat &mask, std::vector &keypoints) { oclMat keypointsGPU; @@ -405,7 +404,7 @@ void cv::ocl::SURF_OCL::operator()(const oclMat &img, const oclMat &mask, vector downloadKeypoints(keypointsGPU, keypoints); } -void cv::ocl::SURF_OCL::operator()(const oclMat &img, const oclMat &mask, vector &keypoints, +void cv::ocl::SURF_OCL::operator()(const oclMat &img, const oclMat &mask, std::vector &keypoints, oclMat &descriptors, bool useProvidedKeypoints) { oclMat keypointsGPU; @@ -418,8 +417,8 @@ void cv::ocl::SURF_OCL::operator()(const oclMat &img, const oclMat &mask, vector downloadKeypoints(keypointsGPU, keypoints); } -void cv::ocl::SURF_OCL::operator()(const oclMat &img, const oclMat &mask, vector &keypoints, - vector &descriptors, bool useProvidedKeypoints) +void cv::ocl::SURF_OCL::operator()(const oclMat &img, const oclMat &mask, std::vector &keypoints, + std::vector &descriptors, bool useProvidedKeypoints) { oclMat descriptorsGPU; @@ -522,19 +521,19 @@ void SURF_OCL_Invoker::icvCalcLayerDetAndTrace_gpu(oclMat &det, oclMat &trace, i const int max_samples_j = 1 + ((img_cols - min_size) >> octave); Context *clCxt = det.clCxt; - string kernelName = "icvCalcLayerDetAndTrace"; - vector< pair > args; + std::string kernelName = "icvCalcLayerDetAndTrace"; + std::vector< std::pair > args; - args.push_back( make_pair( sizeof(cl_mem), (void *)&sumTex)); - args.push_back( make_pair( sizeof(cl_mem), (void *)&det.data)); - args.push_back( make_pair( sizeof(cl_mem), (void *)&trace.data)); - args.push_back( make_pair( sizeof(cl_int), (void *)&det.step)); - args.push_back( make_pair( sizeof(cl_int), (void *)&trace.step)); - args.push_back( make_pair( sizeof(cl_int), (void *)&img_rows)); - args.push_back( make_pair( sizeof(cl_int), (void *)&img_cols)); - args.push_back( make_pair( sizeof(cl_int), (void *)&nOctaveLayers)); - args.push_back( make_pair( sizeof(cl_int), (void *)&octave)); - args.push_back( make_pair( sizeof(cl_int), (void *)&c_layer_rows)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&sumTex)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&det.data)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&trace.data)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&det.step)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&trace.step)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&img_rows)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&img_cols)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&nOctaveLayers)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&octave)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&c_layer_rows)); size_t localThreads[3] = {16, 16, 1}; size_t globalThreads[3] = @@ -552,28 +551,28 @@ void SURF_OCL_Invoker::icvFindMaximaInLayer_gpu(const oclMat &det, const oclMat const int min_margin = ((calcSize(octave, 2) >> 1) >> octave) + 1; Context *clCxt = det.clCxt; - string kernelName = use_mask ? "icvFindMaximaInLayer_withmask" : "icvFindMaximaInLayer"; - vector< pair > args; + std::string kernelName = use_mask ? "icvFindMaximaInLayer_withmask" : "icvFindMaximaInLayer"; + std::vector< std::pair > args; - args.push_back( make_pair( sizeof(cl_mem), (void *)&det.data)); - args.push_back( make_pair( sizeof(cl_mem), (void *)&trace.data)); - args.push_back( make_pair( sizeof(cl_mem), (void *)&maxPosBuffer.data)); - args.push_back( make_pair( sizeof(cl_mem), (void *)&maxCounter.data)); - args.push_back( make_pair( sizeof(cl_int), (void *)&counterOffset)); - args.push_back( make_pair( sizeof(cl_int), (void *)&det.step)); - args.push_back( make_pair( sizeof(cl_int), (void *)&trace.step)); - args.push_back( make_pair( sizeof(cl_int), (void *)&img_rows)); - args.push_back( make_pair( sizeof(cl_int), (void *)&img_cols)); - args.push_back( make_pair( sizeof(cl_int), (void *)&nLayers)); - args.push_back( make_pair( sizeof(cl_int), (void *)&octave)); - args.push_back( make_pair( sizeof(cl_int), (void *)&layer_rows)); - args.push_back( make_pair( sizeof(cl_int), (void *)&layer_cols)); - args.push_back( make_pair( sizeof(cl_int), (void *)&maxCandidates)); - args.push_back( make_pair( sizeof(cl_float), (void *)&surf_.hessianThreshold)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&det.data)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&trace.data)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&maxPosBuffer.data)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&maxCounter.data)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&counterOffset)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&det.step)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&trace.step)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&img_rows)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&img_cols)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&nLayers)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&octave)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&layer_rows)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&layer_cols)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&maxCandidates)); + args.push_back( std::make_pair( sizeof(cl_float), (void *)&surf_.hessianThreshold)); if(use_mask) { - args.push_back( make_pair( sizeof(cl_mem), (void *)&maskSumTex)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&maskSumTex)); } size_t localThreads[3] = {16, 16, 1}; @@ -589,20 +588,20 @@ void SURF_OCL_Invoker::icvInterpolateKeypoint_gpu(const oclMat &det, const oclMa oclMat &keypoints, oclMat &counters, int octave, int layer_rows, int maxFeatures) { Context *clCxt = det.clCxt; - string kernelName = "icvInterpolateKeypoint"; - vector< pair > args; + std::string kernelName = "icvInterpolateKeypoint"; + std::vector< std::pair > args; - args.push_back( make_pair( sizeof(cl_mem), (void *)&det.data)); - args.push_back( make_pair( sizeof(cl_mem), (void *)&maxPosBuffer.data)); - args.push_back( make_pair( sizeof(cl_mem), (void *)&keypoints.data)); - args.push_back( make_pair( sizeof(cl_mem), (void *)&counters.data)); - args.push_back( make_pair( sizeof(cl_int), (void *)&det.step)); - args.push_back( make_pair( sizeof(cl_int), (void *)&keypoints.step)); - args.push_back( make_pair( sizeof(cl_int), (void *)&img_rows)); - args.push_back( make_pair( sizeof(cl_int), (void *)&img_cols)); - args.push_back( make_pair( sizeof(cl_int), (void *)&octave)); - args.push_back( make_pair( sizeof(cl_int), (void *)&layer_rows)); - args.push_back( make_pair( sizeof(cl_int), (void *)&maxFeatures)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&det.data)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&maxPosBuffer.data)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&keypoints.data)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&counters.data)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&det.step)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&keypoints.step)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&img_rows)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&img_cols)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&octave)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&layer_rows)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&maxFeatures)); size_t localThreads[3] = {3, 3, 3}; size_t globalThreads[3] = {maxCounter *localThreads[0], localThreads[1], 1}; @@ -613,15 +612,15 @@ void SURF_OCL_Invoker::icvInterpolateKeypoint_gpu(const oclMat &det, const oclMa void SURF_OCL_Invoker::icvCalcOrientation_gpu(const oclMat &keypoints, int nFeatures) { Context *clCxt = counters.clCxt; - string kernelName = "icvCalcOrientation"; + std::string kernelName = "icvCalcOrientation"; - vector< pair > args; + std::vector< std::pair > args; - args.push_back( make_pair( sizeof(cl_mem), (void *)&sumTex)); - args.push_back( make_pair( sizeof(cl_mem), (void *)&keypoints.data)); - args.push_back( make_pair( sizeof(cl_int), (void *)&keypoints.step)); - args.push_back( make_pair( sizeof(cl_int), (void *)&img_rows)); - args.push_back( make_pair( sizeof(cl_int), (void *)&img_cols)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&sumTex)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&keypoints.data)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&keypoints.step)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&img_rows)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&img_cols)); size_t localThreads[3] = {32, 4, 1}; size_t globalThreads[3] = {nFeatures *localThreads[0], localThreads[1], 1}; @@ -633,8 +632,8 @@ void SURF_OCL_Invoker::compute_descriptors_gpu(const oclMat &descriptors, const { // compute unnormalized descriptors, then normalize them - odd indexing since grid must be 2D Context *clCxt = descriptors.clCxt; - string kernelName = ""; - vector< pair > args; + std::string kernelName = ""; + std::vector< std::pair > args; size_t localThreads[3] = {1, 1, 1}; size_t globalThreads[3] = {1, 1, 1}; @@ -649,11 +648,11 @@ void SURF_OCL_Invoker::compute_descriptors_gpu(const oclMat &descriptors, const globalThreads[1] = 16 * localThreads[1]; args.clear(); - args.push_back( make_pair( sizeof(cl_mem), (void *)&imgTex)); - args.push_back( make_pair( sizeof(cl_mem), (void *)&descriptors.data)); - args.push_back( make_pair( sizeof(cl_mem), (void *)&keypoints.data)); - args.push_back( make_pair( sizeof(cl_int), (void *)&descriptors.step)); - args.push_back( make_pair( sizeof(cl_int), (void *)&keypoints.step)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&imgTex)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&descriptors.data)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&keypoints.data)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&descriptors.step)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&keypoints.step)); openCLExecuteKernel(clCxt, &nonfree_surf, kernelName, globalThreads, localThreads, args, -1, -1); kernelName = "normalize_descriptors64"; @@ -665,8 +664,8 @@ void SURF_OCL_Invoker::compute_descriptors_gpu(const oclMat &descriptors, const globalThreads[1] = localThreads[1]; args.clear(); - args.push_back( make_pair( sizeof(cl_mem), (void *)&descriptors.data)); - args.push_back( make_pair( sizeof(cl_int), (void *)&descriptors.step)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&descriptors.data)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&descriptors.step)); openCLExecuteKernel(clCxt, &nonfree_surf, kernelName, globalThreads, localThreads, args, -1, -1); } else @@ -680,11 +679,11 @@ void SURF_OCL_Invoker::compute_descriptors_gpu(const oclMat &descriptors, const globalThreads[1] = 16 * localThreads[1]; args.clear(); - args.push_back( make_pair( sizeof(cl_mem), (void *)&imgTex)); - args.push_back( make_pair( sizeof(cl_mem), (void *)&descriptors.data)); - args.push_back( make_pair( sizeof(cl_mem), (void *)&keypoints.data)); - args.push_back( make_pair( sizeof(cl_int), (void *)&descriptors.step)); - args.push_back( make_pair( sizeof(cl_int), (void *)&keypoints.step)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&imgTex)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&descriptors.data)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&keypoints.data)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&descriptors.step)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&keypoints.step)); openCLExecuteKernel(clCxt, &nonfree_surf, kernelName, globalThreads, localThreads, args, -1, -1); kernelName = "normalize_descriptors128"; @@ -696,8 +695,8 @@ void SURF_OCL_Invoker::compute_descriptors_gpu(const oclMat &descriptors, const globalThreads[1] = localThreads[1]; args.clear(); - args.push_back( make_pair( sizeof(cl_mem), (void *)&descriptors.data)); - args.push_back( make_pair( sizeof(cl_int), (void *)&descriptors.step)); + args.push_back( std::make_pair( sizeof(cl_mem), (void *)&descriptors.data)); + args.push_back( std::make_pair( sizeof(cl_int), (void *)&descriptors.step)); openCLExecuteKernel(clCxt, &nonfree_surf, kernelName, globalThreads, localThreads, args, -1, -1); } } diff --git a/modules/photo/src/arrays.hpp b/modules/photo/src/arrays.hpp index cb434a611..ae01e9af8 100644 --- a/modules/photo/src/arrays.hpp +++ b/modules/photo/src/arrays.hpp @@ -52,7 +52,7 @@ template struct Array2d { { if (array2d.needToDeallocArray) { // copy constructor for self allocating arrays not supported - throw new exception(); + throw new std::exception(); } } diff --git a/modules/photo/src/denoising.cpp b/modules/photo/src/denoising.cpp index 02d7a6f62..df7bcc2ac 100644 --- a/modules/photo/src/denoising.cpp +++ b/modules/photo/src/denoising.cpp @@ -147,7 +147,7 @@ void cv::fastNlMeansDenoisingMulti( InputArrayOfArrays _srcImgs, OutputArray _ds int imgToDenoiseIndex, int temporalWindowSize, float h, int templateWindowSize, int searchWindowSize) { - vector srcImgs; + std::vector srcImgs; _srcImgs.getMatVector(srcImgs); fastNlMeansDenoisingMultiCheckPreconditions( @@ -187,7 +187,7 @@ void cv::fastNlMeansDenoisingColoredMulti( InputArrayOfArrays _srcImgs, OutputAr float h, float hForColorComponents, int templateWindowSize, int searchWindowSize) { - vector srcImgs; + std::vector srcImgs; _srcImgs.getMatVector(srcImgs); fastNlMeansDenoisingMultiCheckPreconditions( @@ -208,9 +208,9 @@ void cv::fastNlMeansDenoisingColoredMulti( InputArrayOfArrays _srcImgs, OutputAr int from_to[] = { 0,0, 1,1, 2,2 }; // TODO convert only required images - vector src_lab(src_imgs_size); - vector l(src_imgs_size); - vector ab(src_imgs_size); + std::vector src_lab(src_imgs_size); + std::vector l(src_imgs_size); + std::vector ab(src_imgs_size); for (int i = 0; i < src_imgs_size; i++) { src_lab[i] = Mat::zeros(srcImgs[0].size(), CV_8UC3); l[i] = Mat::zeros(srcImgs[0].size(), CV_8UC1); diff --git a/modules/photo/src/fast_nlmeans_denoising_invoker.hpp b/modules/photo/src/fast_nlmeans_denoising_invoker.hpp index c4f13826d..c00f9abf8 100644 --- a/modules/photo/src/fast_nlmeans_denoising_invoker.hpp +++ b/modules/photo/src/fast_nlmeans_denoising_invoker.hpp @@ -51,7 +51,6 @@ #include "fast_nlmeans_denoising_invoker_commons.hpp" #include "arrays.hpp" -using namespace std; using namespace cv; template @@ -79,7 +78,7 @@ struct FastNlMeansDenoisingInvoker { int fixed_point_mult_; int almost_template_window_size_sq_bin_shift_; - vector almost_dist2weight_; + std::vector almost_dist2weight_; void calcDistSumsForFirstElementInRow( int i, @@ -123,7 +122,7 @@ FastNlMeansDenoisingInvoker::FastNlMeansDenoisingInvoker( border_size_, border_size_, border_size_, border_size_, cv::BORDER_DEFAULT); const int max_estimate_sum_value = search_window_size_ * search_window_size_ * 255; - fixed_point_mult_ = numeric_limits::max() / max_estimate_sum_value; + fixed_point_mult_ = std::numeric_limits::max() / max_estimate_sum_value; // precalc weight for every possible l2 dist between blocks // additional optimization of precalced weights to replace division(averaging) by binary shift diff --git a/modules/photo/src/fast_nlmeans_denoising_invoker_commons.hpp b/modules/photo/src/fast_nlmeans_denoising_invoker_commons.hpp index c05d64f9e..7dceec270 100644 --- a/modules/photo/src/fast_nlmeans_denoising_invoker_commons.hpp +++ b/modules/photo/src/fast_nlmeans_denoising_invoker_commons.hpp @@ -46,7 +46,6 @@ #include #include -using namespace std; using namespace cv; template static inline int calcDist(const T a, const T b); diff --git a/modules/photo/src/fast_nlmeans_multi_denoising_invoker.hpp b/modules/photo/src/fast_nlmeans_multi_denoising_invoker.hpp index 2ae5054e0..73e0171c6 100644 --- a/modules/photo/src/fast_nlmeans_multi_denoising_invoker.hpp +++ b/modules/photo/src/fast_nlmeans_multi_denoising_invoker.hpp @@ -51,7 +51,6 @@ #include "fast_nlmeans_denoising_invoker_commons.hpp" #include "arrays.hpp" -using namespace std; using namespace cv; template @@ -71,7 +70,7 @@ struct FastNlMeansMultiDenoisingInvoker { Mat& dst_; - vector extended_srcs_; + std::vector extended_srcs_; Mat main_extended_src_; int border_size_; @@ -85,7 +84,7 @@ struct FastNlMeansMultiDenoisingInvoker { int fixed_point_mult_; int almost_template_window_size_sq_bin_shift; - vector almost_dist2weight; + std::vector almost_dist2weight; void calcDistSumsForFirstElementInRow( int i, @@ -104,7 +103,7 @@ struct FastNlMeansMultiDenoisingInvoker { template FastNlMeansMultiDenoisingInvoker::FastNlMeansMultiDenoisingInvoker( - const vector& srcImgs, + const std::vector& srcImgs, int imgToDenoiseIndex, int temporalWindowSize, cv::Mat& dst, @@ -137,7 +136,7 @@ FastNlMeansMultiDenoisingInvoker::FastNlMeansMultiDenoisingInvoker( const int max_estimate_sum_value = temporal_window_size_ * search_window_size_ * search_window_size_ * 255; - fixed_point_mult_ = numeric_limits::max() / max_estimate_sum_value; + fixed_point_mult_ = std::numeric_limits::max() / max_estimate_sum_value; // precalc weight for every possible l2 dist between blocks // additional optimization of precalced weights to replace division(averaging) by binary shift diff --git a/modules/photo/test/test_inpaint.cpp b/modules/photo/test/test_inpaint.cpp index 26a997e29..2bdb2ddaa 100644 --- a/modules/photo/test/test_inpaint.cpp +++ b/modules/photo/test/test_inpaint.cpp @@ -43,6 +43,7 @@ #include "test_precomp.hpp" #include +using namespace std; using namespace cv; class CV_InpaintTest : public cvtest::BaseTest diff --git a/modules/python/src2/cv2.cpp b/modules/python/src2/cv2.cpp index 7bd705fbc..68dcfb500 100644 --- a/modules/python/src2/cv2.cpp +++ b/modules/python/src2/cv2.cpp @@ -99,26 +99,26 @@ catch (const cv::Exception &e) \ using namespace cv; typedef cv::softcascade::ChannelFeatureBuilder softcascade_ChannelFeatureBuilder; -typedef vector vector_uchar; -typedef vector vector_int; -typedef vector vector_float; -typedef vector vector_double; -typedef vector vector_Point; -typedef vector vector_Point2f; -typedef vector vector_Vec2f; -typedef vector vector_Vec3f; -typedef vector vector_Vec4f; -typedef vector vector_Vec6f; -typedef vector vector_Vec4i; -typedef vector vector_Rect; -typedef vector vector_KeyPoint; -typedef vector vector_Mat; -typedef vector vector_DMatch; -typedef vector vector_string; -typedef vector > vector_vector_Point; -typedef vector > vector_vector_Point2f; -typedef vector > vector_vector_Point3f; -typedef vector > vector_vector_DMatch; +typedef std::vector vector_uchar; +typedef std::vector vector_int; +typedef std::vector vector_float; +typedef std::vector vector_double; +typedef std::vector vector_Point; +typedef std::vector vector_Point2f; +typedef std::vector vector_Vec2f; +typedef std::vector vector_Vec3f; +typedef std::vector vector_Vec4f; +typedef std::vector vector_Vec6f; +typedef std::vector vector_Vec4i; +typedef std::vector vector_Rect; +typedef std::vector vector_KeyPoint; +typedef std::vector vector_Mat; +typedef std::vector vector_DMatch; +typedef std::vector vector_string; +typedef std::vector > vector_vector_Point; +typedef std::vector > vector_vector_Point2f; +typedef std::vector > vector_vector_Point3f; +typedef std::vector > vector_vector_DMatch; typedef Ptr Ptr_Algorithm; typedef Ptr Ptr_FeatureDetector; @@ -136,7 +136,7 @@ typedef Ptr Ptr_flann_IndexParams; typedef Ptr Ptr_flann_SearchParams; typedef Ptr Ptr_FaceRecognizer; -typedef vector vector_Scalar; +typedef std::vector vector_Scalar; static PyObject* failmsgp(const char *fmt, ...) { @@ -543,19 +543,12 @@ static PyObject* pyopencv_from(int64 value) return PyLong_FromLongLong(value); } -#if !defined(__LP64__) -static PyObject* pyopencv_from(uint64 value) -{ - return PyLong_FromUnsignedLongLong(value); -} -#endif - -static PyObject* pyopencv_from(const string& value) +static PyObject* pyopencv_from(const std::string& value) { return PyString_FromString(value.empty() ? "" : value.c_str()); } -static bool pyopencv_to(PyObject* obj, string& value, const char* name = "") +static bool pyopencv_to(PyObject* obj, std::string& value, const char* name = "") { (void)name; if(!obj || obj == Py_None) @@ -563,7 +556,7 @@ static bool pyopencv_to(PyObject* obj, string& value, const char* name = " struct pyopencvVecConverter { - static bool to(PyObject* obj, vector<_Tp>& value, const ArgInfo info) + static bool to(PyObject* obj, std::vector<_Tp>& value, const ArgInfo info) { typedef typename DataType<_Tp>::channel_type _Cp; if(!obj || obj == Py_None) @@ -787,7 +780,7 @@ template struct pyopencvVecConverter return i == n; } - static PyObject* from(const vector<_Tp>& value) + static PyObject* from(const std::vector<_Tp>& value) { if(value.empty()) return PyTuple_New(0); @@ -797,12 +790,12 @@ template struct pyopencvVecConverter }; -template static inline bool pyopencv_to(PyObject* obj, vector<_Tp>& value, const ArgInfo info) +template static inline bool pyopencv_to(PyObject* obj, std::vector<_Tp>& value, const ArgInfo info) { return pyopencvVecConverter<_Tp>::to(obj, value, info); } -template static inline PyObject* pyopencv_from(const vector<_Tp>& value) +template static inline PyObject* pyopencv_from(const std::vector<_Tp>& value) { return pyopencvVecConverter<_Tp>::from(value); } @@ -810,7 +803,7 @@ template static inline PyObject* pyopencv_from(const vector<_Tp>& static PyObject* pyopencv_from(const KeyPoint&); static PyObject* pyopencv_from(const DMatch&); -template static inline bool pyopencv_to_generic_vec(PyObject* obj, vector<_Tp>& value, const ArgInfo info) +template static inline bool pyopencv_to_generic_vec(PyObject* obj, std::vector<_Tp>& value, const ArgInfo info) { if(!obj || obj == Py_None) return true; @@ -834,7 +827,7 @@ template static inline bool pyopencv_to_generic_vec(PyObject* obj, return i == n; } -template static inline PyObject* pyopencv_from_generic_vec(const vector<_Tp>& value) +template static inline PyObject* pyopencv_from_generic_vec(const std::vector<_Tp>& value) { int i, n = (int)value.size(); PyObject* seq = PyList_New(n); @@ -854,14 +847,14 @@ template static inline PyObject* pyopencv_from_generic_vec(const v } -template struct pyopencvVecConverter > +template struct pyopencvVecConverter > { - static bool to(PyObject* obj, vector >& value, const char* name="") + static bool to(PyObject* obj, std::vector >& value, const char* name="") { return pyopencv_to_generic_vec(obj, value, name); } - static PyObject* from(const vector >& value) + static PyObject* from(const std::vector >& value) { return pyopencv_from_generic_vec(value); } @@ -869,12 +862,12 @@ template struct pyopencvVecConverter > template<> struct pyopencvVecConverter { - static bool to(PyObject* obj, vector& value, const ArgInfo info) + static bool to(PyObject* obj, std::vector& value, const ArgInfo info) { return pyopencv_to_generic_vec(obj, value, info); } - static PyObject* from(const vector& value) + static PyObject* from(const std::vector& value) { return pyopencv_from_generic_vec(value); } @@ -882,12 +875,12 @@ template<> struct pyopencvVecConverter template<> struct pyopencvVecConverter { - static bool to(PyObject* obj, vector& value, const ArgInfo info) + static bool to(PyObject* obj, std::vector& value, const ArgInfo info) { return pyopencv_to_generic_vec(obj, value, info); } - static PyObject* from(const vector& value) + static PyObject* from(const std::vector& value) { return pyopencv_from_generic_vec(value); } @@ -895,25 +888,25 @@ template<> struct pyopencvVecConverter template<> struct pyopencvVecConverter { - static bool to(PyObject* obj, vector& value, const ArgInfo info) + static bool to(PyObject* obj, std::vector& value, const ArgInfo info) { return pyopencv_to_generic_vec(obj, value, info); } - static PyObject* from(const vector& value) + static PyObject* from(const std::vector& value) { return pyopencv_from_generic_vec(value); } }; -template<> struct pyopencvVecConverter +template<> struct pyopencvVecConverter { - static bool to(PyObject* obj, vector& value, const ArgInfo info) + static bool to(PyObject* obj, std::vector& value, const ArgInfo info) { return pyopencv_to_generic_vec(obj, value, info); } - static PyObject* from(const vector& value) + static PyObject* from(const std::vector& value) { return pyopencv_from_generic_vec(value); } diff --git a/modules/python/src2/gen2.py b/modules/python/src2/gen2.py index 5061b1147..93ab5ece6 100755 --- a/modules/python/src2/gen2.py +++ b/modules/python/src2/gen2.py @@ -214,7 +214,8 @@ simple_argtype_mapping = { "int": ("int", "i", "0"), "float": ("float", "f", "0.f"), "double": ("double", "d", "0"), - "c_string": ("char*", "s", '(char*)""') + "c_string": ("char*", "s", '(char*)""'), + "string": ("std::string", "s", None) } def normalize_class_name(name): @@ -569,7 +570,7 @@ class FuncInfo(object): else: code_fcall = "ERRWRAP2( " if v.rettype: - code_decl += " " + v.rettype + " retval;\n" + code_decl += " " + simple_argtype_mapping.get(v.rettype, (v.rettype, None, None))[0] + " retval;\n" code_fcall += "retval = " if ismethod: code_fcall += "_self_->" + self.cname diff --git a/modules/softcascade/include/opencv2/softcascade/softcascade.hpp b/modules/softcascade/include/opencv2/softcascade/softcascade.hpp index a84aaa044..266e352c4 100644 --- a/modules/softcascade/include/opencv2/softcascade/softcascade.hpp +++ b/modules/softcascade/include/opencv2/softcascade/softcascade.hpp @@ -204,7 +204,7 @@ public: virtual bool train(const Dataset* dataset, const FeaturePool* pool, int weaks, int treeDepth) = 0; virtual void setRejectThresholds(OutputArray thresholds) = 0; virtual void write( cv::FileStorage &fs, const FeaturePool* pool, InputArray thresholds) const = 0; - virtual void write( CvFileStorage* fs, string name) const = 0; + virtual void write( CvFileStorage* fs, std::string name) const = 0; }; CV_EXPORTS bool initModule_softcascade(void); diff --git a/modules/softcascade/perf/perf_precomp. b/modules/softcascade/perf/perf_precomp. deleted file mode 100644 index e69de29bb..000000000 diff --git a/modules/softcascade/src/integral_channel_builder.cpp b/modules/softcascade/src/integral_channel_builder.cpp index ae18e54d5..7c1a846e0 100644 --- a/modules/softcascade/src/integral_channel_builder.cpp +++ b/modules/softcascade/src/integral_channel_builder.cpp @@ -154,7 +154,7 @@ float ChannelFeature::operator() (const cv::Mat& integrals, const cv::Size& mode return (float)(a - b + c - d); } -void cv::softcascade::write(cv::FileStorage& fs, const string&, const ChannelFeature& f) +void cv::softcascade::write(cv::FileStorage& fs, const std::string&, const ChannelFeature& f) { fs << "{" << "channel" << f.channel << "rect" << f.bb << "}"; } diff --git a/modules/softcascade/src/softcascade.cpp b/modules/softcascade/src/softcascade.cpp index 58a61547a..b7a3d0cca 100644 --- a/modules/softcascade/src/softcascade.cpp +++ b/modules/softcascade/src/softcascade.cpp @@ -53,7 +53,7 @@ namespace { struct SOctave { SOctave(const int i, const cv::Size& origObjSize, const cv::FileNode& fn) - : index(i), weaks((int)fn[SC_OCT_WEAKS]), scale(pow(2,(float)fn[SC_OCT_SCALE])), + : index(i), weaks((int)fn[SC_OCT_WEAKS]), scale(std::pow(2,(float)fn[SC_OCT_SCALE])), size(cvRound(origObjSize.width * scale), cvRound(origObjSize.height * scale)) {} int index; @@ -146,7 +146,7 @@ struct Level workRect(cv::Size(cvRound(w / (float)shrinkage),cvRound(h / (float)shrinkage))), objSize(cv::Size(cvRound(oct.size.width * relScale), cvRound(oct.size.height * relScale))) { - scaling[0] = ((relScale >= 1.f)? 1.f : (0.89f * pow(relScale, 1.099f / log(2.f)))) / (relScale * relScale); + scaling[0] = ((relScale >= 1.f)? 1.f : (0.89f * std::pow(relScale, 1.099f / std::log(2.f)))) / (relScale * relScale); scaling[1] = 1.f; scaleshift = static_cast(relScale * (1 << 16)); } @@ -287,7 +287,7 @@ struct Detector::Fields for (octIt_t oct = octaves.begin(); oct < octaves.end(); ++oct) { const SOctave& octave =*oct; - float logOctave = log(octave.scale); + float logOctave = std::log(octave.scale); float logAbsScale = fabs(logFactor - logOctave); if(logAbsScale < minAbsLog) @@ -309,7 +309,7 @@ struct Detector::Fields CV_Assert(scales > 1); levels.clear(); - float logFactor = (log(maxScale) - log(minScale)) / (scales -1); + float logFactor = (std::log(maxScale) - std::log(minScale)) / (scales -1); float scale = minScale; for (int sc = 0; sc < scales; ++sc) @@ -317,7 +317,7 @@ struct Detector::Fields int width = static_cast(std::max(0.0f, frameSize.width - (origObjWidth * scale))); int height = static_cast(std::max(0.0f, frameSize.height - (origObjHeight * scale))); - float logScale = log(scale); + float logScale = std::log(scale); octIt_t fit = fitOctave(logScale); @@ -329,7 +329,7 @@ struct Detector::Fields levels.push_back(level); if (fabs(scale - maxScale) < FLT_EPSILON) break; - scale = std::min(maxScale, expf(log(scale) + logFactor)); + scale = std::min(maxScale, expf(std::log(scale) + logFactor)); } } @@ -357,14 +357,14 @@ struct Detector::Fields static const char *const FEATURE_FORMAT = "featureFormat"; // only Ada Boost supported - std::string stageTypeStr = (string)root[SC_STAGE_TYPE]; + std::string stageTypeStr = (std::string)root[SC_STAGE_TYPE]; CV_Assert(stageTypeStr == SC_BOOST); - std::string fformat = (string)root[FEATURE_FORMAT]; + std::string fformat = (std::string)root[FEATURE_FORMAT]; bool useBoxes = (fformat == "BOX"); // only HOG-like integral channel features supported - string featureTypeStr = (string)root[SC_FEATURE_TYPE]; + std::string featureTypeStr = (std::string)root[SC_FEATURE_TYPE]; CV_Assert(featureTypeStr == SC_ICF); origObjWidth = (int)root[SC_ORIG_W]; diff --git a/modules/stitching/perf/perf_stich.cpp b/modules/stitching/perf/perf_stich.cpp index 11f52f761..fff134ce1 100644 --- a/modules/stitching/perf/perf_stich.cpp +++ b/modules/stitching/perf/perf_stich.cpp @@ -14,15 +14,15 @@ using std::tr1::get; #define ORB_MATCH_CONFIDENCE 0.3f #define WORK_MEGAPIX 0.6 -typedef TestBaseWithParam stitch; -typedef TestBaseWithParam match; -typedef std::tr1::tuple matchVector_t; +typedef TestBaseWithParam stitch; +typedef TestBaseWithParam match; +typedef std::tr1::tuple matchVector_t; typedef TestBaseWithParam matchVector; #ifdef HAVE_OPENCV_NONFREE_TODO_FIND_WHY_SURF_IS_NOT_ABLE_TO_STITCH_PANOS #define TEST_DETECTORS testing::Values("surf", "orb") #else -#define TEST_DETECTORS testing::Values("orb") +#define TEST_DETECTORS testing::Values("orb") #endif PERF_TEST_P(stitch, a123, TEST_DETECTORS) @@ -166,7 +166,7 @@ PERF_TEST_P( matchVector, bestOf2NearestVectorFeatures, testing::Combine( Ptr finder; Ptr matcher; - String detectorName = get<0>(GetParam()); + string detectorName = get<0>(GetParam()); int featuresVectorSize = get<1>(GetParam()); if (detectorName == "surf") { diff --git a/modules/stitching/src/autocalib.cpp b/modules/stitching/src/autocalib.cpp index 0314b2769..98fe1472f 100644 --- a/modules/stitching/src/autocalib.cpp +++ b/modules/stitching/src/autocalib.cpp @@ -42,7 +42,6 @@ #include "precomp.hpp" -using namespace std; using namespace cv; namespace { @@ -79,8 +78,8 @@ void focalsFromHomography(const Mat& H, double &f0, double &f1, bool &f0_ok, boo v1 = -(h[0] * h[1] + h[3] * h[4]) / d1; v2 = (h[0] * h[0] + h[3] * h[3] - h[1] * h[1] - h[4] * h[4]) / d2; if (v1 < v2) std::swap(v1, v2); - if (v1 > 0 && v2 > 0) f1 = sqrt(std::abs(d1) > std::abs(d2) ? v1 : v2); - else if (v1 > 0) f1 = sqrt(v1); + if (v1 > 0 && v2 > 0) f1 = std::sqrt(std::abs(d1) > std::abs(d2) ? v1 : v2); + else if (v1 > 0) f1 = std::sqrt(v1); else f1_ok = false; f0_ok = true; @@ -89,19 +88,19 @@ void focalsFromHomography(const Mat& H, double &f0, double &f1, bool &f0_ok, boo v1 = -h[2] * h[5] / d1; v2 = (h[5] * h[5] - h[2] * h[2]) / d2; if (v1 < v2) std::swap(v1, v2); - if (v1 > 0 && v2 > 0) f0 = sqrt(std::abs(d1) > std::abs(d2) ? v1 : v2); - else if (v1 > 0) f0 = sqrt(v1); + if (v1 > 0 && v2 > 0) f0 = std::sqrt(std::abs(d1) > std::abs(d2) ? v1 : v2); + else if (v1 > 0) f0 = std::sqrt(v1); else f0_ok = false; } -void estimateFocal(const vector &features, const vector &pairwise_matches, - vector &focals) +void estimateFocal(const std::vector &features, const std::vector &pairwise_matches, + std::vector &focals) { const int num_images = static_cast(features.size()); focals.resize(num_images); - vector all_focals; + std::vector all_focals; for (int i = 0; i < num_images; ++i) { @@ -114,7 +113,7 @@ void estimateFocal(const vector &features, const vector &features, const vector &Hs, Mat &K) +bool calibrateRotatingCamera(const std::vector &Hs, Mat &K) { int m = static_cast(Hs.size()); CV_Assert(m >= 1); - vector Hs_(m); + std::vector Hs_(m); for (int i = 0; i < m; ++i) { CV_Assert(Hs[i].size() == Size(3, 3) && Hs[i].type() == CV_64F); - Hs_[i] = Hs[i] / pow(determinant(Hs[i]), 1./3.); + Hs_[i] = Hs[i] / std::pow(determinant(Hs[i]), 1./3.); } const int idx_map[3][3] = {{0, 1, 2}, {1, 3, 4}, {2, 4, 5}}; diff --git a/modules/stitching/src/blenders.cpp b/modules/stitching/src/blenders.cpp index e65023a55..dc7d1da61 100644 --- a/modules/stitching/src/blenders.cpp +++ b/modules/stitching/src/blenders.cpp @@ -42,8 +42,6 @@ #include "precomp.hpp" -using namespace std; - namespace cv { namespace detail { @@ -62,7 +60,7 @@ Ptr Blender::createDefault(int type, bool try_gpu) } -void Blender::prepare(const vector &corners, const vector &sizes) +void Blender::prepare(const std::vector &corners, const std::vector &sizes) { prepare(resultRoi(corners, sizes)); } @@ -155,8 +153,8 @@ void FeatherBlender::blend(Mat &dst, Mat &dst_mask) } -Rect FeatherBlender::createWeightMaps(const vector &masks, const vector &corners, - vector &weight_maps) +Rect FeatherBlender::createWeightMaps(const std::vector &masks, const std::vector &corners, + std::vector &weight_maps) { weight_maps.resize(masks.size()); for (size_t i = 0; i < masks.size(); ++i) @@ -178,7 +176,7 @@ Rect FeatherBlender::createWeightMaps(const vector &masks, const vector::epsilon()); + tmp.setTo(1, tmp < std::numeric_limits::epsilon()); divide(weight_maps[i], tmp, weight_maps[i]); } @@ -205,8 +203,8 @@ void MultiBandBlender::prepare(Rect dst_roi) dst_roi_final_ = dst_roi; // Crop unnecessary bands - double max_len = static_cast(max(dst_roi.width, dst_roi.height)); - num_bands_ = min(actual_num_bands_, static_cast(ceil(log(max_len) / log(2.0)))); + double max_len = static_cast(std::max(dst_roi.width, dst_roi.height)); + num_bands_ = std::min(actual_num_bands_, static_cast(ceil(std::log(max_len) / std::log(2.0)))); // Add border to the final image, to ensure sizes are divided by (1 << num_bands_) dst_roi.width += ((1 << num_bands_) - dst_roi.width % (1 << num_bands_)) % (1 << num_bands_); @@ -240,10 +238,10 @@ void MultiBandBlender::feed(const Mat &img, const Mat &mask, Point tl) // Keep source image in memory with small border int gap = 3 * (1 << num_bands_); - Point tl_new(max(dst_roi_.x, tl.x - gap), - max(dst_roi_.y, tl.y - gap)); - Point br_new(min(dst_roi_.br().x, tl.x + img.cols + gap), - min(dst_roi_.br().y, tl.y + img.rows + gap)); + Point tl_new(std::max(dst_roi_.x, tl.x - gap), + std::max(dst_roi_.y, tl.y - gap)); + Point br_new(std::min(dst_roi_.br().x, tl.x + img.cols + gap), + std::min(dst_roi_.br().y, tl.y + img.rows + gap)); // Ensure coordinates of top-left, bottom-right corners are divided by (1 << num_bands_). // After that scale between layers is exactly 2. @@ -258,8 +256,8 @@ void MultiBandBlender::feed(const Mat &img, const Mat &mask, Point tl) height += ((1 << num_bands_) - height % (1 << num_bands_)) % (1 << num_bands_); br_new.x = tl_new.x + width; br_new.y = tl_new.y + height; - int dy = max(br_new.y - dst_roi_.br().y, 0); - int dx = max(br_new.x - dst_roi_.br().x, 0); + int dy = std::max(br_new.y - dst_roi_.br().y, 0); + int dx = std::max(br_new.x - dst_roi_.br().x, 0); tl_new.x -= dx; br_new.x -= dx; tl_new.y -= dy; br_new.y -= dy; @@ -272,7 +270,7 @@ void MultiBandBlender::feed(const Mat &img, const Mat &mask, Point tl) Mat img_with_border; copyMakeBorder(img, img_with_border, top, bottom, left, right, BORDER_REFLECT); - vector src_pyr_laplace; + std::vector src_pyr_laplace; if (can_use_gpu_ && img_with_border.depth() == CV_16S) createLaplacePyrGpu(img_with_border, num_bands_, src_pyr_laplace); else @@ -280,7 +278,7 @@ void MultiBandBlender::feed(const Mat &img, const Mat &mask, Point tl) // Create the weight map Gaussian pyramid Mat weight_map; - vector weight_pyr_gauss(num_bands_ + 1); + std::vector weight_pyr_gauss(num_bands_ + 1); if(weight_type_ == CV_32F) { @@ -432,7 +430,7 @@ void createWeightMap(const Mat &mask, float sharpness, Mat &weight) } -void createLaplacePyr(const Mat &img, int num_levels, vector &pyr) +void createLaplacePyr(const Mat &img, int num_levels, std::vector &pyr) { #ifdef HAVE_TEGRA_OPTIMIZATION if(tegra::createLaplacePyr(img, num_levels, pyr)) @@ -489,12 +487,12 @@ void createLaplacePyr(const Mat &img, int num_levels, vector &pyr) } -void createLaplacePyrGpu(const Mat &img, int num_levels, vector &pyr) +void createLaplacePyrGpu(const Mat &img, int num_levels, std::vector &pyr) { #ifdef HAVE_OPENCV_GPU pyr.resize(num_levels + 1); - vector gpu_pyr(num_levels + 1); + std::vector gpu_pyr(num_levels + 1); gpu_pyr[0].upload(img); for (int i = 0; i < num_levels; ++i) gpu::pyrDown(gpu_pyr[i], gpu_pyr[i + 1]); @@ -516,7 +514,7 @@ void createLaplacePyrGpu(const Mat &img, int num_levels, vector &pyr) } -void restoreImageFromLaplacePyr(vector &pyr) +void restoreImageFromLaplacePyr(std::vector &pyr) { if (pyr.empty()) return; @@ -529,13 +527,13 @@ void restoreImageFromLaplacePyr(vector &pyr) } -void restoreImageFromLaplacePyrGpu(vector &pyr) +void restoreImageFromLaplacePyrGpu(std::vector &pyr) { #ifdef HAVE_OPENCV_GPU if (pyr.empty()) return; - vector gpu_pyr(pyr.size()); + std::vector gpu_pyr(pyr.size()); for (size_t i = 0; i < pyr.size(); ++i) gpu_pyr[i].upload(pyr[i]); diff --git a/modules/stitching/src/camera.cpp b/modules/stitching/src/camera.cpp index 7f7b48eeb..2a014bdbf 100644 --- a/modules/stitching/src/camera.cpp +++ b/modules/stitching/src/camera.cpp @@ -42,8 +42,6 @@ #include "precomp.hpp" -using namespace std; - namespace cv { namespace detail { diff --git a/modules/stitching/src/exposure_compensate.cpp b/modules/stitching/src/exposure_compensate.cpp index 575ecae09..d2479b710 100644 --- a/modules/stitching/src/exposure_compensate.cpp +++ b/modules/stitching/src/exposure_compensate.cpp @@ -42,8 +42,6 @@ #include "precomp.hpp" -using namespace std; - namespace cv { namespace detail { @@ -60,18 +58,18 @@ Ptr ExposureCompensator::createDefault(int type) } -void ExposureCompensator::feed(const vector &corners, const vector &images, - const vector &masks) +void ExposureCompensator::feed(const std::vector &corners, const std::vector &images, + const std::vector &masks) { - vector > level_masks; + std::vector > level_masks; for (size_t i = 0; i < masks.size(); ++i) - level_masks.push_back(make_pair(masks[i], 255)); + level_masks.push_back(std::make_pair(masks[i], 255)); feed(corners, images, level_masks); } -void GainCompensator::feed(const vector &corners, const vector &images, - const vector > &masks) +void GainCompensator::feed(const std::vector &corners, const std::vector &images, + const std::vector > &masks) { LOGLN("Exposure compensation..."); #if ENABLE_LOG @@ -102,7 +100,7 @@ void GainCompensator::feed(const vector &corners, const vector &imag submask2 = masks[j].first(Rect(roi.tl() - corners[j], roi.br() - corners[j])); intersect = (submask1 == masks[i].second) & (submask2 == masks[j].second); - N(i, j) = N(j, i) = max(1, countNonZero(intersect)); + N(i, j) = N(j, i) = std::max(1, countNonZero(intersect)); double Isum1 = 0, Isum2 = 0; for (int y = 0; y < roi.height; ++y) @@ -113,8 +111,8 @@ void GainCompensator::feed(const vector &corners, const vector &imag { if (intersect(y, x)) { - Isum1 += sqrt(static_cast(sqr(r1[x].x) + sqr(r1[x].y) + sqr(r1[x].z))); - Isum2 += sqrt(static_cast(sqr(r2[x].x) + sqr(r2[x].y) + sqr(r2[x].z))); + Isum1 += std::sqrt(static_cast(sqr(r1[x].x) + sqr(r1[x].y) + sqr(r1[x].z))); + Isum2 += std::sqrt(static_cast(sqr(r2[x].x) + sqr(r2[x].y) + sqr(r2[x].z))); } } } @@ -153,26 +151,26 @@ void GainCompensator::apply(int index, Point /*corner*/, Mat &image, const Mat & } -vector GainCompensator::gains() const +std::vector GainCompensator::gains() const { - vector gains_vec(gains_.rows); + std::vector gains_vec(gains_.rows); for (int i = 0; i < gains_.rows; ++i) gains_vec[i] = gains_(i, 0); return gains_vec; } -void BlocksGainCompensator::feed(const vector &corners, const vector &images, - const vector > &masks) +void BlocksGainCompensator::feed(const std::vector &corners, const std::vector &images, + const std::vector > &masks) { CV_Assert(corners.size() == images.size() && images.size() == masks.size()); const int num_images = static_cast(images.size()); - vector bl_per_imgs(num_images); - vector block_corners; - vector block_images; - vector > block_masks; + std::vector bl_per_imgs(num_images); + std::vector block_corners; + std::vector block_images; + std::vector > block_masks; // Construct blocks for gain compensator for (int img_idx = 0; img_idx < num_images; ++img_idx) @@ -187,12 +185,12 @@ void BlocksGainCompensator::feed(const vector &corners, const vector for (int bx = 0; bx < bl_per_img.width; ++bx) { Point bl_tl(bx * bl_width, by * bl_height); - Point bl_br(min(bl_tl.x + bl_width, images[img_idx].cols), - min(bl_tl.y + bl_height, images[img_idx].rows)); + Point bl_br(std::min(bl_tl.x + bl_width, images[img_idx].cols), + std::min(bl_tl.y + bl_height, images[img_idx].rows)); block_corners.push_back(corners[img_idx] + bl_tl); block_images.push_back(images[img_idx](Rect(bl_tl, bl_br))); - block_masks.push_back(make_pair(masks[img_idx].first(Rect(bl_tl, bl_br)), + block_masks.push_back(std::make_pair(masks[img_idx].first(Rect(bl_tl, bl_br)), masks[img_idx].second)); } } @@ -200,7 +198,7 @@ void BlocksGainCompensator::feed(const vector &corners, const vector GainCompensator compensator; compensator.feed(block_corners, block_images, block_masks); - vector gains = compensator.gains(); + std::vector gains = compensator.gains(); gain_maps_.resize(num_images); Mat_ ker(1, 3); diff --git a/modules/stitching/src/matchers.cpp b/modules/stitching/src/matchers.cpp index d173de7de..9584d4811 100644 --- a/modules/stitching/src/matchers.cpp +++ b/modules/stitching/src/matchers.cpp @@ -42,7 +42,6 @@ #include "precomp.hpp" -using namespace std; using namespace cv; using namespace cv::detail; @@ -72,8 +71,8 @@ struct MatchPairsBody : matcher(other.matcher), features(other.features), pairwise_matches(other.pairwise_matches), near_pairs(other.near_pairs) {} - MatchPairsBody(FeaturesMatcher &_matcher, const vector &_features, - vector &_pairwise_matches, vector > &_near_pairs) + MatchPairsBody(FeaturesMatcher &_matcher, const std::vector &_features, + std::vector &_pairwise_matches, std::vector > &_near_pairs) : matcher(_matcher), features(_features), pairwise_matches(_pairwise_matches), near_pairs(_near_pairs) {} @@ -107,9 +106,9 @@ struct MatchPairsBody } FeaturesMatcher &matcher; - const vector &features; - vector &pairwise_matches; - vector > &near_pairs; + const std::vector &features; + std::vector &pairwise_matches; + std::vector > &near_pairs; private: void operator =(const MatchPairsBody&); @@ -118,7 +117,7 @@ private: ////////////////////////////////////////////////////////////////////////////// -typedef set > MatchesSet; +typedef std::set > MatchesSet; // These two classes are aimed to find features matches only, not to // estimate homography @@ -146,7 +145,7 @@ private: float match_conf_; GpuMat descriptors1_, descriptors2_; GpuMat train_idx_, distance_, all_dist_; - vector< vector > pair_matches; + std::vector< std::vector > pair_matches; }; #endif @@ -173,7 +172,7 @@ void CpuMatcher::match(const ImageFeatures &features1, const ImageFeatures &feat } FlannBasedMatcher matcher(indexParams, searchParams); - vector< vector > pair_matches; + std::vector< std::vector > pair_matches; MatchesSet matches; // Find 1->2 matches @@ -187,7 +186,7 @@ void CpuMatcher::match(const ImageFeatures &features1, const ImageFeatures &feat if (m0.distance < (1.f - match_conf_) * m1.distance) { matches_info.matches.push_back(m0); - matches.insert(make_pair(m0.queryIdx, m0.trainIdx)); + matches.insert(std::make_pair(m0.queryIdx, m0.trainIdx)); } } LOG("\n1->2 matches: " << matches_info.matches.size() << endl); @@ -202,7 +201,7 @@ void CpuMatcher::match(const ImageFeatures &features1, const ImageFeatures &feat const DMatch& m0 = pair_matches[i][0]; const DMatch& m1 = pair_matches[i][1]; if (m0.distance < (1.f - match_conf_) * m1.distance) - if (matches.find(make_pair(m0.trainIdx, m0.queryIdx)) == matches.end()) + if (matches.find(std::make_pair(m0.trainIdx, m0.queryIdx)) == matches.end()) matches_info.matches.push_back(DMatch(m0.trainIdx, m0.queryIdx, m0.distance)); } LOG("1->2 & 2->1 matches: " << matches_info.matches.size() << endl); @@ -235,7 +234,7 @@ void GpuMatcher::match(const ImageFeatures &features1, const ImageFeatures &feat if (m0.distance < (1.f - match_conf_) * m1.distance) { matches_info.matches.push_back(m0); - matches.insert(make_pair(m0.queryIdx, m0.trainIdx)); + matches.insert(std::make_pair(m0.queryIdx, m0.trainIdx)); } } @@ -250,7 +249,7 @@ void GpuMatcher::match(const ImageFeatures &features1, const ImageFeatures &feat const DMatch& m0 = pair_matches[i][0]; const DMatch& m1 = pair_matches[i][1]; if (m0.distance < (1.f - match_conf_) * m1.distance) - if (matches.find(make_pair(m0.trainIdx, m0.queryIdx)) == matches.end()) + if (matches.find(std::make_pair(m0.trainIdx, m0.queryIdx)) == matches.end()) matches_info.matches.push_back(DMatch(m0.trainIdx, m0.queryIdx, m0.distance)); } } @@ -262,7 +261,7 @@ void GpuMatcher::collectGarbage() train_idx_.release(); distance_.release(); all_dist_.release(); - vector< vector >().swap(pair_matches); + std::vector< std::vector >().swap(pair_matches); } #endif @@ -279,9 +278,9 @@ void FeaturesFinder::operator ()(const Mat &image, ImageFeatures &features) } -void FeaturesFinder::operator ()(const Mat &image, ImageFeatures &features, const vector &rois) +void FeaturesFinder::operator ()(const Mat &image, ImageFeatures &features, const std::vector &rois) { - vector roi_features(rois.size()); + std::vector roi_features(rois.size()); size_t total_kps_count = 0; int total_descriptors_height = 0; @@ -499,7 +498,7 @@ const MatchesInfo& MatchesInfo::operator =(const MatchesInfo &other) ////////////////////////////////////////////////////////////////////////////// -void FeaturesMatcher::operator ()(const vector &features, vector &pairwise_matches, +void FeaturesMatcher::operator ()(const std::vector &features, std::vector &pairwise_matches, const Mat &mask) { const int num_images = static_cast(features.size()); @@ -509,11 +508,11 @@ void FeaturesMatcher::operator ()(const vector &features, vector< if (mask_.empty()) mask_ = Mat::ones(num_images, num_images, CV_8U); - vector > near_pairs; + std::vector > near_pairs; for (int i = 0; i < num_images - 1; ++i) for (int j = i + 1; j < num_images; ++j) if (features[i].keypoints.size() > 0 && features[j].keypoints.size() > 0 && mask_(i, j)) - near_pairs.push_back(make_pair(i, j)); + near_pairs.push_back(std::make_pair(i, j)); pairwise_matches.resize(num_images * num_images); MatchPairsBody body(*this, features, pairwise_matches, near_pairs); @@ -574,7 +573,7 @@ void BestOf2NearestMatcher::match(const ImageFeatures &features1, const ImageFea // Find pair-wise motion matches_info.H = findHomography(src_points, dst_points, matches_info.inliers_mask, CV_RANSAC); - if (std::abs(determinant(matches_info.H)) < numeric_limits::epsilon()) + if (std::abs(determinant(matches_info.H)) < std::numeric_limits::epsilon()) return; // Find number of inliers diff --git a/modules/stitching/src/motion_estimators.cpp b/modules/stitching/src/motion_estimators.cpp index ab27a46a2..f00f563a2 100644 --- a/modules/stitching/src/motion_estimators.cpp +++ b/modules/stitching/src/motion_estimators.cpp @@ -42,7 +42,6 @@ #include "precomp.hpp" -using namespace std; using namespace cv; using namespace cv::detail; @@ -50,7 +49,7 @@ namespace { struct IncDistance { - IncDistance(vector &vdists) : dists(&vdists[0]) {} + IncDistance(std::vector &vdists) : dists(&vdists[0]) {} void operator ()(const GraphEdge &edge) { dists[edge.to] = dists[edge.from] + 1; } int* dists; }; @@ -58,7 +57,7 @@ struct IncDistance struct CalcRotation { - CalcRotation(int _num_images, const vector &_pairwise_matches, vector &_cameras) + CalcRotation(int _num_images, const std::vector &_pairwise_matches, std::vector &_cameras) : num_images(_num_images), pairwise_matches(&_pairwise_matches[0]), cameras(&_cameras[0]) {} void operator ()(const GraphEdge &edge) @@ -101,8 +100,8 @@ void calcDeriv(const Mat &err1, const Mat &err2, double h, Mat res) namespace cv { namespace detail { -void HomographyBasedEstimator::estimate(const vector &features, const vector &pairwise_matches, - vector &cameras) +void HomographyBasedEstimator::estimate(const std::vector &features, const std::vector &pairwise_matches, + std::vector &cameras) { LOGLN("Estimating rotations..."); #if ENABLE_LOG @@ -113,11 +112,11 @@ void HomographyBasedEstimator::estimate(const vector &features, c #if 0 // Robustly estimate focal length from rotating cameras - vector Hs; + std::vector Hs; for (int iter = 0; iter < 100; ++iter) { int len = 2 + rand()%(pairwise_matches.size() - 1); - vector subset; + std::vector subset; selectRandomSubset(len, pairwise_matches.size(), subset); Hs.clear(); for (size_t i = 0; i < subset.size(); ++i) @@ -135,7 +134,7 @@ void HomographyBasedEstimator::estimate(const vector &features, c if (!is_focals_estimated_) { // Estimate focal length and set it for all cameras - vector focals; + std::vector focals; estimateFocal(features, pairwise_matches, focals); cameras.assign(num_images, CameraParams()); for (int i = 0; i < num_images; ++i) @@ -152,7 +151,7 @@ void HomographyBasedEstimator::estimate(const vector &features, c // Restore global motion Graph span_tree; - vector span_tree_centers; + std::vector span_tree_centers; findMaxSpanningTree(num_images, pairwise_matches, span_tree, span_tree_centers); span_tree.walkBreadthFirst(span_tree_centers[0], CalcRotation(num_images, pairwise_matches, cameras)); @@ -169,9 +168,9 @@ void HomographyBasedEstimator::estimate(const vector &features, c ////////////////////////////////////////////////////////////////////////////// -void BundleAdjusterBase::estimate(const vector &features, - const vector &pairwise_matches, - vector &cameras) +void BundleAdjusterBase::estimate(const std::vector &features, + const std::vector &pairwise_matches, + std::vector &cameras) { LOG_CHAT("Bundle adjustment"); #if ENABLE_LOG @@ -192,7 +191,7 @@ void BundleAdjusterBase::estimate(const vector &features, { const MatchesInfo& matches_info = pairwise_matches_[i * num_images_ + j]; if (matches_info.confidence > conf_thresh_) - edges_.push_back(make_pair(i, j)); + edges_.push_back(std::make_pair(i, j)); } } @@ -242,14 +241,14 @@ void BundleAdjusterBase::estimate(const vector &features, } LOGLN_CHAT(""); - LOGLN_CHAT("Bundle adjustment, final RMS error: " << sqrt(err.dot(err) / total_num_matches_)); + LOGLN_CHAT("Bundle adjustment, final RMS error: " << std::sqrt(err.dot(err) / total_num_matches_)); LOGLN_CHAT("Bundle adjustment, iterations done: " << iter); obtainRefinedCameraParams(cameras); // Normalize motion to center image Graph span_tree; - vector span_tree_centers; + std::vector span_tree_centers; findMaxSpanningTree(num_images_, pairwise_matches, span_tree, span_tree_centers); Mat R_inv = cameras[span_tree_centers[0]].R.inv(); for (int i = 0; i < num_images_; ++i) @@ -261,7 +260,7 @@ void BundleAdjusterBase::estimate(const vector &features, ////////////////////////////////////////////////////////////////////////////// -void BundleAdjusterReproj::setUpInitialCameraParams(const vector &cameras) +void BundleAdjusterReproj::setUpInitialCameraParams(const std::vector &cameras) { cam_params_.create(num_images_ * 7, 1, CV_64F); SVD svd; @@ -287,7 +286,7 @@ void BundleAdjusterReproj::setUpInitialCameraParams(const vector & } -void BundleAdjusterReproj::obtainRefinedCameraParams(vector &cameras) const +void BundleAdjusterReproj::obtainRefinedCameraParams(std::vector &cameras) const { for (int i = 0; i < num_images_; ++i) { @@ -442,7 +441,7 @@ void BundleAdjusterReproj::calcJacobian(Mat &jac) ////////////////////////////////////////////////////////////////////////////// -void BundleAdjusterRay::setUpInitialCameraParams(const vector &cameras) +void BundleAdjusterRay::setUpInitialCameraParams(const std::vector &cameras) { cam_params_.create(num_images_ * 4, 1, CV_64F); SVD svd; @@ -465,7 +464,7 @@ void BundleAdjusterRay::setUpInitialCameraParams(const vector &cam } -void BundleAdjusterRay::obtainRefinedCameraParams(vector &cameras) const +void BundleAdjusterRay::obtainRefinedCameraParams(std::vector &cameras) const { for (int i = 0; i < num_images_; ++i) { @@ -537,17 +536,17 @@ void BundleAdjusterRay::calcError(Mat &err) double x1 = H1(0,0)*p1.x + H1(0,1)*p1.y + H1(0,2); double y1 = H1(1,0)*p1.x + H1(1,1)*p1.y + H1(1,2); double z1 = H1(2,0)*p1.x + H1(2,1)*p1.y + H1(2,2); - double len = sqrt(x1*x1 + y1*y1 + z1*z1); + double len = std::sqrt(x1*x1 + y1*y1 + z1*z1); x1 /= len; y1 /= len; z1 /= len; Point2f p2 = features2.keypoints[m.trainIdx].pt; double x2 = H2(0,0)*p2.x + H2(0,1)*p2.y + H2(0,2); double y2 = H2(1,0)*p2.x + H2(1,1)*p2.y + H2(1,2); double z2 = H2(2,0)*p2.x + H2(2,1)*p2.y + H2(2,2); - len = sqrt(x2*x2 + y2*y2 + z2*z2); + len = std::sqrt(x2*x2 + y2*y2 + z2*z2); x2 /= len; y2 /= len; z2 /= len; - double mult = sqrt(f1 * f2); + double mult = std::sqrt(f1 * f2); err.at(3 * match_idx, 0) = mult * (x1 - x2); err.at(3 * match_idx + 1, 0) = mult * (y1 - y2); err.at(3 * match_idx + 2, 0) = mult * (z1 - z2); @@ -583,7 +582,7 @@ void BundleAdjusterRay::calcJacobian(Mat &jac) ////////////////////////////////////////////////////////////////////////////// -void waveCorrect(vector &rmats, WaveCorrectKind kind) +void waveCorrect(std::vector &rmats, WaveCorrectKind kind) { LOGLN("Wave correcting..."); #if ENABLE_LOG @@ -654,14 +653,14 @@ void waveCorrect(vector &rmats, WaveCorrectKind kind) ////////////////////////////////////////////////////////////////////////////// -string matchesGraphAsString(vector &pathes, vector &pairwise_matches, +std::string matchesGraphAsString(std::vector &pathes, std::vector &pairwise_matches, float conf_threshold) { - stringstream str; + std::stringstream str; str << "graph matches_graph{\n"; const int num_images = static_cast(pathes.size()); - set > span_tree_edges; + std::set > span_tree_edges; DisjointSets comps(num_images); for (int i = 0; i < num_images; ++i) @@ -675,25 +674,25 @@ string matchesGraphAsString(vector &pathes, vector &pairwis if (comp1 != comp2) { comps.mergeSets(comp1, comp2); - span_tree_edges.insert(make_pair(i, j)); + span_tree_edges.insert(std::make_pair(i, j)); } } } - for (set >::const_iterator itr = span_tree_edges.begin(); + for (std::set >::const_iterator itr = span_tree_edges.begin(); itr != span_tree_edges.end(); ++itr) { - pair edge = *itr; + std::pair edge = *itr; if (span_tree_edges.find(edge) != span_tree_edges.end()) { - string name_src = pathes[edge.first]; + std::string name_src = pathes[edge.first]; size_t prefix_len = name_src.find_last_of("/\\"); - if (prefix_len != string::npos) prefix_len++; else prefix_len = 0; + if (prefix_len != std::string::npos) prefix_len++; else prefix_len = 0; name_src = name_src.substr(prefix_len, name_src.size() - prefix_len); - string name_dst = pathes[edge.second]; + std::string name_dst = pathes[edge.second]; prefix_len = name_dst.find_last_of("/\\"); - if (prefix_len != string::npos) prefix_len++; else prefix_len = 0; + if (prefix_len != std::string::npos) prefix_len++; else prefix_len = 0; name_dst = name_dst.substr(prefix_len, name_dst.size() - prefix_len); int pos = edge.first*num_images + edge.second; @@ -708,9 +707,9 @@ string matchesGraphAsString(vector &pathes, vector &pairwis { if (comps.size[comps.findSetByElem((int)i)] == 1) { - string name = pathes[i]; + std::string name = pathes[i]; size_t prefix_len = name.find_last_of("/\\"); - if (prefix_len != string::npos) prefix_len++; else prefix_len = 0; + if (prefix_len != std::string::npos) prefix_len++; else prefix_len = 0; name = name.substr(prefix_len, name.size() - prefix_len); str << "\"" << name << "\";\n"; } @@ -720,7 +719,7 @@ string matchesGraphAsString(vector &pathes, vector &pairwis return str.str(); } -vector leaveBiggestComponent(vector &features, vector &pairwise_matches, +std::vector leaveBiggestComponent(std::vector &features, std::vector &pairwise_matches, float conf_threshold) { const int num_images = static_cast(features.size()); @@ -739,18 +738,18 @@ vector leaveBiggestComponent(vector &features, vector(max_element(comps.size.begin(), comps.size.end()) - comps.size.begin()); + int max_comp = static_cast(std::max_element(comps.size.begin(), comps.size.end()) - comps.size.begin()); - vector indices; - vector indices_removed; + std::vector indices; + std::vector indices_removed; for (int i = 0; i < num_images; ++i) if (comps.findSetByElem(i) == max_comp) indices.push_back(i); else indices_removed.push_back(i); - vector features_subset; - vector pairwise_matches_subset; + std::vector features_subset; + std::vector pairwise_matches_subset; for (size_t i = 0; i < indices.size(); ++i) { features_subset.push_back(features[indices[i]]); @@ -779,11 +778,11 @@ vector leaveBiggestComponent(vector &features, vector &pairwise_matches, - Graph &span_tree, vector ¢ers) +void findMaxSpanningTree(int num_images, const std::vector &pairwise_matches, + Graph &span_tree, std::vector ¢ers) { Graph graph(num_images); - vector edges; + std::vector edges; // Construct images graph and remember its edges for (int i = 0; i < num_images; ++i) @@ -800,10 +799,10 @@ void findMaxSpanningTree(int num_images, const vector &pairwise_mat DisjointSets comps(num_images); span_tree.create(num_images); - vector span_tree_powers(num_images, 0); + std::vector span_tree_powers(num_images, 0); // Find maximum spanning tree - sort(edges.begin(), edges.end(), greater()); + sort(edges.begin(), edges.end(), std::greater()); for (size_t i = 0; i < edges.size(); ++i) { int comp1 = comps.findSetByElem(edges[i].from); @@ -819,20 +818,20 @@ void findMaxSpanningTree(int num_images, const vector &pairwise_mat } // Find spanning tree leafs - vector span_tree_leafs; + std::vector span_tree_leafs; for (int i = 0; i < num_images; ++i) if (span_tree_powers[i] == 1) span_tree_leafs.push_back(i); // Find maximum distance from each spanning tree vertex - vector max_dists(num_images, 0); - vector cur_dists; + std::vector max_dists(num_images, 0); + std::vector cur_dists; for (size_t i = 0; i < span_tree_leafs.size(); ++i) { cur_dists.assign(num_images, 0); span_tree.walkBreadthFirst(span_tree_leafs[i], IncDistance(cur_dists)); for (int j = 0; j < num_images; ++j) - max_dists[j] = max(max_dists[j], cur_dists[j]); + max_dists[j] = std::max(max_dists[j], cur_dists[j]); } // Find min-max distance diff --git a/modules/stitching/src/seam_finders.cpp b/modules/stitching/src/seam_finders.cpp index 1439a6919..d55fc70b7 100644 --- a/modules/stitching/src/seam_finders.cpp +++ b/modules/stitching/src/seam_finders.cpp @@ -43,13 +43,11 @@ #include "precomp.hpp" #include -using namespace std; - namespace cv { namespace detail { -void PairwiseSeamFinder::find(const vector &src, const vector &corners, - vector &masks) +void PairwiseSeamFinder::find(const std::vector &src, const std::vector &corners, + std::vector &masks) { LOGLN("Finding seams..."); if (src.size() == 0) @@ -85,8 +83,8 @@ void PairwiseSeamFinder::run() } -void VoronoiSeamFinder::find(const vector &sizes, const vector &corners, - vector &masks) +void VoronoiSeamFinder::find(const std::vector &sizes, const std::vector &corners, + std::vector &masks) { LOGLN("Finding seams..."); if (sizes.size() == 0) @@ -162,7 +160,7 @@ void VoronoiSeamFinder::findInPair(size_t first, size_t second, Rect roi) DpSeamFinder::DpSeamFinder(CostFunction costFunc) : costFunc_(costFunc) {} -void DpSeamFinder::find(const vector &src, const vector &corners, vector &masks) +void DpSeamFinder::find(const std::vector &src, const std::vector &corners, std::vector &masks) { LOGLN("Finding seams..."); #if ENABLE_LOG @@ -172,14 +170,14 @@ void DpSeamFinder::find(const vector &src, const vector &corners, ve if (src.size() == 0) return; - vector > pairs; + std::vector > pairs; for (size_t i = 0; i+1 < src.size(); ++i) for (size_t j = i+1; j < src.size(); ++j) - pairs.push_back(make_pair(i, j)); + pairs.push_back(std::make_pair(i, j)); sort(pairs.begin(), pairs.end(), ImagePairLess(src, corners)); - reverse(pairs.begin(), pairs.end()); + std::reverse(pairs.begin(), pairs.end()); for (size_t i = 0; i < pairs.size(); ++i) { @@ -271,11 +269,11 @@ void DpSeamFinder::findComponents() for (int x = 0; x < unionSize_.width; ++x) { if (mask1_(y, x) && mask2_(y, x)) - labels_(y, x) = numeric_limits::max(); + labels_(y, x) = std::numeric_limits::max(); else if (mask1_(y, x)) - labels_(y, x) = numeric_limits::max()-1; + labels_(y, x) = std::numeric_limits::max()-1; else if (mask2_(y, x)) - labels_(y, x) = numeric_limits::max()-2; + labels_(y, x) = std::numeric_limits::max()-2; else labels_(y, x) = 0; } @@ -285,19 +283,19 @@ void DpSeamFinder::findComponents() { for (int x = 0; x < unionSize_.width; ++x) { - if (labels_(y, x) >= numeric_limits::max()-2) + if (labels_(y, x) >= std::numeric_limits::max()-2) { - if (labels_(y, x) == numeric_limits::max()) + if (labels_(y, x) == std::numeric_limits::max()) states_.push_back(INTERS); - else if (labels_(y, x) == numeric_limits::max()-1) + else if (labels_(y, x) == std::numeric_limits::max()-1) states_.push_back(FIRST); - else if (labels_(y, x) == numeric_limits::max()-2) + else if (labels_(y, x) == std::numeric_limits::max()-2) states_.push_back(SECOND); floodFill(labels_, Point(x, y), ++ncomps_); tls_.push_back(Point(x, y)); brs_.push_back(Point(x+1, y+1)); - contours_.push_back(vector()); + contours_.push_back(std::vector()); } if (labels_(y, x)) @@ -325,14 +323,14 @@ void DpSeamFinder::findEdges() { // find edges between components - map, int> wedges; // weighted edges + std::map, int> wedges; // weighted edges for (int ci = 0; ci < ncomps_-1; ++ci) { for (int cj = ci+1; cj < ncomps_; ++cj) { - wedges[make_pair(ci, cj)] = 0; - wedges[make_pair(cj, ci)] = 0; + wedges[std::make_pair(ci, cj)] = 0; + wedges[std::make_pair(cj, ci)] = 0; } } @@ -346,26 +344,26 @@ void DpSeamFinder::findEdges() if (x > 0 && labels_(y, x-1) && labels_(y, x-1) != l) { - wedges[make_pair(ci, labels_(y, x-1)-1)]++; - wedges[make_pair(labels_(y, x-1)-1, ci)]++; + wedges[std::make_pair(ci, labels_(y, x-1)-1)]++; + wedges[std::make_pair(labels_(y, x-1)-1, ci)]++; } if (y > 0 && labels_(y-1, x) && labels_(y-1, x) != l) { - wedges[make_pair(ci, labels_(y-1, x)-1)]++; - wedges[make_pair(labels_(y-1, x)-1, ci)]++; + wedges[std::make_pair(ci, labels_(y-1, x)-1)]++; + wedges[std::make_pair(labels_(y-1, x)-1, ci)]++; } if (x < unionSize_.width-1 && labels_(y, x+1) && labels_(y, x+1) != l) { - wedges[make_pair(ci, labels_(y, x+1)-1)]++; - wedges[make_pair(labels_(y, x+1)-1, ci)]++; + wedges[std::make_pair(ci, labels_(y, x+1)-1)]++; + wedges[std::make_pair(labels_(y, x+1)-1, ci)]++; } if (y < unionSize_.height-1 && labels_(y+1, x) && labels_(y+1, x) != l) { - wedges[make_pair(ci, labels_(y+1, x)-1)]++; - wedges[make_pair(labels_(y+1, x)-1, ci)]++; + wedges[std::make_pair(ci, labels_(y+1, x)-1)]++; + wedges[std::make_pair(labels_(y+1, x)-1, ci)]++; } } } @@ -376,11 +374,11 @@ void DpSeamFinder::findEdges() { for (int cj = ci+1; cj < ncomps_; ++cj) { - map, int>::iterator itr = wedges.find(make_pair(ci, cj)); + std::map, int>::iterator itr = wedges.find(std::make_pair(ci, cj)); if (itr != wedges.end() && itr->second > 0) edges_.insert(itr->first); - itr = wedges.find(make_pair(cj, ci)); + itr = wedges.find(std::make_pair(cj, ci)); if (itr != wedges.end() && itr->second > 0) edges_.insert(itr->first); } @@ -402,7 +400,7 @@ void DpSeamFinder::resolveConflicts( int c1 = 0, c2 = 0; hasConflict = false; - for (set >::iterator itr = edges_.begin(); itr != edges_.end(); ++itr) + for (std::set >::iterator itr = edges_.begin(); itr != edges_.end(); ++itr) { c1 = itr->first; c2 = itr->second; @@ -436,7 +434,7 @@ void DpSeamFinder::resolveConflicts( Point p1, p2; if (getSeamTips(c1, c2, p1, p2)) { - vector seam; + std::vector seam; bool isHorizontalSeam; if (estimateSeam(image1, image2, tl1, tl2, c1, p1, p2, seam, isHorizontalSeam)) @@ -456,8 +454,8 @@ void DpSeamFinder::resolveConflicts( int x0 = tls_[c[i]].x, x1 = brs_[c[i]].x; int y0 = tls_[c[i]].y, y1 = brs_[c[i]].y; - tls_[c[i]] = Point(numeric_limits::max(), numeric_limits::max()); - brs_[c[i]] = Point(numeric_limits::min(), numeric_limits::min()); + tls_[c[i]] = Point(std::numeric_limits::max(), std::numeric_limits::max()); + brs_[c[i]] = Point(std::numeric_limits::min(), std::numeric_limits::min()); contours_[c[i]].clear(); for (int y = y0; y < y1; ++y) @@ -483,8 +481,8 @@ void DpSeamFinder::resolveConflicts( // remove edges - edges_.erase(make_pair(c1, c2)); - edges_.erase(make_pair(c2, c1)); + edges_.erase(std::make_pair(c1, c2)); + edges_.erase(std::make_pair(c2, c1)); } } @@ -543,9 +541,9 @@ void DpSeamFinder::computeGradients(const Mat &image1, const Mat &image2) bool DpSeamFinder::hasOnlyOneNeighbor(int comp) { - set >::iterator begin, end; - begin = lower_bound(edges_.begin(), edges_.end(), make_pair(comp, numeric_limits::min())); - end = upper_bound(edges_.begin(), edges_.end(), make_pair(comp, numeric_limits::max())); + std::set >::iterator begin, end; + begin = lower_bound(edges_.begin(), edges_.end(), std::make_pair(comp, std::numeric_limits::min())); + end = upper_bound(edges_.begin(), edges_.end(), std::make_pair(comp, std::numeric_limits::max())); return ++begin == end; } @@ -579,7 +577,7 @@ bool DpSeamFinder::getSeamTips(int comp1, int comp2, Point &p1, Point &p2) // find special points - vector specialPoints; + std::vector specialPoints; int l2 = comp2+1; for (size_t i = 0; i < contours_[comp1].size(); ++i) @@ -603,15 +601,15 @@ bool DpSeamFinder::getSeamTips(int comp1, int comp2, Point &p1, Point &p2) // find clusters - vector labels; + std::vector labels; cv::partition(specialPoints, labels, ClosePoints(10)); - int nlabels = *max_element(labels.begin(), labels.end()) + 1; + int nlabels = *std::max_element(labels.begin(), labels.end()) + 1; if (nlabels < 2) return false; - vector sum(nlabels); - vector > points(nlabels); + std::vector sum(nlabels); + std::vector > points(nlabels); for (size_t i = 0; i < specialPoints.size(); ++i) { @@ -622,7 +620,7 @@ bool DpSeamFinder::getSeamTips(int comp1, int comp2, Point &p1, Point &p2) // select two most distant clusters int idx[2] = {-1,-1}; - double maxDist = -numeric_limits::max(); + double maxDist = -std::numeric_limits::max(); for (int i = 0; i < nlabels-1; ++i) { @@ -653,7 +651,7 @@ bool DpSeamFinder::getSeamTips(int comp1, int comp2, Point &p1, Point &p2) double cy = cvRound(sum[idx[i]].y / size); size_t closest = points[idx[i]].size(); - double minDist = numeric_limits::max(); + double minDist = std::numeric_limits::max(); for (size_t j = 0; j < points[idx[i]].size(); ++j) { @@ -781,7 +779,7 @@ void DpSeamFinder::computeCosts( bool DpSeamFinder::estimateSeam( const Mat &image1, const Mat &image2, Point tl1, Point tl2, int comp, - Point p1, Point p2, vector &seam, bool &isHorizontal) + Point p1, Point p2, std::vector &seam, bool &isHorizontal) { CV_Assert(states_[comp] & INTERS); @@ -822,7 +820,7 @@ bool DpSeamFinder::estimateSeam( cost(src) = 0.f; int nsteps; - pair steps[3]; + std::pair steps[3]; if (isHorizontal) { @@ -837,16 +835,16 @@ bool DpSeamFinder::estimateSeam( if (labels_(y + roi.y, x + roi.x) == l) { if (reachable(y, x-1)) - steps[nsteps++] = make_pair(cost(y, x-1) + costH(y, x-1), 1); + steps[nsteps++] = std::make_pair(cost(y, x-1) + costH(y, x-1), 1); if (y > 0 && reachable(y-1, x-1)) - steps[nsteps++] = make_pair(cost(y-1, x-1) + costH(y-1, x-1) + costV(y-1, x), 2); + steps[nsteps++] = std::make_pair(cost(y-1, x-1) + costH(y-1, x-1) + costV(y-1, x), 2); if (y < roi.height-1 && reachable(y+1, x-1)) - steps[nsteps++] = make_pair(cost(y+1, x-1) + costH(y+1, x-1) + costV(y, x), 3); + steps[nsteps++] = std::make_pair(cost(y+1, x-1) + costH(y+1, x-1) + costV(y, x), 3); } if (nsteps) { - pair opt = *min_element(steps, steps + nsteps); + std::pair opt = *min_element(steps, steps + nsteps); cost(y, x) = opt.first; control(y, x) = (uchar)opt.second; reachable(y, x) = 255; @@ -867,16 +865,16 @@ bool DpSeamFinder::estimateSeam( if (labels_(y + roi.y, x + roi.x) == l) { if (reachable(y-1, x)) - steps[nsteps++] = make_pair(cost(y-1, x) + costV(y-1, x), 1); + steps[nsteps++] = std::make_pair(cost(y-1, x) + costV(y-1, x), 1); if (x > 0 && reachable(y-1, x-1)) - steps[nsteps++] = make_pair(cost(y-1, x-1) + costV(y-1, x-1) + costH(y, x-1), 2); + steps[nsteps++] = std::make_pair(cost(y-1, x-1) + costV(y-1, x-1) + costH(y, x-1), 2); if (x < roi.width-1 && reachable(y-1, x+1)) - steps[nsteps++] = make_pair(cost(y-1, x+1) + costV(y-1, x+1) + costH(y, x), 3); + steps[nsteps++] = std::make_pair(cost(y-1, x+1) + costV(y-1, x+1) + costH(y, x), 3); } if (nsteps) { - pair opt = *min_element(steps, steps + nsteps); + std::pair opt = *min_element(steps, steps + nsteps); cost(y, x) = opt.first; control(y, x) = (uchar)opt.second; reachable(y, x) = 255; @@ -914,7 +912,7 @@ bool DpSeamFinder::estimateSeam( } if (!swapped) - reverse(seam.begin(), seam.end()); + std::reverse(seam.begin(), seam.end()); CV_Assert(seam.front() == p1); CV_Assert(seam.back() == p2); @@ -923,7 +921,7 @@ bool DpSeamFinder::estimateSeam( void DpSeamFinder::updateLabelsUsingSeam( - int comp1, int comp2, const vector &seam, bool isHorizontalSeam) + int comp1, int comp2, const std::vector &seam, bool isHorizontalSeam) { Mat_ mask = Mat::zeros(brs_[comp1].y - tls_[comp1].y, brs_[comp1].x - tls_[comp1].x, CV_32S); @@ -1001,13 +999,13 @@ void DpSeamFinder::updateLabelsUsingSeam( // find new components connected with the second component and // with other components except the ones we are working with - map connect2; - map connectOther; + std::map connect2; + std::map connectOther; for (int i = 1; i <= ncomps; ++i) { - connect2.insert(make_pair(i, 0)); - connectOther.insert(make_pair(i, 0)); + connect2.insert(std::make_pair(i, 0)); + connectOther.insert(std::make_pair(i, 0)); } for (size_t i = 0; i < contours_[comp1].size(); ++i) @@ -1032,9 +1030,9 @@ void DpSeamFinder::updateLabelsUsingSeam( } } - vector isAdjComp(ncomps + 1, 0); + std::vector isAdjComp(ncomps + 1, 0); - for (map::iterator itr = connect2.begin(); itr != connect2.end(); ++itr) + for (std::map::iterator itr = connect2.begin(); itr != connect2.end(); ++itr) { double len = static_cast(contours_[comp1].size()); isAdjComp[itr->first] = itr->second / len > 0.05 && connectOther.find(itr->first)->second / len < 0.1; @@ -1057,7 +1055,7 @@ public: ~Impl() {} - void find(const vector &src, const vector &corners, vector &masks); + void find(const std::vector &src, const std::vector &corners, std::vector &masks); void findInPair(size_t first, size_t second, Rect roi); private: @@ -1067,15 +1065,15 @@ private: const Mat &dy1, const Mat &dy2, const Mat &mask1, const Mat &mask2, GCGraph &graph); - vector dx_, dy_; + std::vector dx_, dy_; int cost_type_; float terminal_cost_; float bad_region_penalty_; }; -void GraphCutSeamFinder::Impl::find(const vector &src, const vector &corners, - vector &masks) +void GraphCutSeamFinder::Impl::find(const std::vector &src, const std::vector &corners, + std::vector &masks) { // Compute gradients dx_.resize(src.size()); @@ -1311,16 +1309,16 @@ GraphCutSeamFinder::GraphCutSeamFinder(int cost_type, float terminal_cost, float GraphCutSeamFinder::~GraphCutSeamFinder() {} -void GraphCutSeamFinder::find(const vector &src, const vector &corners, - vector &masks) +void GraphCutSeamFinder::find(const std::vector &src, const std::vector &corners, + std::vector &masks) { impl_->find(src, corners, masks); } #ifdef HAVE_OPENCV_GPU -void GraphCutSeamFinderGpu::find(const vector &src, const vector &corners, - vector &masks) +void GraphCutSeamFinderGpu::find(const std::vector &src, const std::vector &corners, + std::vector &masks) { // Compute gradients dx_.resize(src.size()); diff --git a/modules/stitching/src/stitcher.cpp b/modules/stitching/src/stitcher.cpp index 2b9573b48..cef9fe4e9 100644 --- a/modules/stitching/src/stitcher.cpp +++ b/modules/stitching/src/stitcher.cpp @@ -42,8 +42,6 @@ #include "precomp.hpp" -using namespace std; - namespace cv { Stitcher Stitcher::createDefault(bool try_use_gpu) @@ -90,11 +88,11 @@ Stitcher Stitcher::createDefault(bool try_use_gpu) Stitcher::Status Stitcher::estimateTransform(InputArray images) { - return estimateTransform(images, vector >()); + return estimateTransform(images, std::vector >()); } -Stitcher::Status Stitcher::estimateTransform(InputArray images, const vector > &rois) +Stitcher::Status Stitcher::estimateTransform(InputArray images, const std::vector > &rois) { images.getMatVector(imgs_); rois_ = rois; @@ -113,7 +111,7 @@ Stitcher::Status Stitcher::estimateTransform(InputArray images, const vector(), pano); + return composePanorama(std::vector(), pano); } @@ -121,7 +119,7 @@ Stitcher::Status Stitcher::composePanorama(InputArray images, OutputArray pano) { LOGLN("Warping images (auxiliary)... "); - vector imgs; + std::vector imgs; images.getMatVector(imgs); if (!imgs.empty()) { @@ -137,8 +135,8 @@ Stitcher::Status Stitcher::composePanorama(InputArray images, OutputArray pano) seam_est_imgs_[i] = img.clone(); } - vector seam_est_imgs_subset; - vector imgs_subset; + std::vector seam_est_imgs_subset; + std::vector imgs_subset; for (size_t i = 0; i < indices_.size(); ++i) { @@ -156,11 +154,11 @@ Stitcher::Status Stitcher::composePanorama(InputArray images, OutputArray pano) int64 t = getTickCount(); #endif - vector corners(imgs_.size()); - vector masks_warped(imgs_.size()); - vector images_warped(imgs_.size()); - vector sizes(imgs_.size()); - vector masks(imgs_.size()); + std::vector corners(imgs_.size()); + std::vector masks_warped(imgs_.size()); + std::vector images_warped(imgs_.size()); + std::vector sizes(imgs_.size()); + std::vector masks(imgs_.size()); // Prepare image masks for (size_t i = 0; i < imgs_.size(); ++i) @@ -186,7 +184,7 @@ Stitcher::Status Stitcher::composePanorama(InputArray images, OutputArray pano) w->warp(masks[i], K, cameras_[i].R, INTER_NEAREST, BORDER_CONSTANT, masks_warped[i]); } - vector images_warped_f(imgs_.size()); + std::vector images_warped_f(imgs_.size()); for (size_t i = 0; i < imgs_.size(); ++i) images_warped[i].convertTo(images_warped_f[i], CV_32F); @@ -227,7 +225,7 @@ Stitcher::Status Stitcher::composePanorama(InputArray images, OutputArray pano) if (!is_compose_scale_set) { if (compose_resol_ > 0) - compose_scale = min(1.0, sqrt(compose_resol_ * 1e6 / full_img.size().area())); + compose_scale = std::min(1.0, std::sqrt(compose_resol_ * 1e6 / full_img.size().area())); is_compose_scale_set = true; // Compute relative scales @@ -325,7 +323,7 @@ Stitcher::Status Stitcher::stitch(InputArray images, OutputArray pano) } -Stitcher::Status Stitcher::stitch(InputArray images, const vector > &rois, OutputArray pano) +Stitcher::Status Stitcher::stitch(InputArray images, const std::vector > &rois, OutputArray pano) { Status status = estimateTransform(images, rois); if (status != OK) @@ -372,14 +370,14 @@ Stitcher::Status Stitcher::matchImages() { if (!is_work_scale_set) { - work_scale_ = min(1.0, sqrt(registr_resol_ * 1e6 / full_img.size().area())); + work_scale_ = std::min(1.0, std::sqrt(registr_resol_ * 1e6 / full_img.size().area())); is_work_scale_set = true; } resize(full_img, img, Size(), work_scale_, work_scale_); } if (!is_seam_scale_set) { - seam_scale_ = min(1.0, sqrt(seam_est_resol_ * 1e6 / full_img.size().area())); + seam_scale_ = std::min(1.0, std::sqrt(seam_est_resol_ * 1e6 / full_img.size().area())); seam_work_aspect_ = seam_scale_ / work_scale_; is_seam_scale_set = true; } @@ -388,7 +386,7 @@ Stitcher::Status Stitcher::matchImages() (*features_finder_)(img, features_[i]); else { - vector rois(rois_[i].size()); + std::vector rois(rois_[i].size()); for (size_t j = 0; j < rois_[i].size(); ++j) { Point tl(cvRound(rois_[i][j].x * work_scale_), cvRound(rois_[i][j].y * work_scale_)); @@ -421,9 +419,9 @@ Stitcher::Status Stitcher::matchImages() // Leave only images we are sure are from the same panorama indices_ = detail::leaveBiggestComponent(features_, pairwise_matches_, (float)conf_thresh_); - vector seam_est_imgs_subset; - vector imgs_subset; - vector full_img_sizes_subset; + std::vector seam_est_imgs_subset; + std::vector imgs_subset; + std::vector full_img_sizes_subset; for (size_t i = 0; i < indices_.size(); ++i) { imgs_subset.push_back(imgs_[indices_[i]]); @@ -461,7 +459,7 @@ void Stitcher::estimateCameraParams() (*bundle_adjuster_)(features_, pairwise_matches_, cameras_); // Find median focal length and use it as final image scale - vector focals; + std::vector focals; for (size_t i = 0; i < cameras_.size(); ++i) { LOGLN("Camera #" << indices_[i] + 1 << ":\n" << cameras_[i].K()); @@ -476,7 +474,7 @@ void Stitcher::estimateCameraParams() if (do_wave_correct_) { - vector rmats; + std::vector rmats; for (size_t i = 0; i < cameras_.size(); ++i) rmats.push_back(cameras_[i].R); detail::waveCorrect(rmats, wave_correct_kind_); diff --git a/modules/stitching/src/util.cpp b/modules/stitching/src/util.cpp index ee0a73012..f6abf9e48 100644 --- a/modules/stitching/src/util.cpp +++ b/modules/stitching/src/util.cpp @@ -42,8 +42,6 @@ #include "precomp.hpp" -using namespace std; - namespace cv { namespace detail { @@ -102,10 +100,10 @@ void Graph::addEdge(int from, int to, float weight) bool overlapRoi(Point tl1, Point tl2, Size sz1, Size sz2, Rect &roi) { - int x_tl = max(tl1.x, tl2.x); - int y_tl = max(tl1.y, tl2.y); - int x_br = min(tl1.x + sz1.width, tl2.x + sz2.width); - int y_br = min(tl1.y + sz1.height, tl2.y + sz2.height); + int x_tl = std::max(tl1.x, tl2.x); + int y_tl = std::max(tl1.y, tl2.y); + int x_br = std::min(tl1.x + sz1.width, tl2.x + sz2.width); + int y_br = std::min(tl1.y + sz1.height, tl2.y + sz2.height); if (x_tl < x_br && y_tl < y_br) { roi = Rect(x_tl, y_tl, x_br - x_tl, y_br - y_tl); @@ -115,44 +113,44 @@ bool overlapRoi(Point tl1, Point tl2, Size sz1, Size sz2, Rect &roi) } -Rect resultRoi(const vector &corners, const vector &images) +Rect resultRoi(const std::vector &corners, const std::vector &images) { - vector sizes(images.size()); + std::vector sizes(images.size()); for (size_t i = 0; i < images.size(); ++i) sizes[i] = images[i].size(); return resultRoi(corners, sizes); } -Rect resultRoi(const vector &corners, const vector &sizes) +Rect resultRoi(const std::vector &corners, const std::vector &sizes) { CV_Assert(sizes.size() == corners.size()); - Point tl(numeric_limits::max(), numeric_limits::max()); - Point br(numeric_limits::min(), numeric_limits::min()); + Point tl(std::numeric_limits::max(), std::numeric_limits::max()); + Point br(std::numeric_limits::min(), std::numeric_limits::min()); for (size_t i = 0; i < corners.size(); ++i) { - tl.x = min(tl.x, corners[i].x); - tl.y = min(tl.y, corners[i].y); - br.x = max(br.x, corners[i].x + sizes[i].width); - br.y = max(br.y, corners[i].y + sizes[i].height); + tl.x = std::min(tl.x, corners[i].x); + tl.y = std::min(tl.y, corners[i].y); + br.x = std::max(br.x, corners[i].x + sizes[i].width); + br.y = std::max(br.y, corners[i].y + sizes[i].height); } return Rect(tl, br); } -Point resultTl(const vector &corners) +Point resultTl(const std::vector &corners) { - Point tl(numeric_limits::max(), numeric_limits::max()); + Point tl(std::numeric_limits::max(), std::numeric_limits::max()); for (size_t i = 0; i < corners.size(); ++i) { - tl.x = min(tl.x, corners[i].x); - tl.y = min(tl.y, corners[i].y); + tl.x = std::min(tl.x, corners[i].x); + tl.y = std::min(tl.y, corners[i].y); } return tl; } -void selectRandomSubset(int count, int size, vector &subset) +void selectRandomSubset(int count, int size, std::vector &subset) { subset.clear(); for (int i = 0; i < size; ++i) diff --git a/modules/stitching/src/warpers.cpp b/modules/stitching/src/warpers.cpp index 932958c6f..0df91edc6 100644 --- a/modules/stitching/src/warpers.cpp +++ b/modules/stitching/src/warpers.cpp @@ -42,8 +42,6 @@ #include "precomp.hpp" -using namespace std; - namespace cv { namespace detail { @@ -138,28 +136,28 @@ Rect PlaneWarper::warpRoi(Size src_size, const Mat &K, const Mat &R, const Mat & void PlaneWarper::detectResultRoi(Size src_size, Point &dst_tl, Point &dst_br) { - float tl_uf = numeric_limits::max(); - float tl_vf = numeric_limits::max(); - float br_uf = -numeric_limits::max(); - float br_vf = -numeric_limits::max(); + float tl_uf = std::numeric_limits::max(); + float tl_vf = std::numeric_limits::max(); + float br_uf = -std::numeric_limits::max(); + float br_vf = -std::numeric_limits::max(); float u, v; projector_.mapForward(0, 0, u, v); - tl_uf = min(tl_uf, u); tl_vf = min(tl_vf, v); - br_uf = max(br_uf, u); br_vf = max(br_vf, v); + tl_uf = std::min(tl_uf, u); tl_vf = std::min(tl_vf, v); + br_uf = std::max(br_uf, u); br_vf = std::max(br_vf, v); projector_.mapForward(0, static_cast(src_size.height - 1), u, v); - tl_uf = min(tl_uf, u); tl_vf = min(tl_vf, v); - br_uf = max(br_uf, u); br_vf = max(br_vf, v); + tl_uf = std::min(tl_uf, u); tl_vf = std::min(tl_vf, v); + br_uf = std::max(br_uf, u); br_vf = std::max(br_vf, v); projector_.mapForward(static_cast(src_size.width - 1), 0, u, v); - tl_uf = min(tl_uf, u); tl_vf = min(tl_vf, v); - br_uf = max(br_uf, u); br_vf = max(br_vf, v); + tl_uf = std::min(tl_uf, u); tl_vf = std::min(tl_vf, v); + br_uf = std::max(br_uf, u); br_vf = std::max(br_vf, v); projector_.mapForward(static_cast(src_size.width - 1), static_cast(src_size.height - 1), u, v); - tl_uf = min(tl_uf, u); tl_vf = min(tl_vf, v); - br_uf = max(br_uf, u); br_vf = max(br_vf, v); + tl_uf = std::min(tl_uf, u); tl_vf = std::min(tl_vf, v); + br_uf = std::max(br_uf, u); br_vf = std::max(br_vf, v); dst_tl.x = static_cast(tl_uf); dst_tl.y = static_cast(tl_vf); @@ -186,8 +184,8 @@ void SphericalWarper::detectResultRoi(Size src_size, Point &dst_tl, Point &dst_b float y_ = projector_.k[4] * y / z + projector_.k[5]; if (x_ > 0.f && x_ < src_size.width && y_ > 0.f && y_ < src_size.height) { - tl_uf = min(tl_uf, 0.f); tl_vf = min(tl_vf, static_cast(CV_PI * projector_.scale)); - br_uf = max(br_uf, 0.f); br_vf = max(br_vf, static_cast(CV_PI * projector_.scale)); + tl_uf = std::min(tl_uf, 0.f); tl_vf = std::min(tl_vf, static_cast(CV_PI * projector_.scale)); + br_uf = std::max(br_uf, 0.f); br_vf = std::max(br_vf, static_cast(CV_PI * projector_.scale)); } } @@ -200,8 +198,8 @@ void SphericalWarper::detectResultRoi(Size src_size, Point &dst_tl, Point &dst_b float y_ = projector_.k[4] * y / z + projector_.k[5]; if (x_ > 0.f && x_ < src_size.width && y_ > 0.f && y_ < src_size.height) { - tl_uf = min(tl_uf, 0.f); tl_vf = min(tl_vf, static_cast(0)); - br_uf = max(br_uf, 0.f); br_vf = max(br_vf, static_cast(0)); + tl_uf = std::min(tl_uf, 0.f); tl_vf = std::min(tl_vf, static_cast(0)); + br_uf = std::max(br_uf, 0.f); br_vf = std::max(br_vf, static_cast(0)); } } @@ -314,8 +312,8 @@ void SphericalPortraitWarper::detectResultRoi(Size src_size, Point &dst_tl, Poin float y_ = projector_.k[4] * y / z + projector_.k[5]; if (x_ > 0.f && x_ < src_size.width && y_ > 0.f && y_ < src_size.height) { - tl_uf = min(tl_uf, 0.f); tl_vf = min(tl_vf, static_cast(CV_PI * projector_.scale)); - br_uf = max(br_uf, 0.f); br_vf = max(br_vf, static_cast(CV_PI * projector_.scale)); + tl_uf = std::min(tl_uf, 0.f); tl_vf = std::min(tl_vf, static_cast(CV_PI * projector_.scale)); + br_uf = std::max(br_uf, 0.f); br_vf = std::max(br_vf, static_cast(CV_PI * projector_.scale)); } } @@ -328,8 +326,8 @@ void SphericalPortraitWarper::detectResultRoi(Size src_size, Point &dst_tl, Poin float y_ = projector_.k[4] * y / z + projector_.k[5]; if (x_ > 0.f && x_ < src_size.width && y_ > 0.f && y_ < src_size.height) { - tl_uf = min(tl_uf, 0.f); tl_vf = min(tl_vf, static_cast(0)); - br_uf = max(br_uf, 0.f); br_vf = max(br_vf, static_cast(0)); + tl_uf = std::min(tl_uf, 0.f); tl_vf = std::min(tl_vf, static_cast(0)); + br_uf = std::max(br_uf, 0.f); br_vf = std::max(br_vf, static_cast(0)); } } diff --git a/modules/video/include/opencv2/video/tracking.hpp b/modules/video/include/opencv2/video/tracking.hpp index b49747de7..12a326c11 100644 --- a/modules/video/include/opencv2/video/tracking.hpp +++ b/modules/video/include/opencv2/video/tracking.hpp @@ -1,7 +1,3 @@ -/*! \file tracking.hpp - \brief The Object and Feature Tracking - */ - /*M/////////////////////////////////////////////////////////////////////////////////////// // // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. @@ -244,7 +240,7 @@ CV_EXPORTS_W double calcGlobalOrientation( InputArray orientation, InputArray ma double duration ); CV_EXPORTS_W void segmentMotion(InputArray mhi, OutputArray segmask, - CV_OUT vector& boundingRects, + CV_OUT std::vector& boundingRects, double timestamp, double segThresh); //! updates the object tracking window using CAMSHIFT algorithm diff --git a/modules/video/src/bgfg_gaussmix.cpp b/modules/video/src/bgfg_gaussmix.cpp index 4d8f56530..be3732be5 100644 --- a/modules/video/src/bgfg_gaussmix.cpp +++ b/modules/video/src/bgfg_gaussmix.cpp @@ -95,10 +95,10 @@ BackgroundSubtractorMOG::BackgroundSubtractorMOG(int _history, int _nmixtures, frameType = 0; nframes = 0; - nmixtures = min(_nmixtures > 0 ? _nmixtures : defaultNMixtures, 8); + nmixtures = std::min(_nmixtures > 0 ? _nmixtures : defaultNMixtures, 8); history = _history > 0 ? _history : defaultHistory; varThreshold = defaultVarThreshold; - backgroundRatio = min(_backgroundRatio > 0 ? _backgroundRatio : 0.95, 1.); + backgroundRatio = std::min(_backgroundRatio > 0 ? _backgroundRatio : 0.95, 1.); noiseSigma = _noiseSigma <= 0 ? defaultNoiseSigma : _noiseSigma; } @@ -177,9 +177,9 @@ static void process8uC1( const Mat& image, Mat& fgmask, double learningRate, float dw = alpha*(1.f - w); mptr[k].weight = w + dw; mptr[k].mean = mu + alpha*diff; - var = max(var + alpha*(d2 - var), minVar); + var = std::max(var + alpha*(d2 - var), minVar); mptr[k].var = var; - mptr[k].sortKey = w/sqrt(var); + mptr[k].sortKey = w/std::sqrt(var); for( k1 = k-1; k1 >= 0; k1-- ) { @@ -195,7 +195,7 @@ static void process8uC1( const Mat& image, Mat& fgmask, double learningRate, if( kHit < 0 ) // no appropriate gaussian mixture found at all, remove the weakest mixture and create a new one { - kHit = k = min(k, K-1); + kHit = k = std::min(k, K-1); wsum += w0 - mptr[k].weight; mptr[k].weight = w0; mptr[k].mean = pix; @@ -271,7 +271,7 @@ static void process8uC3( const Mat& image, Mat& fgmask, double learningRate, int K = nmixtures; const float w0 = (float)defaultInitialWeight; - const float sk0 = (float)(w0/(defaultNoiseSigma*2*sqrt(3.))); + const float sk0 = (float)(w0/(defaultNoiseSigma*2*std::sqrt(3.))); const float var0 = (float)(defaultNoiseSigma*defaultNoiseSigma*4); const float minVar = (float)(noiseSigma*noiseSigma); MixData* mptr = (MixData*)bgmodel.data; @@ -305,11 +305,11 @@ static void process8uC3( const Mat& image, Mat& fgmask, double learningRate, float dw = alpha*(1.f - w); mptr[k].weight = w + dw; mptr[k].mean = mu + alpha*diff; - var = Vec3f(max(var[0] + alpha*(diff[0]*diff[0] - var[0]), minVar), - max(var[1] + alpha*(diff[1]*diff[1] - var[1]), minVar), - max(var[2] + alpha*(diff[2]*diff[2] - var[2]), minVar)); + var = Vec3f(std::max(var[0] + alpha*(diff[0]*diff[0] - var[0]), minVar), + std::max(var[1] + alpha*(diff[1]*diff[1] - var[1]), minVar), + std::max(var[2] + alpha*(diff[2]*diff[2] - var[2]), minVar)); mptr[k].var = var; - mptr[k].sortKey = w/sqrt(var[0] + var[1] + var[2]); + mptr[k].sortKey = w/std::sqrt(var[0] + var[1] + var[2]); for( k1 = k-1; k1 >= 0; k1-- ) { @@ -325,7 +325,7 @@ static void process8uC3( const Mat& image, Mat& fgmask, double learningRate, if( kHit < 0 ) // no appropriate gaussian mixture found at all, remove the weakest mixture and create a new one { - kHit = k = min(k, K-1); + kHit = k = std::min(k, K-1); wsum += w0 - mptr[k].weight; mptr[k].weight = w0; mptr[k].mean = pix; @@ -404,7 +404,7 @@ void BackgroundSubtractorMOG::operator()(InputArray _image, OutputArray _fgmask, Mat fgmask = _fgmask.getMat(); ++nframes; - learningRate = learningRate >= 0 && nframes > 1 ? learningRate : 1./min( nframes, history ); + learningRate = learningRate >= 0 && nframes > 1 ? learningRate : 1./std::min( nframes, history ); CV_Assert(learningRate >= 0); if( image.type() == CV_8UC1 ) diff --git a/modules/video/src/bgfg_gaussmix2.cpp b/modules/video/src/bgfg_gaussmix2.cpp index e532af2ae..411cfa320 100644 --- a/modules/video/src/bgfg_gaussmix2.cpp +++ b/modules/video/src/bgfg_gaussmix2.cpp @@ -559,7 +559,7 @@ void BackgroundSubtractorMOG2::operator()(InputArray _image, OutputArray _fgmask Mat fgmask = _fgmask.getMat(); ++nframes; - learningRate = learningRate >= 0 && nframes > 1 ? learningRate : 1./min( 2*nframes, history ); + learningRate = learningRate >= 0 && nframes > 1 ? learningRate : 1./std::min( 2*nframes, history ); CV_Assert(learningRate >= 0); parallel_for(BlockedRange(0, image.rows), @@ -609,7 +609,7 @@ void BackgroundSubtractorMOG2::getBackgroundImage(OutputArray backgroundImage) c { case 1: { - vector channels; + std::vector channels; split(meanBackground, channels); channels[0].copyTo(backgroundImage); break; diff --git a/modules/video/src/lkpyramid.cpp b/modules/video/src/lkpyramid.cpp index 9e47eb802..28477100f 100644 --- a/modules/video/src/lkpyramid.cpp +++ b/modules/video/src/lkpyramid.cpp @@ -626,7 +626,7 @@ void cv::calcOpticalFlowPyrLK( InputArray _prevImg, InputArray _nextImg, err = (float*)errMat.data; } - vector prevPyr, nextPyr; + std::vector prevPyr, nextPyr; int levels1 = -1; int lvlStep1 = 1; int levels2 = -1; @@ -1569,7 +1569,7 @@ cvCalcAffineFlowPyrLK( const void* arrA, const void* arrB, err += t * t; } } - error[i] = (float)sqrt(err); + error[i] = (float)std::sqrt(err); } } } @@ -1856,8 +1856,8 @@ cvEstimateRigidTransform( const CvArr* matA, const CvArr* matB, CvMat* matM, int double dbx2 = b[2].x - b[0].x, dby2 = b[2].y - b[0].y; const double eps = 0.01; - if( fabs(dax1*day2 - day1*dax2) < eps*sqrt(dax1*dax1+day1*day1)*sqrt(dax2*dax2+day2*day2) || - fabs(dbx1*dby2 - dby1*dbx2) < eps*sqrt(dbx1*dbx1+dby1*dby1)*sqrt(dbx2*dbx2+dby2*dby2) ) + if( fabs(dax1*day2 - day1*dax2) < eps*std::sqrt(dax1*dax1+day1*day1)*std::sqrt(dax2*dax2+day2*day2) || + fabs(dbx1*dby2 - dby1*dbx2) < eps*std::sqrt(dbx1*dbx1+dby1*dby1)*std::sqrt(dbx2*dbx2+dby2*dby2) ) continue; } break; diff --git a/modules/video/src/motempl.cpp b/modules/video/src/motempl.cpp index 057573951..f6e52c49e 100644 --- a/modules/video/src/motempl.cpp +++ b/modules/video/src/motempl.cpp @@ -468,7 +468,7 @@ double cv::calcGlobalOrientation( InputArray _orientation, InputArray _mask, } void cv::segmentMotion(InputArray _mhi, OutputArray _segmask, - vector& boundingRects, + std::vector& boundingRects, double timestamp, double segThresh) { Mat mhi = _mhi.getMat(); diff --git a/modules/video/src/simpleflow.cpp b/modules/video/src/simpleflow.cpp index 81886eb2c..8c5c74624 100644 --- a/modules/video/src/simpleflow.cpp +++ b/modules/video/src/simpleflow.cpp @@ -116,7 +116,7 @@ static void crossBilateralFilter(const Mat& image, Mat weights(2*d+1, 2*d+1, CV_32F); Mat weighted_sum(2*d+1, 2*d+1, CV_32F); - vector image_extended_channels; + std::vector image_extended_channels; split(image_extended, image_extended_channels); for (int row = 0; row < rows; ++row) { @@ -161,10 +161,10 @@ static void calcConfidence(const Mat& prev, if (c0 + v0 < 0) { v0 = -c0; } if (c0 + v0 >= cols) { v0 = cols - 1 - c0; } - const int top_row_shift = -min(r0 + u0, max_flow); - const int bottom_row_shift = min(rows - 1 - (r0 + u0), max_flow); - const int left_col_shift = -min(c0 + v0, max_flow); - const int right_col_shift = min(cols - 1 - (c0 + v0), max_flow); + const int top_row_shift = -std::min(r0 + u0, max_flow); + const int bottom_row_shift = std::min(rows - 1 - (r0 + u0), max_flow); + const int left_col_shift = -std::min(c0 + v0, max_flow); + const int right_col_shift = std::min(cols - 1 - (c0 + v0), max_flow); bool first_flow_iteration = true; float sum_e = 0, min_e = 0; @@ -223,10 +223,10 @@ static void calcOpticalFlowSingleScaleSF(const Mat& prev_extended, if (c0 + v0 < 0) { v0 = -c0; } if (c0 + v0 >= cols) { v0 = cols - 1 - c0; } - const int top_row_shift = -min(r0 + u0, max_flow); - const int bottom_row_shift = min(rows - 1 - (r0 + u0), max_flow); - const int left_col_shift = -min(c0 + v0, max_flow); - const int right_col_shift = min(cols - 1 - (c0 + v0), max_flow); + const int top_row_shift = -std::min(r0 + u0, max_flow); + const int bottom_row_shift = std::min(rows - 1 - (r0 + u0), max_flow); + const int left_col_shift = -std::min(c0 + v0, max_flow); + const int right_col_shift = std::min(cols - 1 - (c0 + v0), max_flow); float min_cost = FLT_MAX, best_u = (float)u0, best_v = (float)v0; @@ -289,11 +289,11 @@ static Mat calcIrregularityMat(const Mat& flow, int radius) { const int cols = flow.cols; Mat irregularity(rows, cols, CV_32F); for (int r = 0; r < rows; ++r) { - const int start_row = max(0, r - radius); - const int end_row = min(rows - 1, r + radius); + const int start_row = std::max(0, r - radius); + const int end_row = std::min(rows - 1, r + radius); for (int c = 0; c < cols; ++c) { - const int start_col = max(0, c - radius); - const int end_col = min(cols - 1, c + radius); + const int start_col = std::max(0, c - radius); + const int end_col = std::min(cols - 1, c + radius); for (int dr = start_row; dr <= end_row; ++dr) { for (int dc = start_col; dc <= end_col; ++dc) { const float diff = dist(flow.at(r, c), flow.at(dr, dc)); @@ -448,7 +448,7 @@ static void extrapolateFlow(Mat& flow, } static void buildPyramidWithResizeMethod(const Mat& src, - vector& pyramid, + std::vector& pyramid, int layers, int interpolation_type) { pyramid.push_back(src); @@ -479,13 +479,13 @@ CV_EXPORTS_W void calcOpticalFlowSF(InputArray _from, int upscale_averaging_radius, double upscale_sigma_dist, double upscale_sigma_color, - double speed_up_thr) + double speed_up_thr) { Mat from = _from.getMat(); Mat to = _to.getMat(); - vector pyr_from_images; - vector pyr_to_images; + std::vector pyr_from_images; + std::vector pyr_to_images; buildPyramidWithResizeMethod(from, pyr_from_images, layers - 1, INTER_CUBIC); buildPyramidWithResizeMethod(to, pyr_to_images, layers - 1, INTER_CUBIC); diff --git a/modules/video/src/simpleflow.hpp b/modules/video/src/simpleflow.hpp index cab276687..363fdea16 100644 --- a/modules/video/src/simpleflow.hpp +++ b/modules/video/src/simpleflow.hpp @@ -45,8 +45,6 @@ #include -using namespace std; - #define MASK_TRUE_VALUE 255 #define UNKNOWN_FLOW_THRESH 1e9 diff --git a/modules/video/src/tvl1flow.cpp b/modules/video/src/tvl1flow.cpp index bff1d7ec0..7aa7debd4 100644 --- a/modules/video/src/tvl1flow.cpp +++ b/modules/video/src/tvl1flow.cpp @@ -74,7 +74,6 @@ #include "precomp.hpp" -using namespace std; using namespace cv; namespace { @@ -637,7 +636,7 @@ void EstimateVBody::operator() (const Range& range) const d1 = -l_t * I1wxRow[x]; d2 = -l_t * I1wyRow[x]; } - else if (gradRow[x] > numeric_limits::epsilon()) + else if (gradRow[x] > std::numeric_limits::epsilon()) { float fi = -rho / gradRow[x]; d1 = fi * I1wxRow[x]; @@ -852,7 +851,7 @@ void OpticalFlowDual_TVL1::procOneScale(const Mat_& I0, const Mat_ calcGradRho(I0, I1w, I1wx, I1wy, u1, u2, grad, rho_c); - float error = numeric_limits::max(); + float error = std::numeric_limits::max(); for (int n = 0; error > scaledEpsilon && n < iterations; ++n) { // estimate the values of the variable (v1, v2) (thresholding operator TH) diff --git a/modules/videostab/include/opencv2/videostab/fast_marching_inl.hpp b/modules/videostab/include/opencv2/videostab/fast_marching_inl.hpp index dc860c2c8..6388e6966 100644 --- a/modules/videostab/include/opencv2/videostab/fast_marching_inl.hpp +++ b/modules/videostab/include/opencv2/videostab/fast_marching_inl.hpp @@ -53,7 +53,6 @@ namespace videostab template Inpaint FastMarchingMethod::run(const cv::Mat &mask, Inpaint inpaint) { - using namespace std; using namespace cv; CV_Assert(mask.type() == CV_8U); @@ -129,8 +128,8 @@ Inpaint FastMarchingMethod::run(const cv::Mat &mask, Inpaint inpaint) if (xn >= 0 && xn < flag_.cols && yn >= 0 && yn < flag_.rows && flag_(yn,xn) != KNOWN) { - dist_(yn,xn) = min(min(solve(xn-1, yn, xn, yn-1), solve(xn+1, yn, xn, yn-1)), - min(solve(xn-1, yn, xn, yn+1), solve(xn+1, yn, xn, yn+1))); + dist_(yn,xn) = std::min(std::min(solve(xn-1, yn, xn, yn-1), solve(xn+1, yn, xn, yn-1)), + std::min(solve(xn-1, yn, xn, yn+1), solve(xn+1, yn, xn, yn+1))); if (flag_(yn,xn) == INSIDE) { diff --git a/modules/videostab/src/clp.hpp b/modules/videostab/src/clp.hpp index d829a2a33..223016fe7 100644 --- a/modules/videostab/src/clp.hpp +++ b/modules/videostab/src/clp.hpp @@ -66,11 +66,7 @@ // Clp replaces min and max with ?: globally, we can't use std::min and std::max in case // when HAVE_CLP is true. We create the defines by ourselves when HAVE_CLP == 0. -#ifndef min - #define min(a,b) std::min(a,b) -#endif -#ifndef max - #define max(a,b) std::max(a,b) -#endif +#undef min +#undef max #endif diff --git a/modules/videostab/src/deblurring.cpp b/modules/videostab/src/deblurring.cpp index e26c4b373..227b26170 100644 --- a/modules/videostab/src/deblurring.cpp +++ b/modules/videostab/src/deblurring.cpp @@ -45,8 +45,6 @@ #include "opencv2/videostab/global_motion.hpp" #include "opencv2/videostab/ring_buffer.hpp" -using namespace std; - namespace cv { namespace videostab diff --git a/modules/videostab/src/fast_marching.cpp b/modules/videostab/src/fast_marching.cpp index 141a9616e..dce102723 100644 --- a/modules/videostab/src/fast_marching.cpp +++ b/modules/videostab/src/fast_marching.cpp @@ -44,8 +44,6 @@ #include "opencv2/videostab/fast_marching.hpp" #include "opencv2/videostab/ring_buffer.hpp" -using namespace std; - namespace cv { namespace videostab @@ -60,7 +58,7 @@ float FastMarchingMethod::solve(int x1, int y1, int x2, int y2) const if (y2 >=0 && y2 < flag_.rows && x2 >= 0 && x2 < flag_.cols && flag_(y2,x2) == KNOWN) { float t2 = dist_(y2,x2); - float r = sqrt(2 - sqr(t1 - t2)); + float r = std::sqrt(2 - sqr(t1 - t2)); float s = (t1 + t2 - r) / 2; if (s >= t1 && s >= t2) diff --git a/modules/videostab/src/frame_source.cpp b/modules/videostab/src/frame_source.cpp index 632b1946e..5037213ab 100644 --- a/modules/videostab/src/frame_source.cpp +++ b/modules/videostab/src/frame_source.cpp @@ -49,8 +49,6 @@ # include "opencv2/highgui/highgui.hpp" #endif -using namespace std; - namespace cv { namespace videostab @@ -70,7 +68,7 @@ public: vc.release(); vc.open(path_); if (!vc.isOpened()) - throw runtime_error("can't open file: " + path_); + throw std::runtime_error("can't open file: " + path_); #else CV_Error(CV_StsNotImplemented, "OpenCV has been compiled without video I/O support"); #endif @@ -107,7 +105,7 @@ private: }//namespace -VideoFileSource::VideoFileSource(const string &path, bool volatileFrame) +VideoFileSource::VideoFileSource(const std::string &path, bool volatileFrame) : impl(new VideoFileSourceImpl(path, volatileFrame)) {} void VideoFileSource::reset() { impl->reset(); } diff --git a/modules/videostab/src/global_motion.cpp b/modules/videostab/src/global_motion.cpp index fa05f3737..b8927c856 100644 --- a/modules/videostab/src/global_motion.cpp +++ b/modules/videostab/src/global_motion.cpp @@ -47,8 +47,6 @@ #include "opencv2/opencv_modules.hpp" #include "clp.hpp" -using namespace std; - namespace cv { namespace videostab @@ -71,11 +69,11 @@ static Mat normalizePoints(int npoints, Point2f *points) { points[i].x -= cx; points[i].y -= cy; - d += sqrt(sqr(points[i].x) + sqr(points[i].y)); + d += std::sqrt(sqr(points[i].x) + sqr(points[i].y)); } d /= npoints; - float s = sqrt(2.f) / d; + float s = std::sqrt(2.f) / d; for (int i = 0; i < npoints; ++i) { points[i].x *= s; @@ -108,7 +106,7 @@ static Mat estimateGlobMotionLeastSquaresTranslation( for (int i = 0; i < npoints; ++i) *rmse += sqr(points1[i].x - points0[i].x - M(0,2)) + sqr(points1[i].y - points0[i].y - M(1,2)); - *rmse = sqrt(*rmse / npoints); + *rmse = std::sqrt(*rmse / npoints); } return M; @@ -141,7 +139,7 @@ static Mat estimateGlobMotionLeastSquaresTranslationAndScale( solve(A, b, sol, DECOMP_NORMAL | DECOMP_LU); if (rmse) - *rmse = static_cast(norm(A*sol, b, NORM_L2) / sqrt(static_cast(npoints))); + *rmse = static_cast(norm(A*sol, b, NORM_L2) / std::sqrt(static_cast(npoints))); Mat_ M = Mat::eye(3, 3, CV_32F); M(0,0) = M(1,1) = sol(0,0); @@ -166,7 +164,7 @@ static Mat estimateGlobMotionLeastSquaresRotation( } // A*sin(alpha) + B*cos(alpha) = 0 - float C = sqrt(A*A + B*B); + float C = std::sqrt(A*A + B*B); Mat_ M = Mat::eye(3, 3, CV_32F); if ( C != 0 ) { @@ -189,7 +187,7 @@ static Mat estimateGlobMotionLeastSquaresRotation( *rmse += sqr(p1.x - M(0,0)*p0.x - M(0,1)*p0.y) + sqr(p1.y - M(1,0)*p0.x - M(1,1)*p0.y); } - *rmse = sqrt(*rmse / npoints); + *rmse = std::sqrt(*rmse / npoints); } return M; @@ -243,7 +241,7 @@ static Mat estimateGlobMotionLeastSquaresRigid( *rmse += sqr(pt1.x - M(0,0)*pt0.x - M(0,1)*pt0.y - M(0,2)) + sqr(pt1.y - M(1,0)*pt0.x - M(1,1)*pt0.y - M(1,2)); } - *rmse = sqrt(*rmse / npoints); + *rmse = std::sqrt(*rmse / npoints); } return M; @@ -276,7 +274,7 @@ static Mat estimateGlobMotionLeastSquaresSimilarity( solve(A, b, sol, DECOMP_NORMAL | DECOMP_LU); if (rmse) - *rmse = static_cast(norm(A*sol, b, NORM_L2) / sqrt(static_cast(npoints))); + *rmse = static_cast(norm(A*sol, b, NORM_L2) / std::sqrt(static_cast(npoints))); Mat_ M = Mat::eye(3, 3, CV_32F); M(0,0) = M(1,1) = sol(0,0); @@ -315,7 +313,7 @@ static Mat estimateGlobMotionLeastSquaresAffine( solve(A, b, sol, DECOMP_NORMAL | DECOMP_LU); if (rmse) - *rmse = static_cast(norm(A*sol, b, NORM_L2) / sqrt(static_cast(npoints))); + *rmse = static_cast(norm(A*sol, b, NORM_L2) / std::sqrt(static_cast(npoints))); Mat_ M = Mat::eye(3, 3, CV_32F); for (int i = 0, k = 0; i < 2; ++i) @@ -363,13 +361,13 @@ Mat estimateGlobalMotionRansac( const int niters = params.niters(); // current hypothesis - vector indices(params.size); - vector subset0(params.size); - vector subset1(params.size); + std::vector indices(params.size); + std::vector subset0(params.size); + std::vector subset1(params.size); // best hypothesis - vector subset0best(params.size); - vector subset1best(params.size); + std::vector subset0best(params.size); + std::vector subset1best(params.size); Mat_ bestM; int ninliersMax = -1; @@ -472,7 +470,7 @@ Mat MotionEstimatorRansacL2::estimate(InputArray points0, InputArray points1, bo points0, points1, motionModel(), ransacParams_, 0, &ninliers); else { - vector mask; + std::vector mask; M = findHomography(points0, points1, mask, CV_LMEDS); for (int i = 0; i < npoints; ++i) if (mask[i]) ninliers++; @@ -623,7 +621,7 @@ Mat MotionEstimatorL1::estimate(InputArray points0, InputArray points1, bool *ok } -FromFileMotionReader::FromFileMotionReader(const string &path) +FromFileMotionReader::FromFileMotionReader(const std::string &path) : ImageMotionEstimatorBase(MM_UNKNOWN) { file_.open(path.c_str()); @@ -643,7 +641,7 @@ Mat FromFileMotionReader::estimate(const Mat &/*frame0*/, const Mat &/*frame1*/, } -ToFileMotionWriter::ToFileMotionWriter(const string &path, Ptr estimator) +ToFileMotionWriter::ToFileMotionWriter(const std::string &path, Ptr estimator) : ImageMotionEstimatorBase(estimator->motionModel()), motionEstimator_(estimator) { file_.open(path.c_str()); @@ -657,7 +655,7 @@ Mat ToFileMotionWriter::estimate(const Mat &frame0, const Mat &frame1, bool *ok) Mat_ M = motionEstimator_->estimate(frame0, frame1, &ok_); file_ << M(0,0) << " " << M(0,1) << " " << M(0,2) << " " << M(1,0) << " " << M(1,1) << " " << M(1,2) << " " - << M(2,0) << " " << M(2,1) << " " << M(2,2) << " " << ok_ << endl; + << M(2,0) << " " << M(2,1) << " " << M(2,2) << " " << ok_ << std::endl; if (ok) *ok = ok_; return M; } @@ -804,7 +802,7 @@ Mat KeypointBasedMotionEstimatorGpu::estimate(const gpu::GpuMat &frame0, const g #endif // HAVE_OPENCV_GPU -Mat getMotion(int from, int to, const vector &motions) +Mat getMotion(int from, int to, const std::vector &motions) { Mat M = Mat::eye(3, 3, CV_32F); if (to > from) diff --git a/modules/videostab/src/inpainting.cpp b/modules/videostab/src/inpainting.cpp index 52fe92f5e..e24281b5e 100644 --- a/modules/videostab/src/inpainting.cpp +++ b/modules/videostab/src/inpainting.cpp @@ -48,8 +48,6 @@ #include "opencv2/videostab/ring_buffer.hpp" #include "opencv2/opencv_modules.hpp" -using namespace std; - namespace cv { namespace videostab @@ -63,7 +61,7 @@ void InpaintingPipeline::setRadius(int val) } -void InpaintingPipeline::setFrames(const vector &val) +void InpaintingPipeline::setFrames(const std::vector &val) { for (size_t i = 0; i < inpainters_.size(); ++i) inpainters_[i]->setFrames(val); @@ -79,7 +77,7 @@ void InpaintingPipeline::setMotionModel(MotionModel val) } -void InpaintingPipeline::setMotions(const vector &val) +void InpaintingPipeline::setMotions(const std::vector &val) { for (size_t i = 0; i < inpainters_.size(); ++i) inpainters_[i]->setMotions(val); @@ -87,7 +85,7 @@ void InpaintingPipeline::setMotions(const vector &val) } -void InpaintingPipeline::setStabilizedFrames(const vector &val) +void InpaintingPipeline::setStabilizedFrames(const std::vector &val) { for (size_t i = 0; i < inpainters_.size(); ++i) inpainters_[i]->setStabilizedFrames(val); @@ -95,7 +93,7 @@ void InpaintingPipeline::setStabilizedFrames(const vector &val) } -void InpaintingPipeline::setStabilizationMotions(const vector &val) +void InpaintingPipeline::setStabilizationMotions(const std::vector &val) { for (size_t i = 0; i < inpainters_.size(); ++i) inpainters_[i]->setStabilizationMotions(val); @@ -130,13 +128,13 @@ void ConsistentMosaicInpainter::inpaint(int idx, Mat &frame, Mat &mask) CV_Assert(mask.size() == frame.size() && mask.type() == CV_8U); Mat invS = at(idx, *stabilizationMotions_).inv(); - vector > vmotions(2*radius_ + 1); + std::vector > vmotions(2*radius_ + 1); for (int i = -radius_; i <= radius_; ++i) vmotions[radius_ + i] = getMotion(idx, idx + i, *motions_) * invS; int n; float mean, var; - vector pixels(2*radius_ + 1); + std::vector pixels(2*radius_ + 1); Mat_ > frame_(frame); Mat_ mask_(mask); @@ -297,7 +295,7 @@ public: float distColor = sqr(static_cast(cp.x-cq.x)) + sqr(static_cast(cp.y-cq.y)) + sqr(static_cast(cp.z-cq.z)); - float w = 1.f / (sqrt(distColor * (dx*dx + dy*dy)) + eps); + float w = 1.f / (std::sqrt(distColor * (dx*dx + dy*dy)) + eps); uEst += w * (flowX(qy0,qx0) - dudx*dx - dudy*dy); vEst += w * (flowY(qy0,qx0) - dvdx*dx - dvdy*dy); @@ -338,8 +336,8 @@ MotionInpainter::MotionInpainter() void MotionInpainter::inpaint(int idx, Mat &frame, Mat &mask) { - priority_queue > neighbors; - vector vmotions(2*radius_ + 1); + std::priority_queue > neighbors; + std::vector vmotions(2*radius_ + 1); for (int i = -radius_; i <= radius_; ++i) { @@ -349,7 +347,7 @@ void MotionInpainter::inpaint(int idx, Mat &frame, Mat &mask) if (i != 0) { float err = alignementError(motion0to1, frame, mask, at(idx + i, *frames_)); - neighbors.push(make_pair(-err, idx + i)); + neighbors.push(std::make_pair(-err, idx + i)); } } diff --git a/modules/videostab/src/log.cpp b/modules/videostab/src/log.cpp index e548d1193..4c6d414e0 100644 --- a/modules/videostab/src/log.cpp +++ b/modules/videostab/src/log.cpp @@ -45,8 +45,6 @@ #include #include "opencv2/videostab/log.hpp" -using namespace std; - namespace cv { namespace videostab diff --git a/modules/videostab/src/motion_stabilizing.cpp b/modules/videostab/src/motion_stabilizing.cpp index b92a1f10e..6e9ef7ea3 100644 --- a/modules/videostab/src/motion_stabilizing.cpp +++ b/modules/videostab/src/motion_stabilizing.cpp @@ -46,21 +46,19 @@ #include "opencv2/videostab/ring_buffer.hpp" #include "clp.hpp" -using namespace std; - namespace cv { namespace videostab { void MotionStabilizationPipeline::stabilize( - int size, const vector &motions, pair range, Mat *stabilizationMotions) + int size, const std::vector &motions, std::pair range, Mat *stabilizationMotions) { - vector updatedMotions(motions.size()); + std::vector updatedMotions(motions.size()); for (size_t i = 0; i < motions.size(); ++i) updatedMotions[i] = motions[i].clone(); - vector stabilizationMotions_(size); + std::vector stabilizationMotions_(size); for (int i = 0; i < size; ++i) stabilizationMotions[i] = Mat::eye(3, 3, CV_32F); @@ -83,7 +81,7 @@ void MotionStabilizationPipeline::stabilize( void MotionFilterBase::stabilize( - int size, const vector &motions, pair range, Mat *stabilizationMotions) + int size, const std::vector &motions, std::pair range, Mat *stabilizationMotions) { for (int i = 0; i < size; ++i) stabilizationMotions[i] = stabilize(i, motions, range); @@ -93,7 +91,7 @@ void MotionFilterBase::stabilize( void GaussianMotionFilter::setParams(int _radius, float _stdev) { radius_ = _radius; - stdev_ = _stdev > 0.f ? _stdev : sqrt(static_cast(_radius)); + stdev_ = _stdev > 0.f ? _stdev : std::sqrt(static_cast(_radius)); float sum = 0; weight_.resize(2*radius_ + 1); @@ -104,13 +102,13 @@ void GaussianMotionFilter::setParams(int _radius, float _stdev) } -Mat GaussianMotionFilter::stabilize(int idx, const vector &motions, pair range) +Mat GaussianMotionFilter::stabilize(int idx, const std::vector &motions, std::pair range) { const Mat &cur = at(idx, motions); Mat res = Mat::zeros(cur.size(), cur.type()); float sum = 0.f; - int iMin = max(idx - radius_, range.first); - int iMax = min(idx + radius_, range.second); + int iMin = std::max(idx - radius_, range.first); + int iMax = std::min(idx + radius_, range.second); for (int i = iMin; i <= iMax; ++i) { res += weight_[radius_ + i - idx] * getMotion(idx, i, motions); @@ -134,7 +132,7 @@ LpMotionStabilizer::LpMotionStabilizer(MotionModel model) #ifndef HAVE_CLP -void LpMotionStabilizer::stabilize(int, const vector&, pair, Mat*) +void LpMotionStabilizer::stabilize(int, const std::vector&, std::pair, Mat*) { CV_Error(CV_StsError, "The library is built without Clp support"); } @@ -142,12 +140,12 @@ void LpMotionStabilizer::stabilize(int, const vector&, pair, Mat*) #else void LpMotionStabilizer::stabilize( - int size, const vector &motions, pair /*range*/, Mat *stabilizationMotions) + int size, const std::vector &motions, std::pair /*range*/, Mat *stabilizationMotions) { CV_Assert(model_ <= MM_AFFINE); int N = size; - const vector &M = motions; + const std::vector &M = motions; Mat *S = stabilizationMotions; double w = frameSize_.width, h = frameSize_.height; diff --git a/modules/videostab/src/optical_flow.cpp b/modules/videostab/src/optical_flow.cpp index 44ea6131d..90aa7b5eb 100644 --- a/modules/videostab/src/optical_flow.cpp +++ b/modules/videostab/src/optical_flow.cpp @@ -45,8 +45,6 @@ #include "opencv2/videostab/optical_flow.hpp" #include "opencv2/videostab/ring_buffer.hpp" -using namespace std; - namespace cv { namespace videostab diff --git a/modules/videostab/src/outlier_rejection.cpp b/modules/videostab/src/outlier_rejection.cpp index 493d9ffa5..6509a8766 100644 --- a/modules/videostab/src/outlier_rejection.cpp +++ b/modules/videostab/src/outlier_rejection.cpp @@ -44,8 +44,6 @@ #include "opencv2/core/core.hpp" #include "opencv2/videostab/outlier_rejection.hpp" -using namespace std; - namespace cv { namespace videostab @@ -105,7 +103,7 @@ void TranslationBasedLocalOutlierRejector::process( RNG rng(0); int niters = ransacParams_.niters(); int ninliers, ninliersMax; - vector inliers; + std::vector inliers; float dx, dy, dxBest, dyBest; float x1, y1; int idx; diff --git a/modules/videostab/src/stabilizer.cpp b/modules/videostab/src/stabilizer.cpp index 47c221e1d..50ac05c6f 100644 --- a/modules/videostab/src/stabilizer.cpp +++ b/modules/videostab/src/stabilizer.cpp @@ -47,8 +47,6 @@ // for debug purposes #define SAVE_MOTIONS 0 -using namespace std; - namespace cv { namespace videostab @@ -298,7 +296,7 @@ Mat OnePassStabilizer::estimateMotion() Mat OnePassStabilizer::estimateStabilizationMotion() { - return motionFilter_->stabilize(curStabilizedPos_, motions_, make_pair(0, curPos_)); + return motionFilter_->stabilize(curStabilizedPos_, motions_, std::make_pair(0, curPos_)); } @@ -337,31 +335,31 @@ Mat TwoPassStabilizer::nextFrame() #if SAVE_MOTIONS static void saveMotions( - int frameCount, const vector &motions, const vector &stabilizationMotions) + int frameCount, const std::vector &motions, const std::vector &stabilizationMotions) { - ofstream fm("log_motions.csv"); + std::ofstream fm("log_motions.csv"); for (int i = 0; i < frameCount - 1; ++i) { Mat_ M = at(i, motions); fm << M(0,0) << " " << M(0,1) << " " << M(0,2) << " " << M(1,0) << " " << M(1,1) << " " << M(1,2) << " " - << M(2,0) << " " << M(2,1) << " " << M(2,2) << endl; + << M(2,0) << " " << M(2,1) << " " << M(2,2) << std::endl; } - ofstream fo("log_orig.csv"); + std::ofstream fo("log_orig.csv"); for (int i = 0; i < frameCount; ++i) { Mat_ M = getMotion(0, i, motions); fo << M(0,0) << " " << M(0,1) << " " << M(0,2) << " " << M(1,0) << " " << M(1,1) << " " << M(1,2) << " " - << M(2,0) << " " << M(2,1) << " " << M(2,2) << endl; + << M(2,0) << " " << M(2,1) << " " << M(2,2) << std::endl; } - ofstream fs("log_stab.csv"); + std::ofstream fs("log_stab.csv"); for (int i = 0; i < frameCount; ++i) { Mat_ M = stabilizationMotions[i] * getMotion(0, i, motions); fs << M(0,0) << " " << M(0,1) << " " << M(0,2) << " " << M(1,0) << " " << M(1,1) << " " << M(1,2) << " " - << M(2,0) << " " << M(2,1) << " " << M(2,2) << endl; + << M(2,0) << " " << M(2,1) << " " << M(2,2) << std::endl; } } #endif @@ -432,7 +430,7 @@ void TwoPassStabilizer::runPrePassIfNecessary() stabilizationMotions_.resize(frameCount_); motionStabilizer_->stabilize( - frameCount_, motions_, make_pair(0, frameCount_ - 1), &stabilizationMotions_[0]); + frameCount_, motions_, std::make_pair(0, frameCount_ - 1), &stabilizationMotions_[0]); elapsedTime = clock() - startTime; log_->print("motion stabilization time: %.3f sec\n", diff --git a/modules/videostab/src/wobble_suppression.cpp b/modules/videostab/src/wobble_suppression.cpp index da43bda83..3c48df58f 100644 --- a/modules/videostab/src/wobble_suppression.cpp +++ b/modules/videostab/src/wobble_suppression.cpp @@ -44,8 +44,6 @@ #include "opencv2/videostab/wobble_suppression.hpp" #include "opencv2/videostab/ring_buffer.hpp" -using namespace std; - namespace cv { namespace videostab diff --git a/samples/c/find_obj_ferns.cpp b/samples/c/find_obj_ferns.cpp index 3a27c5eb3..9d19c198f 100644 --- a/samples/c/find_obj_ferns.cpp +++ b/samples/c/find_obj_ferns.cpp @@ -10,7 +10,9 @@ #include #include +using namespace std; using namespace cv; + static void help() { printf( "This program shows the use of the \"fern\" plannar PlanarObjectDetector point\n" diff --git a/samples/c/one_way_sample.cpp b/samples/c/one_way_sample.cpp index ad0153ba0..c017976b0 100644 --- a/samples/c/one_way_sample.cpp +++ b/samples/c/one_way_sample.cpp @@ -26,6 +26,7 @@ static void help() printf("For example: ./one_way_sample . ../c/scene_l.bmp ../c/scene_r.bmp\n"); } +using namespace std; using namespace cv; Mat DrawCorrespondences(const Mat& img1, const vector& features1, const Mat& img2, diff --git a/samples/cpp/calibration_artificial.cpp b/samples/cpp/calibration_artificial.cpp index a95113c1d..b4496615c 100644 --- a/samples/cpp/calibration_artificial.cpp +++ b/samples/cpp/calibration_artificial.cpp @@ -150,7 +150,7 @@ int main() ChessBoardGenerator::ChessBoardGenerator(const Size& _patternSize) : sensorWidth(32), sensorHeight(24), - squareEdgePointsNum(200), min_cos(sqrt(2.f)*0.5f), cov(0.5), + squareEdgePointsNum(200), min_cos(std::sqrt(2.f)*0.5f), cov(0.5), patternSize(_patternSize), rendererResolutionMultiplier(4), tvec(Mat::zeros(1, 3, CV_32F)) { Rodrigues(Mat::eye(3, 3, CV_32F), rvec); @@ -275,7 +275,7 @@ Mat cv::ChessBoardGenerator::generageChessBoard(const Mat& bg, const Mat& camMat Mat cv::ChessBoardGenerator::operator ()(const Mat& bg, const Mat& camMat, const Mat& distCoeffs, vector& corners) const { - cov = min(cov, 0.8); + cov = std::min(cov, 0.8); double fovx, fovy, focalLen; Point2d principalPoint; double aspect; @@ -296,7 +296,7 @@ Mat cv::ChessBoardGenerator::operator ()(const Mat& bg, const Mat& camMat, const Point3f pb1, pb2; generateBasis(pb1, pb2); - float cbHalfWidth = static_cast(norm(p) * sin( min(fovx, fovy) * 0.5 * CV_PI / 180)); + float cbHalfWidth = static_cast(norm(p) * sin( std::min(fovx, fovy) * 0.5 * CV_PI / 180)); float cbHalfHeight = cbHalfWidth * patternSize.height / patternSize.width; vector pts3d(4); diff --git a/samples/cpp/distrans.cpp b/samples/cpp/distrans.cpp index b26c0d178..472c168e3 100644 --- a/samples/cpp/distrans.cpp +++ b/samples/cpp/distrans.cpp @@ -3,6 +3,7 @@ #include +using namespace std; using namespace cv; int maskSize0 = CV_DIST_MASK_5; diff --git a/samples/cpp/generic_descriptor_match.cpp b/samples/cpp/generic_descriptor_match.cpp index 9665bcc88..7c69ccded 100644 --- a/samples/cpp/generic_descriptor_match.cpp +++ b/samples/cpp/generic_descriptor_match.cpp @@ -6,6 +6,7 @@ #include +using namespace std; using namespace cv; static void help() diff --git a/samples/cpp/matcher_simple.cpp b/samples/cpp/matcher_simple.cpp index 42e89fbaa..acdf55f70 100644 --- a/samples/cpp/matcher_simple.cpp +++ b/samples/cpp/matcher_simple.cpp @@ -4,6 +4,7 @@ #include "opencv2/highgui/highgui.hpp" #include "opencv2/nonfree/nonfree.hpp" +using namespace std; using namespace cv; static void help() diff --git a/samples/cpp/matching_to_many_images.cpp b/samples/cpp/matching_to_many_images.cpp index ed98d5960..f6c31b2c4 100644 --- a/samples/cpp/matching_to_many_images.cpp +++ b/samples/cpp/matching_to_many_images.cpp @@ -57,7 +57,7 @@ static void readTrainFilenames( const string& filename, string& dirName, vector< size_t pos = filename.rfind('\\'); char dlmtr = '\\'; - if (pos == String::npos) + if (pos == string::npos) { pos = filename.rfind('/'); dlmtr = '/'; diff --git a/samples/cpp/phase_corr.cpp b/samples/cpp/phase_corr.cpp index f9088a0e8..d9a1419a7 100644 --- a/samples/cpp/phase_corr.cpp +++ b/samples/cpp/phase_corr.cpp @@ -25,14 +25,14 @@ int main(int, char* []) curr.convertTo(curr64f, CV_64F); Point2d shift = phaseCorrelate(prev64f, curr64f, hann); - double radius = cv::sqrt(shift.x*shift.x + shift.y*shift.y); + double radius = std::sqrt(shift.x*shift.x + shift.y*shift.y); if(radius > 5) { // draw a circle and line indicating the shift direction... Point center(curr.cols >> 1, curr.rows >> 1); - cv::circle(frame, center, (int)radius, cv::Scalar(0, 255, 0), 3, CV_AA); - cv::line(frame, center, Point(center.x + (int)shift.x, center.y + (int)shift.y), cv::Scalar(0, 255, 0), 3, CV_AA); + circle(frame, center, (int)radius, Scalar(0, 255, 0), 3, CV_AA); + line(frame, center, Point(center.x + (int)shift.x, center.y + (int)shift.y), Scalar(0, 255, 0), 3, CV_AA); } imshow("phase shift", frame); diff --git a/samples/cpp/segment_objects.cpp b/samples/cpp/segment_objects.cpp index 8195df65a..891b63cff 100644 --- a/samples/cpp/segment_objects.cpp +++ b/samples/cpp/segment_objects.cpp @@ -4,6 +4,7 @@ #include #include +using namespace std; using namespace cv; static void help() diff --git a/samples/cpp/select3dobj.cpp b/samples/cpp/select3dobj.cpp index fa1df6869..a21ee2d29 100644 --- a/samples/cpp/select3dobj.cpp +++ b/samples/cpp/select3dobj.cpp @@ -17,6 +17,7 @@ #include #include +using namespace std; using namespace cv; const char* helphelp = diff --git a/samples/cpp/tutorial_code/ImgTrans/HoughCircle_Demo.cpp b/samples/cpp/tutorial_code/ImgTrans/HoughCircle_Demo.cpp index 71d37fb7a..5782e92a3 100644 --- a/samples/cpp/tutorial_code/ImgTrans/HoughCircle_Demo.cpp +++ b/samples/cpp/tutorial_code/ImgTrans/HoughCircle_Demo.cpp @@ -9,6 +9,7 @@ #include #include +using namespace std; using namespace cv; /** diff --git a/samples/cpp/tutorial_code/features2D/SURF_FlannMatcher.cpp b/samples/cpp/tutorial_code/features2D/SURF_FlannMatcher.cpp index f4cde9b2e..bdfd0789c 100644 --- a/samples/cpp/tutorial_code/features2D/SURF_FlannMatcher.cpp +++ b/samples/cpp/tutorial_code/features2D/SURF_FlannMatcher.cpp @@ -11,6 +11,7 @@ #include "opencv2/highgui/highgui.hpp" #include "opencv2/nonfree/features2d.hpp" +using namespace std; using namespace cv; void readme(); diff --git a/samples/cpp/tutorial_code/features2D/SURF_Homography.cpp b/samples/cpp/tutorial_code/features2D/SURF_Homography.cpp index 506e3b44f..cf99d4e6e 100644 --- a/samples/cpp/tutorial_code/features2D/SURF_Homography.cpp +++ b/samples/cpp/tutorial_code/features2D/SURF_Homography.cpp @@ -12,6 +12,7 @@ #include "opencv2/calib3d/calib3d.hpp" #include "opencv2/nonfree/features2d.hpp" +using namespace std; using namespace cv; void readme(); diff --git a/samples/cpp/tutorial_code/objectDetection/objectDetection.cpp b/samples/cpp/tutorial_code/objectDetection/objectDetection.cpp index e20a7d4ca..0eb1752ec 100644 --- a/samples/cpp/tutorial_code/objectDetection/objectDetection.cpp +++ b/samples/cpp/tutorial_code/objectDetection/objectDetection.cpp @@ -18,8 +18,8 @@ void detectAndDisplay( Mat frame ); /** Global variables */ //-- Note, either copy these two files from opencv/data/haarscascades to your current folder, or change these locations -String face_cascade_name = "haarcascade_frontalface_alt.xml"; -String eyes_cascade_name = "haarcascade_eye_tree_eyeglasses.xml"; +string face_cascade_name = "haarcascade_frontalface_alt.xml"; +string eyes_cascade_name = "haarcascade_eye_tree_eyeglasses.xml"; CascadeClassifier face_cascade; CascadeClassifier eyes_cascade; string window_name = "Capture - Face detection"; diff --git a/samples/cpp/tutorial_code/objectDetection/objectDetection2.cpp b/samples/cpp/tutorial_code/objectDetection/objectDetection2.cpp index 75167f612..086bbaf3b 100644 --- a/samples/cpp/tutorial_code/objectDetection/objectDetection2.cpp +++ b/samples/cpp/tutorial_code/objectDetection/objectDetection2.cpp @@ -17,8 +17,8 @@ using namespace cv; void detectAndDisplay( Mat frame ); /** Global variables */ -String face_cascade_name = "lbpcascade_frontalface.xml"; -String eyes_cascade_name = "haarcascade_eye_tree_eyeglasses.xml"; +string face_cascade_name = "lbpcascade_frontalface.xml"; +string eyes_cascade_name = "haarcascade_eye_tree_eyeglasses.xml"; CascadeClassifier face_cascade; CascadeClassifier eyes_cascade; string window_name = "Capture - Face detection"; diff --git a/samples/gpu/brox_optical_flow.cpp b/samples/gpu/brox_optical_flow.cpp index 143d0b485..56832c4de 100644 --- a/samples/gpu/brox_optical_flow.cpp +++ b/samples/gpu/brox_optical_flow.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include "cvconfig.h" #include "opencv2/core/core.hpp" diff --git a/samples/gpu/morphology.cpp b/samples/gpu/morphology.cpp index 36f518b70..5863eac10 100644 --- a/samples/gpu/morphology.cpp +++ b/samples/gpu/morphology.cpp @@ -5,6 +5,7 @@ #include #include +using namespace std; using namespace cv; using namespace cv::gpu; diff --git a/samples/ocl/facedetect.cpp b/samples/ocl/facedetect.cpp index ec7933951..08f45f885 100644 --- a/samples/ocl/facedetect.cpp +++ b/samples/ocl/facedetect.cpp @@ -28,17 +28,17 @@ void detectAndDraw( Mat& img, cv::ocl::OclCascadeClassifier& cascade, CascadeClassifier& nestedCascade, double scale); -String cascadeName = "../../../data/haarcascades/haarcascade_frontalface_alt.xml"; +string cascadeName = "../../../data/haarcascades/haarcascade_frontalface_alt.xml"; int main( int argc, const char** argv ) { CvCapture* capture = 0; Mat frame, frameCopy, image; - const String scaleOpt = "--scale="; + const string scaleOpt = "--scale="; size_t scaleOptLen = scaleOpt.length(); - const String cascadeOpt = "--cascade="; + const string cascadeOpt = "--cascade="; size_t cascadeOptLen = cascadeOpt.length(); - String inputName; + string inputName; help(); cv::ocl::OclCascadeClassifier cascade; From d586f4a103f39cfa39e093e9c8df1f641c44f384 Mon Sep 17 00:00:00 2001 From: Andrey Kamaev Date: Mon, 25 Feb 2013 11:08:27 +0400 Subject: [PATCH 2/2] Fix x64 build warnings --- modules/core/test/test_mat.cpp | 4 ++-- modules/imgproc/src/demosaicing.cpp | 8 ++++---- modules/imgproc/src/floodfill.cpp | 9 +++++---- modules/imgproc/src/samplers.cpp | 14 +++++++------- modules/imgproc/src/segmentation.cpp | 4 ++-- modules/softcascade/CMakeLists.txt | 3 ++- modules/softcascade/src/_random.hpp | 4 ++++ .../softcascade/src/integral_channel_builder.cpp | 2 +- modules/softcascade/src/soft_cascade_octave.cpp | 4 ++-- modules/softcascade/src/softcascade.cpp | 12 ++++++------ 10 files changed, 35 insertions(+), 29 deletions(-) diff --git a/modules/core/test/test_mat.cpp b/modules/core/test/test_mat.cpp index 8471eae49..3693c2dcb 100644 --- a/modules/core/test/test_mat.cpp +++ b/modules/core/test/test_mat.cpp @@ -869,7 +869,7 @@ int calcDiffElemCountImpl(const vector& mv, const Mat& m) for(int x = 0; x < m.cols; x++) { const ElemType* mElem = &m.at(y,x*mChannels); - int loc = 0; + size_t loc = 0; for(size_t i = 0; i < mv.size(); i++) { const size_t mvChannel = mv[i].channels(); @@ -879,7 +879,7 @@ int calcDiffElemCountImpl(const vector& mv, const Mat& m) diffElemCount++; loc += mvChannel; } - CV_Assert(loc == mChannels); + CV_Assert(loc == (size_t)mChannels); } } return diffElemCount; diff --git a/modules/imgproc/src/demosaicing.cpp b/modules/imgproc/src/demosaicing.cpp index f5cbde95b..14bcea61f 100644 --- a/modules/imgproc/src/demosaicing.cpp +++ b/modules/imgproc/src/demosaicing.cpp @@ -1306,7 +1306,7 @@ public: int dcn = dst.channels(); int dcn2 = dcn<<1; int start_with_green = Start_with_green, blue = Blue; - int sstep = src.step / src.elemSize1(), dstep = dst.step / dst.elemSize1(); + int sstep = int(src.step / src.elemSize1()), dstep = int(dst.step / dst.elemSize1()); SIMDInterpolator vecOp; const T* S = reinterpret_cast(src.data + (range.start + 1) * src.step) + 1; @@ -1415,7 +1415,7 @@ static void Bayer2RGB_EdgeAware_T(const Mat& src, Mat& dst, int code) } size = dst.size(); size.width *= dst.channels(); - int dstep = dst.step / dst.elemSize1(); + size_t dstep = dst.step / dst.elemSize1(); T* firstRow = reinterpret_cast(dst.data); T* lastRow = reinterpret_cast(dst.data) + (size.height-1) * dstep; @@ -1423,8 +1423,8 @@ static void Bayer2RGB_EdgeAware_T(const Mat& src, Mat& dst, int code) { for (int x = 0; x < size.width; ++x) { - firstRow[x] = firstRow[dstep+x]; - lastRow[x] = lastRow[-dstep+x]; + firstRow[x] = (firstRow+dstep)[x]; + lastRow[x] = (lastRow-dstep)[x]; } } else diff --git a/modules/imgproc/src/floodfill.cpp b/modules/imgproc/src/floodfill.cpp index 54a58513e..5436c7b02 100644 --- a/modules/imgproc/src/floodfill.cpp +++ b/modules/imgproc/src/floodfill.cpp @@ -505,14 +505,15 @@ int cv::floodFill( InputOutputArray _image, InputOutputArray _mask, if( is_simple ) { - int elem_size = img.elemSize(); + size_t elem_size = img.elemSize(); const uchar* seed_ptr = img.data + img.step*seedPoint.y + elem_size*seedPoint.x; - for(i = 0; i < elem_size; i++) - if (seed_ptr[i] != nv_buf.b[i]) + size_t k = 0; + for(; k < elem_size; k++) + if (seed_ptr[k] != nv_buf.b[k]) break; - if( i != elem_size ) + if( k != elem_size ) { if( type == CV_8UC1 ) floodFill_CnIR(img, seedPoint, nv_buf.b[0], &comp, flags, &buffer); diff --git a/modules/imgproc/src/samplers.cpp b/modules/imgproc/src/samplers.cpp index 34f0eb3dd..80e2706ba 100644 --- a/modules/imgproc/src/samplers.cpp +++ b/modules/imgproc/src/samplers.cpp @@ -46,7 +46,7 @@ namespace cv { static const uchar* -adjustRect( const uchar* src, int src_step, int pix_size, +adjustRect( const uchar* src, size_t src_step, int pix_size, Size src_size, Size win_size, Point ip, Rect* pRect ) { @@ -127,8 +127,8 @@ struct nop template -void getRectSubPix_Cn_(const _Tp* src, int src_step, Size src_size, - _DTp* dst, int dst_step, Size win_size, Point2f center, int cn ) +void getRectSubPix_Cn_(const _Tp* src, size_t src_step, Size src_size, + _DTp* dst, size_t dst_step, Size win_size, Point2f center, int cn ) { ScaleOp scale_op; CastOp cast_op; @@ -217,8 +217,8 @@ void getRectSubPix_Cn_(const _Tp* src, int src_step, Size src_size, static void getRectSubPix_8u32f -( const uchar* src, int src_step, Size src_size, - float* dst, int dst_step, Size win_size, Point2f center0, int cn ) +( const uchar* src, size_t src_step, Size src_size, + float* dst, size_t dst_step, Size win_size, Point2f center0, int cn ) { Point2f center = center0; Point ip; @@ -269,8 +269,8 @@ static void getRectSubPix_8u32f static void -getQuadrangleSubPix_8u32f_CnR( const uchar* src, int src_step, Size src_size, - float* dst, int dst_step, Size win_size, +getQuadrangleSubPix_8u32f_CnR( const uchar* src, size_t src_step, Size src_size, + float* dst, size_t dst_step, Size win_size, const double *matrix, int cn ) { int x, y, k; diff --git a/modules/imgproc/src/segmentation.cpp b/modules/imgproc/src/segmentation.cpp index 9679add1c..e4cd43401 100644 --- a/modules/imgproc/src/segmentation.cpp +++ b/modules/imgproc/src/segmentation.cpp @@ -148,9 +148,9 @@ void cv::watershed( InputArray _src, InputOutputArray _markers ) CV_Assert( src.size() == dst.size() ); const uchar* img = src.data; - int istep = src.step/sizeof(img[0]); + int istep = int(src.step/sizeof(img[0])); int* mask = dst.ptr(); - int mstep = dst.step / sizeof(mask[0]); + int mstep = int(dst.step / sizeof(mask[0])); for( i = 0; i < 256; i++ ) subs_tab[i] = 0; diff --git a/modules/softcascade/CMakeLists.txt b/modules/softcascade/CMakeLists.txt index ef38c3ad7..fb48814cf 100644 --- a/modules/softcascade/CMakeLists.txt +++ b/modules/softcascade/CMakeLists.txt @@ -1,2 +1,3 @@ set(the_description "Soft Cascade detection and training") -ocv_define_module(softcascade opencv_core opencv_imgproc opencv_ml) \ No newline at end of file +ocv_define_module(softcascade opencv_core opencv_imgproc opencv_ml) +ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4310) \ No newline at end of file diff --git a/modules/softcascade/src/_random.hpp b/modules/softcascade/src/_random.hpp index cf12037aa..63fa2565f 100644 --- a/modules/softcascade/src/_random.hpp +++ b/modules/softcascade/src/_random.hpp @@ -52,6 +52,7 @@ namespace cv { namespace softcascade { namespace internal struct Random { typedef std::mt19937 engine; + typedef engine::result_type seed_type; typedef std::uniform_int uniform; }; @@ -67,6 +68,7 @@ namespace cv { namespace softcascade { namespace internal struct Random { typedef std::mt19937 engine; + typedef engine::result_type seed_type; // True if we're using C++11. #if __cplusplus >= 201103L // C++11 removes uniform_int. @@ -86,6 +88,7 @@ namespace cv { namespace softcascade { namespace internal struct Random { typedef std::tr1::mt19937 engine; + typedef engine::result_type seed_type; typedef std::tr1::uniform_int uniform; }; @@ -125,6 +128,7 @@ private: struct Random { typedef rnd::engine engine; + typedef uint64 seed_type; typedef rnd::uniform_int uniform; }; diff --git a/modules/softcascade/src/integral_channel_builder.cpp b/modules/softcascade/src/integral_channel_builder.cpp index 7c1a846e0..bffc596ff 100644 --- a/modules/softcascade/src/integral_channel_builder.cpp +++ b/modules/softcascade/src/integral_channel_builder.cpp @@ -217,7 +217,7 @@ void ChannelFeaturePool::fill(int desired) int nfeatures = std::min(desired, maxPoolSize); pool.reserve(nfeatures); - Random::engine eng(FEATURE_RECT_SEED); + Random::engine eng((Random::seed_type)FEATURE_RECT_SEED); Random::engine eng_ch(DCHANNELS_SEED); Random::uniform chRand(0, N_CHANNELS - 1); diff --git a/modules/softcascade/src/soft_cascade_octave.cpp b/modules/softcascade/src/soft_cascade_octave.cpp index 30deb4cc8..f7b3b3fb0 100644 --- a/modules/softcascade/src/soft_cascade_octave.cpp +++ b/modules/softcascade/src/soft_cascade_octave.cpp @@ -116,7 +116,7 @@ BoostedSoftCascadeOctave::BoostedSoftCascadeOctave(cv::Rect bb, int np, int nn, _params.truncate_pruned_tree = false; _params.use_surrogates = false; _params.use_1se_rule = false; - _params.regression_accuracy = 1.0e-6; + _params.regression_accuracy = 1.0e-6f; // boost params _params.boost_type = CvBoost::GENTLE; @@ -221,7 +221,7 @@ void BoostedSoftCascadeOctave::generateNegatives(const Dataset* dataset) using namespace cv::softcascade::internal; // ToDo: set seed, use offsets Random::engine eng(DX_DY_SEED); - Random::engine idxEng(INDEX_ENGINE_SEED); + Random::engine idxEng((Random::seed_type)INDEX_ENGINE_SEED); int h = boundingBox.height; diff --git a/modules/softcascade/src/softcascade.cpp b/modules/softcascade/src/softcascade.cpp index b7a3d0cca..635494bea 100644 --- a/modules/softcascade/src/softcascade.cpp +++ b/modules/softcascade/src/softcascade.cpp @@ -180,7 +180,7 @@ struct ChannelStorage cv::Mat hog; int shrinkage; int offset; - int step; + size_t step; int model_height; cv::Ptr builder; @@ -398,7 +398,7 @@ struct Detector::Fields fns = (*st)[SC_INTERNAL]; FileNodeIterator inIt = fns.begin(), inIt_end = fns.end(); for (; inIt != inIt_end;) - nodes.push_back(Node(features.size(), inIt)); + nodes.push_back(Node((int)features.size(), inIt)); fns = (*st)[SC_LEAF]; inIt = fns.begin(), inIt_end = fns.end(); @@ -504,7 +504,7 @@ void Detector::detectNoRoi(const cv::Mat& image, std::vector& objects { for (int dx = 0; dx < level.workRect.width; ++dx) { - storage.offset = dy * storage.step + dx; + storage.offset = (int)(dy * storage.step + dx); fld.detectAt(dx, dy, level, storage, objects); } } @@ -555,7 +555,7 @@ void Detector::detect(cv::InputArray _image, cv::InputArray _rois, std::vector objects; detect( _image, _rois, objects); - _rects.create(1, objects.size(), CV_32SC4); + _rects.create(1, (int)objects.size(), CV_32SC4); cv::Mat_ rects = (cv::Mat_)_rects.getMat(); cv::Rect* rectPtr = rects.ptr(0); - _confs.create(1, objects.size(), CV_32F); + _confs.create(1, (int)objects.size(), CV_32F); cv::Mat confs = _confs.getMat(); float* confPtr = confs.ptr(0);