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