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
Conversation
There was a problem hiding this 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)) |
There was a problem hiding this comment.
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'>
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good to go.
Closes #556.
4.5.2.54
chosen due to factors mentioned in the issue.