Skip to content

Commit

Permalink
added GetOverlayAlpha()
Browse files Browse the repository at this point in the history
  • Loading branch information
dusty-nv committed Mar 5, 2023
1 parent 634573a commit b75e824
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
18 changes: 18 additions & 0 deletions c/segNet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,9 @@ segNet* segNet::Create( const char* prototxt, const char* model, const char* lab
net->loadClassLabels(labels_path);
net->loadClassColors(colors_path);

// set overlay alpha value
net->SetOverlayAlpha(SEGNET_DEFAULT_ALPHA);

return net;
}

Expand Down Expand Up @@ -440,6 +443,21 @@ void segNet::SetClassColor( uint32_t classIndex, float r, float g, float b, floa
}


// GetOverlayAlpha
float segNet::GetOverlayAlpha() const
{
const uint32_t numClasses = GetNumClasses();

for( uint32_t n=0; n < numClasses; n++ )
{
if( !mColorsAlphaSet[n] )
return mClassColors[n].w;
}

return SEGNET_DEFAULT_ALPHA;
}


// SetOverlayAlpha
void segNet::SetOverlayAlpha( float alpha, bool explicit_exempt )
{
Expand Down
5 changes: 5 additions & 0 deletions c/segNet.h
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,11 @@ class segNet : public tensorNet
*/
void SetClassColor( uint32_t classIndex, float r, float g, float b, float a=255.0f );

/**
* Retrieve the overlay alpha blending value for classes that don't have it explicitly set.
*/
float GetOverlayAlpha() const;

/**
* Set overlay alpha blending value for all classes (between 0-255),
* (optionally except for those that have been explicitly set).
Expand Down

0 comments on commit b75e824

Please sign in to comment.