projects
/
trackerpp.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
a80807e
)
finish tracker
author
Peng Li
<seudut@gmail.com>
Mon, 23 Jul 2018 06:21:56 +0000
(14:21 +0800)
committer
Peng Li
<seudut@gmail.com>
Mon, 23 Jul 2018 06:24:59 +0000
(14:24 +0800)
.gitignore
patch
|
blob
|
history
include/Tracker.h
patch
|
blob
|
history
src/MultiTracker.cpp
patch
|
blob
|
history
src/PredictorWrapper.cpp
patch
|
blob
|
history
src/Tracker.cpp
patch
|
blob
|
history
diff --git
a/.gitignore
b/.gitignore
index
c7db8d3
..
8e7feea
100644
(file)
--- a/
.gitignore
+++ b/
.gitignore
@@
-2,3
+2,7
@@
src/*.o
*.o
.sconsign.dblite
*.pyc
*.o
.sconsign.dblite
*.pyc
+main
+temp/
+test/TestMain
+libtracker.a
diff --git
a/include/Tracker.h
b/include/Tracker.h
index
d528670
..
bc36dba
100644
(file)
--- a/
include/Tracker.h
+++ b/
include/Tracker.h
@@
-29,19
+29,18
@@
namespace suanzi {
void updateState(const cv::Mat& image);
void addPatch(PatchPtr p);
void correct(const cv::Mat& image, const Detection& d);
void updateState(const cv::Mat& image);
void addPatch(PatchPtr p);
void correct(const cv::Mat& image, const Detection& d);
-
TrackerStatus status
;
+
void predict()
;
std::vector<PatchPtr> patches;
Detection detection;
std::vector<PatchPtr> patches;
Detection detection;
+ TrackerStatus status = TrackerStatus::Fire;
private:
private:
- TrackerStatus preStatus;
+ TrackerStatus preStatus
= TrackerStatus::Fire
;
int id;
int id;
- int age;
- int last_active;
- cv::KalmanFilter
kf
= {4,2};
+ int age
= 1
;
+ int last_active
= 1
;
+ cv::KalmanFilter
KF
= {4,2};
};
};
-
-
}
#endif /* _TRACKER_H_ */
}
#endif /* _TRACKER_H_ */
diff --git
a/src/MultiTracker.cpp
b/src/MultiTracker.cpp
index
aef5e2e
..
547a195
100644
(file)
--- a/
src/MultiTracker.cpp
+++ b/
src/MultiTracker.cpp
@@
-14,6
+14,7
@@
static const cv::Size PREFERRED_SIZE = Size(64, 128);
static const double MaxCost = 100000;
static const int MaxPatch = 5;
static const double MaxCost = 100000;
static const int MaxPatch = 5;
+static const double ProbThreshold = 0.05;
MultiTracker::MultiTracker(EngineWPtr e)
: engine(e)
MultiTracker::MultiTracker(EngineWPtr e)
: engine(e)
@@
-74,8
+75,11
@@
double MultiTracker::distance(TrackerPtr tracker, const cv::Mat& image, const De
ss = similarity(i, patch);
features.insert(features.end(), ss.begin(), ss.end());
}
ss = similarity(i, patch);
features.insert(features.end(), ss.begin(), ss.end());
}
- double prob = predictor->predict(4, features);
- return prob;
+ double prob = predictor->predict(MaxPatch - 1, features); // TODO ???
+ if (prob > ProbThreshold)
+ return -log(prob);
+ else
+ return MaxCost;
}
static float calc_iou_ratio(const Detection& d1, const Detection& d2)
}
static float calc_iou_ratio(const Detection& d1, const Detection& d2)
@@
-85,6
+89,12
@@
static float calc_iou_ratio(const Detection& d1, const Detection& d2)
void MultiTracker::update(unsigned int total, const Detection* detections, const Mat& image)
{
void MultiTracker::update(unsigned int total, const Detection* detections, const Mat& image)
{
+ // predict trackers, update trackers using kalman filter
+ for (auto t : trackers){
+ t->predict();
+ }
+
+ // match the trackers with the detections
int row = trackers.size();
int col = total;
Eigen::MatrixXi cost_matrix = Eigen::MatrixXi::Zero(row, col);
int row = trackers.size();
int col = total;
Eigen::MatrixXi cost_matrix = Eigen::MatrixXi::Zero(row, col);
diff --git
a/src/PredictorWrapper.cpp
b/src/PredictorWrapper.cpp
index
44e5fed
..
ebe7579
100644
(file)
--- a/
src/PredictorWrapper.cpp
+++ b/
src/PredictorWrapper.cpp
@@
-39,10
+39,8
@@
PredictorWrapperPtr PredictorWrapper::create(const std::string& python_dir, cons
void PredictorWrapper::dump()
{
LOG_DEBUG(TAG, "dump");
void PredictorWrapper::dump()
{
LOG_DEBUG(TAG, "dump");
- cout << "dump" << endl;
std::string ss = "";
try{
std::string ss = "";
try{
- cout << "==== before" << endl;
py::object ret = this->dump_func();
ss = py::extract<std::string>(ret);
} catch (boost::python::error_already_set const &){
py::object ret = this->dump_func();
ss = py::extract<std::string>(ret);
} catch (boost::python::error_already_set const &){
diff --git
a/src/Tracker.cpp
b/src/Tracker.cpp
index
e9353bd
..
b7da363
100644
(file)
--- a/
src/Tracker.cpp
+++ b/
src/Tracker.cpp
@@
-6,29
+6,30
@@
using namespace std;
static const int MaxLost = 5;
static const int MaxLost = 5;
-Tracker::Tracker(const cv::Mat& image, const Detection& detection, int id) : id(id)
+Tracker::Tracker(const cv::Mat& image, const Detection& detection, int id)
+: id(id)
{
status = TrackerStatus::Fire;
preStatus = TrackerStatus::Fire;
// TODO: Kalman filter
{
status = TrackerStatus::Fire;
preStatus = TrackerStatus::Fire;
// TODO: Kalman filter
-
this->kf
.transitionMatrix = (Mat_<double>(4, 4) <<
+
KF
.transitionMatrix = (Mat_<double>(4, 4) <<
1, 0, 1, 0,
0, 1, 0, 1,
0, 0, 1, 0,
0, 0, 0, 1);
1, 0, 1, 0,
0, 1, 0, 1,
0, 0, 1, 0,
0, 0, 0, 1);
-
this->kf
.measurementMatrix = (Mat_<double>(2, 2) <<
+
KF
.measurementMatrix = (Mat_<double>(2, 2) <<
1, 0, 0, 0,
0, 1, 0, 0);
1, 0, 0, 0,
0, 1, 0, 0);
-
this->kf
.processNoiseCov = 1e-5 * Mat_<double>::eye(4, 4);
-
this->kf
.measurementNoiseCov = 1e-1 * Mat_<double>::ones(2, 2);
-
this->kf
.errorCovPost = 1. * Mat_<double>::ones(4, 4);
+
KF
.processNoiseCov = 1e-5 * Mat_<double>::eye(4, 4);
+
KF
.measurementNoiseCov = 1e-1 * Mat_<double>::ones(2, 2);
+
KF
.errorCovPost = 1. * Mat_<double>::ones(4, 4);
//this->kf.statePre = 0.1 * Matx_<int, 4, 1>::randn(4, 1);
//??? TODO
//this->kf.statePre = 0.1 * Matx_<int, 4, 1>::randn(4, 1);
//??? TODO
- randn(
this->kf
.statePre, Scalar::all(0), Scalar::all(0.1));
-
this->kf
.statePost = (Mat_<double>(4, 1) << detection.center_x, detection.center_y, 0, 0);
+ randn(
KF
.statePre, Scalar::all(0), Scalar::all(0.1));
+
KF
.statePost = (Mat_<double>(4, 1) << detection.center_x, detection.center_y, 0, 0);
}
Tracker::~Tracker()
}
Tracker::~Tracker()
@@
-58,9
+59,15
@@
void Tracker::addPatch(PatchPtr p)
void Tracker::correct(const cv::Mat& image, const Detection& detection)
{
void Tracker::correct(const cv::Mat& image, const Detection& detection)
{
- //kf.correct();
+ // detection.center_x, detection.center_y,
+ // KF.correct(detect.center_x, detect.center_y);
preStatus = status;
status = TrackerStatus::Active;
last_active = age;
}
preStatus = status;
status = TrackerStatus::Active;
last_active = age;
}
+void Tracker::predict()
+{
+ age++;
+ //detection = KF.predict();
+}