Skip to content
This repository has been archived by the owner on Mar 19, 2023. It is now read-only.

Commit

Permalink
Merge pull request #29 from robmarkcole/fix_bounding_box
Browse files Browse the repository at this point in the history
Fix bbox
  • Loading branch information
robmarkcole authored Jul 13, 2019
2 parents 36d06dd + 9694aca commit 4c55977
Show file tree
Hide file tree
Showing 5 changed files with 99 additions and 64 deletions.
17 changes: 7 additions & 10 deletions custom_components/deepstack_object/image_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,12 @@
})


def get_bounding_box(prediction):
"""
Returns the bounding box array from a prediction payload.
"""
x1 = prediction['x_min']
x2 = prediction['x_max']
y1 = prediction['y_min']
y2 = prediction['y_max']
return [x1, y1, x2, y2]
def draw_box(draw, prediction, color=(255, 0, 0)):
"""Draw bounding box on image."""
(left, right, top, bottom) = (
prediction['x_min'], prediction['x_max'], prediction['y_min'], prediction['y_max'])
draw.line([(left, top), (left, bottom), (right, bottom),
(right, top), (left, top)], width=5, fill=color)


def get_object_classes(predictions):
Expand Down Expand Up @@ -163,7 +160,7 @@ def save_image(self, image, predictions_json, target, directory):

for prediction in predictions_json:
if prediction['label'] == target:
draw.rectangle(get_bounding_box(prediction), outline='red')
draw_box(draw, prediction)

now = datetime.datetime.now().strftime('%Y-%m-%d-%H-%M-%S')
save_path = directory + 'deepstack_{}_{}.jpg'.format(target, now)
Expand Down

Large diffs are not rendered by default.

Binary file modified development/.ipynb_checkpoints/boxed_img-checkpoint.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
67 changes: 22 additions & 45 deletions development/Deepstack object detection.ipynb

Large diffs are not rendered by default.

Binary file modified development/boxed_img.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 4c55977

Please sign in to comment.