annotate c/feature-based-tracking.cpp @ 804:17e54690af8a dev

work in progress, not fully functional yet
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Wed, 01 Jun 2016 17:57:49 -0400
parents f7cf43b5ad3b
children
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"
803
f7cf43b5ad3b work in progress on stabilization
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 802
diff changeset
16 #include <opencv2/calib3d.hpp>
121
c4d4b5b93add copied the video_homography opencv sample
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 119
diff changeset
17
132
45c64e68053c added drawing function for features
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 130
diff changeset
18 #include <boost/foreach.hpp>
125
28907fde9855 work on klt tracker (problem on computer at poly)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 124
diff changeset
19
121
c4d4b5b93add copied the video_homography opencv sample
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 119
diff changeset
20 #include <iostream>
c4d4b5b93add copied the video_homography opencv sample
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 119
diff changeset
21 #include <vector>
174
ec9734015d53 tested loading trajectory by id numbers
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 172
diff changeset
22 #include <ctime>
509
935430b1d408 corrected mask bug in feature tracking, updated display-trajectories to display on undistorted image
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 507
diff changeset
23 #include <cmath>
654
045d05cef9d0 updating to c++11 capabilities
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 542
diff changeset
24 #include <memory>
679
576d9ea4b41a small update to deal with videos where the number of frames cannot be read
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 655
diff changeset
25 #include <limits>
121
c4d4b5b93add copied the video_homography opencv sample
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 119
diff changeset
26
c4d4b5b93add copied the video_homography opencv sample
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 119
diff changeset
27 using namespace std;
c4d4b5b93add copied the video_homography opencv sample
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 119
diff changeset
28 using namespace cv;
117
fea680fb03ee created main feature based tracking file and minimum doxygen documentation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
29
123
df3bdd8e50ba displays tracking from video and webcam
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 122
diff changeset
30 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
31 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
32 {
df3bdd8e50ba displays tracking from video and webcam
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 122
diff changeset
33 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
34 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
35 Point2f dist = pt_new - pt_old;
df3bdd8e50ba displays tracking from video and webcam
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 122
diff changeset
36 if (norm(dist) < 20) {
127
d19d6e63dd77 simple feature tracking and drawing working
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 125
diff changeset
37 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
38 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
39 }
df3bdd8e50ba displays tracking from video and webcam
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 122
diff changeset
40 }
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
127
d19d6e63dd77 simple feature tracking and drawing working
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 125
diff changeset
43 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
44 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
45 if (status[i]) {
d19d6e63dd77 simple feature tracking and drawing working
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 125
diff changeset
46 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
47 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
48 }
d19d6e63dd77 simple feature tracking and drawing working
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 125
diff changeset
49 }
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
132
45c64e68053c added drawing function for features
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 130
diff changeset
52 struct FeaturePointMatch {
45c64e68053c added drawing function for features
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 130
diff changeset
53 FeatureTrajectoryPtr feature;
45c64e68053c added drawing function for features
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 130
diff changeset
54 int pointNum;
45c64e68053c added drawing function for features
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 130
diff changeset
55
45c64e68053c added drawing function for features
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 130
diff changeset
56 FeaturePointMatch(FeatureTrajectoryPtr _feature, const int& _pointNum):
45c64e68053c added drawing function for features
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 130
diff changeset
57 feature(_feature), pointNum(_pointNum) {}
45c64e68053c added drawing function for features
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 130
diff changeset
58 };
45c64e68053c added drawing function for features
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 130
diff changeset
59
480
f43bc0b0ba74 cleaning code
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 418
diff changeset
60 inline void saveFeatures(vector<FeatureTrajectoryPtr>& features, TrajectoryDBAccess<Point2f>& db, const string& positionsTableName, const string& velocitiesTableName) {
f43bc0b0ba74 cleaning code
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 418
diff changeset
61 BOOST_FOREACH(FeatureTrajectoryPtr f, features) f->write(db, positionsTableName, velocitiesTableName);
f43bc0b0ba74 cleaning code
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 418
diff changeset
62 features.clear();
140
8de5e8256224 added function to save vectors of features
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 139
diff changeset
63 }
8de5e8256224 added function to save vectors of features
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 139
diff changeset
64
164
76610dcf3b8d added test code to read trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 163
diff changeset
65 void trackFeatures(const KLTFeatureTrackingParameters& params) {
803
f7cf43b5ad3b work in progress on stabilization
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 802
diff changeset
66 Mat refHomography = ::loadMat(params.homographyFilename, " ");
804
17e54690af8a work in progress, not fully functional yet
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 803
diff changeset
67 //if (params.stabilize && refHomography.empty())
17e54690af8a work in progress, not fully functional yet
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 803
diff changeset
68 // refHomography = Mat::eye(3, 3, CV_64FC1);
17e54690af8a work in progress, not fully functional yet
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 803
diff changeset
69 //Mat stabilizationHomography(3,3,CV_64FC1), homography(3,3,CV_64FC1);
17e54690af8a work in progress, not fully functional yet
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 803
diff changeset
70 Mat stabilizationHomography, homography;
17e54690af8a work in progress, not fully functional yet
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 803
diff changeset
71 if (!params.stabilize)
17e54690af8a work in progress, not fully functional yet
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 803
diff changeset
72 homography = refHomography;
17e54690af8a work in progress, not fully functional yet
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 803
diff changeset
73
137
445e773c9be3 created the parameter structure to parse parameters (bug remaining)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 136
diff changeset
74 float minTotalFeatureDisplacement = params.nDisplacements*params.minFeatureDisplacement;
127
d19d6e63dd77 simple feature tracking and drawing working
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 125
diff changeset
75 Size window = Size(params.windowSize, params.windowSize);
122
654f1c748644 work on displaying matched features
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 121
diff changeset
76
509
935430b1d408 corrected mask bug in feature tracking, updated display-trajectories to display on undistorted image
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 507
diff changeset
77 int interpolationMethod = -1;
935430b1d408 corrected mask bug in feature tracking, updated display-trajectories to display on undistorted image
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 507
diff changeset
78 if (params.interpolationMethod == 0)
935430b1d408 corrected mask bug in feature tracking, updated display-trajectories to display on undistorted image
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 507
diff changeset
79 interpolationMethod = INTER_NEAREST;
935430b1d408 corrected mask bug in feature tracking, updated display-trajectories to display on undistorted image
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 507
diff changeset
80 else if (params.interpolationMethod == 1)
935430b1d408 corrected mask bug in feature tracking, updated display-trajectories to display on undistorted image
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 507
diff changeset
81 interpolationMethod = INTER_LINEAR;
935430b1d408 corrected mask bug in feature tracking, updated display-trajectories to display on undistorted image
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 507
diff changeset
82 else if (params.interpolationMethod == 2)
935430b1d408 corrected mask bug in feature tracking, updated display-trajectories to display on undistorted image
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 507
diff changeset
83 interpolationMethod = INTER_CUBIC;
935430b1d408 corrected mask bug in feature tracking, updated display-trajectories to display on undistorted image
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 507
diff changeset
84 else if (params.interpolationMethod == 3)
935430b1d408 corrected mask bug in feature tracking, updated display-trajectories to display on undistorted image
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 507
diff changeset
85 interpolationMethod = INTER_LANCZOS4;
935430b1d408 corrected mask bug in feature tracking, updated display-trajectories to display on undistorted image
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 507
diff changeset
86 else
935430b1d408 corrected mask bug in feature tracking, updated display-trajectories to display on undistorted image
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 507
diff changeset
87 cout << "Unsupported option " << interpolationMethod << " for interpolation method" << endl;
935430b1d408 corrected mask bug in feature tracking, updated display-trajectories to display on undistorted image
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 507
diff changeset
88
207
48f83ff769fd removed unused code that has changed in OpenCV 2.4
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 202
diff changeset
89 // BruteForceMatcher<Hamming> descMatcher;
48f83ff769fd removed unused code that has changed in OpenCV 2.4
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 202
diff changeset
90 // vector<DMatch> matches;
122
654f1c748644 work on displaying matched features
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 121
diff changeset
91
655
39fa1c998b29 removed the abstract class to represent folders of images or video files since the capability is now built in OpenCV
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 654
diff changeset
92 if(params.videoFilename.empty()) {
39fa1c998b29 removed the abstract class to represent folders of images or video files since the capability is now built in OpenCV
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 654
diff changeset
93 cout << "Empty video filename. Exiting." << endl;
39fa1c998b29 removed the abstract class to represent folders of images or video files since the capability is now built in OpenCV
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 654
diff changeset
94 exit(0);
39fa1c998b29 removed the abstract class to represent folders of images or video files since the capability is now built in OpenCV
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 654
diff changeset
95 }
39fa1c998b29 removed the abstract class to represent folders of images or video files since the capability is now built in OpenCV
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 654
diff changeset
96
39fa1c998b29 removed the abstract class to represent folders of images or video files since the capability is now built in OpenCV
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 654
diff changeset
97 VideoCapture capture(params.videoFilename);
39fa1c998b29 removed the abstract class to represent folders of images or video files since the capability is now built in OpenCV
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 654
diff changeset
98 if(!capture.isOpened()) {
400
7ef1071e3cc3 clean up of input classes for list of images and video files
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 399
diff changeset
99 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
100 exit(0);
138
c1b260b48d2a corrected initialization bugs and feature shortening before saving
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 137
diff changeset
101 }
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
102
655
39fa1c998b29 removed the abstract class to represent folders of images or video files since the capability is now built in OpenCV
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 654
diff changeset
103 Size videoSize = Size(capture.get(CV_CAP_PROP_FRAME_WIDTH), capture.get(CV_CAP_PROP_FRAME_HEIGHT));
39fa1c998b29 removed the abstract class to represent folders of images or video files since the capability is now built in OpenCV
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 654
diff changeset
104 unsigned int nFrames = capture.get(CV_CAP_PROP_FRAME_COUNT);
679
576d9ea4b41a small update to deal with videos where the number of frames cannot be read
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 655
diff changeset
105 if (nFrames <= 0) {
576d9ea4b41a small update to deal with videos where the number of frames cannot be read
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 655
diff changeset
106 cout << "Guessing that the number of frames could not be read: " << nFrames << endl;
576d9ea4b41a small update to deal with videos where the number of frames cannot be read
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 655
diff changeset
107 nFrames = numeric_limits<int>::max();
576d9ea4b41a small update to deal with videos where the number of frames cannot be read
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 655
diff changeset
108 cout << "Setting arbitrarily high number for testing: " << nFrames << endl;
576d9ea4b41a small update to deal with videos where the number of frames cannot be read
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 655
diff changeset
109 }
576d9ea4b41a small update to deal with videos where the number of frames cannot be read
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 655
diff changeset
110
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
111 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
112 ": 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
113 ", 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
114 ", nframes=" << nFrames << endl;
507
081a9da6f85b first version with undistort implemented in the feature tracking process
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 506 496
diff changeset
115
509
935430b1d408 corrected mask bug in feature tracking, updated display-trajectories to display on undistorted image
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 507
diff changeset
116 Mat map1, map2;
507
081a9da6f85b first version with undistort implemented in the feature tracking process
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 506 496
diff changeset
117 if (params.undistort) {
535
5ad2f51ae42f cleaning up initialization of intrinsic matrix
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 534
diff changeset
118 Mat intrinsicCameraMatrix = ::loadMat(params.intrinsicCameraFilename, " ");
5ad2f51ae42f cleaning up initialization of intrinsic matrix
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 534
diff changeset
119 Mat newIntrinsicCameraMatrix = intrinsicCameraMatrix.clone();
509
935430b1d408 corrected mask bug in feature tracking, updated display-trajectories to display on undistorted image
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 507
diff changeset
120 videoSize = Size(static_cast<int>(round(videoSize.width*params.undistortedImageMultiplication)), static_cast<int>(round(videoSize.height*params.undistortedImageMultiplication)));
935430b1d408 corrected mask bug in feature tracking, updated display-trajectories to display on undistorted image
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 507
diff changeset
121 newIntrinsicCameraMatrix.at<float>(0,2) = videoSize.width/2.;
935430b1d408 corrected mask bug in feature tracking, updated display-trajectories to display on undistorted image
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 507
diff changeset
122 newIntrinsicCameraMatrix.at<float>(1,2) = videoSize.height/2.;
803
f7cf43b5ad3b work in progress on stabilization
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 802
diff changeset
123 initUndistortRectifyMap(intrinsicCameraMatrix, params.distortionCoefficients, Mat::eye(3, 3, CV_32FC1), newIntrinsicCameraMatrix, videoSize, CV_32FC1, map1, map2);
509
935430b1d408 corrected mask bug in feature tracking, updated display-trajectories to display on undistorted image
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 507
diff changeset
124
935430b1d408 corrected mask bug in feature tracking, updated display-trajectories to display on undistorted image
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 507
diff changeset
125 cout << "Undistorted width=" << videoSize.width <<
935430b1d408 corrected mask bug in feature tracking, updated display-trajectories to display on undistorted image
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 507
diff changeset
126 ", height=" << videoSize.height << endl;
507
081a9da6f85b first version with undistort implemented in the feature tracking process
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 506 496
diff changeset
127 }
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
128
146
7150427c665e added loading of mask
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 145
diff changeset
129 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
130 if (mask.empty()) {
68861b52a319 added message if mask not found/loaded
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 278
diff changeset
131 cout << "Mask filename " << params.maskFilename << " could not be opened." << endl;
509
935430b1d408 corrected mask bug in feature tracking, updated display-trajectories to display on undistorted image
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 507
diff changeset
132 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
133 }
804
17e54690af8a work in progress, not fully functional yet
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 803
diff changeset
134 Mat featureMask = mask.clone();
146
7150427c665e added loading of mask
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 145
diff changeset
135
654
045d05cef9d0 updating to c++11 capabilities
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 542
diff changeset
136 std::shared_ptr<TrajectoryDBAccess<Point2f> > trajectoryDB = std::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
137 //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
138 trajectoryDB->connect(params.databaseFilename.c_str());
142
a3532db00c28 added code to write velocities
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 141
diff changeset
139 trajectoryDB->createTable("positions");
a3532db00c28 added code to write velocities
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 141
diff changeset
140 trajectoryDB->createTable("velocities");
a3532db00c28 added code to write velocities
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 141
diff changeset
141 trajectoryDB->beginTransaction();
133
63dd4355b6d1 saving of feature positions in sqlite database
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 132
diff changeset
142
230
bc4ea09b1743 compatibility modifications for visual studio compilation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 207
diff changeset
143 std::vector<KeyPoint> prevKpts, currKpts;
804
17e54690af8a work in progress, not fully functional yet
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 803
diff changeset
144 std::vector<Point2f> prevPts, currPts, newPts, stabilizationRefPts, stabilizationCurrPts;
17e54690af8a work in progress, not fully functional yet
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 803
diff changeset
145 std::vector<uchar> status, stabilizationPtsStatus;
17e54690af8a work in progress, not fully functional yet
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 803
diff changeset
146 std::vector<float> errorPts, stabilizationErrorPts;
127
d19d6e63dd77 simple feature tracking and drawing working
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 125
diff changeset
147 Mat prevDesc, currDesc;
128
536510f60854 new features generated as needed
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 127
diff changeset
148
230
bc4ea09b1743 compatibility modifications for visual studio compilation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 207
diff changeset
149 std::vector<FeatureTrajectoryPtr> lostFeatures;
bc4ea09b1743 compatibility modifications for visual studio compilation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 207
diff changeset
150 std::vector<FeaturePointMatch> featurePointMatches;
163
cde87a07eb58 added graph structures
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 154
diff changeset
151
133
63dd4355b6d1 saving of feature positions in sqlite database
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 132
diff changeset
152 int key = '?';
63dd4355b6d1 saving of feature positions in sqlite database
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 132
diff changeset
153 unsigned int savedFeatureId=0;
803
f7cf43b5ad3b work in progress on stabilization
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 802
diff changeset
154 Mat frame = Mat::zeros(1, 1, CV_8UC1), currentFrameBW, previousFrameBW, undistortedFrame, homographyFrameBW, homographyFrame;
802
d3e8dd9f3ca4 current dev for drone stabilization
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 800
diff changeset
155
803
f7cf43b5ad3b work in progress on stabilization
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 802
diff changeset
156 if (params.stabilize) {
f7cf43b5ad3b work in progress on stabilization
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 802
diff changeset
157 homographyFrame = imread(params.frameHomographyFilename);
f7cf43b5ad3b work in progress on stabilization
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 802
diff changeset
158 if (homographyFrame.empty())
f7cf43b5ad3b work in progress on stabilization
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 802
diff changeset
159 cout << "Homography frame filename " << params.frameHomographyFilename << " could not be opened." << endl;
f7cf43b5ad3b work in progress on stabilization
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 802
diff changeset
160 else {
f7cf43b5ad3b work in progress on stabilization
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 802
diff changeset
161 if (params.undistort) {
f7cf43b5ad3b work in progress on stabilization
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 802
diff changeset
162 remap(homographyFrame, undistortedFrame, map1, map2, interpolationMethod, BORDER_CONSTANT, 0.);
f7cf43b5ad3b work in progress on stabilization
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 802
diff changeset
163 homographyFrame = undistortedFrame;
f7cf43b5ad3b work in progress on stabilization
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 802
diff changeset
164 }
f7cf43b5ad3b work in progress on stabilization
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 802
diff changeset
165
f7cf43b5ad3b work in progress on stabilization
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 802
diff changeset
166 cvtColor(homographyFrame, homographyFrameBW, CV_RGB2GRAY);
804
17e54690af8a work in progress, not fully functional yet
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 803
diff changeset
167 goodFeaturesToTrack(homographyFrameBW, stabilizationRefPts, params.maxNFeatures, MAX(0.01, params.featureQuality), params.minFeatureDistanceKLT, mask, params.blockSize, params.useHarrisDetector, params.k); // take higher quality features?
803
f7cf43b5ad3b work in progress on stabilization
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 802
diff changeset
168 }
802
d3e8dd9f3ca4 current dev for drone stabilization
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 800
diff changeset
169 }
d3e8dd9f3ca4 current dev for drone stabilization
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 800
diff changeset
170
278
f21ef87f98f1 resolved issue 2 and problem with negative nframes parameter
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 234
diff changeset
171 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
172 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
173 lastFrameNum = MIN(params.frame1+static_cast<unsigned int>(params.nFrames), nFrames);
495
82c06ad62254 added parameter description with ranges
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 481
diff changeset
174
804
17e54690af8a work in progress, not fully functional yet
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 803
diff changeset
175 // Main Loop
655
39fa1c998b29 removed the abstract class to represent folders of images or video files since the capability is now built in OpenCV
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 654
diff changeset
176 capture.set(CV_CAP_PROP_POS_FRAMES, params.frame1);
227
b7612c6d5702 cleaned the code
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 225
diff changeset
177 for (unsigned int frameNum = params.frame1; (frameNum < lastFrameNum) && !::interruptionKey(key); frameNum++) {
655
39fa1c998b29 removed the abstract class to represent folders of images or video files since the capability is now built in OpenCV
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 654
diff changeset
178 capture >> frame;
39fa1c998b29 removed the abstract class to represent folders of images or video files since the capability is now built in OpenCV
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 654
diff changeset
179 if (frame.empty()) {
39fa1c998b29 removed the abstract class to represent folders of images or video files since the capability is now built in OpenCV
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 654
diff changeset
180 cout << "Empty frame " << frameNum << ", breaking (" << frame.empty() << " [" << frame.size().width << "x" << frame.size().height << "])" << endl;
39fa1c998b29 removed the abstract class to represent folders of images or video files since the capability is now built in OpenCV
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 654
diff changeset
181 break;
39fa1c998b29 removed the abstract class to represent folders of images or video files since the capability is now built in OpenCV
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 654
diff changeset
182 } else if (frameNum%50 ==0)
39fa1c998b29 removed the abstract class to represent folders of images or video files since the capability is now built in OpenCV
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 654
diff changeset
183 cout << "frame " << frameNum << endl;
532
018653d1db3c corrected bug with empty frames (the program will stop cleanly and store features
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 509
diff changeset
184
802
d3e8dd9f3ca4 current dev for drone stabilization
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 800
diff changeset
185 cvtColor(frame, currentFrameBW, CV_RGB2GRAY);
d3e8dd9f3ca4 current dev for drone stabilization
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 800
diff changeset
186
655
39fa1c998b29 removed the abstract class to represent folders of images or video files since the capability is now built in OpenCV
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 654
diff changeset
187 if (params.undistort) {
802
d3e8dd9f3ca4 current dev for drone stabilization
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 800
diff changeset
188 remap(currentFrameBW, undistortedFrame, map1, map2, interpolationMethod, BORDER_CONSTANT, 0.);
d3e8dd9f3ca4 current dev for drone stabilization
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 800
diff changeset
189 currentFrameBW = undistortedFrame;
655
39fa1c998b29 removed the abstract class to represent folders of images or video files since the capability is now built in OpenCV
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 654
diff changeset
190 if (frame.size() != videoSize) {
39fa1c998b29 removed the abstract class to represent folders of images or video files since the capability is now built in OpenCV
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 654
diff changeset
191 cout << "Different frame size " << frameNum << ", breaking ([" << frame.size().width << "x" << frame.size().height << "])" << endl;
534
d0419b1267dd fixing size issue when testing frames in main loop
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 533
diff changeset
192 break;
507
081a9da6f85b first version with undistort implemented in the feature tracking process
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 506 496
diff changeset
193 }
655
39fa1c998b29 removed the abstract class to represent folders of images or video files since the capability is now built in OpenCV
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 654
diff changeset
194 }
800
2cade72d75ad modified so there is no tracking outside of the mask (does not continue if features can still be matched) as requested
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 716
diff changeset
195
655
39fa1c998b29 removed the abstract class to represent folders of images or video files since the capability is now built in OpenCV
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 654
diff changeset
196 if (!prevPts.empty()) {
39fa1c998b29 removed the abstract class to represent folders of images or video files since the capability is now built in OpenCV
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 654
diff changeset
197 currPts.clear();
804
17e54690af8a work in progress, not fully functional yet
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 803
diff changeset
198 calcOpticalFlowPyrLK(previousFrameBW, currentFrameBW, prevPts, currPts, status, errorPts, window, params.pyramidLevel, TermCriteria(static_cast<int>(TermCriteria::COUNT)+static_cast<int>(TermCriteria::EPS) /* = 3 */, params.maxNumberTrackingIterations, params.minTrackingError), /* int flags = */ 0, params.minFeatureEigThreshold);
655
39fa1c998b29 removed the abstract class to represent folders of images or video files since the capability is now built in OpenCV
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 654
diff changeset
199 /// \todo try calcOpticalFlowFarneback
128
536510f60854 new features generated as needed
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 127
diff changeset
200
803
f7cf43b5ad3b work in progress on stabilization
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 802
diff changeset
201 if (params.stabilize) {
804
17e54690af8a work in progress, not fully functional yet
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 803
diff changeset
202 calcOpticalFlowPyrLK(homographyFrameBW, currentFrameBW, stabilizationRefPts, stabilizationCurrPts, stabilizationPtsStatus, stabilizationErrorPts, window, params.pyramidLevel, TermCriteria(static_cast<int>(TermCriteria::COUNT)+static_cast<int>(TermCriteria::EPS) /* = 3 */, params.maxNumberTrackingIterations, params.minTrackingError), /* int flags = */ 0, params.minFeatureEigThreshold);
802
d3e8dd9f3ca4 current dev for drone stabilization
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 800
diff changeset
203
804
17e54690af8a work in progress, not fully functional yet
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 803
diff changeset
204 std::vector<Point2f> stabilizationRefPts2, stabilizationCurrPts2;
17e54690af8a work in progress, not fully functional yet
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 803
diff changeset
205 for (unsigned int i=0; i<stabilizationRefPts.size(); i++)
17e54690af8a work in progress, not fully functional yet
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 803
diff changeset
206 if (stabilizationPtsStatus[i]) {
17e54690af8a work in progress, not fully functional yet
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 803
diff changeset
207 stabilizationRefPts2.push_back(stabilizationRefPts[i]);
17e54690af8a work in progress, not fully functional yet
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 803
diff changeset
208 stabilizationCurrPts2.push_back(stabilizationCurrPts[i]);
803
f7cf43b5ad3b work in progress on stabilization
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 802
diff changeset
209 }
804
17e54690af8a work in progress, not fully functional yet
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 803
diff changeset
210 stabilizationHomography = findHomography(stabilizationCurrPts2, stabilizationRefPts2, CV_RANSAC, params.stabilizeRansacReprojThreshold);
17e54690af8a work in progress, not fully functional yet
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 803
diff changeset
211 //cout << stabilizationHomography << endl;
17e54690af8a work in progress, not fully functional yet
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 803
diff changeset
212 //cout << stabilizationHomography.type() << " " << refHomography.type() << endl;
17e54690af8a work in progress, not fully functional yet
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 803
diff changeset
213 //for (unsigned int i=0; i<MIN(stabilizationRefPts.size(), 10); i++) {
17e54690af8a work in progress, not fully functional yet
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 803
diff changeset
214 //cout << stabilizationCurrPts2[i] << " " << stabilizationRefPts2[i] << ": projected " << ::project<double>(stabilizationCurrPts2[i], stabilizationHomography) << endl;
17e54690af8a work in progress, not fully functional yet
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 803
diff changeset
215 //cout << stabilizationHomography.at<double>(0,0)*stabilizationCurrPts2[i].x+stabilizationHomography.at<double>(0,1)*stabilizationCurrPts2[i].y+stabilizationHomography.at<double>(0,2) << " " << stabilizationHomography.at<double>(1,0)*stabilizationCurrPts2[i].x+stabilizationHomography.at<double>(1,1)*stabilizationCurrPts2[i].y+stabilizationHomography.at<double>(1,2) << " " << stabilizationHomography.at<double>(2,0)*stabilizationCurrPts2[i].x+stabilizationHomography.at<double>(2,1)*stabilizationCurrPts2[i].y+stabilizationHomography.at<double>(2,2) << endl;
17e54690af8a work in progress, not fully functional yet
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 803
diff changeset
216 //}
17e54690af8a work in progress, not fully functional yet
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 803
diff changeset
217 if (stabilizationHomography.empty()) {
803
f7cf43b5ad3b work in progress on stabilization
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 802
diff changeset
218 homography = refHomography;
804
17e54690af8a work in progress, not fully functional yet
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 803
diff changeset
219 featureMask = mask.clone();
17e54690af8a work in progress, not fully functional yet
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 803
diff changeset
220 } else {
17e54690af8a work in progress, not fully functional yet
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 803
diff changeset
221 if (refHomography.empty())
17e54690af8a work in progress, not fully functional yet
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 803
diff changeset
222 homography = stabilizationHomography;
17e54690af8a work in progress, not fully functional yet
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 803
diff changeset
223 else
17e54690af8a work in progress, not fully functional yet
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 803
diff changeset
224 homography = refHomography*stabilizationHomography;
17e54690af8a work in progress, not fully functional yet
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 803
diff changeset
225 //cout << refHomography << " * " << stabilizationHomography << " = " << homography << endl;
17e54690af8a work in progress, not fully functional yet
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 803
diff changeset
226 warpPerspective(mask, featureMask, stabilizationHomography, videoSize, INTER_LINEAR+WARP_INVERSE_MAP, BORDER_CONSTANT, 0);
17e54690af8a work in progress, not fully functional yet
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 803
diff changeset
227 }
17e54690af8a work in progress, not fully functional yet
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 803
diff changeset
228 } else
17e54690af8a work in progress, not fully functional yet
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 803
diff changeset
229 featureMask = mask.clone();
17e54690af8a work in progress, not fully functional yet
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 803
diff changeset
230
803
f7cf43b5ad3b work in progress on stabilization
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 802
diff changeset
231
655
39fa1c998b29 removed the abstract class to represent folders of images or video files since the capability is now built in OpenCV
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 654
diff changeset
232 std::vector<Point2f> trackedPts;
39fa1c998b29 removed the abstract class to represent folders of images or video files since the capability is now built in OpenCV
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 654
diff changeset
233 std::vector<FeaturePointMatch>::iterator iter = featurePointMatches.begin();
39fa1c998b29 removed the abstract class to represent folders of images or video files since the capability is now built in OpenCV
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 654
diff changeset
234 while (iter != featurePointMatches.end()) {
39fa1c998b29 removed the abstract class to represent folders of images or video files since the capability is now built in OpenCV
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 654
diff changeset
235 bool deleteFeature = false;
804
17e54690af8a work in progress, not fully functional yet
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 803
diff changeset
236
17e54690af8a work in progress, not fully functional yet
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 803
diff changeset
237 if (status[iter->pointNum]) {
17e54690af8a work in progress, not fully functional yet
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 803
diff changeset
238 Point2f homographyFramePt = ::project<double>(currPts[iter->pointNum], stabilizationHomography); // project to space of homography frame (if not stabilization, stabilizationHomography should be empty)
17e54690af8a work in progress, not fully functional yet
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 803
diff changeset
239 cout << currPts[iter->pointNum] << ", " << homographyFramePt << endl;
17e54690af8a work in progress, not fully functional yet
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 803
diff changeset
240 if (::inImage(homographyFramePt, videoSize) && (mask.at<uchar>(static_cast<int>(round(homographyFramePt.y)), static_cast<int>(round(homographyFramePt.x))) != 0)) { // check point is in mask
17e54690af8a work in progress, not fully functional yet
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 803
diff changeset
241 iter->feature->addPoint(frameNum, ::project<double>(homographyFramePt, refHomography));
17e54690af8a work in progress, not fully functional yet
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 803
diff changeset
242 //cout << *(iter->feature) << endl;
17e54690af8a work in progress, not fully functional yet
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 803
diff changeset
243 deleteFeature = iter->feature->isDisplacementSmall(params.nDisplacements, minTotalFeatureDisplacement)
17e54690af8a work in progress, not fully functional yet
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 803
diff changeset
244 || !iter->feature->isMotionSmooth(params.accelerationBound, params.deviationBound);
17e54690af8a work in progress, not fully functional yet
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 803
diff changeset
245 if (deleteFeature)
17e54690af8a work in progress, not fully functional yet
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 803
diff changeset
246 iter->feature->shorten();
17e54690af8a work in progress, not fully functional yet
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 803
diff changeset
247 } else
17e54690af8a work in progress, not fully functional yet
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 803
diff changeset
248 deleteFeature = true;
655
39fa1c998b29 removed the abstract class to represent folders of images or video files since the capability is now built in OpenCV
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 654
diff changeset
249 } else
39fa1c998b29 removed the abstract class to represent folders of images or video files since the capability is now built in OpenCV
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 654
diff changeset
250 deleteFeature = true;
39fa1c998b29 removed the abstract class to represent folders of images or video files since the capability is now built in OpenCV
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 654
diff changeset
251
39fa1c998b29 removed the abstract class to represent folders of images or video files since the capability is now built in OpenCV
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 654
diff changeset
252 if (deleteFeature) {
39fa1c998b29 removed the abstract class to represent folders of images or video files since the capability is now built in OpenCV
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 654
diff changeset
253 if (iter->feature->length() >= params.minFeatureTime) {
39fa1c998b29 removed the abstract class to represent folders of images or video files since the capability is now built in OpenCV
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 654
diff changeset
254 iter->feature->setId(savedFeatureId);
39fa1c998b29 removed the abstract class to represent folders of images or video files since the capability is now built in OpenCV
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 654
diff changeset
255 savedFeatureId++;
39fa1c998b29 removed the abstract class to represent folders of images or video files since the capability is now built in OpenCV
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 654
diff changeset
256 iter->feature->movingAverage(params.nFramesSmoothing);
39fa1c998b29 removed the abstract class to represent folders of images or video files since the capability is now built in OpenCV
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 654
diff changeset
257 lostFeatures.push_back(iter->feature);
138
c1b260b48d2a corrected initialization bugs and feature shortening before saving
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 137
diff changeset
258 }
655
39fa1c998b29 removed the abstract class to represent folders of images or video files since the capability is now built in OpenCV
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 654
diff changeset
259 iter = featurePointMatches.erase(iter);
39fa1c998b29 removed the abstract class to represent folders of images or video files since the capability is now built in OpenCV
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 654
diff changeset
260 } else {
39fa1c998b29 removed the abstract class to represent folders of images or video files since the capability is now built in OpenCV
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 654
diff changeset
261 trackedPts.push_back(currPts[iter->pointNum]);
39fa1c998b29 removed the abstract class to represent folders of images or video files since the capability is now built in OpenCV
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 654
diff changeset
262 iter->pointNum = trackedPts.size()-1;
39fa1c998b29 removed the abstract class to represent folders of images or video files since the capability is now built in OpenCV
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 654
diff changeset
263 iter++;
139
47329bd16cc0 cleaned code, added condition on smooth displacement
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 138
diff changeset
264 }
125
28907fde9855 work on klt tracker (problem on computer at poly)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 124
diff changeset
265 }
655
39fa1c998b29 removed the abstract class to represent folders of images or video files since the capability is now built in OpenCV
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 654
diff changeset
266 currPts = trackedPts;
39fa1c998b29 removed the abstract class to represent folders of images or video files since the capability is now built in OpenCV
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 654
diff changeset
267 assert(currPts.size() == featurePointMatches.size());
39fa1c998b29 removed the abstract class to represent folders of images or video files since the capability is now built in OpenCV
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 654
diff changeset
268 saveFeatures(lostFeatures, *trajectoryDB, "positions", "velocities");
39fa1c998b29 removed the abstract class to represent folders of images or video files since the capability is now built in OpenCV
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 654
diff changeset
269
39fa1c998b29 removed the abstract class to represent folders of images or video files since the capability is now built in OpenCV
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 654
diff changeset
270 if (params.display) {
804
17e54690af8a work in progress, not fully functional yet
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 803
diff changeset
271 cout << featurePointMatches.size() << " matches" << endl;
17e54690af8a work in progress, not fully functional yet
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 803
diff changeset
272 Mat invHomography;
17e54690af8a work in progress, not fully functional yet
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 803
diff changeset
273 if (!homography.empty())
17e54690af8a work in progress, not fully functional yet
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 803
diff changeset
274 invHomography = homography.inv();
655
39fa1c998b29 removed the abstract class to represent folders of images or video files since the capability is now built in OpenCV
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 654
diff changeset
275 BOOST_FOREACH(FeaturePointMatch fp, featurePointMatches)
804
17e54690af8a work in progress, not fully functional yet
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 803
diff changeset
276 fp.feature->draw(frame, invHomography, Colors::red());
655
39fa1c998b29 removed the abstract class to represent folders of images or video files since the capability is now built in OpenCV
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 654
diff changeset
277 }
39fa1c998b29 removed the abstract class to represent folders of images or video files since the capability is now built in OpenCV
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 654
diff changeset
278 }
800
2cade72d75ad modified so there is no tracking outside of the mask (does not continue if features can still be matched) as requested
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 716
diff changeset
279
655
39fa1c998b29 removed the abstract class to represent folders of images or video files since the capability is now built in OpenCV
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 654
diff changeset
280 // adding new features, using mask around existing feature positions
39fa1c998b29 removed the abstract class to represent folders of images or video files since the capability is now built in OpenCV
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 654
diff changeset
281 for (unsigned int n=0;n<currPts.size(); n++)
39fa1c998b29 removed the abstract class to represent folders of images or video files since the capability is now built in OpenCV
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 654
diff changeset
282 for (int j=MAX(0, currPts[n].x-params.minFeatureDistanceKLT); j<MIN(videoSize.width, currPts[n].x+params.minFeatureDistanceKLT+1); j++)
39fa1c998b29 removed the abstract class to represent folders of images or video files since the capability is now built in OpenCV
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 654
diff changeset
283 for (int i=MAX(0, currPts[n].y-params.minFeatureDistanceKLT); i<MIN(videoSize.height, currPts[n].y+params.minFeatureDistanceKLT+1); i++)
39fa1c998b29 removed the abstract class to represent folders of images or video files since the capability is now built in OpenCV
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 654
diff changeset
284 featureMask.at<uchar>(i,j)=0;
39fa1c998b29 removed the abstract class to represent folders of images or video files since the capability is now built in OpenCV
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 654
diff changeset
285 goodFeaturesToTrack(currentFrameBW, newPts, params.maxNFeatures, params.featureQuality, params.minFeatureDistanceKLT, featureMask, params.blockSize, params.useHarrisDetector, params.k);
800
2cade72d75ad modified so there is no tracking outside of the mask (does not continue if features can still be matched) as requested
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 716
diff changeset
286 BOOST_FOREACH(Point2f p, newPts) {
804
17e54690af8a work in progress, not fully functional yet
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 803
diff changeset
287 FeatureTrajectoryPtr f = FeatureTrajectoryPtr(new FeatureTrajectory(frameNum, ::project<double>(::project<double>(p, stabilizationHomography), refHomography)));
655
39fa1c998b29 removed the abstract class to represent folders of images or video files since the capability is now built in OpenCV
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 654
diff changeset
288 featurePointMatches.push_back(FeaturePointMatch(f, currPts.size()));
39fa1c998b29 removed the abstract class to represent folders of images or video files since the capability is now built in OpenCV
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 654
diff changeset
289 currPts.push_back(p);
39fa1c998b29 removed the abstract class to represent folders of images or video files since the capability is now built in OpenCV
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 654
diff changeset
290 }
128
536510f60854 new features generated as needed
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 127
diff changeset
291
655
39fa1c998b29 removed the abstract class to represent folders of images or video files since the capability is now built in OpenCV
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 654
diff changeset
292 if (params.display) {
804
17e54690af8a work in progress, not fully functional yet
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 803
diff changeset
293 cout << currPts.size() << " current points" << endl;
17e54690af8a work in progress, not fully functional yet
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 803
diff changeset
294 Mat maskedFrame;
17e54690af8a work in progress, not fully functional yet
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 803
diff changeset
295 cvtColor(featureMask*256, maskedFrame, CV_GRAY2RGB);
17e54690af8a work in progress, not fully functional yet
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 803
diff changeset
296 addWeighted(frame, 0.5, maskedFrame, 0.5, 0.0, maskedFrame);
17e54690af8a work in progress, not fully functional yet
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 803
diff changeset
297 imshow("masked frame", maskedFrame);
17e54690af8a work in progress, not fully functional yet
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 803
diff changeset
298 //imshow("mask", featureMask*256);
655
39fa1c998b29 removed the abstract class to represent folders of images or video files since the capability is now built in OpenCV
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 654
diff changeset
299 imshow("frame", frame);
803
f7cf43b5ad3b work in progress on stabilization
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 802
diff changeset
300 if (params.stabilize && !stabilizationHomography.empty()) {
f7cf43b5ad3b work in progress on stabilization
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 802
diff changeset
301 Mat warped, vis;
f7cf43b5ad3b work in progress on stabilization
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 802
diff changeset
302 warpPerspective(frame, warped, stabilizationHomography, videoSize);
f7cf43b5ad3b work in progress on stabilization
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 802
diff changeset
303 addWeighted(homographyFrame, 0.5, warped, 0.5, 0.0, vis);
f7cf43b5ad3b work in progress on stabilization
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 802
diff changeset
304 imshow("warped frame", vis);
f7cf43b5ad3b work in progress on stabilization
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 802
diff changeset
305 }
804
17e54690af8a work in progress, not fully functional yet
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 803
diff changeset
306 key = waitKey(0);
655
39fa1c998b29 removed the abstract class to represent folders of images or video files since the capability is now built in OpenCV
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 654
diff changeset
307 }
39fa1c998b29 removed the abstract class to represent folders of images or video files since the capability is now built in OpenCV
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 654
diff changeset
308 previousFrameBW = currentFrameBW.clone();
39fa1c998b29 removed the abstract class to represent folders of images or video files since the capability is now built in OpenCV
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 654
diff changeset
309 prevPts = currPts;
480
f43bc0b0ba74 cleaning code
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 418
diff changeset
310 }
f43bc0b0ba74 cleaning code
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 418
diff changeset
311
f43bc0b0ba74 cleaning code
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 418
diff changeset
312 // save the remaining currently tracked features
f43bc0b0ba74 cleaning code
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 418
diff changeset
313 std::vector<FeaturePointMatch>::iterator iter = featurePointMatches.begin();
f43bc0b0ba74 cleaning code
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 418
diff changeset
314 while (iter != featurePointMatches.end()) {
f43bc0b0ba74 cleaning code
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 418
diff changeset
315 if (iter->feature->length() >= params.minFeatureTime) {
f43bc0b0ba74 cleaning code
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 418
diff changeset
316 iter->feature->setId(savedFeatureId);
f43bc0b0ba74 cleaning code
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 418
diff changeset
317 savedFeatureId++;
481
b6ad86ee7033 implemented smoothing (requires latest trajectory management library version)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 480
diff changeset
318 iter->feature->movingAverage(params.nFramesSmoothing);
b6ad86ee7033 implemented smoothing (requires latest trajectory management library version)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 480
diff changeset
319 iter->feature->write(*trajectoryDB, "positions", "velocities");
480
f43bc0b0ba74 cleaning code
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 418
diff changeset
320 }
f43bc0b0ba74 cleaning code
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 418
diff changeset
321 iter++;
f43bc0b0ba74 cleaning code
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 418
diff changeset
322 }
121
c4d4b5b93add copied the video_homography opencv sample
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 119
diff changeset
323
142
a3532db00c28 added code to write velocities
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 141
diff changeset
324 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
325 trajectoryDB->disconnect();
164
76610dcf3b8d added test code to read trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 163
diff changeset
326 }
76610dcf3b8d added test code to read trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 163
diff changeset
327
169
5f705809d37a created groupFeatures function
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 168
diff changeset
328 void groupFeatures(const KLTFeatureTrackingParameters& params) {
654
045d05cef9d0 updating to c++11 capabilities
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 542
diff changeset
329 std::shared_ptr<TrajectoryDBAccessList<Point2f> > trajectoryDB = std::shared_ptr<TrajectoryDBAccessList<Point2f> >(new TrajectoryDBAccessList<Point2f>());
169
5f705809d37a created groupFeatures function
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 168
diff changeset
330 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
331 trajectoryDB->createObjectTable("objects", "objects_features");
b0b964ba9489 added early saving of objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 194
diff changeset
332 unsigned int savedObjectId=0;
b0b964ba9489 added early saving of objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 194
diff changeset
333
225
d4d3b1e8a9f1 added code to process only needed frames based on saved features
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 222
diff changeset
334 trajectoryDB->createInstants("table");
710
70a3cdf0dbb3 unsucessful acceleration idea
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 679
diff changeset
335 //trajectoryDB->createIndex("positions","trajectory_id"); // does not seem to make loading features faster
70a3cdf0dbb3 unsucessful acceleration idea
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 679
diff changeset
336 //trajectoryDB->createIndex("velocities","trajectory_id");
221
bc93e87a2108 cleaned and corrected connected components and feature groups
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 219
diff changeset
337
225
d4d3b1e8a9f1 added code to process only needed frames based on saved features
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 222
diff changeset
338 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
339 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
340 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
341 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
342 exit(0);
d4d3b1e8a9f1 added code to process only needed frames based on saved features
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 222
diff changeset
343 }
222
426321b46e44 temporary trajectory instants table
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 221
diff changeset
344 cout << "Longest trajectory: " << maxTrajectoryLength << endl;
219
841a1714f702 added comments for future development
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 207
diff changeset
345
191
0e60a306d324 added basic code to identify features and save them (crash)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 189
diff changeset
346 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
347
169
5f705809d37a created groupFeatures function
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 168
diff changeset
348 // main loop
227
b7612c6d5702 cleaned the code
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 225
diff changeset
349 unsigned int frameNum;
b7612c6d5702 cleaned the code
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 225
diff changeset
350 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
351 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
352 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
353 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
354 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
355 for (frameNum = firstFrameNum; frameNum<lastFrameNum; frameNum ++) {
174
ec9734015d53 tested loading trajectory by id numbers
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 172
diff changeset
356 vector<int> trajectoryIds;
231
249d65ff6c35 merged modifications for windows
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 230 228
diff changeset
357 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
358 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
359 cout << "frame " << frameNum << endl;
222
426321b46e44 temporary trajectory instants table
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 221
diff changeset
360 #if DEBUG
174
ec9734015d53 tested loading trajectory by id numbers
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 172
diff changeset
361 cout << trajectoryIds.size() << " trajectories " << endl;
222
426321b46e44 temporary trajectory instants table
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 221
diff changeset
362 #endif
174
ec9734015d53 tested loading trajectory by id numbers
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 172
diff changeset
363 BOOST_FOREACH(int trajectoryId, trajectoryIds) {
177
ae2286b1a3fd added loading FeatureTrajectory from database, printing
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 176
diff changeset
364 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
365 featureGraph.addFeature(ft);
174
ec9734015d53 tested loading trajectory by id numbers
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 172
diff changeset
366 }
172
e508bb0cbb64 modified comments
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 169
diff changeset
367
222
426321b46e44 temporary trajectory instants table
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 221
diff changeset
368 // 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
369 int lastInstant = frameNum+params.minFeatureTime-maxTrajectoryLength;
231
249d65ff6c35 merged modifications for windows
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 230 228
diff changeset
370 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
371 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
372 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
373 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
374 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
375 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
376 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
377 featureNumbers.push_back(featureGroups[i][j]->getId());
716
85af65b6d531 corrected major bug slowing feature grouping
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 710
diff changeset
378 trajectoryDB->writeObject(savedObjectId, featureNumbers, 0 /* unknown type */, 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
379 savedObjectId++;
d4d3b1e8a9f1 added code to process only needed frames based on saved features
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 222
diff changeset
380 }
188
1435965d8181 work on connected components
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 186
diff changeset
381 }
222
426321b46e44 temporary trajectory instants table
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 221
diff changeset
382
225
d4d3b1e8a9f1 added code to process only needed frames based on saved features
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 222
diff changeset
383 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
384 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
385 }
d4d3b1e8a9f1 added code to process only needed frames based on saved features
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 222
diff changeset
386
d4d3b1e8a9f1 added code to process only needed frames based on saved features
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 222
diff changeset
387 // 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
388 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
389 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
390 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
391 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
392 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
393 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
394 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
395 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
396 savedObjectId++;
180
3a4eef37384f method to add features and vertices to graph
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 179
diff changeset
397 }
169
5f705809d37a created groupFeatures function
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 168
diff changeset
398
5f705809d37a created groupFeatures function
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 168
diff changeset
399 trajectoryDB->endTransaction();
5f705809d37a created groupFeatures function
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 168
diff changeset
400 trajectoryDB->disconnect();
654
045d05cef9d0 updating to c++11 capabilities
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 542
diff changeset
401 }
045d05cef9d0 updating to c++11 capabilities
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 542
diff changeset
402
045d05cef9d0 updating to c++11 capabilities
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 542
diff changeset
403 void loadingTimes(const KLTFeatureTrackingParameters& params) {
045d05cef9d0 updating to c++11 capabilities
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 542
diff changeset
404 std::shared_ptr<TrajectoryDBAccessList<Point2f> > trajectoryDB = std::shared_ptr<TrajectoryDBAccessList<Point2f> >(new TrajectoryDBAccessList<Point2f>());
045d05cef9d0 updating to c++11 capabilities
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 542
diff changeset
405 bool success = trajectoryDB->connect(params.databaseFilename.c_str());
045d05cef9d0 updating to c++11 capabilities
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 542
diff changeset
406
045d05cef9d0 updating to c++11 capabilities
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 542
diff changeset
407 vector<std::shared_ptr<Trajectory<Point2f> > > trajectories;
045d05cef9d0 updating to c++11 capabilities
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 542
diff changeset
408 //cout << trajectories.size() << endl;
045d05cef9d0 updating to c++11 capabilities
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 542
diff changeset
409 std::clock_t c_start = std::clock();
045d05cef9d0 updating to c++11 capabilities
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 542
diff changeset
410 success = trajectoryDB->read(trajectories, "positions");
045d05cef9d0 updating to c++11 capabilities
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 542
diff changeset
411 std::clock_t c_end = std::clock();
045d05cef9d0 updating to c++11 capabilities
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 542
diff changeset
412 if (!success)
045d05cef9d0 updating to c++11 capabilities
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 542
diff changeset
413 cout << "Issue with db reading" << endl;
045d05cef9d0 updating to c++11 capabilities
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 542
diff changeset
414 cout << "Loaded " << trajectories.size() << " trajectories in " << 1000.0 * (c_end-c_start) / CLOCKS_PER_SEC << " CPU seconds" << endl;
045d05cef9d0 updating to c++11 capabilities
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 542
diff changeset
415
045d05cef9d0 updating to c++11 capabilities
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 542
diff changeset
416 std::shared_ptr<Trajectory<cv::Point2f> > trajectory;
045d05cef9d0 updating to c++11 capabilities
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 542
diff changeset
417 c_start = std::clock();
045d05cef9d0 updating to c++11 capabilities
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 542
diff changeset
418 for (unsigned int i = 0; i<trajectories.size(); ++i) {
045d05cef9d0 updating to c++11 capabilities
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 542
diff changeset
419 success = trajectoryDB->read(trajectory, i, "positions");
045d05cef9d0 updating to c++11 capabilities
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 542
diff changeset
420 }
045d05cef9d0 updating to c++11 capabilities
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 542
diff changeset
421 c_end = std::clock();
045d05cef9d0 updating to c++11 capabilities
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 542
diff changeset
422 cout << "Loaded " << trajectories.size() << " trajectories one by one in " << 1000.0 * (c_end-c_start) / CLOCKS_PER_SEC << " CPU seconds" << endl;
045d05cef9d0 updating to c++11 capabilities
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 542
diff changeset
423
045d05cef9d0 updating to c++11 capabilities
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 542
diff changeset
424 trajectoryDB->endTransaction();
045d05cef9d0 updating to c++11 capabilities
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 542
diff changeset
425 trajectoryDB->disconnect();
045d05cef9d0 updating to c++11 capabilities
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 542
diff changeset
426 }
169
5f705809d37a created groupFeatures function
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 168
diff changeset
427
164
76610dcf3b8d added test code to read trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 163
diff changeset
428 int main(int argc, char *argv[]) {
76610dcf3b8d added test code to read trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 163
diff changeset
429 KLTFeatureTrackingParameters params(argc, argv);
76610dcf3b8d added test code to read trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 163
diff changeset
430 cout << params.parameterDescription << endl;
654
045d05cef9d0 updating to c++11 capabilities
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 542
diff changeset
431
234
2d34060db2e9 removed included code that put track feature option always to true
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 231
diff changeset
432 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
433 cout << "The program tracks features" << endl;
164
76610dcf3b8d added test code to read trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 163
diff changeset
434 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
435 } 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
436 cout << "The program groups features" << endl;
169
5f705809d37a created groupFeatures function
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 168
diff changeset
437 groupFeatures(params);
654
045d05cef9d0 updating to c++11 capabilities
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 542
diff changeset
438 } else if (params.loadingTime) {
045d05cef9d0 updating to c++11 capabilities
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 542
diff changeset
439 cout << "The program reports loading times" << endl;
045d05cef9d0 updating to c++11 capabilities
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 542
diff changeset
440 loadingTimes(params);
542
a3add9f751ef added differentiate function for curvilinear trajectories and modified the addPosition functions
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 535
diff changeset
441 } else {
a3add9f751ef added differentiate function for curvilinear trajectories and modified the addPosition functions
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 535
diff changeset
442 cout << "Main option missing or misspelt" << endl;
234
2d34060db2e9 removed included code that put track feature option always to true
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 231
diff changeset
443 }
164
76610dcf3b8d added test code to read trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 163
diff changeset
444
117
fea680fb03ee created main feature based tracking file and minimum doxygen documentation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
445 return 0;
fea680fb03ee created main feature based tracking file and minimum doxygen documentation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
446 }
fea680fb03ee created main feature based tracking file and minimum doxygen documentation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
447
fea680fb03ee created main feature based tracking file and minimum doxygen documentation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
448 /* ------------------ DOCUMENTATION ------------------ */
fea680fb03ee created main feature based tracking file and minimum doxygen documentation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
449
fea680fb03ee created main feature based tracking file and minimum doxygen documentation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
450
fea680fb03ee created main feature based tracking file and minimum doxygen documentation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
451 /*! \mainpage
fea680fb03ee created main feature based tracking file and minimum doxygen documentation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
452
fea680fb03ee created main feature based tracking file and minimum doxygen documentation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
453 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
454
fea680fb03ee created main feature based tracking file and minimum doxygen documentation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
455 - \ref feature_based_tracking
fea680fb03ee created main feature based tracking file and minimum doxygen documentation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
456
fea680fb03ee created main feature based tracking file and minimum doxygen documentation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
457 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
458
fea680fb03ee created main feature based tracking file and minimum doxygen documentation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
459 */
fea680fb03ee created main feature based tracking file and minimum doxygen documentation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
460
fea680fb03ee created main feature based tracking file and minimum doxygen documentation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
461 /*! \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
462
fea680fb03ee created main feature based tracking file and minimum doxygen documentation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
463 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
464
fea680fb03ee created main feature based tracking file and minimum doxygen documentation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
465 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
466
fea680fb03ee created main feature based tracking file and minimum doxygen documentation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
467 \section License
fea680fb03ee created main feature based tracking file and minimum doxygen documentation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
468
fea680fb03ee created main feature based tracking file and minimum doxygen documentation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
469 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
470
fea680fb03ee created main feature based tracking file and minimum doxygen documentation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
471 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
472
fea680fb03ee created main feature based tracking file and minimum doxygen documentation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
473 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
474
fea680fb03ee created main feature based tracking file and minimum doxygen documentation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
475 */