MCPcopy Create free account
hub / github.com/CVCUDA/CV-CUDA / CenterCrop

Function CenterCrop

python/mod_cvcuda/operators/OpCenterCrop.cpp:58–80  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

56}
57
58Tensor 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

Callers

nothing calls this directly

Calls 7

CreateShapeFunction · 0.85
CenterCropIntoFunction · 0.85
idxWidthMethod · 0.80
idxHeightMethod · 0.80
layoutMethod · 0.45
shapeMethod · 0.45
dtypeMethod · 0.45

Tested by

no test coverage detected