How to make Vertical Text Dataset?
See original GitHub issueHello, I’m used your code for generating OCR dataset in many case. Thanks for your efforts really 😄
But, I want to make vertical text image…
https://github.com/ankush-me/SynthText/blob/master/text_utils.py#L165 this section would decide “text mask” rendering… but It’s hard to make vertical text data. At present, only horizontal characters are made.
on this line : https://github.com/ankush-me/SynthText/blob/master/text_utils.py#L219
original code :
newrect = font.get_rect(ch)
newrect.y = last_rect.y
if i > mid_idx:
newrect.topleft = (last_rect.topright[0]+2, newrect.topleft[1])
else:
newrect.topright = (last_rect.topleft[0]-2, newrect.topleft[1])
newrect.centery = max(newrect.height, min(fsize[1] - newrect.height, newrect.centery + curve[i]))
try:
bbrect = font.render_to(surf, newrect, ch, rotation=rots[i])
except ValueError:
bbrect = font.render_to(surf, newrect, ch)
bbrect.x = newrect.x + bbrect.x
bbrect.y = newrect.y - bbrect.y
bbs.append(np.array(bbrect))
last_rect = newrect
my code :
newrect = font.get_rect(ch)
# newrect.y = last_rect.y
newrect.x = last_rect.x
if i > mid_idx:
# print(ch, " <- right")
# newrect.topleft = (last_rect.topright[0] + 2, newrect.topleft[1])
# newrect.topleft = (last_rect.topright[0], newrect.topleft[1] + 2)
# newrect.topleft = (newrect.topright[0], last_rect.topleft[1] + 2)
# newrect.topright = (newrect.bottomright[0], last_rect.bottomright[1] + 3)
newrect.topleft = (newrect.bottomleft[0], last_rect.bottomleft[1] + 2)
else:
# print(ch, " <- left")
# newrect.topright = (last_rect.topleft[0] - 2, newrect.topleft[1])
# newrect.topright = (last_rect.topleft[0], newrect.topleft[1] - 2)
# newrect.topright = (newrect.topright[0], last_rect.topleft[1] - 2)
newrect.bottomright = (newrect.topright[0], last_rect.topright[1] - 2)
newrect.centery = max(newrect.height, min(fsize[1] - newrect.height, newrect.centery + curve[i]))
# newrect.centerx = max(newrect.width, min(fsize[0] - newrect.width, newrect.centerx + curve[i]))
try:
bbrect = font.render_to(surf, newrect, ch, rotation=rots[i])
except ValueError:
print("render error, without rotation..")
bbrect = font.render_to(surf, newrect, ch)
bbrect.x = newrect.x + bbrect.x
bbrect.y = newrect.y - bbrect.y
bbs.append(np.array(bbrect))
last_rect = newrect
sample result :
sample result with annotation :
The possibilities are there, but they are not perfect. I really need your help…
Thanks.
Issue Analytics
- State:
- Created 5 years ago
- Comments:16 (4 by maintainers)
Top Results From Across the Web
Simultaneous Recognition of Horizontal and Vertical Text in ...
Using these datasets, we proved that our proposed model can accurately recognize both vertical and horizontal text and can achieve ...
Read more >How to Make Text Vertical in Excel (2 Easy Ways) - ExcelDemy
Then, go to the Home tab> Orientation icon> click Vertical Text. Making Text Vertical in Excel. And now, your text will be vertically...
Read more >Development of Vertical Text Interpreter for Natural Scene ...
Vertical Text Interpreter detects and recognizes vertically oriented scene texts in natural scenes, including vertically-stacked texts, bottom- ...
Read more >How To Make Text Vertical In Google Sheets (Rotate Text)
Select the cells where you want to make the vertical · In the toolbar, click on the text rotation icon · Click on...
Read more >ABBYY FlexiCapture: Extracting Vertical Text - YouTube
Learn how to extract vertical text in ABBYY FlexiCapture.Thank you for watching our video! To find out more about UFC, Inc and the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Final Result :
I just changed render_multiline and render_sample in text_utils.py
` def render_multiline(self,font,text): “”" renders multiline TEXT on the pygame surface SURF with the font style FONT. A new line in text is denoted by \n, no other characters are escaped. Other forms of white-spaces should be converted to space.
in render_sample function, I just change
text = self.text_source.sample(nline,nchar,text_type)
to# text = self.text_source.sample(nline,nchar,text_type) text_arr = random.sample('ABCDEFGHIJKLMNOPQRSTUVWXYZ',3) text = ''.join(text_arr) + 'U' text2 = random.sample('0123456789',7) text2 = ''.join(text2) text = text + text2
It’s hard to explain but
ch_bounds.y didn’t act like horizontal case. So, one character of upside was always missing. Sample Result :
“surf_arr_pixel_alpha.png” from pygame.surfarray.pixels_alpha(surf) :
“surf_arr.png” from self.crop_safe(surf_pixels_alpha, rect_union, bbs, pad=5) :
“surf_arr_swapaxes.png” from surf_arr.swapaxes(0, 1) :
Anyway, the function: render_multiline(self, font, text) for vertical text would be below
Final Result :