From 46110c3d9eceb49626c43d1e36b6aca3a7b8ce2d Mon Sep 17 00:00:00 2001 From: Daniel Canelhas Date: Mon, 30 Sep 2019 23:46:46 +0200 Subject: [PATCH] Merge pull request #1993 from dcanelhas:master waldboost_detector train: avoid failed asserts while training by exiting early * Avoids a failed assert which crashes training * xobjdetect: improve waldboost messages --- modules/xobjdetect/src/waldboost.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/modules/xobjdetect/src/waldboost.cpp b/modules/xobjdetect/src/waldboost.cpp index d1dbdfd84..38b18a9df 100644 --- a/modules/xobjdetect/src/waldboost.cpp +++ b/modules/xobjdetect/src/waldboost.cpp @@ -333,7 +333,14 @@ void WaldBoost::fit(Mat& data_pos, Mat& data_neg) if (loss < 1e-50 || min_err > 0.5) { - std::cerr << "Stopping early" << std::endl; + std::cerr << "Stopping early. loss=" << loss << " min_err=" << min_err << std::endl; + weak_count_ = i + 1; + break; + } + + // Avoid crashing on next Mat creation + if (pos <= 1) { + std::cerr << "Stopping early. pos=" << pos << std::endl; weak_count_ = i + 1; break; }