mirror of
https://github.com/kerberos-io/openalpr-base.git
synced 2025-10-06 07:16:56 +08:00
Added setMask function to main ALPR API
This commit is contained in:
@@ -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)
|
||||||
{
|
{
|
||||||
|
@@ -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);
|
||||||
|
@@ -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)
|
||||||
|
@@ -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);
|
||||||
|
Reference in New Issue
Block a user