Created
August 8, 2019 18:14
-
-
Save Lexie88rus/ff7e57334061f95c6063b4de737a8f25 to your computer and use it in GitHub Desktop.
Transform image with bounding box albumentations
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create bounding boxes from mask with cv2 | |
import cv2 | |
mask = cv2.cvtColor(mask, cv2.COLOR_BGR2GRAY) | |
bboxes = cv2.boundingRect(cv2.findNonZero(mask)) | |
# Augment image and bounding box | |
augmented_boxes = aug_pipeline(image = image, bboxes = [bboxes]) | |
# Access augmented image and bounding box | |
image_aug = augmented_boxes['image'][0] | |
box_aug = augmented_boxes['bboxes'][0] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment