22
33#include < cmath>
44#include < cstdint>
5+ #include < iostream>
56#include < rnexecutorch/Error.h>
67#include < rnexecutorch/ErrorCodes.h>
78#include < rnexecutorch/Log.h>
@@ -283,8 +284,8 @@ std::vector<types::Instance> BaseInstanceSegmentation::finalizeInstances(
283284 instances.resize (maxInstances);
284285 }
285286
286- for (int32_t i = 0 ; i < instances.size (); ++i) {
287- instances[i].instanceId = static_cast < int32_t >(i) ;
287+ for (int32_t i = 0 ; std::cmp_less (i, instances.size () ); ++i) {
288+ instances[i].instanceId = i ;
288289 }
289290
290291 return instances;
@@ -320,10 +321,12 @@ std::vector<types::Instance> BaseInstanceSegmentation::postprocess(
320321
321322 auto isValidDetection =
322323 [&allowedClasses, &confidenceThreshold](float score, int32_t labelIdx) {
323- if (score < confidenceThreshold)
324+ if (score < confidenceThreshold) {
324325 return false ;
325- if (!allowedClasses.empty () && allowedClasses.count (labelIdx) == 0 )
326+ }
327+ if (!allowedClasses.empty () && allowedClasses.count (labelIdx) == 0 ) {
326328 return false ;
329+ }
327330 return true ;
328331 };
329332
@@ -333,13 +336,15 @@ std::vector<types::Instance> BaseInstanceSegmentation::postprocess(
333336 auto [bboxModel, score, labelIdx] =
334337 extractDetectionData (bboxData, scoresData, i);
335338
336- if (!isValidDetection (score, labelIdx))
339+ if (!isValidDetection (score, labelIdx)) {
337340 continue ;
341+ }
338342
339343 utils::computer_vision::BBox bboxOriginal =
340344 bboxModel.scale (widthRatio, heightRatio);
341- if (!bboxOriginal.isValid ())
345+ if (!bboxOriginal.isValid ()) {
342346 continue ;
347+ }
343348
344349 cv::Mat logitsMat (maskH, maskW, CV_32FC1,
345350 const_cast <float *>(maskData + (i * maskH * maskW)));
0 commit comments