usingnamespacestd.patch

Leszek Swirski, 2010-12-05 07:32 pm

Download (19 kB)

 
tests/ml/src/slmltests.cpp (working copy)
43 43
#include <iostream>
44 44
#include <fstream>
45 45

  
46
using namespace std;
47

  
46 48
CV_SLMLTest::CV_SLMLTest( const char* _modelName, const char* _testName ) :
47 49
    CV_MLBaseTest( _modelName, _testName, "load-save" )
48 50
{
tests/ml/src/mltests.cpp (working copy)
319 319
    else
320 320
        CV_Error( CV_StsBadArg, "outputs must be in the first or last column; other cases are not supported" );
321 321
}
322
void ann_get_new_responses( CvMLData* _data, Mat& new_responses, map<int, int>& cls_map )
322
void ann_get_new_responses( CvMLData* _data, Mat& new_responses, std::map<int, int>& cls_map )
323 323
{
324 324
    const CvMat* train_sidx = _data->get_train_sample_idx();
325 325
    int* train_sidx_ptr = train_sidx->data.i;
......
358 358
    CvMat _new_responses = CvMat( new_responses );
359 359
    return ann->train( &predictors, &_new_responses, 0, train_sidx, _params, flags );
360 360
}
361
float ann_calc_error( CvANN_MLP* ann, CvMLData* _data, map<int, int>& cls_map, int type , vector<float> *resp_labels )
361
float ann_calc_error( CvANN_MLP* ann, CvMLData* _data, std::map<int, int>& cls_map, int type , vector<float> *resp_labels )
362 362
{
363 363
    float err = 0;
364 364
    const CvMat* responses = _data->get_responses();
......
388 388
    int cls_count = (int)cls_map.size();
389 389
    Mat output( 1, cls_count, CV_32FC1 );
390 390
    CvMat _output = CvMat(output);
391
    map<int, int>::iterator b_it = cls_map.begin();
391
    std::map<int, int>::iterator b_it = cls_map.begin();
392 392
    for( int i = 0; i < sample_count; i++ )
393 393
    {
394 394
        CvMat sample;
tests/ml/src/mltest.h (working copy)
55 55
#include <string>
56 56
#include <iostream>
57 57

  
58
using namespace std;
59 58
using namespace cv;
60 59

  
61 60
#define CV_NBAYES   "nbayes"
......
83 82
    virtual int validate_test_results( int testCaseIdx ) = 0;
84 83

  
85 84
    int train( int testCaseIdx );
86
    float get_error( int testCaseIdx, int type, vector<float> *resp = 0 );
85
    float get_error( int testCaseIdx, int type, std::vector<float> *resp = 0 );
87 86
    void save( const char* filename );
88 87
    void load( const char* filename );
89 88

  
90 89
    CvMLData data;
91 90
    string modelName, validationFN;
92
    vector<string> dataSetNames;
91
    std::vector<string> dataSetNames;
93 92
    FileStorage validationFS;
94 93

  
95 94
    // MLL models
......
103 102
    CvRTrees* rtrees;
104 103
    CvERTrees* ertrees;
105 104

  
106
    map<int, int> cls_map;
105
    std::map<int, int> cls_map;
107 106

  
108 107
    int64 initSeed;
109 108
};
......
125 124
    virtual int run_test_case( int testCaseIdx );
126 125
    virtual int validate_test_results( int testCaseIdx );
127 126

  
128
    vector<float> test_resps1, test_resps2; // predicted responses for test data
127
    std::vector<float> test_resps1, test_resps2; // predicted responses for test data
129 128
    char fname1[50], fname2[50];
130 129
};
131 130

  
modules/flann/include/opencv2/flann/result_set.h (working copy)
37 37
#include <vector>
38 38
#include "opencv2/flann/dist.h"
39 39

  
40
using namespace std;
41 40

  
42

  
43 41
namespace cvflann
44 42
{
45 43

  
......
181 179
		// bubble up
182 180
		while (i>=1 && (dists[i]<dists[i-1] || (dists[i]==dists[i-1] && indices[i]<indices[i-1]) ) ) {
183 181
//         while (i>=1 && (dists[i]<dists[i-1]) ) {
184
			swap(indices[i],indices[i-1]);
185
			swap(dists[i],dists[i-1]);
182
			std::swap(indices[i],indices[i-1]);
183
			std::swap(dists[i],dists[i-1]);
186 184
			i--;
187 185
		}
188 186

  
......
191 189

  
192 190
	float worstDist() const
193 191
	{
194
		return (count<capacity) ? numeric_limits<float>::max() : dists[count-1];
192
		return (count<capacity) ? std::numeric_limits<float>::max() : dists[count-1];
195 193
	}
196 194
};
197 195

  
......
215 213
		}
