| 56 | } |
| 57 | |
| 58 | Tensor CenterCrop(Tensor &input, const std::tuple<int, int> &cropSize, std::optional<Stream> pstream) |
| 59 | { |
| 60 | auto info = nvcv::TensorLayoutInfoImage::Create(input.layout()); |
| 61 | if (!info) |
| 62 | { |
| 63 | throw std::invalid_argument("Non-supported tensor layout"); |
| 64 | } |
| 65 | |
| 66 | int iwidth = info->idxWidth(); |
| 67 | int iheight = info->idxHeight(); |
| 68 | |
| 69 | NVCV_ASSERT(iwidth >= 0 && "All images have width"); |
| 70 | NVCV_ASSERT(iheight >= 0 && "All images have height"); |
| 71 | |
| 72 | // Use cropSize (width, height) for output |
| 73 | Shape out_shape = CreateShape(input.shape()); |
| 74 | out_shape[iwidth] = std::get<0>(cropSize); |
| 75 | out_shape[iheight] = std::get<1>(cropSize); |
| 76 | |
| 77 | Tensor output = Tensor::Create(out_shape, input.dtype(), input.layout()); |
| 78 | |
| 79 | return CenterCropInto(output, input, cropSize, pstream); |
| 80 | } |
| 81 | |
| 82 | } // namespace |
| 83 |
nothing calls this directly
no test coverage detected