Skip to content

Commit

Permalink
Add threshold for stopping criterion
Browse files Browse the repository at this point in the history
  • Loading branch information
hgaiser committed Oct 22, 2014
1 parent 3bc4956 commit f92293f
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion random/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ find_package(PythonLibs REQUIRED)
find_package(NumPy REQUIRED)
find_package(Objectness REQUIRED)

set(CMAKE_CXX_FLAGS "-std=c++11 -g")
set(CMAKE_CXX_FLAGS "-std=c++11 -O3")

include_directories(
include
Expand Down
Binary file removed random/src/.main.cpp.swo
Binary file not shown.
8 changes: 4 additions & 4 deletions random/src/levels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ typedef std::vector<std::shared_ptr<Segment>> LevelSegments;
std::random_device rd_;
std::mt19937 gen_(rd_());

cv::Mat get_bboxes_(const std::vector<cv::Mat> & levels, int n) {
cv::Mat get_bboxes_(const std::vector<cv::Mat> & levels, int n, float thresh) {
#ifdef DEBUG
cv::namedWindow("Image", cv::WINDOW_NORMAL);
for (const auto & lev: levels) {
Expand Down Expand Up @@ -96,6 +96,7 @@ cv::Mat get_bboxes_(const std::vector<cv::Mat> & levels, int n) {
prior.push_back(lp.computeSelectionPrior(levels[i], level_segments[i]));
}

RandomStoppingCriterion stop(thresh);
for (int i = 0; i < n; i++) {
int sid = rand() % segments_sum;

Expand All @@ -108,7 +109,6 @@ cv::Mat get_bboxes_(const std::vector<cv::Mat> & levels, int n) {
}

std::shared_ptr<Segment> s = lev[prior[j].poll()];
RandomStoppingCriterion stop;

while (s->neighbours.size() && stop.stop(seg, s->bbox()) == false) {
#ifdef DEBUG
Expand Down Expand Up @@ -173,7 +173,7 @@ cv::Mat get_bboxes_(const std::vector<cv::Mat> & levels, int n) {
return bboxes;
}

PyObject * get_bboxes(PyObject * levels_, int n) {
PyObject * get_bboxes(PyObject * levels_, int n, float thresh) {
NDArrayConverter cvt;
std::vector<cv::Mat> levels;

Expand All @@ -182,7 +182,7 @@ PyObject * get_bboxes(PyObject * levels_, int n) {
for (int i = 0; i < nrlevels; i++)
levels.push_back(cvt.toMat(data[i]));

return cvt.toNDArray(get_bboxes_(levels, n));
return cvt.toNDArray(get_bboxes_(levels, n, thresh));
}

static void init_ar() {
Expand Down
2 changes: 1 addition & 1 deletion random/src/random_stopping_criterion.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

class RandomStoppingCriterion : public StoppingCriterion {
public:
RandomStoppingCriterion() : threshold(0.95f) {//threshold(dis(gen)) {
RandomStoppingCriterion(float thresh = 0.85f) : threshold(thresh) {//threshold(dis(gen)) {
}

bool stop(const cv::Mat & image, cv::Rect roi) {
Expand Down

0 comments on commit f92293f

Please sign in to comment.