| 102 | } |
| 103 | |
| 104 | bool ConfigUtils::Load(const std::string& config_file) { |
| 105 | cv::FileStorage fs(config_file, cv::FileStorage::READ); |
| 106 | |
| 107 | if (!fs.isOpened()) { |
| 108 | LOG_WARN("Config file not found, using defaults"); |
| 109 | return false; |
| 110 | } |
| 111 | |
| 112 | // Camera parameters |
| 113 | cv::FileNode camera = fs["camera"]; |
| 114 | if (!camera.empty()) { |
| 115 | camera_width = (int)camera["width"]; |
| 116 | camera_height = (int)camera["height"]; |
| 117 | camera_polar_exclusion_ratio = (float)(double)camera["polar_exclusion_ratio"]; |
| 118 | camera_boundary_margin = (int)camera["boundary_margin"]; |
| 119 | } |
| 120 | |
| 121 | // Feature detection |
| 122 | cv::FileNode feature_detection = fs["feature_detection"]; |
| 123 | if (!feature_detection.empty()) { |
| 124 | max_features = (int)feature_detection["max_features"]; |
| 125 | quality_level = (double)feature_detection["quality_level"]; |
| 126 | min_distance = (double)feature_detection["min_distance"]; |
| 127 | grid_cols = (int)feature_detection["grid_cols"]; |
| 128 | grid_rows = (int)feature_detection["grid_rows"]; |
| 129 | max_features_per_grid = (int)feature_detection["max_features_per_grid"]; |
| 130 | } |
| 131 | |
| 132 | // Optical flow |
| 133 | cv::FileNode optical_flow = fs["optical_flow"]; |
| 134 | if (!optical_flow.empty()) { |
| 135 | optical_flow_window_size = (int)optical_flow["window_size"]; |
| 136 | optical_flow_max_level = (int)optical_flow["max_level"]; |
| 137 | optical_flow_max_iterations = (int)optical_flow["max_iterations"]; |
| 138 | optical_flow_epsilon = (double)optical_flow["epsilon"]; |
| 139 | } |
| 140 | |
| 141 | // RANSAC |
| 142 | cv::FileNode ransac = fs["ransac"]; |
| 143 | if (!ransac.empty()) { |
| 144 | ransac_max_iterations = (int)ransac["max_iterations"]; |
| 145 | ransac_threshold_degrees = (float)(double)ransac["threshold_degrees"]; |
| 146 | ransac_confidence = (float)(double)ransac["confidence"]; |
| 147 | } |
| 148 | |
| 149 | // Tracking |
| 150 | cv::FileNode tracking = fs["tracking"]; |
| 151 | if (!tracking.empty()) { |
| 152 | tracking_min_features_ratio = (float)(double)tracking["min_features_ratio"]; |
| 153 | if (!tracking["min_parallax_for_keyframe"].empty()) { |
| 154 | tracking_min_parallax_for_keyframe = (float)(double)tracking["min_parallax_for_keyframe"]; |
| 155 | } |
| 156 | if (!tracking["window_size"].empty()) { |
| 157 | tracking_window_size = (int)tracking["window_size"]; |
| 158 | } |
| 159 | } |
| 160 | |
| 161 | // Initialization |