Merge pull request #25091 from Dhanwanth1803:scoreThresh

Fixes #25056 : Optimising postProcess(const std::vector<Mat>& output_blobs) #25091

Like mentioned in the issue #25056 , I think checking the condition with `scoreThreshold` and then assigning the bounding boxes can optimize the function pretty well. By doing this, we prevent allocating boxes to faces with scores below the threshold. It also reduces the amount of data that needs to be processed during the subsequent NMS step. Builds and passed locally.

- [X] I agree to contribute to the project under Apache 2 License.
- [X] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
- [X] The PR is proposed to the proper branch
- [X] There is a reference to the original bug report and related work
- [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable
      Patch to opencv_extra has the same branch name.
- [ ] The feature is well documented and sample code can be built with the project CMake

Co-authored-by: Dhanwanth1803 <dhanwanthvarala@gmail,com>
pull/25258/head
Dhanwanth1803 11 months ago committed by GitHub
parent e0b489e917
commit c04750ab57
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 3
      modules/objdetect/src/face_detect.cpp

@ -200,6 +200,9 @@ private:
float score = std::sqrt(cls_score * obj_score);
face.at<float>(0, 14) = score;
// Checking if the score meets the threshold before adding the face
if (score < scoreThreshold)
continue;
// Get bounding box
float cx = ((c + bbox_v[idx * 4 + 0]) * strides[i]);
float cy = ((r + bbox_v[idx * 4 + 1]) * strides[i]);

Loading…
Cancel
Save