mirror of
https://github.com/kerberos-io/openalpr-base.git
synced 2025-10-05 21:26:49 +08:00
Added setPrewarp() function to API. Resolves Issue #199
This commit is contained in:
@@ -91,6 +91,10 @@ namespace alpr
|
||||
impl->setCountry(country);
|
||||
}
|
||||
|
||||
void Alpr::setPrewarp(std::string prewarp_config) {
|
||||
impl->setPrewarp(prewarp_config);
|
||||
}
|
||||
|
||||
|
||||
void Alpr::setDetectRegion(bool detectRegion)
|
||||
{
|
||||
|
@@ -140,6 +140,9 @@ namespace alpr
|
||||
// Set the country used for plate recognition
|
||||
void setCountry(std::string country);
|
||||
|
||||
// Update the prewarp setting without reloading the library
|
||||
void setPrewarp(std::string prewarp_config);
|
||||
|
||||
void setDetectRegion(bool detectRegion);
|
||||
void setTopN(int topN);
|
||||
void setDefaultRegion(std::string region);
|
||||
|
@@ -659,6 +659,11 @@ namespace alpr
|
||||
loadRecognizers();
|
||||
}
|
||||
|
||||
void AlprImpl::setPrewarp(std::string prewarp_config)
|
||||
{
|
||||
prewarp->initialize(prewarp_config);
|
||||
}
|
||||
|
||||
|
||||
void AlprImpl::setDetectRegion(bool detectRegion)
|
||||
{
|
||||
|
@@ -93,6 +93,8 @@ namespace alpr
|
||||
AlprFullDetails analyzeSingleCountry(cv::Mat colorImg, cv::Mat grayImg, std::vector<cv::Rect> regionsOfInterest);
|
||||
|
||||
void setCountry(std::string country);
|
||||
void setPrewarp(std::string prewarp_config);
|
||||
|
||||
void setDetectRegion(bool detectRegion);
|
||||
void setTopN(int topn);
|
||||
void setDefaultRegion(std::string region);
|
||||
|
@@ -28,15 +28,22 @@ using namespace cv;
|
||||
namespace alpr
|
||||
{
|
||||
|
||||
PreWarp::PreWarp(Config* config) {
|
||||
PreWarp::PreWarp(Config* config)
|
||||
{
|
||||
this->config = config;
|
||||
|
||||
string warp_config = config->prewarp;
|
||||
initialize(config->prewarp);
|
||||
}
|
||||
|
||||
|
||||
void PreWarp::initialize(std::string prewarp_config) {
|
||||
|
||||
timespec startTime;
|
||||
getTimeMonotonic(&startTime);
|
||||
|
||||
// Do a cursory verification based on number of commas
|
||||
int commacount = count(warp_config.begin(), warp_config.end(), ',');
|
||||
int commacount = count(prewarp_config.begin(), prewarp_config.end(), ',');
|
||||
|
||||
if (warp_config.length() < 4)
|
||||
if (prewarp_config.length() < 4)
|
||||
{
|
||||
// No config specified. ignore
|
||||
if (this->config->debugPrewarp)
|
||||
@@ -55,10 +62,10 @@ namespace alpr
|
||||
{
|
||||
|
||||
// Parse the warp_config
|
||||
int first_comma = warp_config.find(",");
|
||||
int first_comma = prewarp_config.find(",");
|
||||
|
||||
|
||||
string name = warp_config.substr(0, first_comma);
|
||||
string name = prewarp_config.substr(0, first_comma);
|
||||
|
||||
if (name != "planar")
|
||||
{
|
||||
@@ -66,7 +73,7 @@ namespace alpr
|
||||
}
|
||||
else
|
||||
{
|
||||
stringstream ss(warp_config.substr(first_comma + 1, warp_config.length()));
|
||||
stringstream ss(prewarp_config.substr(first_comma + 1, prewarp_config.length()));
|
||||
|
||||
ss >> w;
|
||||
ss.ignore();
|
||||
@@ -90,9 +97,13 @@ namespace alpr
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
timespec endTime;
|
||||
getTimeMonotonic(&endTime);
|
||||
if (config->debugTiming)
|
||||
cout << "Prewarp Initialization Time: " << diffclock(startTime, endTime) << "ms." << endl;
|
||||
}
|
||||
|
||||
|
||||
PreWarp::~PreWarp() {
|
||||
}
|
||||
|
||||
|
@@ -34,6 +34,8 @@ namespace alpr
|
||||
PreWarp(Config* config);
|
||||
virtual ~PreWarp();
|
||||
|
||||
void initialize(std::string prewarp_config);
|
||||
|
||||
cv::Mat warpImage(cv::Mat image);
|
||||
std::vector<cv::Point2f> projectPoints(std::vector<cv::Point2f> points, bool inverse);
|
||||
std::vector<cv::Rect> projectRects(std::vector<cv::Rect> rects, int maxWidth, int maxHeight, bool inverse);
|
||||
|
Reference in New Issue
Block a user