216 214
	};
217 215

  
218
	vector<Item> items;
216
	std::vector<Item> items;
219 217
	float radius;
220 218

  
221 219
	bool sorted;
modules/flann/include/opencv2/flann/autotuned_index.h (working copy)
224 224
        float totalCost;
225 225
    };
226 226

  
227
    typedef pair<CostData, KDTreeIndexParams> KDTreeCostData;
228
    typedef pair<CostData, KMeansIndexParams> KMeansCostData;
227
    typedef std::pair<CostData, KDTreeIndexParams> KDTreeCostData;
228
    typedef std::pair<CostData, KMeansIndexParams> KMeansCostData;
229 229

  
230 230

  
231 231
    void evaluate_kmeans(CostData& cost, const KMeansIndexParams& kmeans_params)
......
338 338

  
339 339
        int kmeansParamSpaceSize = ARRAY_LEN(maxIterations)*ARRAY_LEN(branchingFactors);
340 340

  
341
        vector<KMeansCostData> kmeansCosts(kmeansParamSpaceSize);
341
        std::vector<KMeansCostData> kmeansCosts(kmeansParamSpaceSize);
342 342

  
343 343
//        CostData* kmeansCosts = new CostData[kmeansParamSpaceSize];
344 344

  
......
356 356
                int k = cnt;
357 357
                // order by time cost
358 358
                while (k>0 && kmeansCosts[k].first.timeCost < kmeansCosts[k-1].first.timeCost) {
359
                    swap(kmeansCosts[k],kmeansCosts[k-1]);
359
                    std::swap(kmeansCosts[k],kmeansCosts[k-1]);
360 360
                    --k;
361 361
                }
362 362
                ++cnt;
......
391 391

  
392 392
            int k = i;
393 393
            while (k>0 && kmeansCosts[k].first.totalCost < kmeansCosts[k-1].first.totalCost) {
394
                swap(kmeansCosts[k],kmeansCosts[k-1]);
394
                std::swap(kmeansCosts[k],kmeansCosts[k-1]);
395 395
                k--;
396 396
            }
397 397
        }
......
417 417
        int testTrees[] = { 1, 4, 8, 16, 32 };
418 418

  
419 419
        size_t kdtreeParamSpaceSize = ARRAY_LEN(testTrees);
420
        vector<KDTreeCostData> kdtreeCosts(kdtreeParamSpaceSize);
420
        std::vector<KDTreeCostData> kdtreeCosts(kdtreeParamSpaceSize);
421 421

  
422 422
        // evaluate kdtree for all parameter combinations
423 423
        int cnt = 0;
......
429 429
            int k = cnt;
430 430
            // order by time cost
431 431
            while (k>0 && kdtreeCosts[k].first.timeCost < kdtreeCosts[k-1].first.timeCost) {
432
                swap(kdtreeCosts[k],kdtreeCosts[k-1]);
432
                std::swap(kdtreeCosts[k],kdtreeCosts[k-1]);
433 433
                --k;
434 434
            }
435 435
            ++cnt;
......
461 461

  
462 462
            int k = (int)i;
463 463
            while (k>0 && kdtreeCosts[k].first.totalCost < kdtreeCosts[k-1].first.totalCost) {
464
                swap(kdtreeCosts[k],kdtreeCosts[k-1]);
464
                std::swap(kdtreeCosts[k],kdtreeCosts[k-1]);
465 465
                k--;
466 466
            }
467 467
        }
......
484 484
    IndexParams* estimateBuildParams()
