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

Drawing refactor #209

Merged
merged 4 commits into from
Nov 21, 2022
Merged

Drawing refactor #209

merged 4 commits into from
Nov 21, 2022

Conversation

javiber
Copy link
Collaborator

@javiber javiber commented Oct 26, 2022

  • Separated drawing.py into multiple files into a new module.
  • Merged drawing functions for TrackedObjects and Detections using the new Drawable interface
  • Encapsulated cv drawing into new Drawer class
  • Added Color palette concepts and changed how we define colors
  • Changed some default values to make the drawings look nicer

@javiber javiber force-pushed the drawing-refactor branch 5 times, most recently from 6326f1d to bd8262c Compare November 3, 2022 17:32
@javiber javiber marked this pull request as ready for review November 9, 2022 12:42
Copy link
Collaborator

@facundo-lezama facundo-lezama left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work @javiber! I left a bunch of comments, but it seems almost ready to merge.

norfair/drawing/color.py Outdated Show resolved Hide resolved
norfair/drawing/color.py Outdated Show resolved Hide resolved
norfair/drawing/color.py Outdated Show resolved Hide resolved
norfair/drawing/color.py Outdated Show resolved Hide resolved
norfair/drawing/absolute_grid.py Outdated Show resolved Hide resolved
text_size : Optional[float], optional
Size of the title, the value is used as a multiplier of the base size of the font.
By default the size is scaled automatically based on the frame size.
text_color : Optional[int], optional
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It isn't consistent with the type hint.

text_size = label_size
# end

if color is None:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

color shouldn't be None right? At least the type hint doesn't mention it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It shouldn't but it can happen when this function is called in draw_tracked_boxes so I added this here to make the function a bit more robust


if drawables is None:
return
if color is None:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

color shouldn't be None right? At least the type hint doesn't mention it.

Comment on lines 133 to 153
else:
obj_text_color = color
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we assign text_color or its parsed color to obj_text_color instead of color?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! I need to parse text_color and use that value here

Comment on lines +135 to +159
# the anchor will become the bottom-left of the text,
# we select-top left of the bbox compensating for the thickness of the box
text_anchor = (
points[0, 0] - thickness // 2,
points[0, 1] - thickness // 2 - 1,
)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this already done inside Drawer.text?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you mean the compensation for the thickness? that needs to be done twice, one considering the thickness of the box and the the other with the thickness of the text


Parameters
----------
string : str
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

string -> hex_value in docstring

- fixed a bug with the text color on draw_boxes.py and draw_points.py
- renamed params on color.py
- added mising typehints in color.py
- typos in color.py
- removed unused imports in absolute_grid.y
@javiber javiber merged commit 25d329a into master Nov 21, 2022
@javiber javiber deleted the drawing-refactor branch November 21, 2022 19:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants