Hello when i custom parser classifier by function:
bool NvDsInferClassiferParseCustomSoftmax (std::vector<NvDsInferLayerInfo> const &outputLayersInfo,
NvDsInferNetworkInfo const &networkInfo,
float classifierThreshold,
std::vector<NvDsInferAttribute> &attrList,
std::string &descString)
{
/* Get the number of attributes supported by the classifier. */
unsigned int batch_size = outputLayersInfo.size();
/* Iterate through all the output coverage layers of the classifier.
*/
for (unsigned int l = 0; l < batch_size; l++)
{
/* outputCoverageBuffer for classifiers is usually a softmax layer.
* The layer is an array of probabilities of the object belonging
* to each class with each probability being in the range [0,1] and
* sum all probabilities will be 1.
*/
unsigned int numClasses = int(labels[l].size()) + 1;
// printf("%d",numClasses); 32
NvDsInferDimsCHW dims;
getDimsCHWFromDims(dims, outputLayersInfo[l].inferDims);
unsigned int Timestep = dims.c; //27
float *outputCoverageBuffer = (float *)outputLayersInfo[l].buffer;
bool attrFound = false;
NvDsInferAttribute attr;
std::string perdictext;
std::list <int> objList;
for (unsigned int k = 2; k < Timestep; k++)
{
float maxPixelValue = 0;
float curPixelValue = 0;
unsigned int index;
for (unsigned int c = k*numClasses; c < (k+1)*numClasses; c++)
{
curPixelValue = outputCoverageBuffer[c];
if (curPixelValue > maxPixelValue)
{
maxPixelValue = curPixelValue;
index = c - k*numClasses;
}
}
objList.push_back(index);
}
std::list<int>::iterator oldIndx;
std::list<int>::iterator curIndx;
std::list<int> objListRemoveOverloop;
for (int idx = 0 ; idx < int(objList.size()); idx++){
curIndx = std::next(objList.begin(), idx);
if (idx == 0){
objListRemoveOverloop.push_back(*curIndx);
oldIndx = curIndx;
}
else{
if (curIndx != oldIndx){
objListRemoveOverloop.push_back(*curIndx);
oldIndx = curIndx;
}
}
}
std::list<int>::iterator curI;
for (int i = 0 ; i < int(objListRemoveOverloop.size()); i++){
curI = std::next(objListRemoveOverloop.begin(), i);
if (*curI < int(labels[l].size())){
perdictext.append(labels[l][*curI]);
attrFound = true;
attr.attributeIndex = l;
attr.attributeValue = 0;
attr.attributeConfidence = 1.0;
}
}
std::cout << ' ' << perdictext;
if (attrFound)
{
attr.attributeLabel = perdictext.c_str();
//attr.attributeLabel = labels[l][1].c_str();
attrList.push_back(attr);
if (attr.attributeLabel)
descString.append(attr.attributeLabel).append(" ");
}
}
return true;
}
there is an error with label show object and on terminal show:
Pango-WARNING **: 12:56:28.228: Invalid UTF-8 string passed to pango_layout_set_text()
how to fix it