485 485
    {
486 486
        int sampleSize = int(index_params.sample_fraction*dataset.rows);
487
        int testSampleSize = min(sampleSize/10, 1000);
487
        int testSampleSize = std::min(sampleSize/10, 1000);
488 488

  
489 489
        logger().info("Entering autotuning, dataset size: %d, sampleSize: %d, testSampleSize: %d\n",dataset.rows, sampleSize, testSampleSize);
490 490

  
......
550 550

  
551 551
        float speedup = 0;
552 552

  
553
        int samples = (int)min(dataset.rows/10, SAMPLE_COUNT);
553
        int samples = (int)std::min(dataset.rows/10, SAMPLE_COUNT);
554 554
        if (samples>0) {
555 555
            Matrix<ELEM_TYPE> testDataset = random_sample(dataset,samples);
556 556

  
modules/flann/include/opencv2/flann/nn_index.h (working copy)
36 36
#include "opencv2/flann/general.h"
37 37
#include "opencv2/flann/matrix.h"
38 38

  
39
using namespace std;
40

  
41 39
namespace cvflann
42 40
{
43 41

  
modules/flann/include/opencv2/flann/dist.h (working copy)
32 32
#define _OPENCV_DIST_H_
33 33

  
34 34
#include <cmath>
35
using namespace std;
36

  
37 35
#include "opencv2/flann/general.h"
38 36

  
39 37
namespace cvflann
modules/flann/include/opencv2/flann/index_testing.h (working copy)
41 41
#include "opencv2/flann/timer.h"
42 42

  
43 43

  
44
using namespace std;
45

  
46 44
namespace cvflann
47 45
{
48 46

  
......
207 205
	const float SEARCH_EPS = 0.001;
208 206

  
209 207
    // make sure precisions array is sorted
210
    sort(precisions, precisions+precisions_length);
208
    std::sort(precisions, precisions+precisions_length);
211 209

  
212 210
    int pindex = 0;
213 211
    float precision = precisions[pindex];
modules/flann/include/opencv2/flann/kmeans_index.h (working copy)
46 46
#include "opencv2/flann/allocator.h"
47 47
#include "opencv2/flann/random.h"
48 48

  
49
using namespace std;
50

  
51 49
namespace cvflann
52 50
{
53 51

  
......
353 351
                // Compute the new potential
354 352
                double newPot = 0;
355 353
                for (int i = 0; i < n; i++)
356
                    newPot += min( flann_dist(dataset[indices[i]], dataset[indices[i]] + dataset.cols, dataset[indices[index]]), closestDistSq[i] );
354
                    newPot += std::min( flann_dist(dataset[indices[i]], dataset[indices[i]] + dataset.cols, dataset[indices[index]]), closestDistSq[i] );
357 355

  
358 356
                // Store the best result
359 357
                if (bestNewPot < 0 || newPot < bestNewPot) {
......
366 364
            centers[centerCount] = indices[bestNewIndex];
367 365
            currentPot = bestNewPot;
368 366
            for (int i = 0; i < n; i++)
369
                closestDistSq[i] = min( flann_dist(dataset[indices[i]], dataset[indices[i]]+dataset.cols, dataset[indices[bestNewIndex]]), closestDistSq[i] );
367
                closestDistSq[i] = std::min( flann_dist(dataset[indices[i]], dataset[indices[i]]+dataset.cols, dataset[indices[bestNewIndex]]), closestDistSq[i] );
370 368
        }
371 369

  
372 370
        centers_length = centerCount;
......
402 400
        branching = params.branching;
403 401
        max_iter = params.iterations;
404 402
        if (max_iter<0) {
405
        	max_iter = numeric_limits<int>::max();
403
        	max_iter = std::numeric_limits<int>::max();
406 404
        }
407 405
        flann_centers_init_t centersInit = params.centers_init;
408 406

  
......
711 709

  
712 710
		if (indices_length < branching) {
713 711
			node->indices = indices;
714
            sort(node->indices,node->indices+indices_length);
712
            std::sort(node->indices,node->indices+indices_length);
715 713
            node->childs = NULL;
716 714
			return;
717 715
		}
......
722 720

  
723 721
		if (centers_length<branching) {
724 722
            node->indices = indices;
725
            sort(node->indices,node->indices+indices_length);
723
            std::sort(node->indices,node->indices+indices_length);
726 724
            node->childs = NULL;
727 725
			return;
728 726
		}
......
859 857
					double d = flann_dist(dataset[indices[i]],dataset[indices[i]]+veclen_,zero());
860 858
					variance += d;
861 859
					mean_radius += sqrt(d);
862
					swap(indices[i],indices[end]);
863
					swap(belongs_to[i],belongs_to[end]);
860
					std::swap(indices[i],indices[end]);
861
					std::swap(belongs_to[i],belongs_to[end]);
864 862
					end++;
865 863
				}
866 864
			}
......
1072 1070
		float meanVariance = root->variance*root->size;
1073 1071

  
1074 1072
		while (clusterCount<clusters_length) {
1075
			float minVariance = numeric_limits<float>::max();
1073
			float minVariance = std::numeric_limits<float>::max();
1076 1074
			int splitIndex = -1;
1077 1075

  
1078 1076
			for (int i=0;i<clusterCount;++i) {
modules/flann/include/opencv2/flann/kdtree_index.h (working copy)
45 45
#include "opencv2/flann/random.h"
46 46
#include "opencv2/flann/saving.h"
47 47

  
48
using namespace std;
49 48

  
50

  
51 49
namespace cvflann
52 50
{
53 51

  
......
232 230
			/* Randomize the order of vectors to allow for unbiased sampling. */
233 231
			for (int j = (int)size_; j > 0; --j) {
234 232
				int rnd = rand_int(j);
235
				swap(vind[j-1], vind[rnd]);
233
				std::swap(vind[j-1], vind[rnd]);
236 234
			}
237 235
			trees[i] = divideTree(0, (int)size_ - 1);
238 236
		}
......
384 382
		/* Compute mean values.  Only the first SAMPLE_MEAN values need to be
385 383
			sampled to get a good estimate.
386 384
		*/
387
		int end = min(first + SAMPLE_MEAN, last);
385
		int end = std::min(first + SAMPLE_MEAN, last);
388 386
		for (int j = first; j <= end; ++j) {
389 387
			ELEM_TYPE* v = dataset[vind[j]];
390 388
            for (size_t k=0; k<veclen_; ++k) {
......
432 430
				/* Bubble end value down to right location by repeated swapping. */
433 431
				int j = num - 1;
434 432
				while (j > 0  &&  v[topind[j]] > v[topind[j-1]]) {
435
					swap(topind[j], topind[j-1]);
433
					std::swap(topind[j], topind[j-1]);
436 434
					--j;
437 435
				}
438 436
			}
......
459 457
				++i;
460 458
			} else {
461 459
				/* Move to end of list by swapping vind i and j. */
462
				swap(vind[i], vind[j]);
460
				std::swap(vind[i], vind[j]);
463 461
				--j;
464 462
			}
465 463
		}
......
506 504

  
507 505
		int checkCount = 0;
508 506
		Heap<BranchSt>* heap = new Heap<BranchSt>((int)size_);
509
		vector<bool> checked(size_,false);
507
		std::vector<bool> checked(size_,false);
510 508

  
511 509
		/* Search once through each tree down to root. */
512 510
		for (i = 0; i < numTrees; ++i) {
......
530 528
	 *  at least "mindistsq".
531 529
	*/
532 530
	void searchLevel(ResultSet<ELEM_TYPE>& result, const ELEM_TYPE* vec, Tree node, float mindistsq, int& checkCount, int maxCheck,
533
			Heap<BranchSt>* heap, vector<bool>& checked)
531
			Heap<BranchSt>* heap, std::vector<bool>& checked)
534 532
	{
535 533
		if (result.worstDist()<mindistsq) {
536 534
//			printf("Ignoring branch, too far\n");
modules/flann/include/opencv2/flann/sampling.h (working copy)
56 56
            dest = srcMatrix[srcMatrix.rows-i-1];
57 57
            src = srcMatrix[r];
58 58
            for (size_t j=0;j<srcMatrix.cols;++j) {
59
                swap(*src,*dest);
59
                std::swap(*src,*dest);
60 60
                src++;
61 61
                dest++;
62 62
            }
modules/flann/include/opencv2/flann/heap.h (working copy)
33 33

  
34 34

  
35 35
#include <algorithm>
36
using namespace std;
37

  
38 36
namespace cvflann
39 37
{
40 38

  
......
152 150
 	 * Returns the node of minimum value from the heap (top of the heap).
153 151
	 *
154 152
	 * Params:
155
	 *     value = out parameter used to return the min element
153
	 *     value = out parameter used to return the std::min element
156 154
	 * Returns: false if heap empty
157 155
	 */
158 156
	bool popMin(T& value)
......
162 160
		}
163 161

  
164 162
		/* Switch first node with last. */
165
		swap(heap[1],heap[count]);
163
		std::swap(heap[1],heap[count]);
166 164

  
167 165
		count -= 1;
168 166
		heapify(1);      /* Move new node 1 to right position. */
......
195 193
			minloc = right;
196 194
		}
197 195

  
198
		/* If a child was smaller, than swap parent with it and Heapify. */
196
		/* If a child was smaller, than std::swap parent with it and Heapify. */
199 197
		if (minloc != parent) {
200
			swap(heap[parent],heap[minloc]);
198
			std::swap(heap[parent],heap[minloc]);
201 199
			heapify(minloc);
202 200
		}
203 201
	}
modules/flann/include/opencv2/flann/logger.h (working copy)
36 36
#include <stdarg.h>
37 37
#include "opencv2/flann/general.h"
38 38

  
39
using namespace std;
40

  
41 39
namespace cvflann
42 40
{
43 41

  
modules/flann/include/opencv2/flann/random.h (working copy)
35 35
#include <cstdlib>
36 36
#include <cassert>
37 37

  
38
using namespace std;
39

  
40 38
namespace cvflann
41 39
{
42 40

  
......
109 107
// 			int rand = cast(int) (drand48() * n);
110 108
			int rnd = rand_int(i);
111 109
			assert(rnd >=0 && rnd < i);
112
			swap(vals[i-1], vals[rnd]);
110
			std::swap(vals[i-1], vals[rnd]);
113 111
		}
114 112

  
115 113
		counter = 0;
modules/flann/include/opencv2/flann/ground_truth.h (working copy)
66 66
        int j = dcnt-1;
67 67
        // bubble up
68 68
        while (j>=1 && dists[j]<dists[j-1]) {
69
            swap(dists[j],dists[j-1]);
70
            swap(match[j],match[j-1]);
69
            std::swap(dists[j],dists[j-1]);
70
            std::swap(match[j],match[j-1]);
71 71
            j--;
72 72
        }
73 73
    }
modules/flann/include/opencv2/flann/flann_base.hpp (working copy)
109 109

  
110 110

  
111 111
template<typename T>
112
NNIndex<T>* load_saved_index(const Matrix<T>& dataset, const string& filename)
112
NNIndex<T>* load_saved_index(const Matrix<T>& dataset, const std::string& filename)
113 113
{
114 114
	FILE* fin = fopen(filename.c_str(), "rb");
115 115
	if (fin==NULL) {
......
222 222

  
223 223

  
224 224
template<typename T>
225
void Index<T>::save(string filename)
225
void Index<T>::save(std::string filename)
226 226
{
227 227
	FILE* fout = fopen(filename.c_str(), "wb");
228 228
	if (fout==NULL) {
modules/contrib/src/chamfermatching.cpp (working copy)
51 51
namespace cv
52 52
{
53 53

  
54
using namespace std;
54 55
using std::queue;
55 56
    
56 57
typedef pair<int,int> coordinate_t;
modules/imgproc/src/gcgraph.hpp (working copy)
42 42
#ifndef _CV_GCGRAPH_H_
43 43
#define _CV_GCGRAPH_H_
44 44

  
45
using namespace std;
46

  
47 45
template <class TWeight> class GCGraph
48 46
{
49 47
public:
......
76 74
        TWeight weight;
77 75
    };
78 76

  
79
    vector<Vtx> vtcs;
80
    vector<Edge> edges;
77
    std::vector<Vtx> vtcs;
78
    std::vector<Edge> edges;
81 79
    TWeight flow;
82 80
};
83 81

  
......
158 156
    Vtx *vtxPtr = &vtcs[0];
159 157
    Edge *edgePtr = &edges[0];
160 158

  
161
    vector<Vtx*> orphans;
159
    std::vector<Vtx*> orphans;
162 160

  
163 161
    // initialize the active queue and the graph vertices
164 162
    for( int i = 0; i < (int)vtcs.size(); i++ )