mirror of
https://github.com/kerberos-io/openalpr-base.git
synced 2025-10-05 23:06:56 +08:00
Changed JSON serialization/deserialization functions to static
This commit is contained in:
@@ -59,11 +59,11 @@ AlprResults Alpr::recognize(unsigned char* pixelData, int bytesPerPixel, int img
|
||||
|
||||
std::string Alpr::toJson( AlprResults results )
|
||||
{
|
||||
return impl->toJson(results);
|
||||
return AlprImpl::toJson(results);
|
||||
}
|
||||
|
||||
AlprResults Alpr::fromJson(std::string json) {
|
||||
return impl->fromJson(json);
|
||||
return AlprImpl::fromJson(json);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -114,8 +114,8 @@ class Alpr
|
||||
AlprResults recognize(unsigned char* pixelData, int bytesPerPixel, int imgWidth, int imgHeight, std::vector<AlprRegionOfInterest> regionsOfInterest);
|
||||
|
||||
|
||||
std::string toJson(const AlprResults results);
|
||||
AlprResults fromJson(std::string json);
|
||||
static std::string toJson(const AlprResults results);
|
||||
static AlprResults fromJson(std::string json);
|
||||
|
||||
bool isLoaded();
|
||||
|
||||
|
@@ -79,8 +79,8 @@ class AlprImpl
|
||||
void setTopN(int topn);
|
||||
void setDefaultRegion(std::string region);
|
||||
|
||||
std::string toJson( const AlprResults results );
|
||||
AlprResults fromJson(std::string json);
|
||||
static std::string toJson( const AlprResults results );
|
||||
static AlprResults fromJson(std::string json);
|
||||
static std::string getVersion();
|
||||
|
||||
Config* config;
|
||||
@@ -99,7 +99,7 @@ class AlprImpl
|
||||
|
||||
std::vector<cv::Rect> convertRects(std::vector<AlprRegionOfInterest> regionsOfInterest);
|
||||
|
||||
cJSON* createJsonObj(const AlprPlateResult* result);
|
||||
static cJSON* createJsonObj(const AlprPlateResult* result);
|
||||
};
|
||||
|
||||
|
||||
|
@@ -18,7 +18,6 @@ using namespace std;
|
||||
|
||||
TEST_CASE( "JSON Serialization/Deserialization", "[json]" ) {
|
||||
|
||||
Alpr alpr("us");
|
||||
AlprResults origResults;
|
||||
origResults.epoch_time = getEpochTime();
|
||||
origResults.img_width = 640;
|
||||
@@ -53,8 +52,8 @@ TEST_CASE( "JSON Serialization/Deserialization", "[json]" ) {
|
||||
origResults.plates.push_back(apr);
|
||||
|
||||
|
||||
std::string resultsJson = alpr.toJson(origResults);
|
||||
AlprResults roundTrip = alpr.fromJson(resultsJson);
|
||||
std::string resultsJson = Alpr::toJson(origResults);
|
||||
AlprResults roundTrip = Alpr::fromJson(resultsJson);
|
||||
|
||||
REQUIRE( roundTrip.epoch_time == origResults.epoch_time );
|
||||
REQUIRE( roundTrip.img_width == origResults.img_width );
|
||||
|
Reference in New Issue
Block a user