Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Display polygon labels in the image itself. #483

Closed
krishvishal opened this issue Sep 12, 2019 · 15 comments
Closed

Display polygon labels in the image itself. #483

krishvishal opened this issue Sep 12, 2019 · 15 comments

Comments

@krishvishal
Copy link

krishvishal commented Sep 12, 2019

Right now to know the label assigned to a polygon we have to check by de-selecting that particular instance of the label. This is a trail and error method and takes considerable amount of to recheck which label a particular polygon has been assigned. Is there a way to display label names around each polygon?

@wkentaro wkentaro added enhancement pr help wanted Extra attention is needed labels Sep 19, 2019
@wkentaro
Copy link
Member

Currently, this feature is not supported.

@dexception
Copy link

Taking 10x more time to individually click and check category name.

This should be there from the very beginning.

@ashuezy
Copy link

ashuezy commented Sep 21, 2019

+1

4 similar comments
@deimsdeutsch
Copy link

+1

@jamessmith90
Copy link

+1

@uday60
Copy link

uday60 commented Sep 21, 2019

+1

@suman-19
Copy link

+1

@yuhorun
Copy link

yuhorun commented Sep 26, 2019

p.setPen(QColor(168, 34, 3))
p.setFont(QFont('Decorative', 20))
p.drawText(shape.points[0].x(),shape.points[0].y(), shape.label)

image

if anybody want be helped label image,please tell me,i can help you

@deimsdeutsch
Copy link

Which file i have to edit for this ?

@tboenig
Copy link

tboenig commented Sep 30, 2019

What @yuhorun suggests sounds good. @yuhorun you could suggest your suggestion @wkentaro in a branch.

@yuhorun
Copy link

yuhorun commented Oct 2, 2019

Which file i have to edit for this ?

unzip, and replace it in ***\site-packages\labelme\widgets\canvas.py

canvas.zip

@sarahmunirj
Copy link

hello can you help me with this, I try to make these changes but they don't appear in the app

@yuhorun
Copy link

yuhorun commented Oct 16, 2019

no problem,how can i help you?

@ratnadeepkedar
Copy link

ratnadeepkedar commented Jun 8, 2021

  • Go to Canvas.py file
  • find out the def paintEvent(self, event):
  • add below code in just before for loop and inside loop
    p.setPen(QtGui.QColor(168, 34, 3))
    p.setFont(QtGui.QFont('Decorative', 20))
    Shape.scale = self.scale
    for shape in self.shapes:
    p.drawText(shape.points[0].x(),shape.points[0].y(), shape.label)
  • You will see the below result
    image

@korhun
Copy link

korhun commented Oct 5, 2021

Thanks, @ratnadeepkedar. I've modified your answer a little:

            pixel = 1.0 / self.scale
            p.setFont(QtGui.QFont('Decorative', int(12 * pixel)))
            for shape in self.shapes:
                x, y = (min(shape.points[0].x(), shape.points[1].x()), shape.points[0].y() - pixel * 6) \
                    if shape.shape_type == "rectangle" else (shape.points[0].x(), shape.points[0].y() - pixel * 6)
                color = shape.line_color
                p.setPen(color.darker(200))
                p.drawText(x + pixel * 2, y + pixel * 2, shape.label)
                p.setPen(color)
                p.drawText(x + pixel, y + pixel, shape.label)
                p.setPen(color.lighter(200))
                p.drawText(x, y, shape.label)

@wkentaro wkentaro removed help wanted Extra attention is needed enhancement pr labels Jun 25, 2022
@labelmeai labelmeai locked and limited conversation to collaborators Jun 25, 2022
@wkentaro wkentaro converted this issue into discussion #1132 Jun 25, 2022

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests