diff --git a/apps/CMakeLists.txt b/apps/CMakeLists.txt deleted file mode 100644 index cb397c3f7..000000000 --- a/apps/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -add_definitions(-D__OPENCV_BUILD=1) -link_libraries(${OPENCV_LINKER_LIBS}) - -add_subdirectory(icf) diff --git a/modules/adas/CMakeLists.txt b/modules/adas/CMakeLists.txt new file mode 100644 index 000000000..8284dfc57 --- /dev/null +++ b/modules/adas/CMakeLists.txt @@ -0,0 +1,4 @@ +set(the_description "Automatic driver assistance algorithms") +ocv_define_module(adas opencv_xobjdetect) + +add_subdirectory(tools) diff --git a/apps/icf/CMakeLists.txt b/modules/adas/tools/CMakeLists.txt similarity index 86% rename from apps/icf/CMakeLists.txt rename to modules/adas/tools/CMakeLists.txt index 12c24fbd0..8bf244807 100644 --- a/apps/icf/CMakeLists.txt +++ b/modules/adas/tools/CMakeLists.txt @@ -1,7 +1,8 @@ -set(name icf) +set(name fcw-train) set(the_target opencv_${name}) -set(OPENCV_${the_target}_DEPS opencv_core opencv_imgproc opencv_highgui) +set(OPENCV_${the_target}_DEPS opencv_xobjdetect) + ocv_check_dependencies(${OPENCV_${the_target}_DEPS}) if(NOT OCV_DEPENDENCIES_FOUND) @@ -24,7 +25,7 @@ set_target_properties(${the_target} PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${LIBRARY_OUTPUT_PATH} RUNTIME_OUTPUT_DIRECTORY ${EXECUTABLE_OUTPUT_PATH} INSTALL_NAME_DIR lib - OUTPUT_NAME "opencv_trainicfcascade") + OUTPUT_NAME ${the_target}) if(ENABLE_SOLUTION_FOLDERS) set_target_properties(${the_target} PROPERTIES FOLDER "applications") diff --git a/apps/icf/main.cpp b/modules/adas/tools/fcw-train.cpp similarity index 95% rename from apps/icf/main.cpp rename to modules/adas/tools/fcw-train.cpp index 2f23ecd4f..a24771fe8 100644 --- a/apps/icf/main.cpp +++ b/modules/adas/tools/fcw-train.cpp @@ -17,11 +17,14 @@ using std::stringstream; #include using cv::Rect; -#include "icfdetector.hpp" -#include "waldboost.hpp" +#include +#include using cv::adas::ICFDetectorParams; using cv::adas::ICFDetector; +using cv::adas::WaldBoost; +using cv::adas::WaldBoostParams; +using cv::Mat; static bool read_pos_int(const char *str, int *n) { @@ -171,6 +174,9 @@ int main(int argc, char *argv[]) try { + WaldBoostParams p; + WaldBoost b(p); + b.train(Mat(), Mat()); ICFDetector detector; vector filenames; vector< vector > labelling; diff --git a/modules/xobjdetect/CMakeLists.txt b/modules/xobjdetect/CMakeLists.txt new file mode 100644 index 000000000..82488a70e --- /dev/null +++ b/modules/xobjdetect/CMakeLists.txt @@ -0,0 +1,2 @@ +set(the_description "Object detection algorithms") +ocv_define_module(xobjdetect opencv_core opencv_imgproc opencv_highgui) diff --git a/modules/xobjdetect/include/opencv2/xobjdetect.hpp b/modules/xobjdetect/include/opencv2/xobjdetect.hpp new file mode 100644 index 000000000..520f5b375 --- /dev/null +++ b/modules/xobjdetect/include/opencv2/xobjdetect.hpp @@ -0,0 +1,9 @@ +#ifndef __OPENCV_XOBJDETECT_XOBJDETECT_HPP__ +#define __OPENCV_XOBJDETECT_XOBJDETECT_HPP__ + +#include "xobjdetect/stump.hpp" +#include "xobjdetect/waldboost.hpp" +#include "xobjdetect/acffeature.hpp" +#include "xobjdetect/icfdetector.hpp" + +#endif /* __OPENCV_XOBJDETECT_XOBJDETECT_HPP__ */ diff --git a/apps/icf/acffeature.hpp b/modules/xobjdetect/include/opencv2/xobjdetect/acffeature.hpp similarity index 98% rename from apps/icf/acffeature.hpp rename to modules/xobjdetect/include/opencv2/xobjdetect/acffeature.hpp index 82ad9635a..06832d3e3 100644 --- a/apps/icf/acffeature.hpp +++ b/modules/xobjdetect/include/opencv2/xobjdetect/acffeature.hpp @@ -59,7 +59,7 @@ namespace adas */ void computeChannels(InputArray image, OutputArrayOfArrays channels); -class ACFFeatureEvaluator +class CV_EXPORTS ACFFeatureEvaluator { public: /* Construct evaluator, set features to evaluate */ diff --git a/apps/icf/icfdetector.hpp b/modules/xobjdetect/include/opencv2/xobjdetect/icfdetector.hpp similarity index 97% rename from apps/icf/icfdetector.hpp rename to modules/xobjdetect/include/opencv2/xobjdetect/icfdetector.hpp index 47400d021..e674c7096 100644 --- a/apps/icf/icfdetector.hpp +++ b/modules/xobjdetect/include/opencv2/xobjdetect/icfdetector.hpp @@ -52,7 +52,7 @@ namespace cv namespace adas { -struct ICFDetectorParams +struct CV_EXPORTS ICFDetectorParams { int feature_count; int weak_count; @@ -61,7 +61,7 @@ struct ICFDetectorParams double overlap; }; -class ICFDetector +class CV_EXPORTS ICFDetector { public: /* Train detector diff --git a/apps/icf/stump.hpp b/modules/xobjdetect/include/opencv2/xobjdetect/stump.hpp similarity index 98% rename from apps/icf/stump.hpp rename to modules/xobjdetect/include/opencv2/xobjdetect/stump.hpp index 9beed546a..8afa0080f 100644 --- a/apps/icf/stump.hpp +++ b/modules/xobjdetect/include/opencv2/xobjdetect/stump.hpp @@ -8,7 +8,7 @@ namespace cv namespace adas { -class Stump +class CV_EXPORTS Stump { public: diff --git a/apps/icf/waldboost.hpp b/modules/xobjdetect/include/opencv2/xobjdetect/waldboost.hpp similarity index 95% rename from apps/icf/waldboost.hpp rename to modules/xobjdetect/include/opencv2/xobjdetect/waldboost.hpp index 6e2c08db7..de2d06b7b 100644 --- a/apps/icf/waldboost.hpp +++ b/modules/xobjdetect/include/opencv2/xobjdetect/waldboost.hpp @@ -44,21 +44,21 @@ the use of this software, even if advised of the possibility of such damage. #include -#include "acffeature.hpp" -#include "stump.hpp" +#include +#include namespace cv { namespace adas { -struct WaldBoostParams +struct CV_EXPORTS WaldBoostParams { int weak_count; float alpha; }; -class WaldBoost +class CV_EXPORTS WaldBoost { public: /* Initialize WaldBoost cascade with default of specified parameters */ diff --git a/apps/icf/acffeature.cpp b/modules/xobjdetect/src/acffeature.cpp similarity index 98% rename from apps/icf/acffeature.cpp rename to modules/xobjdetect/src/acffeature.cpp index 3eb0ba627..1dfbdd197 100644 --- a/apps/icf/acffeature.cpp +++ b/modules/xobjdetect/src/acffeature.cpp @@ -1,4 +1,4 @@ -#include "acffeature.hpp" +#include using std::vector; diff --git a/apps/icf/icfdetector.cpp b/modules/xobjdetect/src/icfdetector.cpp similarity index 88% rename from apps/icf/icfdetector.cpp rename to modules/xobjdetect/src/icfdetector.cpp index 96f19d6f4..8e24a49cc 100644 --- a/apps/icf/icfdetector.cpp +++ b/modules/xobjdetect/src/icfdetector.cpp @@ -1,5 +1,5 @@ -#include "icfdetector.hpp" -#include "waldboost.hpp" +#include +#include #include @@ -38,10 +38,10 @@ void ICFDetector::train(const vector& image_filenames, vector samples; /* positive samples + negative samples */ Mat sample, resized_sample; - int pos_count = 0; + size_t pos_count = 0; for( size_t i = 0; i < image_filenames.size(); ++i, ++pos_count ) { - Mat img = imread(image_filenames[i]); + Mat img = imread(String(image_filenames[i].c_str())); for( size_t j = 0; j < labelling[i].size(); ++j ) { Rect r = labelling[i][j]; @@ -59,10 +59,10 @@ void ICFDetector::train(const vector& image_filenames, int neg_count = 0; RNG rng; - for( size_t i = 0; i < image_filenames.size(); ++i, ++neg_count ) + for( size_t i = 0; i < image_filenames.size(); ++i ) { - Mat img = imread(image_filenames[i]); - for( size_t j = 0; j < pos_count / image_filenames.size() + 1; ++j ) + Mat img = imread(String(image_filenames[i].c_str())); + for( size_t j = 0; j < pos_count / image_filenames.size() + 1; ) { Rect r; r.x = rng.uniform(0, img.cols); @@ -73,9 +73,10 @@ void ICFDetector::train(const vector& image_filenames, if( !overlap(r, labelling[i]) ) { sample = img.colRange(r.x, r.width).rowRange(r.y, r.height); - resize(sample, resized_sample); + //resize(sample, resized_sample); samples.push_back(resized_sample); ++neg_count; + ++j; } } } diff --git a/apps/icf/stump.cpp b/modules/xobjdetect/src/stump.cpp similarity index 99% rename from apps/icf/stump.cpp rename to modules/xobjdetect/src/stump.cpp index 0b463e3fc..d7e11e71c 100644 --- a/apps/icf/stump.cpp +++ b/modules/xobjdetect/src/stump.cpp @@ -1,4 +1,4 @@ -#include "stump.hpp" +#include namespace cv { diff --git a/apps/icf/waldboost.cpp b/modules/xobjdetect/src/waldboost.cpp similarity index 98% rename from apps/icf/waldboost.cpp rename to modules/xobjdetect/src/waldboost.cpp index 4655f39a5..9224cee57 100644 --- a/apps/icf/waldboost.cpp +++ b/modules/xobjdetect/src/waldboost.cpp @@ -3,7 +3,7 @@ #include using std::swap; -#include "waldboost.hpp" +#include using std::vector;