mirror of
https://github.com/kerberos-io/openalpr-base.git
synced 2025-10-06 07:06:54 +08:00
Added toJson function for single result
This commit is contained in:
@@ -82,6 +82,10 @@ namespace alpr
|
|||||||
{
|
{
|
||||||
return AlprImpl::toJson(results);
|
return AlprImpl::toJson(results);
|
||||||
}
|
}
|
||||||
|
std::string Alpr::toJson( AlprPlateResult result )
|
||||||
|
{
|
||||||
|
return AlprImpl::toJson(result);
|
||||||
|
}
|
||||||
|
|
||||||
AlprResults Alpr::fromJson(std::string json) {
|
AlprResults Alpr::fromJson(std::string json) {
|
||||||
return AlprImpl::fromJson(json);
|
return AlprImpl::fromJson(json);
|
||||||
|
@@ -163,6 +163,7 @@ namespace alpr
|
|||||||
|
|
||||||
|
|
||||||
static std::string toJson(const AlprResults results);
|
static std::string toJson(const AlprResults results);
|
||||||
|
static std::string toJson(const AlprPlateResult result);
|
||||||
static AlprResults fromJson(std::string json);
|
static AlprResults fromJson(std::string json);
|
||||||
|
|
||||||
bool isLoaded();
|
bool isLoaded();
|
||||||
|
@@ -542,6 +542,21 @@ namespace alpr
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
std::string AlprImpl::toJson( const AlprPlateResult result )
|
||||||
|
{
|
||||||
|
cJSON *resultObj = createJsonObj( &result );
|
||||||
|
|
||||||
|
char *out;
|
||||||
|
out=cJSON_PrintUnformatted(resultObj);
|
||||||
|
|
||||||
|
cJSON_Delete(resultObj);
|
||||||
|
|
||||||
|
string response(out);
|
||||||
|
|
||||||
|
free(out);
|
||||||
|
|
||||||
|
return response;
|
||||||
|
}
|
||||||
cJSON* AlprImpl::createJsonObj(const AlprPlateResult* result)
|
cJSON* AlprImpl::createJsonObj(const AlprPlateResult* result)
|
||||||
{
|
{
|
||||||
cJSON *root, *coords, *candidates;
|
cJSON *root, *coords, *candidates;
|
||||||
|
@@ -99,6 +99,8 @@ namespace alpr
|
|||||||
void setDefaultRegion(std::string region);
|
void setDefaultRegion(std::string region);
|
||||||
|
|
||||||
static std::string toJson( const AlprResults results );
|
static std::string toJson( const AlprResults results );
|
||||||
|
static std::string toJson( const AlprPlateResult result );
|
||||||
|
|
||||||
static AlprResults fromJson(std::string json);
|
static AlprResults fromJson(std::string json);
|
||||||
static std::string getVersion();
|
static std::string getVersion();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user