mirror of
https://github.com/kerberos-io/openalpr-base.git
synced 2025-10-06 16:27:07 +08:00
Wrapped OpenALPR library in "alpr" namespace. Resolves issue #60.
This commit is contained in:
@@ -24,105 +24,109 @@
|
||||
#include <vector>
|
||||
#include <fstream>
|
||||
|
||||
struct AlprPlate
|
||||
namespace alpr
|
||||
{
|
||||
std::string characters;
|
||||
float overall_confidence;
|
||||
|
||||
bool matches_template;
|
||||
};
|
||||
|
||||
struct AlprCoordinate
|
||||
{
|
||||
int x;
|
||||
int y;
|
||||
};
|
||||
|
||||
class AlprRegionOfInterest
|
||||
{
|
||||
public:
|
||||
AlprRegionOfInterest();
|
||||
AlprRegionOfInterest(int x, int y, int width, int height)
|
||||
{
|
||||
this->x = x;
|
||||
this->y = y;
|
||||
this->width = width;
|
||||
this->height = height;
|
||||
};
|
||||
|
||||
int x;
|
||||
int y;
|
||||
int width;
|
||||
int height;
|
||||
};
|
||||
struct AlprPlate
|
||||
{
|
||||
std::string characters;
|
||||
float overall_confidence;
|
||||
|
||||
class AlprPlateResult
|
||||
{
|
||||
bool matches_template;
|
||||
};
|
||||
|
||||
struct AlprCoordinate
|
||||
{
|
||||
int x;
|
||||
int y;
|
||||
};
|
||||
|
||||
class AlprRegionOfInterest
|
||||
{
|
||||
public:
|
||||
AlprPlateResult() {};
|
||||
virtual ~AlprPlateResult() {};
|
||||
AlprRegionOfInterest();
|
||||
AlprRegionOfInterest(int x, int y, int width, int height)
|
||||
{
|
||||
this->x = x;
|
||||
this->y = y;
|
||||
this->width = width;
|
||||
this->height = height;
|
||||
};
|
||||
|
||||
int requested_topn;
|
||||
int x;
|
||||
int y;
|
||||
int width;
|
||||
int height;
|
||||
};
|
||||
|
||||
AlprPlate bestPlate;
|
||||
std::vector<AlprPlate> topNPlates;
|
||||
class AlprPlateResult
|
||||
{
|
||||
public:
|
||||
AlprPlateResult() {};
|
||||
virtual ~AlprPlateResult() {};
|
||||
|
||||
float processing_time_ms;
|
||||
AlprCoordinate plate_points[4];
|
||||
int requested_topn;
|
||||
|
||||
int regionConfidence;
|
||||
std::string region;
|
||||
};
|
||||
AlprPlate bestPlate;
|
||||
std::vector<AlprPlate> topNPlates;
|
||||
|
||||
class AlprResults
|
||||
{
|
||||
public:
|
||||
AlprResults() {};
|
||||
virtual ~AlprResults() {};
|
||||
float processing_time_ms;
|
||||
AlprCoordinate plate_points[4];
|
||||
|
||||
long epoch_time;
|
||||
int img_width;
|
||||
int img_height;
|
||||
float total_processing_time_ms;
|
||||
|
||||
std::vector<AlprPlateResult> plates;
|
||||
|
||||
std::vector<AlprRegionOfInterest> regionsOfInterest;
|
||||
int regionConfidence;
|
||||
std::string region;
|
||||
};
|
||||
|
||||
};
|
||||
class AlprResults
|
||||
{
|
||||
public:
|
||||
AlprResults() {};
|
||||
virtual ~AlprResults() {};
|
||||
|
||||
long epoch_time;
|
||||
int img_width;
|
||||
int img_height;
|
||||
float total_processing_time_ms;
|
||||
|
||||
std::vector<AlprPlateResult> plates;
|
||||
|
||||
std::vector<AlprRegionOfInterest> regionsOfInterest;
|
||||
|
||||
};
|
||||
|
||||
|
||||
class AlprImpl;
|
||||
class Alpr
|
||||
{
|
||||
class AlprImpl;
|
||||
class Alpr
|
||||
{
|
||||
|
||||
public:
|
||||
Alpr(const std::string country, const std::string configFile = "", const std::string runtimeDir = "");
|
||||
virtual ~Alpr();
|
||||
public:
|
||||
Alpr(const std::string country, const std::string configFile = "", const std::string runtimeDir = "");
|
||||
virtual ~Alpr();
|
||||
|
||||
void setDetectRegion(bool detectRegion);
|
||||
void setTopN(int topN);
|
||||
void setDefaultRegion(std::string region);
|
||||
void setDetectRegion(bool detectRegion);
|
||||
void setTopN(int topN);
|
||||
void setDefaultRegion(std::string region);
|
||||
|
||||
// Recognize from an image on disk
|
||||
AlprResults recognize(std::string filepath);
|
||||
|
||||
// Recognize from byte data representing an encoded image (e.g., BMP, PNG, JPG, GIF etc).
|
||||
AlprResults recognize(std::vector<char> imageBytes);
|
||||
|
||||
// Recognize from raw pixel data.
|
||||
AlprResults recognize(unsigned char* pixelData, int bytesPerPixel, int imgWidth, int imgHeight, std::vector<AlprRegionOfInterest> regionsOfInterest);
|
||||
// Recognize from an image on disk
|
||||
AlprResults recognize(std::string filepath);
|
||||
|
||||
|
||||
static std::string toJson(const AlprResults results);
|
||||
static AlprResults fromJson(std::string json);
|
||||
// Recognize from byte data representing an encoded image (e.g., BMP, PNG, JPG, GIF etc).
|
||||
AlprResults recognize(std::vector<char> imageBytes);
|
||||
|
||||
bool isLoaded();
|
||||
|
||||
static std::string getVersion();
|
||||
// Recognize from raw pixel data.
|
||||
AlprResults recognize(unsigned char* pixelData, int bytesPerPixel, int imgWidth, int imgHeight, std::vector<AlprRegionOfInterest> regionsOfInterest);
|
||||
|
||||
private:
|
||||
AlprImpl* impl;
|
||||
};
|
||||
|
||||
static std::string toJson(const AlprResults results);
|
||||
static AlprResults fromJson(std::string json);
|
||||
|
||||
bool isLoaded();
|
||||
|
||||
static std::string getVersion();
|
||||
|
||||
private:
|
||||
AlprImpl* impl;
|
||||
};
|
||||
|
||||
}
|
||||
#endif // OPENALPR_APLR_H
|
||||
|
Reference in New Issue
Block a user