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

Commit

Permalink
Merge pull request #481 from yuyu2172/fix-flip-keypoint
Browse files Browse the repository at this point in the history
Fix flip_keypoint to accept keypoints on the edge
  • Loading branch information
Hakuyume authored Nov 29, 2017
2 parents 608cca8 + 542c3c7 commit f2aa567
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
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

0 comments on commit f2aa567

Please sign in to comment.