| 38 | namespace |
| 39 | { |
| 40 | inline void configure_crop(const ICLTensor *input, |
| 41 | ICLTensor *crop_boxes, |
| 42 | ICLTensor *box_ind, |
| 43 | ICLTensor *output, |
| 44 | uint32_t crop_box_ind, |
| 45 | Coordinates &start, |
| 46 | Coordinates &end, |
| 47 | uint32_t &batch_index) |
| 48 | { |
| 49 | batch_index = *(reinterpret_cast<int32_t *>(box_ind->ptr_to_element(Coordinates(crop_box_ind)))); |
| 50 | |
| 51 | // _crop_box_ind is used to index crop_boxes and retrieve the appropriate crop box. |
| 52 | // The crop box is specified by normalized coordinates [y0, x0, y1, x1]. |
| 53 | const float x0 = *reinterpret_cast<const float *>(crop_boxes->ptr_to_element(Coordinates(1, crop_box_ind))); |
| 54 | const float y0 = *reinterpret_cast<const float *>(crop_boxes->ptr_to_element(Coordinates(0, crop_box_ind))); |
| 55 | const float x1 = *reinterpret_cast<const float *>(crop_boxes->ptr_to_element(Coordinates(3, crop_box_ind))); |
| 56 | const float y1 = *reinterpret_cast<const float *>(crop_boxes->ptr_to_element(Coordinates(2, crop_box_ind))); |
| 57 | // The normalized coordinates are scaled to retrieve the floating point image coordinates which are rounded to integers. |
| 58 | start = Coordinates(std::floor(x0 * (input->info()->tensor_shape()[1] - 1) + 0.5f), |
| 59 | std::floor(y0 * (input->info()->tensor_shape()[2] - 1) + 0.5f)); |
| 60 | end = Coordinates(std::floor(x1 * (input->info()->tensor_shape()[1] - 1) + 0.5f), |
| 61 | std::floor(y1 * (input->info()->tensor_shape()[2] - 1) + 0.5f)); |
| 62 | const TensorShape out_shape(input->info()->tensor_shape()[0], static_cast<uint32_t>(abs(end[0] - start[0])) + 1, |
| 63 | static_cast<uint32_t>(abs(end[1] - start[1])) + 1); |
| 64 | output->info()->set_tensor_shape(out_shape); |
| 65 | } |
| 66 | } // namespace |
| 67 | |
| 68 | CLCropResize::CLCropResize() |
no test coverage detected