| 33 | |
| 34 | namespace { |
| 35 | Tensor 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 | |
| 67 | Tensor CopyMakeBorder(Tensor &input, NVCVBorderType borderMode, const std::vector<float> &borderValue, int top, |
| 68 | int bottom, int left, int right, std::optional<Stream> pstream) |
no test coverage detected