Skip to content
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

Double click rectangle change default width, height, location #6903

Open
TychoBomer opened this issue Jan 14, 2025 · 1 comment
Open

Double click rectangle change default width, height, location #6903

TychoBomer opened this issue Jan 14, 2025 · 1 comment

Comments

@TychoBomer
Copy link

Is your feature request related to a problem? Please describe.
So with the default double click event when selecting one object type (I am using rectangle), it spawns a rectangle (very nice).
Now hat default rectangle has a pre-defined width and height. I have one relatively small object in my dataset that I would like to annotate with a default width and height that is way smaller then the default one.

This object comes for 50 times more then other objects so it would save me a lot of time if i can just double click it.

Is this possible by modifiying something in the source code?

Thanks!

@heidi-humansignal
Copy link
Collaborator

Hello,

Hello,
Thank you for your question.
Yes, it is possible to change the default width and height of the rectangle created when you double-click in Label Studio. You can modify the default dimensions by adjusting the DEFAULT_DIMENSIONS constants in the source code.
Here are the steps to do this:

  1. Locate the Base.jsx file:
    The file is located at web/libs/editor/src/tools/Base.jsx in the Label Studio codebase.
    Link to Base.jsx on GitHub

  2. Modify the default rectangle dimensions:
    In the Base.jsx file, you will find the following constants:

    export const MIN_SIZE = { X: 3, Y: 3 }; export const DEFAULT_DIMENSIONS = { rect: { width: 30, height: 30 }, ellipse: { radius: 30 }, polygon: { length: 30 }, };

You can change the width and height values under rect to your desired default dimensions. For example, to set the default rectangle size to 10x10 pixels:

export const DEFAULT_DIMENSIONS = { rect: { width: 10, height: 10 }, ellipse: { radius: 30 }, polygon: { length: 30 }, };
  1. Rebuild Label Studio:
    After making the changes, rebuild the Label Studio frontend to apply the changes.
    Please refer to the Label Studio Contributor Guide for instructions on building the project.
    Please Note:
  • Modifying the source code may affect future updates and could lead to unexpected behavior. Make sure to document your changes and consider maintaining a fork of the repository if you plan to update Label Studio in the future.
    Alternative Approach:
    If modifying the source code is not preferable, consider using the copy-paste functionality:

  • Draw a rectangle with the desired size.

  • Use Ctrl+C (or Cmd+C on macOS) to copy the rectangle.

  • Use Ctrl+V (or Cmd+V) to paste it multiple times across your image.
    This method allows you to quickly replicate rectangles of the same size without altering the code.
    Let me know if you have any questions or need further assistance.
    Best regards,

Thank you,
Abu

Comment by Abubakar Saad
Workflow Run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants