Wrapped OpenALPR library in "alpr" namespace. Resolves issue #60.

This commit is contained in:
Matt Hill
2014-10-27 20:12:57 -04:00
parent 83ed86c6b4
commit 85f52a6b8c
79 changed files with 7234 additions and 6968 deletions

View File

@@ -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