Mercurial Hosting > traffic-intelligence
diff c/feature-based-tracking.cpp @ 401:b829ebdc18e6
simplified input of directories of video frames (simply use the video filename parameter to point at the directory)
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Mon, 29 Jul 2013 18:58:05 -0400 |
parents | 7ef1071e3cc3 |
children | 31604ef1cad4 |
line wrap: on
line diff
--- a/c/feature-based-tracking.cpp Mon Jul 29 18:06:55 2013 -0400 +++ b/c/feature-based-tracking.cpp Mon Jul 29 18:58:05 2013 -0400 @@ -16,17 +16,18 @@ #include <boost/shared_ptr.hpp> #include <boost/foreach.hpp> +#include <boost/filesystem.hpp> #include "InputVideoFileModule.h" #include "InputFrameListModule.h" - #include <iostream> #include <vector> #include <ctime> using namespace std; using namespace cv; +namespace fs = boost::filesystem; void drawMatchesRelative(const vector<KeyPoint>& train, const vector<KeyPoint>& query, std::vector<cv::DMatch>& matches, Mat& img) { for (int i = 0; i < (int)matches.size(); i++) @@ -82,13 +83,13 @@ // BruteForceMatcher<Hamming> descMatcher; // vector<DMatch> matches; - InputFrameProviderIface* capture = 0; - if(!params.listFilename.empty() && !params.folderData.empty()) - capture = new InputFrameListModule(params.folderData, params.listFilename); + boost::shared_ptr<InputFrameProviderIface> capture; + if (fs::is_directory(fs::path(params.videoFilename))) + capture = boost::shared_ptr<InputFrameListModule>(new InputFrameListModule(params.videoFilename)); else if(!params.videoFilename.empty()) - capture = new InputVideoFileModule(params.videoFilename); + capture = boost::shared_ptr<InputVideoFileModule>(new InputVideoFileModule(params.videoFilename)); else - cout << "No valid input parameters"; + cout << "No valid input parameters" << endl; if(!capture->isOpen()) { cout << "Video filename " << params.videoFilename << " could not be opened. Exiting." << endl; @@ -124,8 +125,8 @@ std::vector<FeatureTrajectoryPtr> lostFeatures; std::vector<FeaturePointMatch> featurePointMatches; - HOGDescriptor hog; - hog.setSVMDetector(HOGDescriptor::getDefaultPeopleDetector()); + //HOGDescriptor hog; + //hog.setSVMDetector(HOGDescriptor::getDefaultPeopleDetector()); int key = '?'; unsigned int savedFeatureId=0; @@ -233,8 +234,8 @@ //brief.compute(currentFrameBW, currKpts, currDesc); //Compute brief descriptors at each keypoint location if (params.display) { + imshow("mask", featureMask*256); imshow("frame", frame); - imshow("mask", featureMask*256); key = waitKey(2); } previousFrameBW = currentFrameBW.clone(); @@ -245,8 +246,6 @@ trajectoryDB->endTransaction(); trajectoryDB->disconnect(); - delete capture; - } void groupFeatures(const KLTFeatureTrackingParameters& params) {