summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp3
-rw-r--r--FTNoIR_Tracker_PT/ftnoir_tracker_pt.h4
-rw-r--r--FTNoIR_Tracker_PT/timer.cpp66
-rw-r--r--FTNoIR_Tracker_PT/timer.h44
4 files changed, 3 insertions, 114 deletions
diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp
index 7bd447cb..83bf6911 100644
--- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp
+++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp
@@ -76,8 +76,7 @@ void Tracker::run()
if (commands & PAUSE) continue;
commands = 0;
- dt = time.elapsed() / 1000.0;
- time.restart();
+ dt = time.restart() / 1000.0;
new_frame = camera.get_frame(dt, &frame);
if (new_frame && !frame.empty())
diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.h b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.h
index c7f1dc02..067a4072 100644
--- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.h
+++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.h
@@ -18,7 +18,7 @@
#include "point_extractor.h"
#include "point_tracker.h"
#include "pt_video_widget.h"
-#include "timer.h"
+#include <QElapsedTimer>
#include <QThread>
#include <QMutex>
@@ -84,7 +84,7 @@ protected:
bool tracking_valid;
settings s;
- Timer time;
+ QElapsedTimer time;
};
#undef VideoWidget
diff --git a/FTNoIR_Tracker_PT/timer.cpp b/FTNoIR_Tracker_PT/timer.cpp
deleted file mode 100644
index 080dd713..00000000
--- a/FTNoIR_Tracker_PT/timer.cpp
+++ /dev/null
@@ -1,66 +0,0 @@
-/* Copyright (c) 2012 Patrick Ruoff
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- */
-
-#include "timer.h"
-
-#include <stdlib.h>
-
-// ----------------------------------------------------------------------------
-Timer::Timer()
-: startTime(0), endTime(0), running(false)
-{
-#ifdef WIN32
- QueryPerformanceFrequency(&frequency);
- startCount.QuadPart = 0;
- endCount.QuadPart = 0;
-#else
- startCount.tv_sec = startCount.tv_usec = 0;
- endCount.tv_sec = endCount.tv_usec = 0;
-#endif
-}
-
-
-void Timer::start()
-{
-#ifdef WIN32
- QueryPerformanceCounter(&startCount);
-#else
- gettimeofday(&startCount, NULL);
-#endif
- running = true;
-}
-
-
-void Timer::stop()
-{
-#ifdef WIN32
- QueryPerformanceCounter(&endCount);
-#else
- gettimeofday(&endCount, NULL);
-#endif
- running = false;
-}
-
-
-double Timer::elapsed()
-{
-#ifdef WIN32
- if (running)
- QueryPerformanceCounter(&endCount);
-
- startTime = startCount.QuadPart * (1e3 / frequency.QuadPart);
- endTime = endCount.QuadPart * (1e3 / frequency.QuadPart);
- return endTime - startTime;
-#else
- if(running)
- gettimeofday(&endCount, NULL);
-
- startTime = (startCount.tv_sec) + startCount.tv_usec * 1e-6;
- endTime = (endCount.tv_sec) + endCount.tv_usec * 1e-6;
- return (endTime - startTime) * 1e3;
-#endif
-}
diff --git a/FTNoIR_Tracker_PT/timer.h b/FTNoIR_Tracker_PT/timer.h
deleted file mode 100644
index f189e23c..00000000
--- a/FTNoIR_Tracker_PT/timer.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/* Copyright (c) 2012 Patrick Ruoff
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- */
-
-#ifndef PT_TIMER_H
-#define PT_TIMER_H
-
-#ifdef WIN32 // Windows system specific
-#include <windows.h>
-#else // Unix based system specific
-#include <sys/time.h>
-#endif
-
-// ----------------------------------------------------------------------------
-// High resolution timer based on http://www.songho.ca/misc/timer/timer.html
-class Timer
-{
-public:
- Timer();
-
- void start();
- void stop();
- void restart() { start(); } // for Qt compatibility
- double elapsed(); // get elapsed time in ms
-
-protected:
- double startTime; // starting time in ms
- double endTime; // ending time in ms
- bool running;
-
-#ifdef WIN32
- LARGE_INTEGER frequency; // ticks per second
- LARGE_INTEGER startCount;
- LARGE_INTEGER endCount;
-#else
- timeval startCount;
- timeval endCount;
-#endif
-};
-
-#endif //PT_TIMER_H \ No newline at end of file