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

Function CopyMakeBorderInto

python/mod_cvcuda/operators/OpCopyMakeBorder.cpp:35–65  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

33
34namespace {
35Tensor CopyMakeBorderInto(Tensor &output, Tensor &input, NVCVBorderType borderMode,
36 const std::vector<float> &borderValue, int top, int left, std::optional<Stream> pstream)
37{
38 if (!pstream)
39 {
40 pstream = Stream::Current();
41 }
42
43 size_t bValueDims = borderValue.size();
44 if (bValueDims > 4)
45 {
46 throw std::runtime_error(
47 util::FormatString("Channels of borderValue should <= 4, current is '%lu'", bValueDims));
48 }
49 float4 bValue;
50 for (size_t i = 0; i < 4; i++)
51 {
52 nvcv::cuda::GetElement(bValue, i) = bValueDims > i ? borderValue[i] : 0.f;
53 }
54
55 auto copyMakeBorder = CreateOperator<cvcuda::CopyMakeBorder>();
56
57 ResourceGuard guard(*pstream);
58 guard.add(LockMode::LOCK_MODE_READ, {input});
59 guard.add(LockMode::LOCK_MODE_WRITE, {output});
60 guard.add(LockMode::LOCK_MODE_NONE, {*copyMakeBorder});
61
62 copyMakeBorder->submit(pstream->cudaHandle(), input, output, top, left, borderMode, bValue);
63
64 return output;
65}
66
67Tensor CopyMakeBorder(Tensor &input, NVCVBorderType borderMode, const std::vector<float> &borderValue, int top,
68 int bottom, int left, int right, std::optional<Stream> pstream)

Callers 1

CopyMakeBorderFunction · 0.85

Calls 5

FormatStringFunction · 0.85
cudaHandleMethod · 0.80
sizeMethod · 0.45
addMethod · 0.45
submitMethod · 0.45

Tested by

no test coverage detected