Inference confidence and image class description

I noticed in detectnet-camera.cpp that there’s a bit of code to display confidence and description, but it’s commented out:

/*if( font != NULL )
{
	char str[256];
	sprintf(str, "%05.2f%% %s", confidence * 100.0f, net->GetClassDesc(img_class));		

	font->RenderOverlay((float4*)imgRGBA, (float4*)imgRGBA, camera->GetWidth(), camera->GetHeight(),
	str, 10, 10, make_float4(255.0f, 255.0f, 255.0f, 255.0f));
}*/

Here is the error on TX2:

/home/nvidia/jetson-inference/detectnet-camera/detectnet-camera.cpp:316:59: error: ‘class detectNet’ has no member named ‘GetClassDesc’
     sprintf(str, "%05.2f%% %s", confidence * 100.0f, net->GetClassDesc(img_clas
                                                           ^
/home/nvidia/jetson-inference/detectnet-camera/detectnet-camera.cpp:316:72: error: ‘img_class’ was not declared in this scope
  sprintf(str, "%05.2f%% %s", confidence * 100.0f, net->GetClassDesc(img_class))

I tried uncommenting it with no success. Are there any plans to get it working? … Thanks.

Hi, that uncommented code was left over from imagenet-camera program, which only classifies one object per image.

If you wanted to render the confidence for detectnet-camera, you would have to do a similar cudaFont::Overlay() call at the end of this loop (at this point of the code), which iterates through the detected objects.

Thanks for reply.
I’m not worried too much about having the data displayed in the screen overlay - I just need it in the serial console. However, it looks to me like both image class and confidence is exclusive to imagenet-camera.cpp … and functions in imagenet-camera and detectnet-camera don’t play together yet?

It would be really great to have confidence and class in detectnet-camera.cpp !!!

The confidence and class of each bounding box is already returned in the detectnet-camera code here, via the confCPU pointer.

Each bounding box has two float entries in the confCPU array, first is the confidence and then is the object class.

You can loop through the bounding boxes and confidence/class list like so:

for( int n=0; n < numBoundingBoxes; n++ )
{
     const float obj_conf = confCPU[n*2];
     const int obj_class = confCPU[n*2+1];
     float* bb = bbCPU + (n * 4);
}

Perfect - I’ll try that in the morning.

… Confidence works well, but cant test image class as I’m just using one class at the moment - it just gives zero - I’m sure it will work with another model!

It’s a shame I can’t get the image description string eg “dog”. I’m guessing that’s embedded somewhere deep within imagenet-camera and is not easily accessible?

Thanks !!!

Unlike the imageNet models, detectNet models do not have a file listing the object class names. Typically the imageNet models have 1000 object classes, so that file with the class names is important. However detectNet models usually only have a single or few object classes.

You could write your own object class file for the detectNet models, or have the class names embedded in your code.

Thanks - I’ll make sure I don’t try to work with too many classes in detectnet :)