diff --git a/modules/adas/tools/fcw_train/fcw_train.cpp b/modules/adas/tools/fcw_train/fcw_train.cpp index 6f28960f6..8f0375e5b 100644 --- a/modules/adas/tools/fcw_train/fcw_train.cpp +++ b/modules/adas/tools/fcw_train/fcw_train.cpp @@ -52,6 +52,7 @@ int main(int argc, char *argv[]) "{help | | print this message}" "{pos_path | pos | path to training object samples}" "{bg_path | bg | path to background images}" + "{bg_per_image | 5 | number of windows to sample per bg image}" "{feature_count | 10000 | number of features to generate}" "{weak_count | 100 | number of weak classifiers in cascade}" "{model_size | 40x40 | model size in pixels}" @@ -71,12 +72,10 @@ int main(int argc, char *argv[]) string bg_path = parser.get("bg_path"); string model_filename = parser.get("model_filename"); - cerr << pos_path << endl; - cerr << bg_path << endl; - ICFDetectorParams params; params.feature_count = parser.get("feature_count"); params.weak_count = parser.get("weak_count"); + params.bg_per_image = parser.get("bg_per_image"); string model_size = parser.get("model_size"); if( !read_model_size(model_size.c_str(), ¶ms.model_n_rows, diff --git a/modules/xobjdetect/include/opencv2/xobjdetect.hpp b/modules/xobjdetect/include/opencv2/xobjdetect.hpp index 110ac105a..d84f7b240 100644 --- a/modules/xobjdetect/include/opencv2/xobjdetect.hpp +++ b/modules/xobjdetect/include/opencv2/xobjdetect.hpp @@ -159,9 +159,10 @@ struct CV_EXPORTS ICFDetectorParams int weak_count; int model_n_rows; int model_n_cols; + int bg_per_image; ICFDetectorParams(): feature_count(UINT_MAX), weak_count(100), - model_n_rows(40), model_n_cols(40) + model_n_rows(56), model_n_cols(56), bg_per_image(5) {} }; diff --git a/modules/xobjdetect/src/icfdetector.cpp b/modules/xobjdetect/src/icfdetector.cpp index 0d2607af6..32a3a748f 100644 --- a/modules/xobjdetect/src/icfdetector.cpp +++ b/modules/xobjdetect/src/icfdetector.cpp @@ -97,11 +97,11 @@ void ICFDetector::train(const String& pos_path, { cout << setw(6) << (i + 1) << "/" << bg_filenames.size() << "\r"; Mat img = imread(bg_filenames[i]); - for( int j = 0; j < 50; - ++j, ++neg_count) + for( int j = 0; j < params.bg_per_image; ++j, ++neg_count) { Rect r; - r.x = rng.uniform(0, img.cols); r.width = rng.uniform(r.x + 1, img.cols); + r.x = rng.uniform(0, img.cols); + r.width = rng.uniform(r.x + 1, img.cols); r.y = rng.uniform(0, img.rows); r.height = rng.uniform(r.y + 1, img.rows);