Commit 7d42dbdd authored by Marius Muja's avatar Marius Muja

Removing 'using namespace std' from header files, closes bugs #730 and #846

parent 6b345329
......@@ -132,7 +132,7 @@ public:
private:
void computeRNG(Graph &rng, std::vector<cv::Point2f> &vectors, cv::Mat *drawImage = 0) const;
void rng2gridGraph(Graph &rng, std::vector<cv::Point2f> &vectors) const;
void eraseUsedGraph(vector<Graph> &basisGraphs) const;
void eraseUsedGraph(std::vector<Graph> &basisGraphs) const;
void filterOutliersByDensity(const std::vector<cv::Point2f> &samples, std::vector<cv::Point2f> &filteredSamples);
void findBasis(const std::vector<cv::Point2f> &samples, std::vector<cv::Point2f> &basis,
std::vector<Graph> &basisGraphs);
......@@ -164,12 +164,12 @@ private:
//if endpoint is on a segment then function return false
static bool areSegmentsIntersecting(Segment seg1, Segment seg2);
static bool doesIntersectionExist(const vector<Segment> &corner, const vector<vector<Segment> > &segments);
void getCornerSegments(const vector<vector<size_t> > &points, vector<vector<Segment> > &segments,
vector<cv::Point> &cornerIndices, vector<cv::Point> &firstSteps,
vector<cv::Point> &secondSteps) const;
size_t getFirstCorner(vector<cv::Point> &largeCornerIndices, vector<cv::Point> &smallCornerIndices,
vector<cv::Point> &firstSteps, vector<cv::Point> &secondSteps) const;
static bool doesIntersectionExist(const std::vector<Segment> &corner, const std::vector<std::vector<Segment> > &segments);
void getCornerSegments(const std::vector<std::vector<size_t> > &points, std::vector<std::vector<Segment> > &segments,
std::vector<cv::Point> &cornerIndices, std::vector<cv::Point> &firstSteps,
std::vector<cv::Point> &secondSteps) const;
size_t getFirstCorner(std::vector<cv::Point> &largeCornerIndices, std::vector<cv::Point> &smallCornerIndices,
std::vector<cv::Point> &firstSteps, std::vector<cv::Point> &secondSteps) const;
static double getDirection(cv::Point2f p1, cv::Point2f p2, cv::Point2f p3);
std::vector<cv::Point2f> keypoints;
......
......@@ -53,11 +53,11 @@ namespace cv
using std::queue;
typedef pair<int,int> coordinate_t;
typedef float orientation_t;;
typedef vector<coordinate_t> template_coords_t;
typedef vector<orientation_t> template_orientations_t;
typedef pair<Point, float> location_scale_t;
typedef std::pair<int,int> coordinate_t;
typedef float orientation_t;
typedef std::vector<coordinate_t> template_coords_t;
typedef std::vector<orientation_t> template_orientations_t;
typedef std::pair<Point, float> location_scale_t;
class ChamferMatcher
{
......@@ -106,7 +106,7 @@ private:
class LocationImageRange : public ImageRange
{
const vector<Point>& locations_;
const std::vector<Point>& locations_;
int scales_;
float min_scale_;
......@@ -116,7 +116,7 @@ private:
LocationImageRange& operator=(const LocationImageRange&);
public:
LocationImageRange(const vector<Point>& locations, int scales = 5, float min_scale = 0.6, float max_scale = 1.6) :
LocationImageRange(const std::vector<Point>& locations, int scales = 5, float min_scale = 0.6, float max_scale = 1.6) :
locations_(locations), scales_(scales), min_scale_(min_scale), max_scale_(max_scale)
{
}
......@@ -130,13 +130,13 @@ private:
class LocationScaleImageRange : public ImageRange
{
const vector<Point>& locations_;
const vector<float>& scales_;
const std::vector<Point>& locations_;
const std::vector<float>& scales_;
LocationScaleImageRange(const LocationScaleImageRange&);
LocationScaleImageRange& operator=(const LocationScaleImageRange&);
public:
LocationScaleImageRange(const vector<Point>& locations, const vector<float>& scales) :
LocationScaleImageRange(const std::vector<Point>& locations, const std::vector<float>& scales) :
locations_(locations), scales_(scales)
{
assert(locations.size()==scales.size());
......@@ -162,8 +162,8 @@ public:
public:
vector<Template*> scaled_templates;
vector<int> addr;
std::vector<Template*> scaled_templates;
std::vector<int> addr;
int addr_width;
float scale;
template_coords_t coords;
......@@ -200,7 +200,7 @@ public:
*/
Template* rescale(float scale);
vector<int>& getTemplateAddresses(int width);
std::vector<int>& getTemplateAddresses(int width);
};
......@@ -217,7 +217,7 @@ public:
const Template* tpl;
};
typedef vector<Match> Matches;
typedef std::vector<Match> Matches;
private:
/**
......@@ -230,7 +230,7 @@ private:
float truncate_;
bool use_orientation_;
vector<Template*> templates;
std::vector<Template*> templates;
public:
Matching(bool use_orientation = true, float truncate = 10) : truncate_(truncate), use_orientation_(use_orientation)
{
......@@ -347,7 +347,7 @@ private:
class LocationImageIterator : public ImageIterator
{
const vector<Point>& locations_;
const std::vector<Point>& locations_;
size_t iter_;
......@@ -365,7 +365,7 @@ private:
LocationImageIterator& operator=(const LocationImageIterator&);
public:
LocationImageIterator(const vector<Point>& locations, int scales, float min_scale, float max_scale);
LocationImageIterator(const std::vector<Point>& locations, int scales, float min_scale, float max_scale);
bool hasNext() const {
return has_next_;
......@@ -376,8 +376,8 @@ private:
class LocationScaleImageIterator : public ImageIterator
{
const vector<Point>& locations_;
const vector<float>& scales_;
const std::vector<Point>& locations_;
const std::vector<float>& scales_;
size_t iter_;
......@@ -387,7 +387,7 @@ private:
LocationScaleImageIterator& operator=(const LocationScaleImageIterator&);
public:
LocationScaleImageIterator(const vector<Point>& locations, const vector<float>& scales) :
LocationScaleImageIterator(const std::vector<Point>& locations, const std::vector<float>& scales) :
locations_(locations), scales_(scales)
{
assert(locations.size()==scales.size());
......@@ -511,7 +511,7 @@ ChamferMatcher::SlidingWindowImageIterator::SlidingWindowImageIterator( int widt
location_scale_t ChamferMatcher::SlidingWindowImageIterator::next()
{
location_scale_t next_val = make_pair(Point(x_,y_),scale_);
location_scale_t next_val = std::make_pair(Point(x_,y_),scale_);
x_ += x_step_;
......@@ -544,7 +544,7 @@ ChamferMatcher::ImageIterator* ChamferMatcher::SlidingWindowImageRange::iterator
ChamferMatcher::LocationImageIterator::LocationImageIterator(const vector<Point>& locations,
ChamferMatcher::LocationImageIterator::LocationImageIterator(const std::vector<Point>& locations,
int scales = 5,
float min_scale = 0.6,
float max_scale = 1.6) :
......@@ -562,7 +562,7 @@ ChamferMatcher::LocationImageIterator::LocationImageIterator(const vector<Point>
location_scale_t ChamferMatcher::LocationImageIterator:: next()
{
location_scale_t next_val = make_pair(locations_[iter_],scale_);
location_scale_t next_val = std::make_pair(locations_[iter_],scale_);
iter_ ++;
if (iter_==locations_.size()) {
......@@ -583,7 +583,7 @@ location_scale_t ChamferMatcher::LocationImageIterator:: next()
location_scale_t ChamferMatcher::LocationScaleImageIterator::next()
{
location_scale_t next_val = make_pair(locations_[iter_],scales_[iter_]);
location_scale_t next_val = std::make_pair(locations_[iter_],scales_[iter_]);
iter_ ++;
if (iter_==locations_.size()) {
......@@ -738,7 +738,7 @@ void ChamferMatcher::Matching::findContourOrientations(const template_coords_t&
const int M = 5;
int coords_size = coords.size();
vector<float> angles(2*M);
std::vector<float> angles(2*M);
orientations.insert(orientations.begin(), coords_size, float(-3*CV_PI)); // mark as invalid in the beginning
if (coords_size<2*M+1) { // if contour not long enough to estimate orientations, abort
......@@ -948,7 +948,7 @@ void ChamferMatcher::Matching::computeDistanceTransform(Mat& edges_img, Mat& dis
int w = s.width;
int h = s.height;
// set distance to the edge pixels to 0 and put them in the queue
queue<pair<int,int> > q;
std::queue<std::pair<int,int> > q;
......@@ -957,7 +957,7 @@ void ChamferMatcher::Matching::computeDistanceTransform(Mat& edges_img, Mat& dis
unsigned char edge_val = edges_img.at<uchar>(y,x);
if ( (edge_val!=0) ) {
q.push(make_pair(x,y));
q.push(std::make_pair(x,y));
dist_img.at<float>(y,x)= 0;
if (&annotate_img!=NULL) {
......@@ -972,7 +972,7 @@ void ChamferMatcher::Matching::computeDistanceTransform(Mat& edges_img, Mat& dis
}
// breadth first computation of distance transform
pair<int,int> crt;
std::pair<int,int> crt;
while (!q.empty()) {
crt = q.front();
q.pop();
......@@ -1000,7 +1000,7 @@ void ChamferMatcher::Matching::computeDistanceTransform(Mat& edges_img, Mat& dis
if (dt==-1 || dt>dist) {
dist_img.at<float>(ny,nx) = dist;
q.push(make_pair(nx,ny));
q.push(std::make_pair(nx,ny));
if (&annotate_img!=NULL) {
annotate_img.at<Vec2i>(ny,nx)[0]=annotate_img.at<Vec2i>(y,x)[0];
......@@ -1082,7 +1082,7 @@ ChamferMatcher::Match* ChamferMatcher::Matching::localChamferDistance(Point offs
float beta = 1-alpha;
vector<int>& addr = tpl->getTemplateAddresses(dist_img.cols);
std::vector<int>& addr = tpl->getTemplateAddresses(dist_img.cols);
float* ptr = dist_img.ptr<float>(y)+x;
......@@ -1271,7 +1271,7 @@ void ChamferMatcher::addMatch(float cost, Point offset, const Template* tpl)
void ChamferMatcher::showMatch(Mat& img, int index)
{
if (index>=count) {
cout << "Index too big.\n" << endl;
std::cout << "Index too big.\n" << std::endl;
}
assert(img.channels()==3);
......@@ -1347,7 +1347,7 @@ const ChamferMatcher::Matches& ChamferMatcher::matching(Template& tpl, Mat& imag
int chamerMatching( Mat& img, Mat& templ,
vector<vector<Point> >& results, vector<float>& costs,
std::vector<std::vector<Point> >& results, std::vector<float>& costs,
double templScale, int maxMatches, double minMatchDistance, int padX,
int padY, int scales, double minScale, double maxScale,
double orientationWeight, double truncate )
......@@ -1381,7 +1381,7 @@ int chamerMatching( Mat& img, Mat& templ,
costs[i] = (float)cval;
const template_coords_t& templ_coords = match.tpl->coords;
vector<Point>& templPoints = results[i];
std::vector<Point>& templPoints = results[i];
size_t j, npoints = templ_coords.size();
templPoints.resize(npoints);
......
......@@ -224,8 +224,8 @@ private:
float totalCost;
};
typedef pair<CostData, KDTreeIndexParams> KDTreeCostData;
typedef pair<CostData, KMeansIndexParams> KMeansCostData;
typedef std::pair<CostData, KDTreeIndexParams> KDTreeCostData;
typedef std::pair<CostData, KMeansIndexParams> KMeansCostData;
void evaluate_kmeans(CostData& cost, const KMeansIndexParams& kmeans_params)
......@@ -338,7 +338,7 @@ private:
int kmeansParamSpaceSize = ARRAY_LEN(maxIterations)*ARRAY_LEN(branchingFactors);
vector<KMeansCostData> kmeansCosts(kmeansParamSpaceSize);
std::vector<KMeansCostData> kmeansCosts(kmeansParamSpaceSize);
// CostData* kmeansCosts = new CostData[kmeansParamSpaceSize];
......@@ -417,7 +417,7 @@ private:
int testTrees[] = { 1, 4, 8, 16, 32 };
size_t kdtreeParamSpaceSize = ARRAY_LEN(testTrees);
vector<KDTreeCostData> kdtreeCosts(kdtreeParamSpaceSize);
std::vector<KDTreeCostData> kdtreeCosts(kdtreeParamSpaceSize);
// evaluate kdtree for all parameter combinations
int cnt = 0;
......@@ -484,7 +484,7 @@ private:
IndexParams* estimateBuildParams()
{
int sampleSize = int(index_params.sample_fraction*dataset.rows);
int testSampleSize = min(sampleSize/10, 1000);
int testSampleSize = std::min(sampleSize/10, 1000);
logger().info("Entering autotuning, dataset size: %d, sampleSize: %d, testSampleSize: %d\n",dataset.rows, sampleSize, testSampleSize);
......@@ -550,7 +550,7 @@ private:
float speedup = 0;
int samples = (int)min(dataset.rows/10, SAMPLE_COUNT);
int samples = (int)std::min(dataset.rows/10, SAMPLE_COUNT);
if (samples>0) {
Matrix<ELEM_TYPE> testDataset = random_sample(dataset,samples);
......
......@@ -32,7 +32,6 @@
#define _OPENCV_DIST_H_
#include <cmath>
using namespace std;
#include "opencv2/flann/general.h"
......
......@@ -109,7 +109,7 @@ public:
template<typename T>
NNIndex<T>* load_saved_index(const Matrix<T>& dataset, const string& filename)
NNIndex<T>* load_saved_index(const Matrix<T>& dataset, const std::string& filename)
{
FILE* fin = fopen(filename.c_str(), "rb");
if (fin==NULL) {
......@@ -208,7 +208,7 @@ int Index<T>::radiusSearch(const Matrix<T>& query, Matrix<int>& indices, Matrix<
// TODO: optimise here
int* neighbors = resultSet.getNeighbors();
float* distances = resultSet.getDistances();
size_t count_nn = min(resultSet.size(), indices.cols);
size_t count_nn = std::min(resultSet.size(), indices.cols);
assert (dists.cols>=count_nn);
......@@ -222,7 +222,7 @@ int Index<T>::radiusSearch(const Matrix<T>& query, Matrix<int>& indices, Matrix<
template<typename T>
void Index<T>::save(string filename)
void Index<T>::save(std::string filename)
{
FILE* fout = fopen(filename.c_str(), "wb");
if (fout==NULL) {
......
......@@ -66,8 +66,8 @@ void find_nearest(const Matrix<T>& dataset, T* query, int* matches, int nn, int
int j = dcnt-1;
// bubble up
while (j>=1 && dists[j]<dists[j-1]) {
swap(dists[j],dists[j-1]);
swap(match[j],match[j-1]);
std::swap(dists[j],dists[j-1]);
std::swap(match[j],match[j-1]);
j--;
}
}
......
......@@ -33,7 +33,6 @@
#include <algorithm>
using namespace std;
namespace cvflann
{
......@@ -162,7 +161,7 @@ public:
}
/* Switch first node with last. */
swap(heap[1],heap[count]);
std::swap(heap[1],heap[count]);
count -= 1;
heapify(1); /* Move new node 1 to right position. */
......@@ -197,7 +196,7 @@ public:
/* If a child was smaller, than swap parent with it and Heapify. */
if (minloc != parent) {
swap(heap[parent],heap[minloc]);
std::swap(heap[parent],heap[minloc]);
heapify(minloc);
}
}
......
......@@ -41,7 +41,6 @@
#include "opencv2/flann/timer.h"
using namespace std;
namespace cvflann
{
......@@ -207,7 +206,7 @@ float test_index_precisions(NNIndex<ELEM_TYPE>& index, const Matrix<ELEM_TYPE>&
const float SEARCH_EPS = 0.001;
// make sure precisions array is sorted
sort(precisions, precisions+precisions_length);
std::sort(precisions, precisions+precisions_length);
int pindex = 0;
float precision = precisions[pindex];
......
......@@ -45,8 +45,6 @@
#include "opencv2/flann/random.h"
#include "opencv2/flann/saving.h"
using namespace std;
namespace cvflann
{
......@@ -232,7 +230,7 @@ public:
/* Randomize the order of vectors to allow for unbiased sampling. */
for (int j = (int)size_; j > 0; --j) {
int rnd = rand_int(j);
swap(vind[j-1], vind[rnd]);
std::swap(vind[j-1], vind[rnd]);
}
trees[i] = divideTree(0, (int)size_ - 1);
}
......@@ -384,7 +382,7 @@ private:
/* Compute mean values. Only the first SAMPLE_MEAN values need to be
sampled to get a good estimate.
*/
int end = min(first + SAMPLE_MEAN, last);
int end = std::min(first + SAMPLE_MEAN, last);
for (int j = first; j <= end; ++j) {
ELEM_TYPE* v = dataset[vind[j]];
for (size_t k=0; k<veclen_; ++k) {
......@@ -432,7 +430,7 @@ private:
/* Bubble end value down to right location by repeated swapping. */
int j = num - 1;
while (j > 0 && v[topind[j]] > v[topind[j-1]]) {
swap(topind[j], topind[j-1]);
std::swap(topind[j], topind[j-1]);
--j;
}
}
......@@ -459,7 +457,7 @@ private:
++i;
} else {
/* Move to end of list by swapping vind i and j. */
swap(vind[i], vind[j]);
std::swap(vind[i], vind[j]);
--j;
}
}
......@@ -506,7 +504,7 @@ private:
int checkCount = 0;
Heap<BranchSt>* heap = new Heap<BranchSt>((int)size_);
vector<bool> checked(size_,false);
std::vector<bool> checked(size_,false);
/* Search once through each tree down to root. */
for (i = 0; i < numTrees; ++i) {
......@@ -530,7 +528,7 @@ private:
* at least "mindistsq".
*/
void searchLevel(ResultSet<ELEM_TYPE>& result, const ELEM_TYPE* vec, Tree node, float mindistsq, int& checkCount, int maxCheck,
Heap<BranchSt>* heap, vector<bool>& checked)
Heap<BranchSt>* heap, std::vector<bool>& checked)
{
if (result.worstDist()<mindistsq) {
// printf("Ignoring branch, too far\n");
......
......@@ -46,12 +46,10 @@
#include "opencv2/flann/allocator.h"
#include "opencv2/flann/random.h"
using namespace std;
namespace cvflann
{
struct CV_EXPORTS KMeansIndexParams : public IndexParams {
KMeansIndexParams(int branching_ = 32, int iterations_ = 11,
flann_centers_init_t centers_init_ = CENTERS_RANDOM, float cb_index_ = 0.2 ) :
......@@ -353,7 +351,7 @@ class KMeansIndex : public NNIndex<ELEM_TYPE>
// Compute the new potential
double newPot = 0;
for (int i = 0; i < n; i++)
newPot += min( flann_dist(dataset[indices[i]], dataset[indices[i]] + dataset.cols, dataset[indices[index]]), closestDistSq[i] );
newPot += std::min( flann_dist(dataset[indices[i]], dataset[indices[i]] + dataset.cols, dataset[indices[index]]), closestDistSq[i] );
// Store the best result
if (bestNewPot < 0 || newPot < bestNewPot) {
......@@ -366,7 +364,7 @@ class KMeansIndex : public NNIndex<ELEM_TYPE>
centers[centerCount] = indices[bestNewIndex];
currentPot = bestNewPot;
for (int i = 0; i < n; i++)
closestDistSq[i] = min( flann_dist(dataset[indices[i]], dataset[indices[i]]+dataset.cols, dataset[indices[bestNewIndex]]), closestDistSq[i] );
closestDistSq[i] = std::min( flann_dist(dataset[indices[i]], dataset[indices[i]]+dataset.cols, dataset[indices[bestNewIndex]]), closestDistSq[i] );
}
centers_length = centerCount;
......@@ -402,7 +400,7 @@ public:
branching = params.branching;
max_iter = params.iterations;
if (max_iter<0) {
max_iter = numeric_limits<int>::max();
max_iter = (std::numeric_limits<int>::max)();
}
flann_centers_init_t centersInit = params.centers_init;
......@@ -711,7 +709,7 @@ private:
if (indices_length < branching) {
node->indices = indices;
sort(node->indices,node->indices+indices_length);
std::sort(node->indices,node->indices+indices_length);
node->childs = NULL;
return;
}
......@@ -722,7 +720,7 @@ private:
if (centers_length<branching) {
node->indices = indices;
sort(node->indices,node->indices+indices_length);
std::sort(node->indices,node->indices+indices_length);
node->childs = NULL;
return;
}
......@@ -859,8 +857,8 @@ private:
double d = flann_dist(dataset[indices[i]],dataset[indices[i]]+veclen_,zero());
variance += d;
mean_radius += sqrt(d);
swap(indices[i],indices[end]);
swap(belongs_to[i],belongs_to[end]);
std::swap(indices[i],indices[end]);
std::swap(belongs_to[i],belongs_to[end]);
end++;
}
}
......@@ -1072,7 +1070,7 @@ private:
float meanVariance = root->variance*root->size;
while (clusterCount<clusters_length) {
float minVariance = numeric_limits<float>::max();
float minVariance = (std::numeric_limits<float>::max)();
int splitIndex = -1;
for (int i=0;i<clusterCount;++i) {
......
......@@ -36,7 +36,6 @@
#include <stdarg.h>
#include "opencv2/flann/general.h"
using namespace std;
namespace cvflann
{
......
......@@ -36,8 +36,6 @@
#include "opencv2/flann/general.h"
#include "opencv2/flann/matrix.h"
using namespace std;
namespace cvflann
{
......
......@@ -35,7 +35,6 @@
#include <cstdlib>
#include <cassert>
using namespace std;
namespace cvflann
{
......@@ -109,7 +108,7 @@ public:
// int rand = cast(int) (drand48() * n);
int rnd = rand_int(i);
assert(rnd >=0 && rnd < i);
swap(vals[i-1], vals[rnd]);
std::swap(vals[i-1], vals[rnd]);
}
counter = 0;
......
......@@ -37,8 +37,6 @@
#include <vector>
#include "opencv2/flann/dist.h"
using namespace std;
namespace cvflann
{
......@@ -181,8 +179,8 @@ public:
// bubble up
while (i>=1 && (dists[i]<dists[i-1] || (dists[i]==dists[i-1] && indices[i]<indices[i-1]) ) ) {
// while (i>=1 && (dists[i]<dists[i-1]) ) {
swap(indices[i],indices[i-1]);
swap(dists[i],dists[i-1]);
std::swap(indices[i],indices[i-1]);
std::swap(dists[i],dists[i-1]);
i--;
}
......@@ -191,7 +189,7 @@ public:
float worstDist() const
{
return (count<capacity) ? numeric_limits<float>::max() : dists[count-1];
return (count<capacity) ? (std::numeric_limits<float>::max)() : dists[count-1];
}
};
......@@ -215,7 +213,7 @@ class RadiusResultSet : public ResultSet<ELEM_TYPE>
}
};
vector<Item> items;
std::vector<Item> items;
float radius;
bool sorted;
......
......@@ -56,7 +56,7 @@ Matrix<T> random_sample(Matrix<T>& srcMatrix, long size, bool remove = false)
dest = srcMatrix[srcMatrix.rows-i-1];
src = srcMatrix[r];
for (size_t j=0;j<srcMatrix.cols;++j) {
swap(*src,*dest);
std::swap(*src,*dest);
src++;
dest++;
}
......
......@@ -89,7 +89,7 @@ int countCorrectMatches(int* neighbors, int* groundTruth, int n)
return count;
}
// ----------------------- logger().cpp ---------------------------
// ----------------------- logger.cpp ---------------------------
Logger logger_;
......
......@@ -42,8 +42,6 @@
#ifndef _CV_GCGRAPH_H_
#define _CV_GCGRAPH_H_
using namespace std;
template <class TWeight> class GCGraph
{
public:
......@@ -76,8 +74,8 @@ private:
TWeight weight;
};
vector<Vtx> vtcs;
vector<Edge> edges;
std::vector<Vtx> vtcs;
std::vector<Edge> edges;
TWeight flow;
};
......@@ -158,7 +156,7 @@ TWeight GCGraph<TWeight>::maxFlow()
Vtx *vtxPtr = &vtcs[0];
Edge *edgePtr = &edges[0];
vector<Vtx*> orphans;
std::vector<Vtx*> orphans;
// initialize the active queue and the graph vertices
for( int i = 0; i < (int)vtcs.size(); i++ )
......
......@@ -16,11 +16,11 @@
int main()
{
#if !defined(HAVE_CUDA)
cout << "CUDA support is required (CMake key 'WITH_CUDA' must be true).\n";
std::cout << "CUDA support is required (CMake key 'WITH_CUDA' must be true).\n";
#endif
#if !defined(HAVE_TBB)
cout << "TBB support is required (CMake key 'WITH_TBB' must be true).\n";
std::cout << "TBB support is required (CMake key 'WITH_TBB' must be true).\n";
#endif
return 0;
......@@ -44,7 +44,7 @@ inline void safeCall_(int code, const char* expr, const char* file, int line)
{
if (code != CUDA_SUCCESS)
{
cout << "CUDA driver API error: code " << code << ", expr " << expr
std::cout << "CUDA driver API error: code " << code << ", expr " << expr
<< ", file " << file << ", line " << line << endl;
destroyContexts();
exit(-1);
......@@ -59,7 +59,7 @@ int main()
int num_devices = getCudaEnabledDeviceCount();
if (num_devices < 2)
{
cout << "Two or more GPUs are required\n";
std::cout << "Two or more GPUs are required\n";
return -1;
}
......@@ -68,7 +68,7 @@ int main()
DeviceInfo dev_info(i);
if (!dev_info.isCompatible())
{
cout << "GPU module isn't built for GPU #" << i << " ("
std::cout << "GPU module isn't built for GPU #" << i << " ("
<< dev_info.name() << ", CC " << dev_info.majorVersion()
<< dev_info.minorVersion() << "\n";
return -1;
......@@ -122,7 +122,7 @@ void Worker::operator()(int device_id) const
// Check results
bool passed = norm(dst - Mat(d_dst), NORM_INF) < 1e-3;
cout << "GPU #" << device_id << " (" << DeviceInfo().name() << "): "
std::cout << "GPU #" << device_id << " (" << DeviceInfo().name() << "): "
<< (passed ? "passed" : "FAILED") << endl;
// Deallocate data here, otherwise deallocation will be performed
......
......@@ -18,11 +18,11 @@
int main()
{
#if !defined(HAVE_CUDA)
cout << "CUDA support is required (CMake key 'WITH_CUDA' must be true).\n";
std::cout << "CUDA support is required (CMake key 'WITH_CUDA' must be true).\n";
#endif
#if !defined(HAVE_TBB)
cout << "TBB support is required (CMake key 'WITH_TBB' must be true).\n";
std::cout << "TBB support is required (CMake key 'WITH_TBB' must be true).\n";
#endif
return 0;
......@@ -46,7 +46,7 @@ inline void safeCall_(int code, const char* expr, const char* file, int line)
{
if (code != CUDA_SUCCESS)
{
cout << "CUDA driver API error: code " << code << ", expr " << expr
std::cout << "CUDA driver API error: code " << code << ", expr " << expr
<< ", file " << file << ", line " << line << endl;
destroyContexts();
exit(-1);
......@@ -80,14 +80,14 @@ int main(int argc, char** argv)
{
if (argc < 3)
{
cout << "Usage: stereo_multi_gpu <left_image> <right_image>\n";
std::cout << "Usage: stereo_multi_gpu <left_image> <right_image>\n";
return -1;
}
int num_devices = getCudaEnabledDeviceCount();
if (num_devices < 2)
{
cout << "Two or more GPUs are required\n";
std::cout << "Two or more GPUs are required\n";
return -1;
}
......@@ -96,7 +96,7 @@ int main(int argc, char** argv)
DeviceInfo dev_info(i);
if (!dev_info.isCompatible())
{
cout << "GPU module isn't built for GPU #" << i << " ("
std::cout << "GPU module isn't built for GPU #" << i << " ("
<< dev_info.name() << ", CC " << dev_info.majorVersion()
<< dev_info.minorVersion() << "\n";
return -1;
......@@ -108,12 +108,12 @@ int main(int argc, char** argv)
Mat right = imread(argv[2], CV_LOAD_IMAGE_GRAYSCALE);
if (left.empty())
{
cout << "Cannot open '" << argv[1] << "'\n";
std::cout << "Cannot open '" << argv[1] << "'\n";
return -1;
}
if (right.empty())
{
cout << "Cannot open '" << argv[2] << "'\n";
std::cout << "Cannot open '" << argv[2] << "'\n";
return -1;
}
......@@ -180,7 +180,7 @@ void Worker::operator()(int device_id) const
bm[device_id]->operator()(d_left[device_id], d_right[device_id],
d_result[device_id]);
cout << "GPU #" << device_id << " (" << DeviceInfo().name()
std::cout << "GPU #" << device_id << " (" << DeviceInfo().name()
<< "): finished\n";
contextOff();
......
......@@ -16,11 +16,11 @@
int main()
{
#if !defined(HAVE_CUDA)
cout << "CUDA support is required (CMake key 'WITH_CUDA' must be true).\n";
std::cout << "CUDA support is required (CMake key 'WITH_CUDA' must be true).\n";
#endif
#if !defined(HAVE_TBB)
cout << "TBB support is required (CMake key 'WITH_TBB' must be true).\n";
std::cout << "TBB support is required (CMake key 'WITH_TBB' must be true).\n";
#endif
return 0;
......@@ -43,7 +43,7 @@ int main()
int num_devices = getCudaEnabledDeviceCount();
if (num_devices < 2)
{
cout << "Two or more GPUs are required\n";
std::cout << "Two or more GPUs are required\n";
return -1;
}
for (int i = 0; i < num_devices; ++i)
......@@ -51,7 +51,7 @@ int main()
DeviceInfo dev_info(i);
if (!dev_info.isCompatible())
{
cout << "GPU module isn't built for GPU #" << i << " ("
std::cout << "GPU module isn't built for GPU #" << i << " ("
<< dev_info.name() << ", CC " << dev_info.majorVersion()
<< dev_info.minorVersion() << "\n";
return -1;
......@@ -88,7 +88,7 @@ void Worker::operator()(int device_id) const
// Check results
bool passed = norm(dst - Mat(d_dst), NORM_INF) < 1e-3;
cout << "GPU #" << device_id << " (" << DeviceInfo().name() << "): "
std::cout << "GPU #" << device_id << " (" << DeviceInfo().name() << "): "
<< (passed ? "passed" : "FAILED") << endl;
// Deallocate data here, otherwise deallocation will be performed
......
......@@ -18,11 +18,11 @@
int main()
{
#if !defined(HAVE_CUDA)
cout << "CUDA support is required (CMake key 'WITH_CUDA' must be true).\n";
std::cout << "CUDA support is required (CMake key 'WITH_CUDA' must be true).\n";
#endif
#if !defined(HAVE_TBB)
cout << "TBB support is required (CMake key 'WITH_TBB' must be true).\n";
std::cout << "TBB support is required (CMake key 'WITH_TBB' must be true).\n";
#endif
return 0;
......@@ -53,14 +53,14 @@ int main(int argc, char** argv)
{
if (argc < 3)
{
cout << "Usage: stereo_multi_gpu <left_image> <right_image>\n";
std::cout << "Usage: stereo_multi_gpu <left_image> <right_image>\n";
return -1;
}
int num_devices = getCudaEnabledDeviceCount();
if (num_devices < 2)
{
cout << "Two or more GPUs are required\n";
std::cout << "Two or more GPUs are required\n";
return -1;
}
for (int i = 0; i < num_devices; ++i)
......@@ -68,7 +68,7 @@ int main(int argc, char** argv)
DeviceInfo dev_info(i);
if (!dev_info.isCompatible())
{
cout << "GPU module isn't built for GPU #" << i << " ("
std::cout << "GPU module isn't built for GPU #" << i << " ("
<< dev_info.name() << ", CC " << dev_info.majorVersion()
<< dev_info.minorVersion() << "\n";
return -1;
......@@ -80,12 +80,12 @@ int main(int argc, char** argv)
Mat right = imread(argv[2], CV_LOAD_IMAGE_GRAYSCALE);
if (left.empty())
{
cout << "Cannot open '" << argv[1] << "'\n";
std::cout << "Cannot open '" << argv[1] << "'\n";
return -1;
}
if (right.empty())
{
cout << "Cannot open '" << argv[2] << "'\n";
std::cout << "Cannot open '" << argv[2] << "'\n";
return -1;
}
......@@ -139,7 +139,7 @@ void Worker::operator()(int device_id) const
bm[device_id]->operator()(d_left[device_id], d_right[device_id],
d_result[device_id]);
cout << "GPU #" << device_id << " (" << DeviceInfo().name()
std::cout << "GPU #" << device_id << " (" << DeviceInfo().name()
<< "): finished\n";
multi_gpu_mgr.gpuOff();
......
......@@ -55,7 +55,6 @@
#include <string>
#include <iostream>
using namespace std;
using namespace cv;
#define CV_NBAYES "nbayes"
......@@ -83,13 +82,13 @@ protected:
virtual int validate_test_results( int testCaseIdx ) = 0;
int train( int testCaseIdx );
float get_error( int testCaseIdx, int type, vector<float> *resp = 0 );
float get_error( int testCaseIdx, int type, std::vector<float> *resp = 0 );
void save( const char* filename );
void load( const char* filename );
CvMLData data;
string modelName, validationFN;
vector<string> dataSetNames;
std::vector<string> dataSetNames;
FileStorage validationFS;
// MLL models
......@@ -103,7 +102,7 @@ protected:
CvRTrees* rtrees;
CvERTrees* ertrees;
map<int, int> cls_map;
std::map<int, int> cls_map;
int64 initSeed;
};
......@@ -125,7 +124,7 @@ protected:
virtual int run_test_case( int testCaseIdx );
virtual int validate_test_results( int testCaseIdx );
vector<float> test_resps1, test_resps2; // predicted responses for test data
std::vector<float> test_resps1, test_resps2; // predicted responses for test data
char fname1[50], fname2[50];
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment