mirror of
https://github.com/kerberos-io/openalpr-base.git
synced 2025-10-06 04:26:52 +08:00
Using site-camera-epochtime rather than random UUID. Removed UUID lib dependency
This commit is contained in:
@@ -65,7 +65,7 @@ TARGET_LINK_LIBRARIES(alpr
|
|||||||
|
|
||||||
# Compile the alprd library on Unix-based OS
|
# Compile the alprd library on Unix-based OS
|
||||||
IF (NOT WIN32)
|
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
|
TARGET_LINK_LIBRARIES(alprd
|
||||||
openalpr
|
openalpr
|
||||||
|
@@ -4,7 +4,6 @@
|
|||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
#include "daemon/beanstalk.hpp"
|
#include "daemon/beanstalk.hpp"
|
||||||
#include "daemon/uuid.h"
|
|
||||||
#include "video/logging_videobuffer.h"
|
#include "video/logging_videobuffer.h"
|
||||||
|
|
||||||
#include "tclap/CmdLine.h"
|
#include "tclap/CmdLine.h"
|
||||||
@@ -265,24 +264,26 @@ void streamRecognitionThread(void* arg)
|
|||||||
|
|
||||||
if (results.size() > 0)
|
if (results.size() > 0)
|
||||||
{
|
{
|
||||||
// Create a UUID for the image
|
long epoch_time = getEpochTime();
|
||||||
std::string uuid = newUUID();
|
|
||||||
|
std::stringstream uuid;
|
||||||
|
uuid << tdata->site_id << "-cam" << tdata->camera_id << "-" << epoch_time;
|
||||||
|
|
||||||
// Save the image to disk (using the UUID)
|
// Save the image to disk (using the UUID)
|
||||||
if (tdata->output_images)
|
if (tdata->output_images)
|
||||||
{
|
{
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss << tdata->output_image_folder << "/" << uuid << ".jpg";
|
ss << tdata->output_image_folder << "/" << uuid.str() << ".jpg";
|
||||||
|
|
||||||
cv::imwrite(ss.str(), latestFrame);
|
cv::imwrite(ss.str(), latestFrame);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the JSON content to include UUID and camera ID
|
// 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 *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_AddNumberToObject(root, "camera_id", tdata->camera_id);
|
||||||
cJSON_AddStringToObject(root, "site_id", tdata->site_id.c_str());
|
cJSON_AddStringToObject(root, "site_id", tdata->site_id.c_str());
|
||||||
cJSON_AddNumberToObject(root, "img_width", latestFrame.cols);
|
cJSON_AddNumberToObject(root, "img_width", latestFrame.cols);
|
||||||
|
@@ -1,31 +0,0 @@
|
|||||||
#include "uuid.h"
|
|
||||||
|
|
||||||
extern "C"
|
|
||||||
{
|
|
||||||
#ifdef WIN32
|
|
||||||
#include <Rpc.h>
|
|
||||||
#else
|
|
||||||
#include <uuid/uuid.h>
|
|
||||||
#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;
|
|
||||||
}
|
|
@@ -1,11 +0,0 @@
|
|||||||
#ifndef OPENALPR_UUID_H
|
|
||||||
#define OPENALPR_UUID_H
|
|
||||||
|
|
||||||
#include <cstdio>
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
|
|
||||||
std::string newUUID();
|
|
||||||
|
|
||||||
|
|
||||||
#endif // OPENALPR_UUID_H
|
|
@@ -54,9 +54,9 @@ std::vector<AlprResult> Alpr::recognize(std::vector<unsigned char> imageBuffer,
|
|||||||
return impl->recognize(imageBuffer, regionsOfInterest);
|
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)
|
void Alpr::setDetectRegion(bool detectRegion)
|
||||||
|
@@ -82,7 +82,7 @@ class Alpr
|
|||||||
std::vector<AlprResult> recognize(std::vector<unsigned char> imageBuffer);
|
std::vector<AlprResult> recognize(std::vector<unsigned char> imageBuffer);
|
||||||
std::vector<AlprResult> recognize(std::vector<unsigned char> imageBuffer, std::vector<AlprRegionOfInterest> regionsOfInterest);
|
std::vector<AlprResult> recognize(std::vector<unsigned char> imageBuffer, std::vector<AlprRegionOfInterest> regionsOfInterest);
|
||||||
|
|
||||||
std::string toJson(const std::vector<AlprResult> results, double processing_time_ms = -1);
|
std::string toJson(const std::vector<AlprResult> results, double processing_time_ms = -1, long epoch_time = -1);
|
||||||
|
|
||||||
bool isLoaded();
|
bool isLoaded();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user