This commit is contained in:
Ayzen
2026-05-06 16:08:24 +03:00
parent cb4ba861d9
commit cf3f3cbd67
24 changed files with 670 additions and 247 deletions
@@ -13,10 +13,9 @@ enum class HistoryCommand {
ClearAll,
};
enum class GprAlgorithm {
Backprojection,
LegacyPoint,
LegacyExtended,
enum class LegacyGprMode {
Point,
Extended,
};
struct ProcessingLiveConfig {
@@ -32,7 +31,7 @@ struct ProcessingLiveConfig {
float bscan_gain = 1.0F;
float bscan_start_freq_mhz = 100.0F;
float bscan_stop_freq_mhz = 8800.0F;
GprAlgorithm gpr_algorithm = GprAlgorithm::Backprojection;
LegacyGprMode legacy_gpr_mode = LegacyGprMode::Point;
std::vector<std::uint32_t> gpr_input_positions{};
std::vector<std::uint32_t> gpr_output_positions{};
float gpr_min_depth_m = 2.0F;
@@ -162,6 +162,10 @@ auto create_default_processors() -> ProcessorRegistry {
auto processor = std::make_unique<GprProcessor>();
processors.emplace(processor->name(), std::move(processor));
}
{
auto processor = std::make_unique<LegacyGprProcessor>();
processors.emplace(processor->name(), std::move(processor));
}
return processors;
}
@@ -31,19 +31,32 @@ using Json = nlohmann::json;
throw std::runtime_error("processing.history_command must be one of: none, remove_last, clear_all");
}
[[nodiscard]] auto parse_gpr_algorithm(const std::string& value) -> GprAlgorithm {
[[nodiscard]] auto parse_legacy_gpr_mode(const std::string& value, const std::string& field_name) -> LegacyGprMode {
if (value == "point") {
return LegacyGprMode::Point;
}
if (value == "extended") {
return LegacyGprMode::Extended;
}
throw std::runtime_error(field_name + " must be one of: point, extended");
}
void apply_legacy_gpr_algorithm_alias(ProcessingLiveConfig& config, const std::string& value) {
if (value == "backprojection") {
return GprAlgorithm::Backprojection;
return;
}
if (value == "legacy_point") {
return GprAlgorithm::LegacyPoint;
config.legacy_gpr_mode = LegacyGprMode::Point;
} else if (value == "legacy_extended") {
config.legacy_gpr_mode = LegacyGprMode::Extended;
} else {
throw std::runtime_error(
"processing.gpr_algorithm must be one of: backprojection, legacy_point, legacy_extended"
);
}
if (value == "legacy_extended") {
return GprAlgorithm::LegacyExtended;
if (config.processor_mode.empty() || config.processor_mode == "gpr") {
config.processor_mode = "legacy_gpr";
}
throw std::runtime_error(
"processing.gpr_algorithm must be one of: backprojection, legacy_point, legacy_extended"
);
}
[[nodiscard]] auto parse_s_parameter_channel(const std::string& value, const std::string& field_name) -> std::string {
@@ -179,11 +192,18 @@ using Json = nlohmann::json;
}
config.bscan_stop_freq_mhz = static_cast<float>(found->get<double>());
}
if (const auto found = root.find("legacy_gpr_mode"); found != root.end()) {
if (!found->is_string()) {
throw std::runtime_error("processing.legacy_gpr_mode must be string");
}
config.legacy_gpr_mode =
parse_legacy_gpr_mode(found->get<std::string>(), "processing.legacy_gpr_mode");
}
if (const auto found = root.find("gpr_algorithm"); found != root.end()) {
if (!found->is_string()) {
throw std::runtime_error("processing.gpr_algorithm must be string");
}
config.gpr_algorithm = parse_gpr_algorithm(found->get<std::string>());
apply_legacy_gpr_algorithm_alias(config, found->get<std::string>());
}
if (const auto found = root.find("gpr_input_positions"); found != root.end()) {
config.gpr_input_positions = parse_u32_array(*found, "processing.gpr_input_positions");
@@ -15,4 +15,15 @@ class GprProcessor final : public ProcessorInterface {
) -> ipc::ResultCollection override;
};
class LegacyGprProcessor final : public ProcessorInterface {
public:
[[nodiscard]] auto name() const -> std::string override;
[[nodiscard]] auto process_collection(
const config::RunConfig& run_config,
const ipc::PreprocessedCollection& collection,
std::span<const ipc::PreprocessedCollection> previous_collections,
const ProcessingLiveConfig& live_config
) -> ipc::ResultCollection override;
};
} // namespace radar::processing
@@ -750,7 +750,7 @@ void apply_legacy_motion_correction(
return results;
}
if (live_config.gpr_algorithm == GprAlgorithm::LegacyExtended) {
if (live_config.legacy_gpr_mode == LegacyGprMode::Extended) {
const auto [regions, smoothed_accumulator] = extended_legacy_find_regions(
grid,
peaks_by_pair,
@@ -35,10 +35,20 @@ auto GprProcessor::process_collection(
std::span<const ipc::PreprocessedCollection> previous_collections,
const ProcessingLiveConfig& live_config
) -> ipc::ResultCollection {
if (live_config.gpr_algorithm != GprAlgorithm::Backprojection) {
return process_legacy_gpr(run_config, collection, previous_collections, live_config);
}
return process_backprojection_gpr(run_config, collection, previous_collections, live_config);
}
auto LegacyGprProcessor::name() const -> std::string {
return "legacy_gpr";
}
auto LegacyGprProcessor::process_collection(
const config::RunConfig& run_config,
const ipc::PreprocessedCollection& collection,
std::span<const ipc::PreprocessedCollection> previous_collections,
const ProcessingLiveConfig& live_config
) -> ipc::ResultCollection {
return process_legacy_gpr(run_config, collection, previous_collections, live_config);
}
} // namespace radar::processing