summaryrefslogtreecommitdiffhomepage
path: root/tracker-pt/ftnoir_tracker_pt.cpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2015-12-19 20:43:24 +0100
committerStanislaw Halik <sthalik@misaki.pl>2015-12-19 20:46:26 +0100
commit90138a999b4c95afeb9a49d355b0234b6145e221 (patch)
treeec1c749b9837dc3dee7d37dbb8facb38aee4a854 /tracker-pt/ftnoir_tracker_pt.cpp
parenta2ceed01e32fd941e20e1362b6c44af8db05b5b2 (diff)
tracker/pt: don't allocate temporary frame
Diffstat (limited to 'tracker-pt/ftnoir_tracker_pt.cpp')
-rw-r--r--tracker-pt/ftnoir_tracker_pt.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/tracker-pt/ftnoir_tracker_pt.cpp b/tracker-pt/ftnoir_tracker_pt.cpp
index 80227a39..9a4fa037 100644
--- a/tracker-pt/ftnoir_tracker_pt.cpp
+++ b/tracker-pt/ftnoir_tracker_pt.cpp
@@ -14,6 +14,7 @@
#include <QCoreApplication>
#include "opentrack-compat/camera-names.hpp"
#include "opentrack-compat/sleep.hpp"
+#include <functional>
//#define PT_PERF_LOG //log performance
@@ -78,7 +79,7 @@ void Tracker_PT::run()
#endif
apply_settings();
- cv::Mat frame;
+ cv::Mat frame_;
while((commands & ABORT) == 0)
{
@@ -89,9 +90,12 @@ void Tracker_PT::run()
{
QMutexLocker l(&camera_mtx);
new_frame = camera.get_frame(dt, &frame);
+ if (frame.rows != frame_.rows || frame.cols != frame_.cols)
+ frame_ = cv::Mat(frame.rows, frame.cols, CV_8UC3);
+ frame.copyTo(frame_);
}
- if (new_frame && !frame.empty())
+ if (new_frame && !frame_.empty())
{
std::vector<cv::Vec2f> points = point_extractor.extract_points(frame);
@@ -142,11 +146,6 @@ void Tracker_PT::run()
video_widget->update_image(frame);
}
-#ifdef PT_PERF_LOG
- log_stream<<"dt: "<<dt;
- if (!frame.empty()) log_stream<<" fps: "<<camera.get_info().fps;
- log_stream<<"\n";
-#endif
}
qDebug()<<"Tracker:: Thread stopping";
}
@@ -160,6 +159,7 @@ void Tracker_PT::apply_settings()
camera.set_res(s.cam_res_x, s.cam_res_y);
camera.set_fps(s.cam_fps);
camera.start();
+ frame = cv::Mat();
qDebug()<<"Tracker::apply ends";
}