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

@@ -20,76 +20,80 @@
#include "alpr.h"
#include "alpr_impl.h"
// ALPR code
Alpr::Alpr(const std::string country, const std::string configFile, const std::string runtimeDir)
{
impl = new AlprImpl(country, configFile, runtimeDir);
}
Alpr::~Alpr()
{
delete impl;
}
AlprResults Alpr::recognize(std::string filepath)
namespace alpr
{
std::ifstream ifs(filepath.c_str(), std::ios::binary|std::ios::ate);
std::ifstream::pos_type pos = ifs.tellg();
// ALPR code
std::vector<char> buffer(pos);
Alpr::Alpr(const std::string country, const std::string configFile, const std::string runtimeDir)
{
impl = new AlprImpl(country, configFile, runtimeDir);
}
ifs.seekg(0, std::ios::beg);
ifs.read(&buffer[0], pos);
Alpr::~Alpr()
{
delete impl;
}
return this->recognize( buffer );
}
AlprResults Alpr::recognize(std::string filepath)
{
AlprResults Alpr::recognize(std::vector<char> imageBytes)
{
std::vector<AlprRegionOfInterest> regionsOfInterest;
return impl->recognize(imageBytes, regionsOfInterest);
}
std::ifstream ifs(filepath.c_str(), std::ios::binary|std::ios::ate);
std::ifstream::pos_type pos = ifs.tellg();
AlprResults Alpr::recognize(unsigned char* pixelData, int bytesPerPixel, int imgWidth, int imgHeight, std::vector<AlprRegionOfInterest> regionsOfInterest)
{
return impl->recognize(pixelData, bytesPerPixel, imgWidth, imgHeight, regionsOfInterest);
}
std::vector<char> buffer(pos);
std::string Alpr::toJson( AlprResults results )
{
return AlprImpl::toJson(results);
}
ifs.seekg(0, std::ios::beg);
ifs.read(&buffer[0], pos);
AlprResults Alpr::fromJson(std::string json) {
return AlprImpl::fromJson(json);
}
return this->recognize( buffer );
}
AlprResults Alpr::recognize(std::vector<char> imageBytes)
{
std::vector<AlprRegionOfInterest> regionsOfInterest;
return impl->recognize(imageBytes, regionsOfInterest);
}
AlprResults Alpr::recognize(unsigned char* pixelData, int bytesPerPixel, int imgWidth, int imgHeight, std::vector<AlprRegionOfInterest> regionsOfInterest)
{
return impl->recognize(pixelData, bytesPerPixel, imgWidth, imgHeight, regionsOfInterest);
}
std::string Alpr::toJson( AlprResults results )
{
return AlprImpl::toJson(results);
}
AlprResults Alpr::fromJson(std::string json) {
return AlprImpl::fromJson(json);
}
void Alpr::setDetectRegion(bool detectRegion)
{
impl->setDetectRegion(detectRegion);
}
void Alpr::setDetectRegion(bool detectRegion)
{
impl->setDetectRegion(detectRegion);
}
void Alpr::setTopN(int topN)
{
impl->setTopN(topN);
}
void Alpr::setTopN(int topN)
{
impl->setTopN(topN);
}
void Alpr::setDefaultRegion(std::string region)
{
impl->setDefaultRegion(region);
}
void Alpr::setDefaultRegion(std::string region)
{
impl->setDefaultRegion(region);
}
bool Alpr::isLoaded()
{
return impl->isLoaded();
}
bool Alpr::isLoaded()
{
return impl->isLoaded();
}
std::string Alpr::getVersion()
{
return AlprImpl::getVersion();
}
std::string Alpr::getVersion()
{
return AlprImpl::getVersion();
}
}