Skip to content
This repository has been archived by the owner on Jul 2, 2021. It is now read-only.

Fix flip_keypoint to accept keypoints on the edge #481

Merged
merged 1 commit into from
Nov 29, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions chainercv/transforms/keypoint/flip_keypoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def flip_keypoint(keypoint, size, y_flip=False, x_flip=False):
H, W = size
keypoint = keypoint.copy()
if y_flip:
keypoint[:, 0] = H - 1 - keypoint[:, 0]
keypoint[:, 0] = H - keypoint[:, 0]
if x_flip:
keypoint[:, 1] = W - 1 - keypoint[:, 1]
keypoint[:, 1] = W - keypoint[:, 1]
return keypoint
4 changes: 2 additions & 2 deletions tests/transforms_tests/keypoint_tests/test_flip_keypoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ def test_flip_keypoint(self):

out = flip_keypoint(keypoint, size=(34, 32), y_flip=True)
keypoint_expected = keypoint.copy()
keypoint_expected[:, 0] = 33 - keypoint[:, 0]
keypoint_expected[:, 0] = 34 - keypoint[:, 0]
np.testing.assert_equal(out, keypoint_expected)

out = flip_keypoint(keypoint, size=(34, 32), x_flip=True)
keypoint_expected = keypoint.copy()
keypoint_expected[:, 1] = 31 - keypoint[:, 1]
keypoint_expected[:, 1] = 32 - keypoint[:, 1]
np.testing.assert_equal(out, keypoint_expected)


Expand Down