From 3585e0436f527c5667512d48d0e1c115e830649d Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Tue, 30 Sep 2014 22:34:06 -0400 Subject: [PATCH] Added epoch_time as an optional value for json serializing --- src/openalpr/alpr_impl.cpp | 7 +++++-- src/openalpr/alpr_impl.h | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/openalpr/alpr_impl.cpp b/src/openalpr/alpr_impl.cpp index fce858a..2eda4f8 100644 --- a/src/openalpr/alpr_impl.cpp +++ b/src/openalpr/alpr_impl.cpp @@ -281,12 +281,15 @@ std::vector AlprImpl::recognize(cv::Mat img, std::vector r return rectRegions; } -string AlprImpl::toJson(const vector< AlprResult > results, double processing_time_ms) +string AlprImpl::toJson(const vector results, double processing_time_ms, long epoch_time) { cJSON *root, *jsonResults; root = cJSON_CreateObject(); - cJSON_AddNumberToObject(root,"epoch_time", getEpochTime() ); + if (epoch_time <= 0) + epoch_time = getEpochTime(); + + cJSON_AddNumberToObject(root,"epoch_time", epoch_time ); if (processing_time_ms >= 0) { cJSON_AddNumberToObject(root,"processing_time_ms", processing_time_ms ); diff --git a/src/openalpr/alpr_impl.h b/src/openalpr/alpr_impl.h index 2b518be..2c1d1f4 100644 --- a/src/openalpr/alpr_impl.h +++ b/src/openalpr/alpr_impl.h @@ -79,7 +79,7 @@ class AlprImpl void setTopN(int topn); void setDefaultRegion(std::string region); - std::string toJson(const std::vector results, double processing_time_ms = -1); + std::string toJson(const std::vector results, double processing_time_ms = -1, long epoch_time = -1); static std::string getVersion(); Config* config;