55{
56 NeuroParametersHough neuroParametersHough;
57 std::ifstream configFile(fileName);
58 if (!configFile.is_open()) {
59 B2ERROR("Could not open configuration file: " + fileName);
60 exit(EXIT_FAILURE);
61 }
62 std::string completeLine;
63 while (std::getline(configFile, completeLine)) {
64 std::size_t hashtag = completeLine.find('#');
65 std::string line = completeLine.substr(0, hashtag);
66 std::string configParameter;
67 std::string parameterValue;
68 if (line.length() < 3 || line.find('=') == std::string::npos) {
69 continue;
70 }
71 line.erase(std::remove(line.begin(), line.end(), ' '), line.end());
72 size_t equalPosition = line.find('=');
73 configParameter = line.substr(0, equalPosition);
74 parameterValue = line.substr((equalPosition + 1), line.length() - equalPosition - 1);
75 if (configParameter == "nInput") {
76 neuroParametersHough.nInput = std::stoull(parameterValue);
77 } else if (configParameter == "nOutput") {
78 neuroParametersHough.nOutput = std::stoull(parameterValue);
79 } else if (configParameter == "nHidden") {
80 neuroParametersHough.nHidden = readArray<size_t>(parameterValue);
81 } else if (configParameter == "outputScale") {
82 neuroParametersHough.outputScale = readArray<float>(parameterValue);
83 } else {
84 B2WARNING("Unknown config parameter: " + configParameter);
85 }
86 }
87 return neuroParametersHough;
88}