# HG changeset patch # User Nicolas Saunier # Date 1341000913 14400 # Node ID bc4ea09b1743e5b6067ed202da04e8370147211a # Parent 48f83ff769fd25da66b5f59d1ff7c92c48a611a2 compatibility modifications for visual studio compilation diff -r 48f83ff769fd -r bc4ea09b1743 c/Motion.cpp --- 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 lastInstants(num, 0); // last instant of component with id - vector > tmpobjects(num), objects; // vector of components (component = vector of vertex descriptors) + std::vector lastInstants(num, 0); // last instant of component with id + std::vector > tmpobjects(num), objects; // vector of components (component = vector of vertex descriptors) graph_traits::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 > FeatureGraph::getFeatureGroups(void) { - vector > featureGroups; +std::vector > FeatureGraph::getFeatureGroups(void) { + std::vector > featureGroups; for (unsigned int i=0; i(objectHypotheses[i].size()) > minNFeaturesPerGroup) { cout << "save group " << objectHypotheses[i].size() << " " << totalFeatureTime/static_cast(objectHypotheses[i].size()) << endl; - featureGroups.push_back(vector()); + featureGroups.push_back(std::vector()); for (unsigned int j=0; jgetId());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::vertex_iterator vi, vend; graph_traits::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++; } diff -r 48f83ff769fd -r bc4ea09b1743 c/Parameters.cpp --- 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 > optionsVec = options.options(); + std::vector > optionsVec = options.options(); for (unsigned int i=0; ilong_name()].value(); if (value.type() == typeid(bool)) diff -r 48f83ff769fd -r bc4ea09b1743 c/feature-based-tracking.cpp --- 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 descMatcher; - // vector matches; + // std::vector 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 prevKpts, currKpts; - vector prevPts, currPts, newPts; - vector status; - vector errors; + std::vector prevKpts, currKpts; + std::vector prevPts, currPts, newPts; + std::vector status; + std::vector errors; Mat prevDesc, currDesc; - vector lostFeatures; - vector featurePointMatches; + std::vector lostFeatures; + std::vector 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(TermCriteria::COUNT)+static_cast(TermCriteria::EPS)*/, params.maxNumberTrackingIterations, params.minTrackingError), 0.5 /* unused */, 0); // OPTFLOW_USE_INITIAL_FLOW /// \todo try calcOpticalFlowFarneback - vector trackedPts; - vector::iterator iter = featurePointMatches.begin(); + std::vector trackedPts; + std::vector::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 trajectoryIds; + std::vector 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 > featureGroups = featureGraph.getFeatureGroups(); + std::vector > featureGroups = featureGraph.getFeatureGroups(); for (unsigned int i=0; iwriteObject(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) diff -r 48f83ff769fd -r bc4ea09b1743 c/optical-flow.cpp --- 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 #include +/* 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) { diff -r 48f83ff769fd -r bc4ea09b1743 c/test_graph.cpp --- 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 > components = featureGraph.getFeatureGroups(); + std::vector > components = featureGraph.getFeatureGroups(); BOOST_CHECK_EQUAL(components.size(), 0); BOOST_CHECK_EQUAL(featureGraph.getNVertices(), 2); BOOST_CHECK_EQUAL(featureGraph.getNEdges(), 1); diff -r 48f83ff769fd -r bc4ea09b1743 c/utils.cpp --- 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 > loadNumbers(const string& filename, const string& separator /* = " " */) { +std::vector > loadNumbers(const string& filename, const string& separator /* = " " */) { ifstream in(filename.c_str()); - vector > result; + std::vector > result; if (::openCheck(in, filename, "loadNumbers")) { while (!in.eof()) { string line = ::getlineComment(in); - vector tokens; + std::vector tokens; ::split(tokens, line, separator); - vector numbers; + std::vector numbers; BOOST_FOREACH(string s, tokens) numbers.push_back(::toFloat(s)); if (!numbers.empty()) diff -r 48f83ff769fd -r bc4ea09b1743 include/Motion.hpp --- a/include/Motion.hpp Wed May 16 02:23:49 2012 -0400 +++ b/include/Motion.hpp Fri Jun 29 16:15:13 2012 -0400 @@ -2,7 +2,6 @@ #define MOTION_HPP #include "src/Trajectory.h" - #include #include