From 7947474ee31af77552e4b81ad9fe9f7f2ddc437c Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Tue, 20 May 2014 21:06:35 -0500 Subject: [PATCH] Added epoch time to json output --- src/openalpr/alpr_impl.cpp | 1 + src/openalpr/support/timing.cpp | 6 ++++++ src/openalpr/support/timing.h | 3 +++ 3 files changed, 10 insertions(+) diff --git a/src/openalpr/alpr_impl.cpp b/src/openalpr/alpr_impl.cpp index 76977e7..156734d 100644 --- a/src/openalpr/alpr_impl.cpp +++ b/src/openalpr/alpr_impl.cpp @@ -294,6 +294,7 @@ cJSON* AlprImpl::createJsonObj(const AlprResult* result) root=cJSON_CreateObject(); cJSON_AddStringToObject(root,"plate", result->bestPlate.characters.c_str()); + cJSON_AddNumberToObject(root,"epoch_time", getEpochTime() ); cJSON_AddNumberToObject(root,"confidence", result->bestPlate.overall_confidence); cJSON_AddNumberToObject(root,"matches_template", result->bestPlate.matches_template); diff --git a/src/openalpr/support/timing.cpp b/src/openalpr/support/timing.cpp index 4cc7442..a633aef 100644 --- a/src/openalpr/support/timing.cpp +++ b/src/openalpr/support/timing.cpp @@ -139,3 +139,9 @@ timespec diff(timespec start, timespec end) } #endif + + +int getEpochTime() +{ + return std::time(0); +} diff --git a/src/openalpr/support/timing.h b/src/openalpr/support/timing.h index 7eb506a..b48e14d 100644 --- a/src/openalpr/support/timing.h +++ b/src/openalpr/support/timing.h @@ -2,6 +2,7 @@ #define TIMING_H #include +#include // Support for OS X #ifdef __MACH__ @@ -19,4 +20,6 @@ void getTime(timespec* time); double diffclock(timespec time1,timespec time2); +int getEpochTime(); + #endif