diff --git a/modules/ximgproc/include/opencv2/ximgproc/edgeboxes.hpp b/modules/ximgproc/include/opencv2/ximgproc/edgeboxes.hpp index b413b8086..966f9cd09 100644 --- a/modules/ximgproc/include/opencv2/ximgproc/edgeboxes.hpp +++ b/modules/ximgproc/include/opencv2/ximgproc/edgeboxes.hpp @@ -74,8 +74,9 @@ public: @param edge_map edge image. @param orientation_map orientation map. @param boxes proposal boxes. + @param scores of the proposal boxes, provided a vector of float types. */ - CV_WRAP virtual void getBoundingBoxes(InputArray edge_map, InputArray orientation_map, CV_OUT std::vector &boxes) = 0; + CV_WRAP virtual void getBoundingBoxes(InputArray edge_map, InputArray orientation_map, CV_OUT std::vector &boxes, OutputArray scores = noArray()) = 0; /** @brief Returns the step size of sliding window search. */ diff --git a/modules/ximgproc/src/edgeboxes.cpp b/modules/ximgproc/src/edgeboxes.cpp index 1b05e7f43..fe454a8a9 100644 --- a/modules/ximgproc/src/edgeboxes.cpp +++ b/modules/ximgproc/src/edgeboxes.cpp @@ -48,7 +48,6 @@ OpenCV port by: Leonardo Lontra */ #include "precomp.hpp" - using namespace cv; using namespace std; @@ -79,7 +78,7 @@ public: float gamma, float kappa); - virtual void getBoundingBoxes(InputArray edge_map, InputArray orientation_map, std::vector &boxes) CV_OVERRIDE; + virtual void getBoundingBoxes(InputArray edge_map, InputArray orientation_map, std::vector &boxes, OutputArray scores = noArray()) CV_OVERRIDE; float getAlpha() const CV_OVERRIDE { return _alpha; } void setAlpha(float value) CV_OVERRIDE @@ -910,13 +909,14 @@ void EdgeBoxesImpl::boxesNms(Boxes &boxes, float thr, float eta, int maxBoxes) } -void EdgeBoxesImpl::getBoundingBoxes(InputArray edge_map, InputArray orientation_map, std::vector &boxes) +void EdgeBoxesImpl::getBoundingBoxes(InputArray edge_map, InputArray orientation_map, std::vector &boxes, OutputArray scores) { CV_Assert(edge_map.depth() == CV_32F); CV_Assert(orientation_map.depth() == CV_32F); Mat E = edge_map.getMat().t(); Mat O = orientation_map.getMat().t(); + std::vector _scores; h = E.cols; w = E.rows; @@ -931,9 +931,25 @@ void EdgeBoxesImpl::getBoundingBoxes(InputArray edge_map, InputArray orientation // create output boxes int n = (int) b.size(); boxes.resize(n); + + if (scores.needed()) + { + _scores.resize(n); + } + for(int i=0; i < n; i++) { boxes[i] = Rect((int)b[i].x + 1, (int)b[i].y + 1, (int)b[i].w, (int)b[i].h); + if (scores.needed()) + { + _scores[i] = b[i].score; + } + } + + // return scores if asked for + if (scores.needed()) + { + Mat(_scores).copyTo(scores); } }