summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2014-01-04 13:41:46 +0100
committerStanislaw Halik <sthalik@misaki.pl>2014-01-04 13:41:46 +0100
commit8b845f242495a91aca45cd1bf59d1823517b32c8 (patch)
treeb7c1cee3ed3944c6affc31c2fd1df431f2ae8c28
parent66466d0c30e7a2aed1a0c6c45db4b86dd5f0a99e (diff)
disable hysteresis debug; throttle frame update rate
-rw-r--r--FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp4
-rw-r--r--FTNoIR_Tracker_PT/pt_video_widget.cpp13
-rw-r--r--FTNoIR_Tracker_PT/pt_video_widget.h11
3 files changed, 22 insertions, 6 deletions
diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp
index e8bc7208..6bcad861 100644
--- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp
+++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp
@@ -83,9 +83,9 @@ void Tracker::run()
if (new_frame && !frame.empty())
{
frame = frame_rotation.rotate_frame(frame);
- const std::vector<cv::Vec2f>& points = point_extractor.extract_points(frame, dt, has_observers());
+ const std::vector<cv::Vec2f>& points = point_extractor.extract_points(frame, dt, false);
tracking_valid = point_tracker.track(points, camera.get_info().f, dt);
- video_widget->update_image(frame.clone());
+ video_widget->update_image(frame);
}
#ifdef PT_PERF_LOG
log_stream<<"dt: "<<dt;
diff --git a/FTNoIR_Tracker_PT/pt_video_widget.cpp b/FTNoIR_Tracker_PT/pt_video_widget.cpp
index 5ac002f4..38c49567 100644
--- a/FTNoIR_Tracker_PT/pt_video_widget.cpp
+++ b/FTNoIR_Tracker_PT/pt_video_widget.cpp
@@ -18,7 +18,15 @@ using namespace std;
void PTVideoWidget::update_image(const cv::Mat& frame)
{
QMutexLocker foo(&mtx);
- _frame = frame;
+ const int rate = 40;
+ if (freshp)
+ return;
+ if (!update_throttler.isValid() || update_throttler.elapsed() > rate)
+ {
+ _frame = frame.clone();
+ update_throttler.restart();
+ freshp = true;
+ }
}
// ----------------------------------------------------------------------------
@@ -42,8 +50,9 @@ VideoWidgetDialog::VideoWidgetDialog(QWidget *parent, FrameProvider* provider)
void PTVideoWidget::update_and_repaint()
{
QMutexLocker foo(&mtx);
- if (_frame.empty())
+ if (_frame.empty() || !freshp)
return;
+ freshp = false;
QImage qframe = QImage(_frame.cols, _frame.rows, QImage::Format_RGB888);
uchar* data = qframe.bits();
const int pitch = qframe.bytesPerLine();
diff --git a/FTNoIR_Tracker_PT/pt_video_widget.h b/FTNoIR_Tracker_PT/pt_video_widget.h
index acff43fb..c47198db 100644
--- a/FTNoIR_Tracker_PT/pt_video_widget.h
+++ b/FTNoIR_Tracker_PT/pt_video_widget.h
@@ -24,15 +24,20 @@
#include <QPainter>
#include <QPaintEvent>
#include <QTimer>
+#include <QElapsedTimer>
class PTVideoWidget : public QWidget, public FrameObserver
{
Q_OBJECT
public:
- PTVideoWidget(QWidget *parent, FrameProvider* provider) : QWidget(parent), /* to avoid linker errors */ FrameObserver(provider) {
+ PTVideoWidget(QWidget *parent, FrameProvider* provider) :
+ QWidget(parent),
+ /* to avoid linker errors */ FrameObserver(provider),
+ freshp(false)
+ {
connect(&timer, SIGNAL(timeout()), this, SLOT(update_and_repaint()));
- timer.start(45);
+ timer.start(40);
}
void update_image(const cv::Mat &frame);
void update_frame_and_points() {}
@@ -48,6 +53,8 @@ private:
QImage texture;
QTimer timer;
cv::Mat _frame;
+ QElapsedTimer update_throttler;
+ bool freshp;
};
// ----------------------------------------------------------------------------