MCPcopy Create free account
hub / github.com/PABannier/sam3.cpp / sam3_resolve_overlaps

Function sam3_resolve_overlaps

sam3.cpp:9550–9570  ·  view source on GitHub ↗

Resolve overlapping masks: higher-scoring instances take priority.

Source from the content-addressed store, hash-verified

9548
9549// Resolve overlapping masks: higher-scoring instances take priority.
9550static void sam3_resolve_overlaps(std::vector<sam3_detection>& dets) {
9551 if (dets.size() <= 1) return;
9552 const int w = dets[0].mask.width;
9553 const int h = dets[0].mask.height;
9554 if (w == 0 || h == 0) return;
9555 std::sort(dets.begin(), dets.end(), [](const sam3_detection& a, const sam3_detection& b) {
9556 return a.score > b.score;
9557 });
9558 const int n = w * h;
9559 for (int i = 0; i < n; ++i) {
9560 bool claimed = false;
9561 for (auto& det : dets) {
9562 if (det.mask.data.empty()) continue;
9563 if (claimed) {
9564 det.mask.data[i] = 0;
9565 } else if (det.mask.data[i] > 127) {
9566 claimed = true;
9567 }
9568 }
9569 }
9570}
9571
9572/*****************************************************************************
9573** Post-processing: NMS, bilinear interpolation, mask binarization

Callers 2

sam3_track_frameFunction · 0.85
sam3_propagate_frameFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected