Skip to content

Commit fc979a8

Browse files
saskatchewancatchalalek
authored andcommitted
Merge pull request #2152 from saskatchewancatch:issue-2060
* issue-2060: implement ability to return scores for edgeboxes implementation * issue-2060: address feedback to add some foolproofing
1 parent 3244184 commit fc979a8

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

modules/ximgproc/include/opencv2/ximgproc/edgeboxes.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,9 @@ class CV_EXPORTS_W EdgeBoxes : public Algorithm
7474
@param edge_map edge image.
7575
@param orientation_map orientation map.
7676
@param boxes proposal boxes.
77+
@param scores of the proposal boxes, provided a vector of float types.
7778
*/
78-
CV_WRAP virtual void getBoundingBoxes(InputArray edge_map, InputArray orientation_map, CV_OUT std::vector<Rect> &boxes) = 0;
79+
CV_WRAP virtual void getBoundingBoxes(InputArray edge_map, InputArray orientation_map, CV_OUT std::vector<Rect> &boxes, OutputArray scores = noArray()) = 0;
7980

8081
/** @brief Returns the step size of sliding window search.
8182
*/

modules/ximgproc/src/edgeboxes.cpp

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ OpenCV port by: Leonardo Lontra <lhe dot lontra at gmail dot com>
4848
*/
4949

5050
#include "precomp.hpp"
51-
5251
using namespace cv;
5352
using namespace std;
5453

@@ -79,7 +78,7 @@ class EdgeBoxesImpl : public EdgeBoxes
7978
float gamma,
8079
float kappa);
8180

82-
virtual void getBoundingBoxes(InputArray edge_map, InputArray orientation_map, std::vector<Rect> &boxes) CV_OVERRIDE;
81+
virtual void getBoundingBoxes(InputArray edge_map, InputArray orientation_map, std::vector<Rect> &boxes, OutputArray scores = noArray()) CV_OVERRIDE;
8382

8483
float getAlpha() const CV_OVERRIDE { return _alpha; }
8584
void setAlpha(float value) CV_OVERRIDE
@@ -910,13 +909,14 @@ void EdgeBoxesImpl::boxesNms(Boxes &boxes, float thr, float eta, int maxBoxes)
910909
}
911910

912911

913-
void EdgeBoxesImpl::getBoundingBoxes(InputArray edge_map, InputArray orientation_map, std::vector<Rect> &boxes)
912+
void EdgeBoxesImpl::getBoundingBoxes(InputArray edge_map, InputArray orientation_map, std::vector<Rect> &boxes, OutputArray scores)
914913
{
915914
CV_Assert(edge_map.depth() == CV_32F);
916915
CV_Assert(orientation_map.depth() == CV_32F);
917916

918917
Mat E = edge_map.getMat().t();
919918
Mat O = orientation_map.getMat().t();
919+
std::vector<float> _scores;
920920

921921
h = E.cols;
922922
w = E.rows;
@@ -931,9 +931,25 @@ void EdgeBoxesImpl::getBoundingBoxes(InputArray edge_map, InputArray orientation
931931
// create output boxes
932932
int n = (int) b.size();
933933
boxes.resize(n);
934+
935+
if (scores.needed())
936+
{
937+
_scores.resize(n);
938+
}
939+
934940
for(int i=0; i < n; i++)
935941
{
936942
boxes[i] = Rect((int)b[i].x + 1, (int)b[i].y + 1, (int)b[i].w, (int)b[i].h);
943+
if (scores.needed())
944+
{
945+
_scores[i] = b[i].score;
946+
}
947+
}
948+
949+
// return scores if asked for
950+
if (scores.needed())
951+
{
952+
Mat(_scores).copyTo(scores);
937953
}
938954
}
939955

0 commit comments

Comments
 (0)