| 33 | namespace { |
| 34 | |
| 35 | TupleTensor3 LabelInto(Tensor &output, std::optional<Tensor> count, std::optional<Tensor> stats, Tensor &input, |
| 36 | NVCVConnectivityType connectivity, NVCVLabelType assignLabels, NVCVLabelMaskType maskType, |
| 37 | std::optional<Tensor> bgLabel, std::optional<Tensor> minThresh, std::optional<Tensor> maxThresh, |
| 38 | std::optional<Tensor> minSize, std::optional<Tensor> mask, std::optional<Stream> pstream) |
| 39 | { |
| 40 | if (!pstream) |
| 41 | { |
| 42 | pstream = Stream::Current(); |
| 43 | } |
| 44 | |
| 45 | auto op = CreateOperator<cvcuda::Label>(); |
| 46 | |
| 47 | ResourceGuard guard(*pstream); |
| 48 | guard.add(LockMode::LOCK_MODE_READ, {input}); |
| 49 | guard.add(LockMode::LOCK_MODE_WRITE, {output}); |
| 50 | guard.add(LockMode::LOCK_MODE_NONE, {*op}); |
| 51 | |
| 52 | if (count) |
| 53 | { |
| 54 | guard.add(LockMode::LOCK_MODE_WRITE, {*count}); |
| 55 | } |
| 56 | if (stats) |
| 57 | { |
| 58 | guard.add(LockMode::LOCK_MODE_WRITE, {*stats}); |
| 59 | } |
| 60 | if (bgLabel) |
| 61 | { |
| 62 | guard.add(LockMode::LOCK_MODE_READ, {*bgLabel}); |
| 63 | } |
| 64 | if (minThresh) |
| 65 | { |
| 66 | guard.add(LockMode::LOCK_MODE_READ, {*minThresh}); |
| 67 | } |
| 68 | if (maxThresh) |
| 69 | { |
| 70 | guard.add(LockMode::LOCK_MODE_READ, {*maxThresh}); |
| 71 | } |
| 72 | if (minSize) |
| 73 | { |
| 74 | guard.add(LockMode::LOCK_MODE_READ, {*minSize}); |
| 75 | } |
| 76 | if (mask) |
| 77 | { |
| 78 | guard.add(LockMode::LOCK_MODE_READ, {*mask}); |
| 79 | } |
| 80 | |
| 81 | op->submit(pstream->cudaHandle(), input, output, (bgLabel ? *bgLabel : nvcv::Tensor{nullptr}), |
| 82 | (minThresh ? *minThresh : nvcv::Tensor{nullptr}), (maxThresh ? *maxThresh : nvcv::Tensor{nullptr}), |
| 83 | (minSize ? *minSize : nvcv::Tensor{nullptr}), (count ? *count : nvcv::Tensor{nullptr}), |
| 84 | (stats ? *stats : nvcv::Tensor{nullptr}), (mask ? *mask : nvcv::Tensor{nullptr}), connectivity, |
| 85 | assignLabels, maskType); |
| 86 | |
| 87 | return TupleTensor3(std::move(output), count, stats); |
| 88 | } |
| 89 | |
| 90 | TupleTensor3 Label(Tensor &input, NVCVConnectivityType connectivity, NVCVLabelType assignLabels, |
| 91 | NVCVLabelMaskType maskType, bool count, bool stats, int maxLabels, std::optional<Tensor> bgLabel, |
no test coverage detected