-
Notifications
You must be signed in to change notification settings - Fork 255
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
Add optimized IoU function #226
Conversation
3e1f820
to
ab5eda7
Compare
norfair/distances.py
Outdated
to be in `[x_min, y_min, x_max, y_max]` format. | ||
|
||
Normal IoU is 1 when the boxes are the same and 0 when they don't overlap, | ||
to transform that into a distance that makes sense we return `1 - iou`. | ||
|
||
Performs faster but errors might be cryptic if the bounding boxes are not valid. |
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.
Should we add some checks?
d905f71
to
e1df7a5
Compare
The distance. | ||
""" | ||
return _iou(detection.points, tracked_object.estimate) | ||
iou_opt = iou # deprecated |
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.
Is it still necessary with the change in line 415?
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.
I did this so that users can still import iou_opt
as a function, trying not to make that many breaking changes.
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.
LGTM but I have a question regarding the tests
tests/test_distances.py
Outdated
np.testing.assert_almost_equal(iou.distance_function(det, obj), 0) | ||
np.testing.assert_almost_equal(iou_opt.distance_function(det, obj), 0) | ||
det.points = det.points.reshape(1, 4) | ||
obj.estimate = obj.estimate.reshape(1, 4) |
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.
why is the reshaping necessary?
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.
As we discussed, I simplified these.
e1df7a5
to
02af4c5
Compare
02af4c5
to
c316914
Compare
Also enables kwargs to be passed to scipy's cdist
This PR adds a new implementation for the IoU distance calculation by leveraging
numpy
for vectorized calculations.Changes include:
iou_opt
Pending: