diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 1970d4c..7e2ec79 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -65,7 +65,7 @@ TARGET_LINK_LIBRARIES(alpr # Compile the alprd library on Unix-based OS IF (NOT WIN32) - ADD_EXECUTABLE( alprd daemon.cpp daemon/beanstalk.c daemon/beanstalk.cc daemon/uuid.cpp ) + ADD_EXECUTABLE( alprd daemon.cpp daemon/beanstalk.c daemon/beanstalk.cc ) TARGET_LINK_LIBRARIES(alprd openalpr diff --git a/src/daemon.cpp b/src/daemon.cpp index cd6e189..356b27b 100644 --- a/src/daemon.cpp +++ b/src/daemon.cpp @@ -4,7 +4,6 @@ #include #include "daemon/beanstalk.hpp" -#include "daemon/uuid.h" #include "video/logging_videobuffer.h" #include "tclap/CmdLine.h" @@ -265,24 +264,26 @@ void streamRecognitionThread(void* arg) if (results.size() > 0) { - // Create a UUID for the image - std::string uuid = newUUID(); + long epoch_time = getEpochTime(); + + std::stringstream uuid; + uuid << tdata->site_id << "-cam" << tdata->camera_id << "-" << epoch_time; // Save the image to disk (using the UUID) if (tdata->output_images) { std::stringstream ss; - ss << tdata->output_image_folder << "/" << uuid << ".jpg"; + ss << tdata->output_image_folder << "/" << uuid.str() << ".jpg"; cv::imwrite(ss.str(), latestFrame); } // Update the JSON content to include UUID and camera ID - std::string json = alpr.toJson(results, totalProcessingTime); + std::string json = alpr.toJson(results, totalProcessingTime, epoch_time); cJSON *root = cJSON_Parse(json.c_str()); - cJSON_AddStringToObject(root, "uuid", uuid.c_str()); + cJSON_AddStringToObject(root, "uuid", uuid.str().c_str()); cJSON_AddNumberToObject(root, "camera_id", tdata->camera_id); cJSON_AddStringToObject(root, "site_id", tdata->site_id.c_str()); cJSON_AddNumberToObject(root, "img_width", latestFrame.cols); diff --git a/src/daemon/uuid.cpp b/src/daemon/uuid.cpp deleted file mode 100644 index f389a2b..0000000 --- a/src/daemon/uuid.cpp +++ /dev/null @@ -1,31 +0,0 @@ -#include "uuid.h" - -extern "C" -{ -#ifdef WIN32 -#include -#else -#include -#endif -} - -std::string newUUID() -{ -#ifdef WIN32 - UUID uuid; - UuidCreate ( &uuid ); - - unsigned char * str; - UuidToStringA ( &uuid, &str ); - - std::string s( ( char* ) str ); - - RpcStringFreeA ( &str ); -#else - uuid_t uuid; - uuid_generate_random ( uuid ); - char s[37]; - uuid_unparse ( uuid, s ); -#endif - return s; -} \ No newline at end of file diff --git a/src/daemon/uuid.h b/src/daemon/uuid.h deleted file mode 100644 index 952e887..0000000 --- a/src/daemon/uuid.h +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef OPENALPR_UUID_H -#define OPENALPR_UUID_H - -#include -#include - - -std::string newUUID(); - - -#endif // OPENALPR_UUID_H \ No newline at end of file diff --git a/src/openalpr/alpr.cpp b/src/openalpr/alpr.cpp index 03c8f09..558e225 100644 --- a/src/openalpr/alpr.cpp +++ b/src/openalpr/alpr.cpp @@ -54,9 +54,9 @@ std::vector Alpr::recognize(std::vector imageBuffer, return impl->recognize(imageBuffer, regionsOfInterest); } -std::string Alpr::toJson(const std::vector< AlprResult > results, double processing_time_ms) +std::string Alpr::toJson(const std::vector< AlprResult > results, double processing_time_ms, long epoch_time) { - return impl->toJson(results, processing_time_ms); + return impl->toJson(results, processing_time_ms, epoch_time); } void Alpr::setDetectRegion(bool detectRegion) diff --git a/src/openalpr/alpr.h b/src/openalpr/alpr.h index 4e74ecc..9199c63 100644 --- a/src/openalpr/alpr.h +++ b/src/openalpr/alpr.h @@ -82,7 +82,7 @@ class Alpr std::vector recognize(std::vector imageBuffer); std::vector recognize(std::vector imageBuffer, std::vector regionsOfInterest); - 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); bool isLoaded();