Skip to content

Instantly share code, notes, and snippets.

@Lexie88rus
Created August 8, 2019 18:14
Show Gist options
  • Save Lexie88rus/ff7e57334061f95c6063b4de737a8f25 to your computer and use it in GitHub Desktop.
Save Lexie88rus/ff7e57334061f95c6063b4de737a8f25 to your computer and use it in GitHub Desktop.
Transform image with bounding box albumentations
# 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