Skip to content

Instantly share code, notes, and snippets.

@ggarlic
Created July 14, 2016 09:54
Show Gist options
  • Save ggarlic/af7951eeba8f631a3031c0c473ab5750 to your computer and use it in GitHub Desktop.
Save ggarlic/af7951eeba8f631a3031c0c473ab5750 to your computer and use it in GitHub Desktop.
def _find_neg_rect(image, pos_rects):
image_width, image_height = image.shape
rand = partial(random.randint, 1)
while True:
x = rand(image_width - 1)
width = rand(image_width - x)
y = rand(image_height - 1)
height = rand(image_height - y)
random_rect = Rect(x, y, width, height)
if any(map(lambda x: is_same_target(random_rect, x, 0), pos_rect)):
return random_rect
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment