Mercurial Hosting > traffic-intelligence
changeset 231:249d65ff6c35
merged modifications for windows
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Mon, 02 Jul 2012 23:49:39 -0400 |
parents | bc4ea09b1743 (diff) 6e73b112370b (current diff) |
children | 04355e51d895 |
files | c/Motion.cpp c/Parameters.cpp c/feature-based-tracking.cpp c/test_graph.cpp include/Motion.hpp |
diffstat | 6 files changed, 38 insertions(+), 21 deletions(-) [+] |
line wrap: on
line diff
diff -r 6e73b112370b -r 249d65ff6c35 c/Motion.cpp --- a/c/Motion.cpp Fri Jun 29 10:27:46 2012 -0400 +++ b/c/Motion.cpp Mon Jul 02 23:49:39 2012 -0400 @@ -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); + tr1::tie(e, unused) = add_edge(newVertex, *vi, graph); // no need to add measures to graph[e] (edge properties) } } @@ -185,7 +185,7 @@ vector<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(tr1::tie(vi,vend) = vertices(graph); vi != vend; ++vi) { unsigned int id = components[*vi]; lastInstants[id] = max(lastInstants[id], graph[*vi].feature->getLastInstant()); tmpobjects[id].push_back(*vi); @@ -246,6 +246,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(tr1::tie(vi,vend) = vertices(graph); vi != vend; ++vi) graph[*vi].index = cnt++; }
diff -r 6e73b112370b -r 249d65ff6c35 c/Parameters.cpp --- a/c/Parameters.cpp Fri Jun 29 10:27:46 2012 -0400 +++ b/c/Parameters.cpp Mon Jul 02 23:49:39 2012 -0400 @@ -9,7 +9,7 @@ using namespace std; KLTFeatureTrackingParameters::KLTFeatureTrackingParameters(const int argc, char* argv[]) { - std::string configurationFilename; + string configurationFilename; po::options_description onlyCmdLine("Command line only"); po::options_description cmdLineAndFile("Command line and configuration file");
diff -r 6e73b112370b -r 249d65ff6c35 c/feature-based-tracking.cpp --- a/c/feature-based-tracking.cpp Fri Jun 29 10:27:46 2012 -0400 +++ b/c/feature-based-tracking.cpp Mon Jul 02 23:49:39 2012 -0400 @@ -111,14 +111,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()); @@ -148,7 +148,6 @@ // } cvtColor(frame, currentFrameBW, CV_RGB2GRAY); - // "normal" feature detectors: detect features here // detector.detect(currentFrameBW, currKpts); // see video_homography c++ sample @@ -158,8 +157,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; @@ -282,7 +281,7 @@ lastFrameNum = MIN(lastFrameNum,params.frame1+params.nFrames); for (frameNum = firstFrameNum; frameNum<lastFrameNum; frameNum ++) { vector<int> trajectoryIds; - success = trajectoryDB->trajectoryIdEndingAt(trajectoryIds, frameNum); // ending + success = trajectoryDB->trajectoryIdEndingAt(trajectoryIds, frameNum); if (frameNum%100 ==0) cout << "frame " << frameNum << endl; //success = trajectoryDB->trajectoryIdInInterval(trajectoryIds, frameNum, min(frameNum+queryIntervalLength-1, frameNum+params.nFrames)); // ending @@ -306,7 +305,7 @@ // check for connected components int lastInstant = frameNum+params.minFeatureTime-maxTrajectoryLength; - if (lastInstant > 0) { + if (lastInstant > 0 && frameNum%10==0) { featureGraph.connectedComponents(lastInstant); vector<vector<unsigned int> > featureGroups = featureGraph.getFeatureGroups(); for (unsigned int i=0; i<featureGroups.size(); ++i) { @@ -334,7 +333,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 6e73b112370b -r 249d65ff6c35 c/optical-flow.cpp --- a/c/optical-flow.cpp Fri Jun 29 10:27:46 2012 -0400 +++ b/c/optical-flow.cpp Mon Jul 02 23:49:39 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) {
diff -r 6e73b112370b -r 249d65ff6c35 c/utils.cpp --- a/c/utils.cpp Fri Jun 29 10:27:46 2012 -0400 +++ b/c/utils.cpp Mon Jul 02 23:49:39 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())
diff -r 6e73b112370b -r 249d65ff6c35 include/Motion.hpp --- a/include/Motion.hpp Fri Jun 29 10:27:46 2012 -0400 +++ b/include/Motion.hpp Mon Jul 02 23:49:39 2012 -0400 @@ -2,7 +2,6 @@ #define MOTION_HPP #include "src/Trajectory.h" - #include <boost/shared_ptr.hpp> #include <boost/graph/adjacency_list.hpp>