From 41bedff338d56e75d0898d79609c659cbb16d55e Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Sun, 31 Aug 2014 10:34:50 -0400 Subject: [PATCH] Partially resolves issue #46 Use epoch milliseconds rather than seconds --- src/openalpr/support/timing.cpp | 18 ++++++++++++++---- src/openalpr/support/timing.h | 8 +++++++- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/src/openalpr/support/timing.cpp b/src/openalpr/support/timing.cpp index a633aef..95c941d 100644 --- a/src/openalpr/support/timing.cpp +++ b/src/openalpr/support/timing.cpp @@ -97,6 +97,12 @@ timespec diff(timespec start, timespec end) return temp; } + +long getEpochTime() +{ + return std::time(0) * 1000; +} + #else void getTime(timespec* time) @@ -138,10 +144,14 @@ timespec diff(timespec start, timespec end) return temp; } + +long getEpochTime() +{ + struct timeval tp; + gettimeofday(&tp, NULL); + long int ms = tp.tv_sec * 1000 + tp.tv_usec / 1000; +} + #endif -int getEpochTime() -{ - return std::time(0); -} diff --git a/src/openalpr/support/timing.h b/src/openalpr/support/timing.h index b48e14d..2de04d2 100644 --- a/src/openalpr/support/timing.h +++ b/src/openalpr/support/timing.h @@ -4,6 +4,12 @@ #include #include +#ifdef WINDOWS + // Import windows only stuff +#else + #include +#endif + // Support for OS X #ifdef __MACH__ #include @@ -20,6 +26,6 @@ void getTime(timespec* time); double diffclock(timespec time1,timespec time2); -int getEpochTime(); +long getEpochTime(); #endif