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

modified the flip augmentation part #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
10 changes: 7 additions & 3 deletions BoundingBoxAugmenters.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,12 +382,14 @@ def horizontalFlip(self, frame = None, boundingBoxes = None):
raise TypeError("ERROR: Bounding boxes parameter has to be of type list.")
# Local variables
localFrame = frame[:, :, :]
# Copy of Local variables
tmpFrame = localFrame.copy()
# Flip only the pixels inside the bounding boxes
for bndbox in boundingBoxes:
# Decode bounding box
ix, iy, x, y = bndbox
# Flip ROI
roi = cv2.flip(localFrame[iy:y, ix:x, :], 1)
roi = cv2.flip(tmpFrame[iy:y, ix:x, :], 1)
localFrame[iy:y, ix:x, :] = roi
return localFrame

Expand All @@ -410,12 +412,14 @@ def verticalFlip(self, frame = None, boundingBoxes = None):
raise TypeError("ERROR: Bounding boxes parameter has to be of type list.")
# Local variables
localFrame = frame[:, :, :]
# Copy of Local variables
tmpFrame = localFrame.copy()
# Flip only the pixels inside the bounding boxes
for bndbox in boundingBoxes:
# Decode bounding box
ix, iy, x, y = bndbox
# Flip ROI
roi = cv2.flip(localFrame[iy:y, ix:x, :], 0)
# Flip ROI in Local variables
roi = cv2.flip(tmpFrame[iy:y, ix:x, :], 0)
localFrame[iy:y, ix:x, :] = roi
return localFrame

Expand Down
2 changes: 1 addition & 1 deletion BoundingBoxAugmenters_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def test_horizontal_flip(self):

def test_vertical_flip(self):
if (self.visualize):
# Perform horizontal flip.
# Perform vertical flip.
frame = self.augmenter.verticalFlip(frame = self.frame.copy(),
boundingBoxes = self.bndboxes)
# Visualization.
Expand Down