Mercurial Hosting > traffic-intelligence
changeset 230:bc4ea09b1743
compatibility modifications for visual studio compilation
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Fri, 29 Jun 2012 16:15:13 -0400 |
parents | 48f83ff769fd |
children | 249d65ff6c35 |
files | c/Motion.cpp c/Parameters.cpp c/feature-based-tracking.cpp c/optical-flow.cpp c/test_graph.cpp c/utils.cpp include/Motion.hpp |
diffstat | 7 files changed, 47 insertions(+), 30 deletions(-) [+] |
line wrap: on
line diff
--- a/c/Motion.cpp Wed May 16 02:23:49 2012 -0400 +++ b/c/Motion.cpp Fri Jun 29 16:15:13 2012 -0400 @@ -101,8 +101,8 @@ if (frameNum > lastInstant) lastInstant = frameNum; computeMotionData(frameNum); - assert(positions.size() == displacementDistances.size()+1); - assert(positions.size() == velocities.size()+1); + assert(positions->size() == displacementDistances.size()+1); + assert(positions->size() == velocities->size()+1); } void FeatureTrajectory::shorten(void) { @@ -164,7 +164,7 @@ if (ft->minMaxSimilarity(*ft2, firstInstant, lastInstant, connectionDistance, segmentationDistance)) { UndirectedGraph::edge_descriptor e; bool unused; - tie(e, unused) = add_edge(newVertex, *vi, graph); + std::tr1::tie(e, unused) = add_edge(newVertex, *vi, graph); // no need to add measures to graph[e] (edge properties) } } @@ -179,11 +179,11 @@ int num = connected_components(graph, components, vertex_index_map(get(&VertexInformation::index, graph))); cout << "last instant threshold " << lastInstant << " Total number of components: " << num << endl; - vector<unsigned int> lastInstants(num, 0); // last instant of component with id - vector<vector<vertex_descriptor> > tmpobjects(num), objects; // vector of components (component = vector of vertex descriptors) + std::vector<unsigned int> lastInstants(num, 0); // last instant of component with id + std::vector<std::vector<vertex_descriptor> > tmpobjects(num), objects; // vector of components (component = vector of vertex descriptors) graph_traits<UndirectedGraph>::vertex_iterator vi, vend; - for(tie(vi,vend) = vertices(graph); vi != vend; ++vi) { + for(std::tr1::tie(vi,vend) = vertices(graph); vi != vend; ++vi) { //for (int i = 0; i < nVertices; ++i) { unsigned int id = components[*vi]; //cout << "Vertex " << *vi << " is in component " << id << endl;// "(last " << graph[i].feature->getLastInstant() << " " << lastInstants[components[i]] << " " << (lastInstants[components[i]] < graph[i].feature->getLastInstant()) << ")" << endl; @@ -200,8 +200,8 @@ } } -vector<vector<unsigned int> > FeatureGraph::getFeatureGroups(void) { - vector<vector<unsigned int> > featureGroups; +std::vector<std::vector<unsigned int> > FeatureGraph::getFeatureGroups(void) { + std::vector<std::vector<unsigned int> > featureGroups; for (unsigned int i=0; i<objectHypotheses.size(); ++i) { // check that there is on average at least minNFeaturesPerGroup features at each frame in the group @@ -211,7 +211,7 @@ cout << i << endl; if (totalFeatureTime/static_cast<float>(objectHypotheses[i].size()) > minNFeaturesPerGroup) { cout << "save group " << objectHypotheses[i].size() << " " << totalFeatureTime/static_cast<float>(objectHypotheses[i].size()) << endl; - featureGroups.push_back(vector<unsigned int>()); + featureGroups.push_back(std::vector<unsigned int>()); for (unsigned int j=0; j<objectHypotheses[i].size(); ++j) { featureGroups.back().push_back(graph[objectHypotheses[i][j]].feature->getId());cout << featureGroups.size() << " " << objectHypotheses[i][j] << endl; clear_vertex(objectHypotheses[i][j], graph);cout << "cleared "<< objectHypotheses[i][j] << endl; @@ -236,6 +236,6 @@ void FeatureGraph::computeVertexIndex(void) { graph_traits<FeatureGraph::UndirectedGraph>::vertex_iterator vi, vend; graph_traits<FeatureGraph::UndirectedGraph>::vertices_size_type cnt = 0; - for(tie(vi,vend) = vertices(graph); vi != vend; ++vi) + for(std::tr1::tie(vi,vend) = vertices(graph); vi != vend; ++vi) graph[*vi].index = cnt++; }
--- a/c/Parameters.cpp Wed May 16 02:23:49 2012 -0400 +++ b/c/Parameters.cpp Fri Jun 29 16:15:13 2012 -0400 @@ -95,7 +95,7 @@ string KLTFeatureTrackingParameters::getParameterDescription(po::options_description& options, const po::variables_map& vm, const string& separator /* = " " */) const { stringstream stream; - vector<boost::shared_ptr<po::option_description> > optionsVec = options.options(); + std::vector<boost::shared_ptr<po::option_description> > optionsVec = options.options(); for (unsigned int i=0; i<optionsVec.size(); ++i) { boost::any value = vm[optionsVec[i]->long_name()].value(); if (value.type() == typeid(bool))
--- a/c/feature-based-tracking.cpp Wed May 16 02:23:49 2012 -0400 +++ b/c/feature-based-tracking.cpp Fri Jun 29 16:15:13 2012 -0400 @@ -76,7 +76,7 @@ Size window = Size(params.windowSize, params.windowSize); // BruteForceMatcher<Hamming> descMatcher; - // vector<DMatch> matches; + // std::vector<DMatch> matches; Size videoSize; // if( argc == 1 || (argc == 2 && strlen(argv[1]) == 1 && isdigit(argv[1][0]))) // if no parameter or number parameter @@ -130,14 +130,14 @@ trajectoryDB->createTable("velocities"); trajectoryDB->beginTransaction(); - vector<KeyPoint> prevKpts, currKpts; - vector<Point2f> prevPts, currPts, newPts; - vector<uchar> status; - vector<float> errors; + std::vector<KeyPoint> prevKpts, currKpts; + std::vector<Point2f> prevPts, currPts, newPts; + std::vector<uchar> status; + std::vector<float> errors; Mat prevDesc, currDesc; - vector<FeatureTrajectoryPtr> lostFeatures; - vector<FeaturePointMatch> featurePointMatches; + std::vector<FeatureTrajectoryPtr> lostFeatures; + std::vector<FeaturePointMatch> featurePointMatches; HOGDescriptor hog; hog.setSVMDetector(HOGDescriptor::getDefaultPeopleDetector()); @@ -158,7 +158,6 @@ } cvtColor(frame, currentFrameBW, CV_RGB2GRAY); - // "normal" feature detectors: detect features here // detector.detect(currentFrameBW, currKpts); // see video_homography c++ sample @@ -168,8 +167,8 @@ calcOpticalFlowPyrLK(previousFrameBW, currentFrameBW, prevPts, currPts, status, errors, window, params.pyramidLevel, TermCriteria(3 /*static_cast<int>(TermCriteria::COUNT)+static_cast<int>(TermCriteria::EPS)*/, params.maxNumberTrackingIterations, params.minTrackingError), 0.5 /* unused */, 0); // OPTFLOW_USE_INITIAL_FLOW /// \todo try calcOpticalFlowFarneback - vector<Point2f> trackedPts; - vector<FeaturePointMatch>::iterator iter = featurePointMatches.begin(); + std::vector<Point2f> trackedPts; + std::vector<FeaturePointMatch>::iterator iter = featurePointMatches.begin(); while (iter != featurePointMatches.end()) { bool deleteFeature = false; @@ -284,7 +283,7 @@ // main loop // TODO version that can be interrupted? for (int frameNum = params.frame1; ((frameNum-params.frame1 < params.nFrames) || (params.nFrames < 0)); frameNum++) { - vector<int> trajectoryIds; + std::vector<int> trajectoryIds; success = trajectoryDB->trajectoryIdEndingAt(trajectoryIds, frameNum); // ending cout << "frame " << frameNum << " " << success << endl; cout << trajectoryIds.size() << " trajectories " << endl; @@ -302,7 +301,7 @@ // we could check only when some features are getting old enough? if (frameNum%10 == 0) { featureGraph.connectedComponents(frameNum-maxTrajectoryLength+params.minFeatureTime); - vector<vector<unsigned int> > featureGroups = featureGraph.getFeatureGroups(); + std::vector<vector<unsigned int> > featureGroups = featureGraph.getFeatureGroups(); for (unsigned int i=0; i<featureGroups.size(); ++i) { trajectoryDB->writeObject(savedObjectId, featureGroups[i], -1, 1, string("objects"), string("objects_features")); savedObjectId++; @@ -319,7 +318,7 @@ int main(int argc, char *argv[]) { KLTFeatureTrackingParameters params(argc, argv); cout << params.parameterDescription << endl; - + params.trackFeatures = true; if (params.trackFeatures) trackFeatures(params); else if (params.groupFeatures)
--- a/c/optical-flow.cpp Wed May 16 02:23:49 2012 -0400 +++ b/c/optical-flow.cpp Fri Jun 29 16:15:13 2012 -0400 @@ -7,6 +7,25 @@ #include <iostream> #include <ctime> +/* MSVC does not have lrintf */ +#ifdef _MSC_VER +static inline long lrintf(float f){ +/* x64 does not supported embedded assembly */ +#ifdef _M_X64 + return (long)((f>0.0f) ? (f + 0.5f):(f -0.5f)); +#else + int i; + + _asm{ + fld f + fistp i + }; + + return i; +#endif +} +#endif + using namespace std; void videoTiming(CvCapture* inputVideo) {
--- a/c/test_graph.cpp Wed May 16 02:23:49 2012 -0400 +++ b/c/test_graph.cpp Fri Jun 29 16:15:13 2012 -0400 @@ -28,7 +28,7 @@ BOOST_CHECK_EQUAL(featureGraph.getNEdges(), 1); featureGraph.connectedComponents(lastInstant); - vector<vector<unsigned int> > components = featureGraph.getFeatureGroups(); + std::vector<std::vector<unsigned int> > components = featureGraph.getFeatureGroups(); BOOST_CHECK_EQUAL(components.size(), 0); BOOST_CHECK_EQUAL(featureGraph.getNVertices(), 2); BOOST_CHECK_EQUAL(featureGraph.getNEdges(), 1);
--- a/c/utils.cpp Wed May 16 02:23:49 2012 -0400 +++ b/c/utils.cpp Fri Jun 29 16:15:13 2012 -0400 @@ -8,16 +8,16 @@ using namespace std; -vector<vector<float> > loadNumbers(const string& filename, const string& separator /* = " " */) { +std::vector<std::vector<float> > loadNumbers(const string& filename, const string& separator /* = " " */) { ifstream in(filename.c_str()); - vector<vector<float> > result; + std::vector<std::vector<float> > result; if (::openCheck(in, filename, "loadNumbers")) { while (!in.eof()) { string line = ::getlineComment(in); - vector<string> tokens; + std::vector<string> tokens; ::split(tokens, line, separator); - vector<float> numbers; + std::vector<float> numbers; BOOST_FOREACH(string s, tokens) numbers.push_back(::toFloat(s)); if (!numbers.empty())