Using utf-8 character length rather than num bytes

This commit is contained in:
Matt Hill
2015-04-26 22:10:39 -04:00
parent 9d7991857c
commit ca20a6c643
2 changed files with 12 additions and 3 deletions

View File

@@ -18,7 +18,8 @@
*/
#include "alpr_impl.h"
#include "prewarp.h"
#include "support/utf8.h"
void plateAnalysisThread(void* arg);
@@ -197,8 +198,9 @@ namespace alpr
if (pp >= topN)
break;
if (ppResults[pp].letters.size() >= config->postProcessMinCharacters &&
ppResults[pp].letters.size() <= config->postProcessMaxCharacters)
int plate_char_length = utf8::distance(ppResults[pp].letters.begin(), ppResults[pp].letters.end());
if (plate_char_length >= config->postProcessMinCharacters &&
plate_char_length <= config->postProcessMaxCharacters)
{
// Set our "best plate" match to either the first entry, or the first entry with a postprocessor template match
if (bestPlateIndex == 0 && ppResults[pp].matchesTemplate)
@@ -210,6 +212,11 @@ namespace alpr
aplate.matches_template = ppResults[pp].matchesTemplate;
plateResult.topNPlates.push_back(aplate);
}
else if (plate_char_length > config->postProcessMaxCharacters)
{
cout << "Not within character count... " << ppResults[pp].letters << endl;
cout << plate_char_length << endl;
}
}
if (plateResult.topNPlates.size() > bestPlateIndex)