(self, image, instance)
| 76 | |
| 77 | |
| 78 | def crop_image(self, image, instance): |
| 79 | """ |
| 80 | |
| 81 | """ |
| 82 | x_min, y_min = instance.x_min, instance.y_min |
| 83 | x_max, y_max = instance.x_max, instance.y_max |
| 84 | print(x_min, y_min, x_max, y_max) |
| 85 | logger.debug(f"Min Coordinates: ({x_min},{y_min})") |
| 86 | logger.debug(f"Max Coordinates: ({x_max},{y_max})") |
| 87 | cropped_image = image[y_min : y_max, x_min : x_max] |
| 88 | |
| 89 | # Maintain aspect ratio |
| 90 | |
| 91 | # Check for div by 0 errors |
| 92 | if cropped_image.shape[0] == 0 or cropped_image.shape[1] == 0: |
| 93 | return False |
| 94 | |
| 95 | ratio = min((160 / cropped_image.shape[0]), |
| 96 | (160 / cropped_image.shape[1])) |
| 97 | |
| 98 | shape_x = int(round(cropped_image.shape[0] * ratio)) |
| 99 | shape_y = int(round(cropped_image.shape[1] * ratio)) |
| 100 | |
| 101 | resized_cropped_image = imresize(cropped_image, |
| 102 | (shape_x, shape_y)) |
| 103 | |
| 104 | return resized_cropped_image |
| 105 | |
| 106 | def upload(self, session, instance, cropped_image): |
| 107 |
no test coverage detected