Added setMask function to main ALPR API

This commit is contained in:
Matt Hill
2016-03-27 13:49:13 -04:00
parent ac4ff70e96
commit 53dda59829
4 changed files with 26 additions and 0 deletions

View File

@@ -95,6 +95,10 @@ namespace alpr
impl->setPrewarp(prewarp_config); impl->setPrewarp(prewarp_config);
} }
void Alpr::setMask(unsigned char* pixelData, int bytesPerPixel, int imgWidth, int imgHeight)
{
impl->setMask(pixelData, bytesPerPixel, imgWidth, imgHeight);
}
void Alpr::setDetectRegion(bool detectRegion) void Alpr::setDetectRegion(bool detectRegion)
{ {

View File

@@ -142,6 +142,8 @@ namespace alpr
// Update the prewarp setting without reloading the library // Update the prewarp setting without reloading the library
void setPrewarp(std::string prewarp_config); void setPrewarp(std::string prewarp_config);
// Update the detection mask without reloading the library
void setMask(unsigned char* pixelData, int bytesPerPixel, int imgWidth, int imgHeight);
void setDetectRegion(bool detectRegion); void setDetectRegion(bool detectRegion);
void setTopN(int topN); void setTopN(int topN);

View File

@@ -680,6 +680,25 @@ namespace alpr
else else
prewarp->initialize(prewarp_config); prewarp->initialize(prewarp_config);
} }
void AlprImpl::setMask(unsigned char* pixelData, int bytesPerPixel, int imgWidth, int imgHeight) {
try
{
int arraySize = imgWidth * imgHeight * bytesPerPixel;
cv::Mat imgData = cv::Mat(arraySize, 1, CV_8U, pixelData);
cv::Mat mask = imgData.reshape(bytesPerPixel, imgHeight);
typedef std::map<std::string, AlprRecognizers>::iterator it_type;
for (it_type iterator = recognizers.begin(); iterator != recognizers.end(); iterator++)
iterator->second.plateDetector->setMask(mask);
}
catch (cv::Exception& e)
{
std::cerr << "Caught (and ignoring) error in setMask: " << e.msg << std::endl;
}
}
void AlprImpl::setDetectRegion(bool detectRegion) void AlprImpl::setDetectRegion(bool detectRegion)

View File

@@ -92,6 +92,7 @@ namespace alpr
void setCountry(std::string country); void setCountry(std::string country);
void setPrewarp(std::string prewarp_config); void setPrewarp(std::string prewarp_config);
void setMask(unsigned char* pixelData, int bytesPerPixel, int imgWidth, int imgHeight);
void setDetectRegion(bool detectRegion); void setDetectRegion(bool detectRegion);
void setTopN(int topn); void setTopN(int topn);