std::shared_ptr<SupervisedController> ControllerFactory::createController(tue::Configuration& config, double dt) const { std::shared_ptr<SupervisedController> supervised_controller; // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Get controller name and type std::string name, type; if (!config.value("name", name) | !config.value("type", type)) return supervised_controller; config.setShortErrorContext(name); // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Create controller core from given type std::map<std::string, t_controller_creator>::const_iterator it = controller_types_.find(type); if (it == controller_types_.end()) { config.addError("Unknown controller type: '" + type + "'"); return supervised_controller; } std::shared_ptr<Controller> c = it->second(); // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Configure controller core c->configure(config, dt); c->setName(name); // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Wrap controller in supervised controller, and configure it supervised_controller.reset(new SupervisedController); supervised_controller->setController(c); supervised_controller->configure(config, dt); return supervised_controller; }
void FaceDetector::configureClassification(tue::Configuration config) { // default values in case configure(...) is not called! debug_mode_ = false; classifier_front_scale_factor_ = 1.2; classifier_front_min_neighbours_ = 3; classif_front_min_size_ = cv::Size(20,20); classifier_profile_scale_factor_= 1.2; classifier_profile_min_neighbours_ = 3; classif_profile_min_size_ = cv::Size(20,20); debug_folder_ = "/tmp/face_detector/"; // load training files for frontal classifier std::string cascade_front_files_path_; if (config.value("cascade_front_files_path", cascade_front_files_path_)) { if (!classifier_front_.load(cascade_front_files_path_)) config.addError("Unable to load front haar cascade files (" + cascade_front_files_path_ + ")"); } // load training files for profile classifier std::string cascade_profile_files_path_; if (config.value("cascade_profile_front_path", cascade_profile_files_path_)) { if (!classifier_profile_.load(cascade_profile_files_path_)) config.addError("Unable to load profile haar cascade files (" + cascade_profile_files_path_ + ")"); } if (config.hasError()) return; if (!config.value("debug_mode", debug_mode_, tue::OPTIONAL)) ed::log::info() << "Parameter 'debug_mode' not found. Using default: " << debug_mode_ << std::endl; if (!config.value("debug_folder", debug_folder_, tue::OPTIONAL)) ed::log::info() << "Parameter 'debug_folder' not found. Using default: " << debug_folder_ << std::endl; if (!config.value("classifier_front_scale_factor", classifier_front_scale_factor_, tue::OPTIONAL)) ed::log::info() << "Parameter 'classifier_front_scale_factor' not found. Using default: " << classifier_front_scale_factor_ << std::endl; if (!config.value("classifier_front_min_neighbours", classifier_front_min_neighbours_, tue::OPTIONAL)) ed::log::info() << "Parameter 'classifier_front_min_neighbours' not found. Using default: " << classifier_front_min_neighbours_ << std::endl; if (!config.value("classifier_profile_scale_factor", classifier_profile_scale_factor_, tue::OPTIONAL)) ed::log::info() << "Parameter 'classifier_profile_scale_factor' not found. Using default: " << classifier_profile_scale_factor_ << std::endl; if (!config.value("classifier_profile_min_neighbours", classifier_profile_min_neighbours_, tue::OPTIONAL)) ed::log::info() << "Parameter 'classifier_profile_min_neighbours' not found. Using default: " << classifier_profile_min_neighbours_ << std::endl; if (debug_mode_) { // clean the debug folder if debugging is active try { boost::filesystem::path dir(debug_folder_); boost::filesystem::remove_all(dir); boost::filesystem::create_directories(dir); } catch(const boost::filesystem::filesystem_error& e) { if(e.code() == boost::system::errc::permission_denied) ed::log::error() << "boost::filesystem permission denied" << std::endl; else ed::log::error() << "boost::filesystem failed with error: " << e.code().message() << std::endl; } // create debug window cv::namedWindow("Face Detector Output", CV_WINDOW_AUTOSIZE); } }