mirror of
https://github.com/kerberos-io/openalpr-base.git
synced 2025-10-06 01:27:03 +08:00
Made binarizefontsheet utility ignore whitespace
This commit is contained in:
@@ -246,26 +246,33 @@ int main(int argc, char** argv) {
|
|||||||
if (debug)
|
if (debug)
|
||||||
show_debug_image(rectangles, thresholds[t]);
|
show_debug_image(rectangles, thresholds[t]);
|
||||||
|
|
||||||
int text_content_length = utf8::distance(text_content.begin(), text_content.end());
|
vector<std::string> valid_characters;
|
||||||
if (rectangles.size() != text_content_length - 1)
|
|
||||||
|
string::iterator utf_iterator = text_content.begin();
|
||||||
|
while (utf_iterator < text_content.end())
|
||||||
{
|
{
|
||||||
cout << "Number of blobs (" << rectangles.size() << ") != number of characters (" << text_content_length - 1 << ")" << endl;
|
int cp = utf8::next(utf_iterator, text_content.end());
|
||||||
|
string utf_character = utf8chr(cp);
|
||||||
|
if (utf_character != "\n" && utf_character != " " && utf_character != " ")
|
||||||
|
valid_characters.push_back(utf_character);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rectangles.size() != valid_characters.size())
|
||||||
|
{
|
||||||
|
cout << "Number of blobs (" << rectangles.size() << ") != number of characters (" << valid_characters.size() << ")" << endl;
|
||||||
cout << "Skipping..." << endl;
|
cout << "Skipping..." << endl;
|
||||||
//return 1;
|
//return 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
string::iterator utf_iterator = text_content.begin();
|
|
||||||
|
|
||||||
|
|
||||||
for (unsigned int i = 0; i < rectangles.size(); i++)
|
for (unsigned int i = 0; i < rectangles.size(); i++)
|
||||||
{
|
{
|
||||||
Rect mr = rectangles[i];
|
Rect mr = rectangles[i];
|
||||||
Mat croppedChar = thresholds[t](mr);
|
Mat croppedChar = thresholds[t](mr);
|
||||||
|
|
||||||
int cp = utf8::next(utf_iterator, text_content.end());
|
|
||||||
stringstream ss;
|
stringstream ss;
|
||||||
ss << out_dir << "/" << utf8chr(cp) << "-" << font_sheet_index << "-" << t << "-" << i << ".png";
|
ss << out_dir << "/" << valid_characters[i] << "-" << font_sheet_index << "-" << t << "-" << i << ".png";
|
||||||
|
|
||||||
imwrite(ss.str(), croppedChar);
|
imwrite(ss.str(), croppedChar);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user