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

Upgrade OpenCV version #557

Merged
merged 2 commits into from Dec 21, 2021
Merged

Conversation

leeping-ng
Copy link
Contributor

Closes #556.

  • 4.5.2.54 chosen due to factors mentioned in the issue.
  • unpinned dependency version as a good practice for releasing packages

Copy link
Contributor

@ongtw ongtw left a comment

Choose a reason for hiding this comment

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

Two minor technical notes for consideration.

@@ -162,7 +162,7 @@ def _draw_tag(
)
bbox_width = btm_right[0] - top_left[0]
offset = int((bbox_width - text_width) / 2)
position = (int(top_left[0] + offset), int(top_left[1] - baseline))
position = (top_left[0] + offset, int(top_left[1] - baseline))
Copy link
Contributor

Choose a reason for hiding this comment

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

cv2.getTextSize() returns (text_width, text_height), baseline, all of which are integers.
So there is no need to int() once the coords are integers.
The same applies to line 111 in bbox.py for _draw_label().

Verified from opencv C++ docs, source, and runtime printouts:
*getTextSize: text_width=<class 'int'>, text_height=<class 'int'>, baseline=<class 'int'>

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Wasn't able to find this, thanks! Updated.

@@ -59,4 +59,4 @@ def project_points_onto_original_image(
projected_points[:, 0] *= width
projected_points[:, 1] *= height

return projected_points
return projected_points.astype(int)
Copy link
Contributor

@ongtw ongtw Dec 20, 2021

Choose a reason for hiding this comment

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

Just a note that numpy.astype() does not round up the numbers:

>>> import numpy as np
>>> x = np.array([1.1, 2.5, 3.7])
>>> x
array([1.1, 2.5, 3.7])
>>> x.astype(int)
array([1, 2, 3])

If intention is to round, can do this:

>>> np.round(x).astype(int)
array([1, 2, 4])

NB: numpy implements the round-half-to-even method.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Implemented rounding for that extra bit of accuracy.

Copy link
Contributor

@ongtw ongtw left a comment

Choose a reason for hiding this comment

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

Good to go.

@ongtw ongtw merged commit 15aec8e into aisingapore:dev Dec 21, 2021
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.

Upgrade OpenCV Version
2 participants