annotate c/feature-based-tracking.cpp @ 412:97cb5c969ef2

corrected grouping bug (last object type -1) and added script to rescale homographies
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Sun, 01 Sep 2013 22:00:11 -0400
parents 31604ef1cad4
children ca5784652d57
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
136
0f790de9437e renamed Feature to Motion files and added code to test blob db
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 135
diff changeset
1 #include "Motion.hpp"
124
1e68e18b1aa5 renaming and working on klt
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 123
diff changeset
2 #include "Parameters.hpp"
127
d19d6e63dd77 simple feature tracking and drawing working
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 125
diff changeset
3 #include "cvutils.hpp"
122
654f1c748644 work on displaying matched features
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 121
diff changeset
4 #include "utils.hpp"
117
fea680fb03ee created main feature based tracking file and minimum doxygen documentation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
5
124
1e68e18b1aa5 renaming and working on klt
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 123
diff changeset
6 #include "src/Trajectory.h"
133
63dd4355b6d1 saving of feature positions in sqlite database
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 132
diff changeset
7 #include "src/TrajectoryDBAccessList.h"
136
0f790de9437e renamed Feature to Motion files and added code to test blob db
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 135
diff changeset
8 #include "src/TrajectoryDBAccessBlob.h"
124
1e68e18b1aa5 renaming and working on klt
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 123
diff changeset
9
127
d19d6e63dd77 simple feature tracking and drawing working
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 125
diff changeset
10 #include "opencv2/core/core.hpp"
165
50964af05a80 solved issue with header inclusion
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 164
diff changeset
11 #include "opencv2/imgproc/imgproc.hpp"
50964af05a80 solved issue with header inclusion
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 164
diff changeset
12 #include "opencv2/video/tracking.hpp"
50964af05a80 solved issue with header inclusion
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 164
diff changeset
13 #include "opencv2/features2d/features2d.hpp"
121
c4d4b5b93add copied the video_homography opencv sample
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 119
diff changeset
14 #include "opencv2/highgui/highgui.hpp"
193
a728fce85881 simple test of adding and using default HoG pedestrian detector
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 191
diff changeset
15 #include "opencv2/objdetect/objdetect.hpp"
121
c4d4b5b93add copied the video_homography opencv sample
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 119
diff changeset
16
125
28907fde9855 work on klt tracker (problem on computer at poly)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 124
diff changeset
17 #include <boost/shared_ptr.hpp>
132
45c64e68053c added drawing function for features
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 130
diff changeset
18 #include <boost/foreach.hpp>
401
b829ebdc18e6 simplified input of directories of video frames (simply use the video filename parameter to point at the directory)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 400
diff changeset
19 #include <boost/filesystem.hpp>
125
28907fde9855 work on klt tracker (problem on computer at poly)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 124
diff changeset
20
399
c389fae9689a Added a class to read list of image instead of video. This is controlled by the use of the database-filename and folder-data parameters in the config file.
Jean-Philippe Jodoin <jpjodoin@gmail.com>
parents: 391
diff changeset
21 #include "InputVideoFileModule.h"
c389fae9689a Added a class to read list of image instead of video. This is controlled by the use of the database-filename and folder-data parameters in the config file.
Jean-Philippe Jodoin <jpjodoin@gmail.com>
parents: 391
diff changeset
22 #include "InputFrameListModule.h"
c389fae9689a Added a class to read list of image instead of video. This is controlled by the use of the database-filename and folder-data parameters in the config file.
Jean-Philippe Jodoin <jpjodoin@gmail.com>
parents: 391
diff changeset
23
121
c4d4b5b93add copied the video_homography opencv sample
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 119
diff changeset
24 #include <iostream>
c4d4b5b93add copied the video_homography opencv sample
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 119
diff changeset
25 #include <vector>
174
ec9734015d53 tested loading trajectory by id numbers
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 172
diff changeset
26 #include <ctime>
121
c4d4b5b93add copied the video_homography opencv sample
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 119
diff changeset
27
c4d4b5b93add copied the video_homography opencv sample
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 119
diff changeset
28 using namespace std;
c4d4b5b93add copied the video_homography opencv sample
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 119
diff changeset
29 using namespace cv;
401
b829ebdc18e6 simplified input of directories of video frames (simply use the video filename parameter to point at the directory)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 400
diff changeset
30 namespace fs = boost::filesystem;
117
fea680fb03ee created main feature based tracking file and minimum doxygen documentation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
31
123
df3bdd8e50ba displays tracking from video and webcam
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 122
diff changeset
32 void drawMatchesRelative(const vector<KeyPoint>& train, const vector<KeyPoint>& query, std::vector<cv::DMatch>& matches, Mat& img) {
df3bdd8e50ba displays tracking from video and webcam
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 122
diff changeset
33 for (int i = 0; i < (int)matches.size(); i++)
df3bdd8e50ba displays tracking from video and webcam
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 122
diff changeset
34 {
df3bdd8e50ba displays tracking from video and webcam
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 122
diff changeset
35 Point2f pt_new = query[matches[i].queryIdx].pt;
df3bdd8e50ba displays tracking from video and webcam
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 122
diff changeset
36 Point2f pt_old = train[matches[i].trainIdx].pt;
df3bdd8e50ba displays tracking from video and webcam
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 122
diff changeset
37 Point2f dist = pt_new - pt_old;
df3bdd8e50ba displays tracking from video and webcam
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 122
diff changeset
38 if (norm(dist) < 20) {
127
d19d6e63dd77 simple feature tracking and drawing working
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 125
diff changeset
39 line(img, pt_new, pt_old, Scalar(125, 255, 125), 1);
d19d6e63dd77 simple feature tracking and drawing working
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 125
diff changeset
40 circle(img, pt_old, 2, Scalar(255, 0, 125), 1);
123
df3bdd8e50ba displays tracking from video and webcam
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 122
diff changeset
41 }
df3bdd8e50ba displays tracking from video and webcam
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 122
diff changeset
42 }
df3bdd8e50ba displays tracking from video and webcam
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 122
diff changeset
43 }
df3bdd8e50ba displays tracking from video and webcam
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 122
diff changeset
44
127
d19d6e63dd77 simple feature tracking and drawing working
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 125
diff changeset
45 void drawOpticalFlow(const vector<Point2f>& prevPts, const vector<Point2f>& currPts, const vector<uchar> status, Mat& img) {
d19d6e63dd77 simple feature tracking and drawing working
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 125
diff changeset
46 for (unsigned int i=0; i<status.size(); i++) {
d19d6e63dd77 simple feature tracking and drawing working
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 125
diff changeset
47 if (status[i]) {
d19d6e63dd77 simple feature tracking and drawing working
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 125
diff changeset
48 line(img, prevPts[i], currPts[i], Scalar(125, 255, 125), 1);
d19d6e63dd77 simple feature tracking and drawing working
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 125
diff changeset
49 circle(img, prevPts[i], 2, Scalar(255, 0, 125), 1);
d19d6e63dd77 simple feature tracking and drawing working
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 125
diff changeset
50 }
d19d6e63dd77 simple feature tracking and drawing working
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 125
diff changeset
51 }
d19d6e63dd77 simple feature tracking and drawing working
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 125
diff changeset
52 }
d19d6e63dd77 simple feature tracking and drawing working
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 125
diff changeset
53
132
45c64e68053c added drawing function for features
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 130
diff changeset
54 struct FeaturePointMatch {
45c64e68053c added drawing function for features
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 130
diff changeset
55 FeatureTrajectoryPtr feature;
45c64e68053c added drawing function for features
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 130
diff changeset
56 int pointNum;
45c64e68053c added drawing function for features
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 130
diff changeset
57
45c64e68053c added drawing function for features
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 130
diff changeset
58 FeaturePointMatch(FeatureTrajectoryPtr _feature, const int& _pointNum):
45c64e68053c added drawing function for features
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 130
diff changeset
59 feature(_feature), pointNum(_pointNum) {}
45c64e68053c added drawing function for features
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 130
diff changeset
60 };
45c64e68053c added drawing function for features
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 130
diff changeset
61
142
a3532db00c28 added code to write velocities
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 141
diff changeset
62 inline void saveFeatures(vector<FeatureTrajectoryPtr>& features, TrajectoryDBAccess<Point2f>& db, const string& positionsTableName, const string& velocitiesTableName, const unsigned int& minNFeatures = 0) {
147
0089fb29cd26 added projection of points and reprojection for display
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 146
diff changeset
63 /// \todo smoothing
140
8de5e8256224 added function to save vectors of features
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 139
diff changeset
64 if (features.size() >= minNFeatures) {
142
a3532db00c28 added code to write velocities
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 141
diff changeset
65 BOOST_FOREACH(FeatureTrajectoryPtr f, features) f->write(db, positionsTableName, velocitiesTableName);
140
8de5e8256224 added function to save vectors of features
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 139
diff changeset
66 features.clear();
8de5e8256224 added function to save vectors of features
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 139
diff changeset
67 }
8de5e8256224 added function to save vectors of features
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 139
diff changeset
68 }
8de5e8256224 added function to save vectors of features
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 139
diff changeset
69
164
76610dcf3b8d added test code to read trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 163
diff changeset
70 void trackFeatures(const KLTFeatureTrackingParameters& params) {
174
ec9734015d53 tested loading trajectory by id numbers
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 172
diff changeset
71 // BriefDescriptorExtractor brief(32);
ec9734015d53 tested loading trajectory by id numbers
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 172
diff changeset
72 // const int DESIRED_FTRS = 500;
ec9734015d53 tested loading trajectory by id numbers
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 172
diff changeset
73 // GridAdaptedFeatureDetector detector(new FastFeatureDetector(10, true), DESIRED_FTRS, 4, 4);
ec9734015d53 tested loading trajectory by id numbers
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 172
diff changeset
74
147
0089fb29cd26 added projection of points and reprojection for display
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 146
diff changeset
75 Mat homography = ::loadMat(params.homographyFilename, " ");
0089fb29cd26 added projection of points and reprojection for display
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 146
diff changeset
76 Mat invHomography;
0089fb29cd26 added projection of points and reprojection for display
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 146
diff changeset
77 if (params.display && !homography.empty())
0089fb29cd26 added projection of points and reprojection for display
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 146
diff changeset
78 invHomography = homography.inv();
144
b32947b002da added the code to read matrices from text files
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 142
diff changeset
79
137
445e773c9be3 created the parameter structure to parse parameters (bug remaining)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 136
diff changeset
80 float minTotalFeatureDisplacement = params.nDisplacements*params.minFeatureDisplacement;
127
d19d6e63dd77 simple feature tracking and drawing working
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 125
diff changeset
81 Size window = Size(params.windowSize, params.windowSize);
122
654f1c748644 work on displaying matched features
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 121
diff changeset
82
207
48f83ff769fd removed unused code that has changed in OpenCV 2.4
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 202
diff changeset
83 // BruteForceMatcher<Hamming> descMatcher;
48f83ff769fd removed unused code that has changed in OpenCV 2.4
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 202
diff changeset
84 // vector<DMatch> matches;
122
654f1c748644 work on displaying matched features
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 121
diff changeset
85
401
b829ebdc18e6 simplified input of directories of video frames (simply use the video filename parameter to point at the directory)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 400
diff changeset
86 boost::shared_ptr<InputFrameProviderIface> capture;
b829ebdc18e6 simplified input of directories of video frames (simply use the video filename parameter to point at the directory)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 400
diff changeset
87 if (fs::is_directory(fs::path(params.videoFilename)))
b829ebdc18e6 simplified input of directories of video frames (simply use the video filename parameter to point at the directory)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 400
diff changeset
88 capture = boost::shared_ptr<InputFrameListModule>(new InputFrameListModule(params.videoFilename));
399
c389fae9689a Added a class to read list of image instead of video. This is controlled by the use of the database-filename and folder-data parameters in the config file.
Jean-Philippe Jodoin <jpjodoin@gmail.com>
parents: 391
diff changeset
89 else if(!params.videoFilename.empty())
401
b829ebdc18e6 simplified input of directories of video frames (simply use the video filename parameter to point at the directory)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 400
diff changeset
90 capture = boost::shared_ptr<InputVideoFileModule>(new InputVideoFileModule(params.videoFilename));
399
c389fae9689a Added a class to read list of image instead of video. This is controlled by the use of the database-filename and folder-data parameters in the config file.
Jean-Philippe Jodoin <jpjodoin@gmail.com>
parents: 391
diff changeset
91 else
401
b829ebdc18e6 simplified input of directories of video frames (simply use the video filename parameter to point at the directory)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 400
diff changeset
92 cout << "No valid input parameters" << endl;
400
7ef1071e3cc3 clean up of input classes for list of images and video files
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 399
diff changeset
93
7ef1071e3cc3 clean up of input classes for list of images and video files
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 399
diff changeset
94 if(!capture->isOpen()) {
7ef1071e3cc3 clean up of input classes for list of images and video files
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 399
diff changeset
95 cout << "Video filename " << params.videoFilename << " could not be opened. Exiting." << endl;
7ef1071e3cc3 clean up of input classes for list of images and video files
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 399
diff changeset
96 exit(0);
138
c1b260b48d2a corrected initialization bugs and feature shortening before saving
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 137
diff changeset
97 }
399
c389fae9689a Added a class to read list of image instead of video. This is controlled by the use of the database-filename and folder-data parameters in the config file.
Jean-Philippe Jodoin <jpjodoin@gmail.com>
parents: 391
diff changeset
98
c389fae9689a Added a class to read list of image instead of video. This is controlled by the use of the database-filename and folder-data parameters in the config file.
Jean-Philippe Jodoin <jpjodoin@gmail.com>
parents: 391
diff changeset
99 Size videoSize = capture->getSize();
c389fae9689a Added a class to read list of image instead of video. This is controlled by the use of the database-filename and folder-data parameters in the config file.
Jean-Philippe Jodoin <jpjodoin@gmail.com>
parents: 391
diff changeset
100 unsigned int nFrames = capture->getNbFrames();
c389fae9689a Added a class to read list of image instead of video. This is controlled by the use of the database-filename and folder-data parameters in the config file.
Jean-Philippe Jodoin <jpjodoin@gmail.com>
parents: 391
diff changeset
101 cout << "Video " << params.videoFilename <<
c389fae9689a Added a class to read list of image instead of video. This is controlled by the use of the database-filename and folder-data parameters in the config file.
Jean-Philippe Jodoin <jpjodoin@gmail.com>
parents: 391
diff changeset
102 ": width=" << videoSize.width <<
c389fae9689a Added a class to read list of image instead of video. This is controlled by the use of the database-filename and folder-data parameters in the config file.
Jean-Philippe Jodoin <jpjodoin@gmail.com>
parents: 391
diff changeset
103 ", height=" << videoSize.height <<
c389fae9689a Added a class to read list of image instead of video. This is controlled by the use of the database-filename and folder-data parameters in the config file.
Jean-Philippe Jodoin <jpjodoin@gmail.com>
parents: 391
diff changeset
104 ", nframes=" << nFrames << endl;
c389fae9689a Added a class to read list of image instead of video. This is controlled by the use of the database-filename and folder-data parameters in the config file.
Jean-Philippe Jodoin <jpjodoin@gmail.com>
parents: 391
diff changeset
105
146
7150427c665e added loading of mask
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 145
diff changeset
106 Mat mask = imread(params.maskFilename, 0);
363
68861b52a319 added message if mask not found/loaded
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 278
diff changeset
107 if (mask.empty()) {
68861b52a319 added message if mask not found/loaded
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 278
diff changeset
108 cout << "Mask filename " << params.maskFilename << " could not be opened." << endl;
146
7150427c665e added loading of mask
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 145
diff changeset
109 mask = Mat::ones(videoSize, CV_8UC1);
363
68861b52a319 added message if mask not found/loaded
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 278
diff changeset
110 }
146
7150427c665e added loading of mask
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 145
diff changeset
111
140
8de5e8256224 added function to save vectors of features
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 139
diff changeset
112 boost::shared_ptr<TrajectoryDBAccess<Point2f> > trajectoryDB = boost::shared_ptr<TrajectoryDBAccess<Point2f> >(new TrajectoryDBAccessList<Point2f>());
136
0f790de9437e renamed Feature to Motion files and added code to test blob db
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 135
diff changeset
113 //TrajectoryDBAccess<Point2f>* trajectoryDB = new TrajectoryDBAccessBlob<Point2f>();
138
c1b260b48d2a corrected initialization bugs and feature shortening before saving
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 137
diff changeset
114 trajectoryDB->connect(params.databaseFilename.c_str());
142
a3532db00c28 added code to write velocities
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 141
diff changeset
115 trajectoryDB->createTable("positions");
a3532db00c28 added code to write velocities
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 141
diff changeset
116 trajectoryDB->createTable("velocities");
a3532db00c28 added code to write velocities
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 141
diff changeset
117 trajectoryDB->beginTransaction();
133
63dd4355b6d1 saving of feature positions in sqlite database
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 132
diff changeset
118
230
bc4ea09b1743 compatibility modifications for visual studio compilation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 207
diff changeset
119 std::vector<KeyPoint> prevKpts, currKpts;
bc4ea09b1743 compatibility modifications for visual studio compilation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 207
diff changeset
120 std::vector<Point2f> prevPts, currPts, newPts;
bc4ea09b1743 compatibility modifications for visual studio compilation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 207
diff changeset
121 std::vector<uchar> status;
bc4ea09b1743 compatibility modifications for visual studio compilation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 207
diff changeset
122 std::vector<float> errors;
127
d19d6e63dd77 simple feature tracking and drawing working
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 125
diff changeset
123 Mat prevDesc, currDesc;
128
536510f60854 new features generated as needed
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 127
diff changeset
124
230
bc4ea09b1743 compatibility modifications for visual studio compilation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 207
diff changeset
125 std::vector<FeatureTrajectoryPtr> lostFeatures;
bc4ea09b1743 compatibility modifications for visual studio compilation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 207
diff changeset
126 std::vector<FeaturePointMatch> featurePointMatches;
163
cde87a07eb58 added graph structures
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 154
diff changeset
127
401
b829ebdc18e6 simplified input of directories of video frames (simply use the video filename parameter to point at the directory)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 400
diff changeset
128 //HOGDescriptor hog;
b829ebdc18e6 simplified input of directories of video frames (simply use the video filename parameter to point at the directory)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 400
diff changeset
129 //hog.setSVMDetector(HOGDescriptor::getDefaultPeopleDetector());
193
a728fce85881 simple test of adding and using default HoG pedestrian detector
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 191
diff changeset
130
133
63dd4355b6d1 saving of feature positions in sqlite database
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 132
diff changeset
131 int key = '?';
63dd4355b6d1 saving of feature positions in sqlite database
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 132
diff changeset
132 unsigned int savedFeatureId=0;
278
f21ef87f98f1 resolved issue 2 and problem with negative nframes parameter
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 234
diff changeset
133 Mat frame = Mat::zeros(1, 1, CV_8UC1), currentFrameBW, previousFrameBW;
227
b7612c6d5702 cleaned the code
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 225
diff changeset
134
278
f21ef87f98f1 resolved issue 2 and problem with negative nframes parameter
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 234
diff changeset
135 unsigned int lastFrameNum = nFrames;
228
23da16442433 minor modifications for unsigned int (nframes is now 0 to process all frames)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 227
diff changeset
136 if (params.nFrames > 0)
278
f21ef87f98f1 resolved issue 2 and problem with negative nframes parameter
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 234
diff changeset
137 lastFrameNum = MIN(params.frame1+static_cast<unsigned int>(params.nFrames), nFrames);
227
b7612c6d5702 cleaned the code
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 225
diff changeset
138
400
7ef1071e3cc3 clean up of input classes for list of images and video files
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 399
diff changeset
139 capture->setFrameNumber(params.frame1);
227
b7612c6d5702 cleaned the code
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 225
diff changeset
140 for (unsigned int frameNum = params.frame1; (frameNum < lastFrameNum) && !::interruptionKey(key); frameNum++) {
399
c389fae9689a Added a class to read list of image instead of video. This is controlled by the use of the database-filename and folder-data parameters in the config file.
Jean-Philippe Jodoin <jpjodoin@gmail.com>
parents: 391
diff changeset
141 bool success = capture->getNextFrame(frame);
278
f21ef87f98f1 resolved issue 2 and problem with negative nframes parameter
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 234
diff changeset
142
399
c389fae9689a Added a class to read list of image instead of video. This is controlled by the use of the database-filename and folder-data parameters in the config file.
Jean-Philippe Jodoin <jpjodoin@gmail.com>
parents: 391
diff changeset
143 if (!success || frame.empty() || frame.size() != videoSize)
278
f21ef87f98f1 resolved issue 2 and problem with negative nframes parameter
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 234
diff changeset
144 break;
f21ef87f98f1 resolved issue 2 and problem with negative nframes parameter
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 234
diff changeset
145
227
b7612c6d5702 cleaned the code
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 225
diff changeset
146 if (frameNum%50 ==0)
b7612c6d5702 cleaned the code
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 225
diff changeset
147 cout << "frame " << frameNum << endl;
278
f21ef87f98f1 resolved issue 2 and problem with negative nframes parameter
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 234
diff changeset
148
227
b7612c6d5702 cleaned the code
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 225
diff changeset
149 //capture.get(CV_CAP_PROP_POS_FRAMES) << " " << prevPts.size() << endl;
b7612c6d5702 cleaned the code
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 225
diff changeset
150
b7612c6d5702 cleaned the code
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 225
diff changeset
151 // int emptyFrameNum = 0;
b7612c6d5702 cleaned the code
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 225
diff changeset
152 // while (frame.empty()) {
b7612c6d5702 cleaned the code
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 225
diff changeset
153 // cerr << "empty frame " << emptyFrameNum << " " << capture.get(CV_CAP_PROP_POS_FRAMES)<< endl;
b7612c6d5702 cleaned the code
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 225
diff changeset
154 // capture >> frame;//break;
b7612c6d5702 cleaned the code
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 225
diff changeset
155 // emptyFrameNum++;
b7612c6d5702 cleaned the code
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 225
diff changeset
156 // if (emptyFrameNum>=3000)
b7612c6d5702 cleaned the code
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 225
diff changeset
157 // exit(0);
b7612c6d5702 cleaned the code
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 225
diff changeset
158 // }
121
c4d4b5b93add copied the video_homography opencv sample
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 119
diff changeset
159
127
d19d6e63dd77 simple feature tracking and drawing working
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 125
diff changeset
160 cvtColor(frame, currentFrameBW, CV_RGB2GRAY);
130
2a6e7a9a5c53 changed to goodFeaturesToTrack instead of generic detectors
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 128
diff changeset
161 // "normal" feature detectors: detect features here
2a6e7a9a5c53 changed to goodFeaturesToTrack instead of generic detectors
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 128
diff changeset
162 // detector.detect(currentFrameBW, currKpts); // see video_homography c++ sample
121
c4d4b5b93add copied the video_homography opencv sample
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 119
diff changeset
163
128
536510f60854 new features generated as needed
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 127
diff changeset
164 if (!prevPts.empty()) {
536510f60854 new features generated as needed
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 127
diff changeset
165 //::keyPoints2Points(prevKpts, prevPts);
127
d19d6e63dd77 simple feature tracking and drawing working
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 125
diff changeset
166 currPts.clear();
137
445e773c9be3 created the parameter structure to parse parameters (bug remaining)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 136
diff changeset
167 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
154
668710d4c773 updated computeTranslation with cv2
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 147
diff changeset
168 /// \todo try calcOpticalFlowFarneback
128
536510f60854 new features generated as needed
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 127
diff changeset
169
230
bc4ea09b1743 compatibility modifications for visual studio compilation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 207
diff changeset
170 std::vector<Point2f> trackedPts;
bc4ea09b1743 compatibility modifications for visual studio compilation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 207
diff changeset
171 std::vector<FeaturePointMatch>::iterator iter = featurePointMatches.begin();
132
45c64e68053c added drawing function for features
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 130
diff changeset
172 while (iter != featurePointMatches.end()) {
135
32d2722d4028 added constraint on minimum displacement
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 134
diff changeset
173 bool deleteFeature = false;
32d2722d4028 added constraint on minimum displacement
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 134
diff changeset
174
132
45c64e68053c added drawing function for features
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 130
diff changeset
175 if (status[iter->pointNum]) {
147
0089fb29cd26 added projection of points and reprojection for display
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 146
diff changeset
176 iter->feature->addPoint(frameNum, currPts[iter->pointNum], homography);
135
32d2722d4028 added constraint on minimum displacement
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 134
diff changeset
177
176
9323427aa0a3 changed positions and velocities to shared pointers and renamed methods
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 175
diff changeset
178 deleteFeature |= iter->feature->isDisplacementSmall(params.nDisplacements, minTotalFeatureDisplacement)
9323427aa0a3 changed positions and velocities to shared pointers and renamed methods
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 175
diff changeset
179 || !iter->feature->isMotionSmooth(params.accelerationBound, params.deviationBound);
139
47329bd16cc0 cleaned code, added condition on smooth displacement
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 138
diff changeset
180 if (deleteFeature)
138
c1b260b48d2a corrected initialization bugs and feature shortening before saving
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 137
diff changeset
181 iter->feature->shorten();
139
47329bd16cc0 cleaned code, added condition on smooth displacement
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 138
diff changeset
182 } else
47329bd16cc0 cleaned code, added condition on smooth displacement
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 138
diff changeset
183 deleteFeature = true;
135
32d2722d4028 added constraint on minimum displacement
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 134
diff changeset
184
32d2722d4028 added constraint on minimum displacement
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 134
diff changeset
185 if (deleteFeature) {
134
a617d0808bbc added test on feature length and display control
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 133
diff changeset
186 if (iter->feature->length() >= params.minFeatureTime) {
a617d0808bbc added test on feature length and display control
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 133
diff changeset
187 iter->feature->setId(savedFeatureId);
a617d0808bbc added test on feature length and display control
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 133
diff changeset
188 savedFeatureId++;
140
8de5e8256224 added function to save vectors of features
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 139
diff changeset
189 lostFeatures.push_back(iter->feature);
134
a617d0808bbc added test on feature length and display control
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 133
diff changeset
190 }
132
45c64e68053c added drawing function for features
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 130
diff changeset
191 iter = featurePointMatches.erase(iter);
138
c1b260b48d2a corrected initialization bugs and feature shortening before saving
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 137
diff changeset
192 } else {
c1b260b48d2a corrected initialization bugs and feature shortening before saving
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 137
diff changeset
193 trackedPts.push_back(currPts[iter->pointNum]);
c1b260b48d2a corrected initialization bugs and feature shortening before saving
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 137
diff changeset
194 iter->pointNum = trackedPts.size()-1;
135
32d2722d4028 added constraint on minimum displacement
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 134
diff changeset
195 iter++;
138
c1b260b48d2a corrected initialization bugs and feature shortening before saving
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 137
diff changeset
196 }
132
45c64e68053c added drawing function for features
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 130
diff changeset
197 }
128
536510f60854 new features generated as needed
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 127
diff changeset
198 currPts = trackedPts;
132
45c64e68053c added drawing function for features
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 130
diff changeset
199 assert(currPts.size() == featurePointMatches.size());
142
a3532db00c28 added code to write velocities
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 141
diff changeset
200 saveFeatures(lostFeatures, *trajectoryDB, "positions", "velocities");
134
a617d0808bbc added test on feature length and display control
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 133
diff changeset
201
139
47329bd16cc0 cleaned code, added condition on smooth displacement
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 138
diff changeset
202 if (params.display) {
134
a617d0808bbc added test on feature length and display control
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 133
diff changeset
203 BOOST_FOREACH(FeaturePointMatch fp, featurePointMatches)
147
0089fb29cd26 added projection of points and reprojection for display
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 146
diff changeset
204 fp.feature->draw(frame, invHomography, Colors::red());
193
a728fce85881 simple test of adding and using default HoG pedestrian detector
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 191
diff changeset
205 // object detection
a728fce85881 simple test of adding and using default HoG pedestrian detector
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 191
diff changeset
206 // vector<Rect> locations;
a728fce85881 simple test of adding and using default HoG pedestrian detector
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 191
diff changeset
207 // hog.detectMultiScale(frame, locations, 0, Size(8,8), Size(32,32), 1.05, 2);
a728fce85881 simple test of adding and using default HoG pedestrian detector
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 191
diff changeset
208 // BOOST_FOREACH(Rect r, locations)
a728fce85881 simple test of adding and using default HoG pedestrian detector
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 191
diff changeset
209 // rectangle(frame, r.tl(), r.br(), cv::Scalar(0,255,0), 3);
139
47329bd16cc0 cleaned code, added condition on smooth displacement
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 138
diff changeset
210 }
132
45c64e68053c added drawing function for features
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 130
diff changeset
211 //drawOpticalFlow(prevPts, currPts, status, frame);
134
a617d0808bbc added test on feature length and display control
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 133
diff changeset
212
127
d19d6e63dd77 simple feature tracking and drawing working
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 125
diff changeset
213 // cout << matches.size() << " matches" << endl;
d19d6e63dd77 simple feature tracking and drawing working
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 125
diff changeset
214 // descMatcher.match(currDesc, prevDesc, matches);
d19d6e63dd77 simple feature tracking and drawing working
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 125
diff changeset
215 // cout << matches.size() << " matches" << endl;
128
536510f60854 new features generated as needed
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 127
diff changeset
216 //drawMatchesRelative(prevKpts, currKpts, matches, frame);
125
28907fde9855 work on klt tracker (problem on computer at poly)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 124
diff changeset
217 }
28907fde9855 work on klt tracker (problem on computer at poly)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 124
diff changeset
218
128
536510f60854 new features generated as needed
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 127
diff changeset
219 // adding new features, using mask around existing feature positions
146
7150427c665e added loading of mask
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 145
diff changeset
220 Mat featureMask = mask.clone();
128
536510f60854 new features generated as needed
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 127
diff changeset
221 for (unsigned int n=0;n<currPts.size(); n++)
536510f60854 new features generated as needed
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 127
diff changeset
222 for (int j=MAX(0, currPts[n].x-params.minFeatureDistanceKLT); j<MIN(videoSize.width, currPts[n].x+params.minFeatureDistanceKLT+1); j++)
536510f60854 new features generated as needed
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 127
diff changeset
223 for (int i=MAX(0, currPts[n].y-params.minFeatureDistanceKLT); i<MIN(videoSize.height, currPts[n].y+params.minFeatureDistanceKLT+1); i++)
536510f60854 new features generated as needed
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 127
diff changeset
224 featureMask.at<uchar>(i,j)=0;
130
2a6e7a9a5c53 changed to goodFeaturesToTrack instead of generic detectors
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 128
diff changeset
225 goodFeaturesToTrack(currentFrameBW, newPts, params.maxNFeatures, params.featureQuality, params.minFeatureDistanceKLT, featureMask, params.windowSize, params.useHarrisDetector, params.k);
132
45c64e68053c added drawing function for features
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 130
diff changeset
226 BOOST_FOREACH(Point2f p, newPts) { //for (unsigned int i=0; i<newPts.size(); i++) {
147
0089fb29cd26 added projection of points and reprojection for display
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 146
diff changeset
227 FeatureTrajectoryPtr f = FeatureTrajectoryPtr(new FeatureTrajectory(frameNum, p, homography));
132
45c64e68053c added drawing function for features
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 130
diff changeset
228 featurePointMatches.push_back(FeaturePointMatch(f, currPts.size()));
45c64e68053c added drawing function for features
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 130
diff changeset
229 currPts.push_back(p);
45c64e68053c added drawing function for features
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 130
diff changeset
230 }
45c64e68053c added drawing function for features
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 130
diff changeset
231 // currPts.insert(currPts.end(), newPts.begin(), newPts.end());
130
2a6e7a9a5c53 changed to goodFeaturesToTrack instead of generic detectors
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 128
diff changeset
232 //::keyPoints2Points(currKpts, currPts, false);
128
536510f60854 new features generated as needed
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 127
diff changeset
233
536510f60854 new features generated as needed
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 127
diff changeset
234 //brief.compute(currentFrameBW, currKpts, currDesc); //Compute brief descriptors at each keypoint location
536510f60854 new features generated as needed
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 127
diff changeset
235
134
a617d0808bbc added test on feature length and display control
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 133
diff changeset
236 if (params.display) {
401
b829ebdc18e6 simplified input of directories of video frames (simply use the video filename parameter to point at the directory)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 400
diff changeset
237 imshow("mask", featureMask*256);
134
a617d0808bbc added test on feature length and display control
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 133
diff changeset
238 imshow("frame", frame);
a617d0808bbc added test on feature length and display control
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 133
diff changeset
239 key = waitKey(2);
a617d0808bbc added test on feature length and display control
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 133
diff changeset
240 }
127
d19d6e63dd77 simple feature tracking and drawing working
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 125
diff changeset
241 previousFrameBW = currentFrameBW.clone();
128
536510f60854 new features generated as needed
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 127
diff changeset
242 prevPts = currPts;
536510f60854 new features generated as needed
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 127
diff changeset
243 //prevKpts = currKpts;
536510f60854 new features generated as needed
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 127
diff changeset
244 //currDesc.copyTo(prevDesc);
121
c4d4b5b93add copied the video_homography opencv sample
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 119
diff changeset
245 }
c4d4b5b93add copied the video_homography opencv sample
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 119
diff changeset
246
142
a3532db00c28 added code to write velocities
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 141
diff changeset
247 trajectoryDB->endTransaction();
136
0f790de9437e renamed Feature to Motion files and added code to test blob db
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 135
diff changeset
248 trajectoryDB->disconnect();
164
76610dcf3b8d added test code to read trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 163
diff changeset
249 }
76610dcf3b8d added test code to read trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 163
diff changeset
250
169
5f705809d37a created groupFeatures function
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 168
diff changeset
251 void groupFeatures(const KLTFeatureTrackingParameters& params) {
5f705809d37a created groupFeatures function
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 168
diff changeset
252 boost::shared_ptr<TrajectoryDBAccessList<Point2f> > trajectoryDB = boost::shared_ptr<TrajectoryDBAccessList<Point2f> >(new TrajectoryDBAccessList<Point2f>());
5f705809d37a created groupFeatures function
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 168
diff changeset
253 //TODO write generic methods for blob and list versions TrajectoryDBAccess<Point2f>* trajectoryDB = new TrajectoryDBAccessBlob<Point2f>();
5f705809d37a created groupFeatures function
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 168
diff changeset
254 bool success = trajectoryDB->connect(params.databaseFilename.c_str());
202
b0b964ba9489 added early saving of objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 194
diff changeset
255 trajectoryDB->createObjectTable("objects", "objects_features");
b0b964ba9489 added early saving of objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 194
diff changeset
256 unsigned int savedObjectId=0;
b0b964ba9489 added early saving of objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 194
diff changeset
257
188
1435965d8181 work on connected components
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 186
diff changeset
258 // vector<boost::shared_ptr<Trajectory<Point2f> > > trajectories;
1435965d8181 work on connected components
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 186
diff changeset
259 // cout << trajectories.size() << endl;
174
ec9734015d53 tested loading trajectory by id numbers
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 172
diff changeset
260 // std::clock_t c_start = std::clock();
ec9734015d53 tested loading trajectory by id numbers
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 172
diff changeset
261 // success = trajectoryDB->read(trajectories, "positions"); // TODO load velocities as well in a FeatureTrajectory object // attention, velocities lack the first instant
ec9734015d53 tested loading trajectory by id numbers
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 172
diff changeset
262 // std::clock_t c_end = std::clock();
ec9734015d53 tested loading trajectory by id numbers
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 172
diff changeset
263 // cout << "Loaded " << trajectories.size() << " trajectories in " << 1000.0 * (c_end-c_start) / CLOCKS_PER_SEC << " CPU seconds" << endl;
ec9734015d53 tested loading trajectory by id numbers
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 172
diff changeset
264
ec9734015d53 tested loading trajectory by id numbers
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 172
diff changeset
265 // boost::shared_ptr<Trajectory<cv::Point2f> > trajectory;
ec9734015d53 tested loading trajectory by id numbers
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 172
diff changeset
266 // c_start = std::clock();
ec9734015d53 tested loading trajectory by id numbers
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 172
diff changeset
267 // for (unsigned int i = 0; i<trajectories.size(); ++i) {
ec9734015d53 tested loading trajectory by id numbers
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 172
diff changeset
268 // success = trajectoryDB->read(trajectory, i, "positions");
169
5f705809d37a created groupFeatures function
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 168
diff changeset
269 // }
174
ec9734015d53 tested loading trajectory by id numbers
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 172
diff changeset
270 // c_end = std::clock();
ec9734015d53 tested loading trajectory by id numbers
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 172
diff changeset
271 // cout << "Loaded " << trajectories.size() << " trajectories one by one in " << 1000.0 * (c_end-c_start) / CLOCKS_PER_SEC << " CPU seconds" << endl;
169
5f705809d37a created groupFeatures function
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 168
diff changeset
272
225
d4d3b1e8a9f1 added code to process only needed frames based on saved features
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 222
diff changeset
273 trajectoryDB->createInstants("table");
221
bc93e87a2108 cleaned and corrected connected components and feature groups
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 219
diff changeset
274
225
d4d3b1e8a9f1 added code to process only needed frames based on saved features
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 222
diff changeset
275 unsigned int maxTrajectoryLength = 0;
d4d3b1e8a9f1 added code to process only needed frames based on saved features
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 222
diff changeset
276 success = trajectoryDB->maxTrajectoryLength(maxTrajectoryLength);
d4d3b1e8a9f1 added code to process only needed frames based on saved features
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 222
diff changeset
277 if (!success || maxTrajectoryLength == 0) {
d4d3b1e8a9f1 added code to process only needed frames based on saved features
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 222
diff changeset
278 cout << "problem with trajectory length " << success << endl;
d4d3b1e8a9f1 added code to process only needed frames based on saved features
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 222
diff changeset
279 exit(0);
d4d3b1e8a9f1 added code to process only needed frames based on saved features
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 222
diff changeset
280 }
222
426321b46e44 temporary trajectory instants table
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 221
diff changeset
281 cout << "Longest trajectory: " << maxTrajectoryLength << endl;
219
841a1714f702 added comments for future development
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 207
diff changeset
282
191
0e60a306d324 added basic code to identify features and save them (crash)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 189
diff changeset
283 FeatureGraph featureGraph(params.mmConnectionDistance, params.mmSegmentationDistance, params.minFeatureTime, params.minNFeaturesPerGroup);
180
3a4eef37384f method to add features and vertices to graph
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 179
diff changeset
284
169
5f705809d37a created groupFeatures function
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 168
diff changeset
285 // main loop
227
b7612c6d5702 cleaned the code
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 225
diff changeset
286 unsigned int frameNum;
b7612c6d5702 cleaned the code
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 225
diff changeset
287 unsigned int firstFrameNum = -1, lastFrameNum = -1;
225
d4d3b1e8a9f1 added code to process only needed frames based on saved features
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 222
diff changeset
288 trajectoryDB->firstLastInstants(firstFrameNum, lastFrameNum);
d4d3b1e8a9f1 added code to process only needed frames based on saved features
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 222
diff changeset
289 firstFrameNum = MAX(firstFrameNum, params.frame1);
d4d3b1e8a9f1 added code to process only needed frames based on saved features
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 222
diff changeset
290 if (params.nFrames>0)
d4d3b1e8a9f1 added code to process only needed frames based on saved features
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 222
diff changeset
291 lastFrameNum = MIN(lastFrameNum,params.frame1+params.nFrames);
d4d3b1e8a9f1 added code to process only needed frames based on saved features
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 222
diff changeset
292 for (frameNum = firstFrameNum; frameNum<lastFrameNum; frameNum ++) {
174
ec9734015d53 tested loading trajectory by id numbers
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 172
diff changeset
293 vector<int> trajectoryIds;
231
249d65ff6c35 merged modifications for windows
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 230 228
diff changeset
294 success = trajectoryDB->trajectoryIdEndingAt(trajectoryIds, frameNum);
225
d4d3b1e8a9f1 added code to process only needed frames based on saved features
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 222
diff changeset
295 if (frameNum%100 ==0)
d4d3b1e8a9f1 added code to process only needed frames based on saved features
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 222
diff changeset
296 cout << "frame " << frameNum << endl;
222
426321b46e44 temporary trajectory instants table
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 221
diff changeset
297 //success = trajectoryDB->trajectoryIdInInterval(trajectoryIds, frameNum, min(frameNum+queryIntervalLength-1, frameNum+params.nFrames)); // ending
426321b46e44 temporary trajectory instants table
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 221
diff changeset
298 #if DEBUG
174
ec9734015d53 tested loading trajectory by id numbers
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 172
diff changeset
299 cout << trajectoryIds.size() << " trajectories " << endl;
222
426321b46e44 temporary trajectory instants table
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 221
diff changeset
300 #endif
426321b46e44 temporary trajectory instants table
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 221
diff changeset
301 // vector<TrajectoryPoint2fPtr> positions, velocities;
426321b46e44 temporary trajectory instants table
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 221
diff changeset
302 // trajectoryDB->read(positions, trajectoryIds, "positions");
426321b46e44 temporary trajectory instants table
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 221
diff changeset
303 // trajectoryDB->read(velocities, trajectoryIds, "velocities");
426321b46e44 temporary trajectory instants table
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 221
diff changeset
304 // for (unsigned int i=0; i<trajectoryIds.size(); ++i) {
426321b46e44 temporary trajectory instants table
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 221
diff changeset
305 // FeatureTrajectoryPtr ft = FeatureTrajectoryPtr(new FeatureTrajectory(positions[i], velocities[i]));
174
ec9734015d53 tested loading trajectory by id numbers
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 172
diff changeset
306 BOOST_FOREACH(int trajectoryId, trajectoryIds) {
ec9734015d53 tested loading trajectory by id numbers
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 172
diff changeset
307 //cout << trajectoryId << " " << endl;
177
ae2286b1a3fd added loading FeatureTrajectory from database, printing
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 176
diff changeset
308 // boost::shared_ptr<Trajectory<cv::Point2f> > trajectory;
ae2286b1a3fd added loading FeatureTrajectory from database, printing
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 176
diff changeset
309 // success = trajectoryDB->read(trajectory, trajectoryId, "positions"); // velocities
ae2286b1a3fd added loading FeatureTrajectory from database, printing
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 176
diff changeset
310 FeatureTrajectoryPtr ft = FeatureTrajectoryPtr(new FeatureTrajectory(trajectoryId, *trajectoryDB, "positions", "velocities"));
180
3a4eef37384f method to add features and vertices to graph
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 179
diff changeset
311 // stringstream ss;ss << *ft; cout << ss.str() << endl;
3a4eef37384f method to add features and vertices to graph
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 179
diff changeset
312 // cout << ft->getFirstInstant() << " " << ft->getLastInstant() << endl;
3a4eef37384f method to add features and vertices to graph
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 179
diff changeset
313 featureGraph.addFeature(ft);
174
ec9734015d53 tested loading trajectory by id numbers
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 172
diff changeset
314 }
172
e508bb0cbb64 modified comments
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 169
diff changeset
315
222
426321b46e44 temporary trajectory instants table
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 221
diff changeset
316 // check for connected components
225
d4d3b1e8a9f1 added code to process only needed frames based on saved features
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 222
diff changeset
317 int lastInstant = frameNum+params.minFeatureTime-maxTrajectoryLength;
231
249d65ff6c35 merged modifications for windows
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 230 228
diff changeset
318 if (lastInstant > 0 && frameNum%10==0) {
225
d4d3b1e8a9f1 added code to process only needed frames based on saved features
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 222
diff changeset
319 featureGraph.connectedComponents(lastInstant);
391
03dbecd3a887 modified feature grouping to return vectors of pointers to feature trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 363
diff changeset
320 vector<vector<FeatureTrajectoryPtr> > featureGroups;
03dbecd3a887 modified feature grouping to return vectors of pointers to feature trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 363
diff changeset
321 featureGraph.getFeatureGroups(featureGroups);
225
d4d3b1e8a9f1 added code to process only needed frames based on saved features
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 222
diff changeset
322 for (unsigned int i=0; i<featureGroups.size(); ++i) {
391
03dbecd3a887 modified feature grouping to return vectors of pointers to feature trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 363
diff changeset
323 vector<unsigned int> featureNumbers;
03dbecd3a887 modified feature grouping to return vectors of pointers to feature trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 363
diff changeset
324 for (unsigned int j=0; j<featureGroups[i].size(); ++j)
03dbecd3a887 modified feature grouping to return vectors of pointers to feature trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 363
diff changeset
325 featureNumbers.push_back(featureGroups[i][j]->getId());
411
31604ef1cad4 added hog functions and the display of road user types if known
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 401
diff changeset
326 trajectoryDB->writeObject(savedObjectId, featureNumbers, 0 /* unknown */, 1, string("objects"), string("objects_features"));
225
d4d3b1e8a9f1 added code to process only needed frames based on saved features
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 222
diff changeset
327 savedObjectId++;
d4d3b1e8a9f1 added code to process only needed frames based on saved features
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 222
diff changeset
328 }
188
1435965d8181 work on connected components
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 186
diff changeset
329 }
222
426321b46e44 temporary trajectory instants table
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 221
diff changeset
330
225
d4d3b1e8a9f1 added code to process only needed frames based on saved features
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 222
diff changeset
331 if (frameNum%100 ==0)
d4d3b1e8a9f1 added code to process only needed frames based on saved features
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 222
diff changeset
332 cout << featureGraph.informationString() << endl;
d4d3b1e8a9f1 added code to process only needed frames based on saved features
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 222
diff changeset
333 }
d4d3b1e8a9f1 added code to process only needed frames based on saved features
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 222
diff changeset
334
d4d3b1e8a9f1 added code to process only needed frames based on saved features
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 222
diff changeset
335 // save remaining objects
d4d3b1e8a9f1 added code to process only needed frames based on saved features
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 222
diff changeset
336 featureGraph.connectedComponents(frameNum+maxTrajectoryLength+1);
391
03dbecd3a887 modified feature grouping to return vectors of pointers to feature trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 363
diff changeset
337 vector<vector<FeatureTrajectoryPtr> > featureGroups;
03dbecd3a887 modified feature grouping to return vectors of pointers to feature trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 363
diff changeset
338 featureGraph.getFeatureGroups(featureGroups);
225
d4d3b1e8a9f1 added code to process only needed frames based on saved features
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 222
diff changeset
339 for (unsigned int i=0; i<featureGroups.size(); ++i) {
391
03dbecd3a887 modified feature grouping to return vectors of pointers to feature trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 363
diff changeset
340 vector<unsigned int> featureNumbers;
03dbecd3a887 modified feature grouping to return vectors of pointers to feature trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 363
diff changeset
341 for (unsigned int j=0; j<featureGroups[i].size(); ++j)
03dbecd3a887 modified feature grouping to return vectors of pointers to feature trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 363
diff changeset
342 featureNumbers.push_back(featureGroups[i][j]->getId());
412
97cb5c969ef2 corrected grouping bug (last object type -1) and added script to rescale homographies
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 411
diff changeset
343 trajectoryDB->writeObject(savedObjectId, featureNumbers, 0 /* unknown */, 1, string("objects"), string("objects_features"));
225
d4d3b1e8a9f1 added code to process only needed frames based on saved features
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 222
diff changeset
344 savedObjectId++;
180
3a4eef37384f method to add features and vertices to graph
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 179
diff changeset
345 }
169
5f705809d37a created groupFeatures function
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 168
diff changeset
346
5f705809d37a created groupFeatures function
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 168
diff changeset
347 trajectoryDB->endTransaction();
5f705809d37a created groupFeatures function
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 168
diff changeset
348 trajectoryDB->disconnect();
5f705809d37a created groupFeatures function
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 168
diff changeset
349 }
5f705809d37a created groupFeatures function
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 168
diff changeset
350
164
76610dcf3b8d added test code to read trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 163
diff changeset
351 int main(int argc, char *argv[]) {
76610dcf3b8d added test code to read trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 163
diff changeset
352 KLTFeatureTrackingParameters params(argc, argv);
76610dcf3b8d added test code to read trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 163
diff changeset
353 cout << params.parameterDescription << endl;
234
2d34060db2e9 removed included code that put track feature option always to true
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 231
diff changeset
354
2d34060db2e9 removed included code that put track feature option always to true
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 231
diff changeset
355 if (params.trackFeatures) {
2d34060db2e9 removed included code that put track feature option always to true
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 231
diff changeset
356 cout << "The program tracks features" << endl;
164
76610dcf3b8d added test code to read trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 163
diff changeset
357 trackFeatures(params);
234
2d34060db2e9 removed included code that put track feature option always to true
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 231
diff changeset
358 } else if (params.groupFeatures) {
2d34060db2e9 removed included code that put track feature option always to true
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 231
diff changeset
359 cout << "The program groups features" << endl;
169
5f705809d37a created groupFeatures function
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 168
diff changeset
360 groupFeatures(params);
234
2d34060db2e9 removed included code that put track feature option always to true
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 231
diff changeset
361 }
164
76610dcf3b8d added test code to read trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 163
diff changeset
362
117
fea680fb03ee created main feature based tracking file and minimum doxygen documentation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
363 return 0;
fea680fb03ee created main feature based tracking file and minimum doxygen documentation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
364 }
fea680fb03ee created main feature based tracking file and minimum doxygen documentation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
365
fea680fb03ee created main feature based tracking file and minimum doxygen documentation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
366 /* ------------------ DOCUMENTATION ------------------ */
fea680fb03ee created main feature based tracking file and minimum doxygen documentation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
367
fea680fb03ee created main feature based tracking file and minimum doxygen documentation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
368
fea680fb03ee created main feature based tracking file and minimum doxygen documentation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
369 /*! \mainpage
fea680fb03ee created main feature based tracking file and minimum doxygen documentation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
370
fea680fb03ee created main feature based tracking file and minimum doxygen documentation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
371 This project is a collection of software tools for transportation called Traffic Intelligence. Other documents are:
fea680fb03ee created main feature based tracking file and minimum doxygen documentation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
372
fea680fb03ee created main feature based tracking file and minimum doxygen documentation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
373 - \ref feature_based_tracking
fea680fb03ee created main feature based tracking file and minimum doxygen documentation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
374
fea680fb03ee created main feature based tracking file and minimum doxygen documentation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
375 The code is partially self-described using the doxygen tool and comment formatting. The documentation can be extracted using doxygen, typing \c doxygen in the main directory (or <tt>make doc</tt> on a system with the Makefile tool installed).
fea680fb03ee created main feature based tracking file and minimum doxygen documentation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
376
fea680fb03ee created main feature based tracking file and minimum doxygen documentation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
377 */
fea680fb03ee created main feature based tracking file and minimum doxygen documentation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
378
fea680fb03ee created main feature based tracking file and minimum doxygen documentation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
379 /*! \page feature_based_tracking Feature-based Tracking: User Manual
fea680fb03ee created main feature based tracking file and minimum doxygen documentation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
380
fea680fb03ee created main feature based tracking file and minimum doxygen documentation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
381 This document describes a software tool for object tracking in video data, developed for road traffic monitoring and safety diagnosis. It is part of a larger collection of software tools for transportation called Traffic Intelligence.
fea680fb03ee created main feature based tracking file and minimum doxygen documentation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
382
fea680fb03ee created main feature based tracking file and minimum doxygen documentation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
383 The tool relies on feature-based tracking, a robust object tracking methods, particularly suited for the extraction of traffic data such as trajectories and speeds. The best description of this method is given in <a href="http://nicolas.saunier.confins.net/data/saunier06crv.html">this paper</a>. The program has a command line interface and this document will shortly explain how to use the tool. Keep in mind this is a work in progress and major changes are continuously being made.
fea680fb03ee created main feature based tracking file and minimum doxygen documentation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
384
fea680fb03ee created main feature based tracking file and minimum doxygen documentation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
385 \section License
fea680fb03ee created main feature based tracking file and minimum doxygen documentation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
386
fea680fb03ee created main feature based tracking file and minimum doxygen documentation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
387 The code is licensed under the MIT open source license (http://www.opensource.org/licenses/mit-license).
fea680fb03ee created main feature based tracking file and minimum doxygen documentation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
388
fea680fb03ee created main feature based tracking file and minimum doxygen documentation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
389 If you make use of this piece of software, please cite one of my paper, e.g. N. Saunier, T. Sayed and K. Ismail. Large Scale Automated Analysis of Vehicle Interactions and Collisions. Transportation Research Record: Journal of the Transportation Research Board, 2147:42-50, 2010. I would be very happy in any case to know about any use of the code, and to discuss any opportunity for collaboration.
fea680fb03ee created main feature based tracking file and minimum doxygen documentation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
390
fea680fb03ee created main feature based tracking file and minimum doxygen documentation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
391 Contact me at nicolas.saunier@polymtl.ca and learn more about my work at http://nicolas.saunier.confins.net.
fea680fb03ee created main feature based tracking file and minimum doxygen documentation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
392
fea680fb03ee created main feature based tracking file and minimum doxygen documentation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
393 */