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

Function Label

python/mod_cvcuda/operators/OpLabel.cpp:90–138  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

88}
89
90TupleTensor3 Label(Tensor &input, NVCVConnectivityType connectivity, NVCVLabelType assignLabels,
91 NVCVLabelMaskType maskType, bool count, bool stats, int maxLabels, std::optional<Tensor> bgLabel,
92 std::optional<Tensor> minThresh, std::optional<Tensor> maxThresh, std::optional<Tensor> minSize,
93 std::optional<Tensor> mask, std::optional<Stream> pstream)
94{
95 constexpr nvcv::DataType outType = nvcv::TYPE_S32;
96
97 auto inputData = input.exportData<nvcv::TensorDataStridedCuda>();
98 if (!inputData)
99 {
100 throw nvcv::Exception(nvcv::Status::ERROR_INVALID_ARGUMENT, "Input must be a valid CUDA strided tensor");
101 }
102 auto inAccess = nvcv::TensorDataAccessStridedImagePlanar::Create(*inputData);
103 if (!inAccess)
104 {
105 throw nvcv::Exception(nvcv::Status::ERROR_INVALID_ARGUMENT, "Input must be a valid image-based tensor");
106 }
107 int numSamples = inAccess->numSamples();
108
109 Tensor output = Tensor::Create(input.shape(), outType);
110 std::optional<Tensor> countTensor, statsTensor;
111
112 if (count)
113 {
114 countTensor = Tensor::Create({{numSamples}, "N"}, outType);
115 }
116 if (stats)
117 {
118 int numStats = 1;
119 if (connectivity == NVCV_CONNECTIVITY_4_2D || connectivity == NVCV_CONNECTIVITY_8_2D)
120 {
121 numStats = 7;
122 }
123 if (connectivity == NVCV_CONNECTIVITY_6_3D || connectivity == NVCV_CONNECTIVITY_26_3D)
124 {
125 numStats = 9;
126 }
127
128 statsTensor = Tensor::Create(
129 {
130 {numSamples, maxLabels, numStats},
131 "NMA"
132 },
133 outType);
134 }
135
136 return LabelInto(output, countTensor, statsTensor, input, connectivity, assignLabels, maskType, bgLabel, minThresh,
137 maxThresh, minSize, mask, pstream);
138}
139
140} // namespace
141

Callers

nothing calls this directly

Calls 4

ExceptionClass · 0.85
LabelIntoFunction · 0.85
numSamplesMethod · 0.45
shapeMethod · 0.45

Tested by

no test coverage detected