-
Notifications
You must be signed in to change notification settings - Fork 91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to get character bbox annotation? #8
Comments
Hi, |
@moonbings |
I ask if I can get the word or sentence bbox |
Hi, You can modify https://github.com/clovaai/synthtiger/blob/master/examples/synthtiger/template.py#L177-L190 this code to get character/word bbox. Here's an example. def _generate_fg(self, color, style):
...
char_layers = [layers.TextLayer(char, **font) for char in chars]
self.shape.apply(char_layers)
self.layout.apply(char_layers, {"meta": {"vertical": self.vertical}})
layer = layers.Group(char_layers).merge()
self.color.apply([layer], color)
self.texture.apply([layer])
self.style.apply([layer], style)
self.style.apply(char_layers, style) # added
transform = self.transform.sample() # added
self.transform.apply([layer], transform) # changed
self.transform.apply(char_layers, transform) # added
self.fit.apply([layer])
self.fit.apply(char_layers) # changed
self.pad.apply([layer])
out = layer.output()
# change coordinates
for char_layer in char_layers:
char_layer.topleft -= layer.topleft
# get bboxes
char_bboxes = [char_layer.bbox for char_layer in char_layers] # [[left, top, width, height], ...]
word_bbox = utils.merge_bbox(char_bboxes) # [left, top, width, height]
return out, label, char_bboxes, word_bbox And then, you need to modify this part to save bboxes. After changing the template, you can generate data with following command.
Thanks. |
this project is very helpful for generating synth text for scene text recognition, and it seem to generate text image by combine several character images, but the outputs doesn't contain information of each character, is it possible to get character annotation, for example, each character and its location?
The text was updated successfully, but these errors were encountered: