From 7f89ea58cd8e9d89be61721fb7c23b0fcb8aa2b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Grzeczkowicz?= Date: Sun, 27 Oct 2024 17:54:04 +0000 Subject: [PATCH] COS43 DIGITANIE --- bridge.cpp | 14 ++++++------ label.hpp | 66 +++++++++++++++++++++++++++++++++++++++++------------- path.cpp | 2 +- raster.cpp | 4 ++-- 4 files changed, 61 insertions(+), 25 deletions(-) diff --git a/bridge.cpp b/bridge.cpp index 5c65f80..b184832 100644 --- a/bridge.cpp +++ b/bridge.cpp @@ -128,7 +128,7 @@ std::set link_paths(const Surface_mesh &mesh, const std::vector result; - for (int selected_label: {3, 8, 9}) { + for (int selected_label: {LABEL_WATER, LABEL_RAIL, LABEL_ROAD}) { // List path with selected label std::list same_label_paths; for (std::size_t i = 0; i < paths.size(); i++) { @@ -605,7 +605,7 @@ class SurfaceCost : public ceres::SizedCostFunction<1, 1, 1, 1> { local_cost = abs(z[0] - ((double) point_bottom.z())) * normal_angle_coef[location_bottom.first]; if (grad != nullptr) *grad = (z[0] > point_bottom.z()) ? 1 : -1; if (l != 0 && l != label) { - if ((l != 8 && l != 9) || (label != 8 && label != 9)) { + if ((l != LABEL_RAIL && l != LABEL_ROAD) || (label != LABEL_RAIL && label != LABEL_ROAD)) { local_cost += cost * normal_angle_coef[location_bottom.first]; } } @@ -621,7 +621,7 @@ class SurfaceCost : public ceres::SizedCostFunction<1, 1, 1, 1> { local_cost = abs(z[0] - ((double) point_bottom.z())) * normal_angle_coef[location_bottom.first]; if (grad != nullptr) *grad = (z[0] > point_bottom.z()) ? 1 : -1; if (l != 0 && l != label) { - if ((l != 8 && l != 9) || (label != 8 && label != 9)) { + if ((l != LABEL_RAIL && l != LABEL_ROAD) || (label != LABEL_RAIL && label != LABEL_ROAD)) { local_cost += cost * normal_angle_coef[location_bottom.first]; } } @@ -639,7 +639,7 @@ class SurfaceCost : public ceres::SizedCostFunction<1, 1, 1, 1> { local_cost = (((double) point_top.z()) - z[0]) * normal_angle_coef[location_top.first]; if (grad != nullptr) *grad = -1; if (l != 0 && l != label) { - if ((l != 8 && l != 9) || (label != 8 && label != 9)) { + if ((l != LABEL_RAIL && l != LABEL_ROAD) || (label != LABEL_RAIL && label != LABEL_ROAD)) { local_cost += cost * normal_angle_coef[location_top.first]; } } @@ -1096,7 +1096,7 @@ pathBridge bridge (pathLink link, const Surface_mesh &mesh, const AABB_tree &tre auto point_bottom = PMP::construct_point(location_bottom, mesh); point_cost = abs(bridge.z_segment[i] - point_bottom.z()) * normal_angle_coef[location_bottom.first]; if (l != 0 && l != bridge.label) { - if ((l != 8 && l != 9) || (bridge.label != 8 && bridge.label != 9)) { + if ((l != LABEL_RAIL && l != LABEL_ROAD) || (bridge.label != LABEL_RAIL && bridge.label != LABEL_ROAD)) { point_cost += theta * normal_angle_coef[location_bottom.first]; } else { bridge_crossing.insert(location_bottom.first); @@ -1113,7 +1113,7 @@ pathBridge bridge (pathLink link, const Surface_mesh &mesh, const AABB_tree &tre auto point_bottom = PMP::construct_point(location_bottom, mesh); point_cost = abs(bridge.z_segment[i] - point_bottom.z()) * normal_angle_coef[location_bottom.first]; if (l != 0 && l != bridge.label) { - if ((l != 8 && l != 9) || (bridge.label != 8 && bridge.label != 9)) { + if ((l != LABEL_RAIL && l != LABEL_ROAD) || (bridge.label != LABEL_RAIL && bridge.label != LABEL_ROAD)) { point_cost += theta * normal_angle_coef[location_bottom.first]; } else { bridge_crossing.insert(location_bottom.first); @@ -1131,7 +1131,7 @@ pathBridge bridge (pathLink link, const Surface_mesh &mesh, const AABB_tree &tre auto l = label[location_top.first]; point_cost = abs(bridge.z_segment[i] - ((double) point_top.z())) * normal_angle_coef[location_top.first]; if (l != 0 && l != bridge.label) { - if ((l != 8 && l != 9) || (bridge.label != 8 && bridge.label != 9)) { + if ((l != LABEL_RAIL && l != LABEL_ROAD) || (bridge.label != LABEL_RAIL && bridge.label != LABEL_ROAD)) { point_cost += theta * normal_angle_coef[location_top.first]; } else { bridge_crossing.insert(location_top.first); diff --git a/label.hpp b/label.hpp index c338cfc..99fb569 100644 --- a/label.hpp +++ b/label.hpp @@ -4,7 +4,7 @@ #include #include -//Digitanie COS11 labels +//Digitanie COS43 labels struct Label { unsigned char value; @@ -15,22 +15,58 @@ struct Label { Label(unsigned char value, std::string label, unsigned char red, unsigned char green, unsigned char blue): value(value), label(label), red(red), green(green), blue(blue) {} }; -static std::array LABELS { +static std::array LABELS { Label(0, "other", 255, 255, 255), - Label(1, "bare ground", 100, 50, 0), - Label(2, "low vegetation", 0, 250, 50), - Label(3, "water", 0, 50, 250), - Label(4, "building", 250, 50, 50), - Label(5, "high vegetation", 0, 100, 50), - Label(6, "parking", 200, 200, 200), - Label(7, "pedestrian", 200, 150, 50), - Label(8, "road", 100, 100, 100), - Label(9, "railways", 200, 100, 200), - Label(10, "swimming pool", 50, 150, 250), - Label(11, "rail crossing", 250, 150, 0), - Label(12, "unknown", 250, 250, 150) + Label(1, "construction_site", 140, 90, 100), + Label(2, "bare_ground", 71, 58, 17), + Label(3, "bare_parking", 160, 130, 105), + Label(4, "bare_road", 160, 119, 34), + Label(5, "bare_pedestrian", 230, 167, 31), + Label(6, "sand", 234, 220, 90), + Label(7, "snow", 240, 239, 220), + Label(8, "field", 235, 255, 6), + Label(9, "sport_vegetation", 190, 215, 165), + Label(10, "grassland", 140, 240, 118), + Label(11, "aquaculture", 11, 222, 189), + Label(12, "hedge", 119, 211, 0), + Label(13, "shrub", 113, 184, 48), + Label(14, "vegetation", 0, 210, 50), + Label(15, "arboriculture", 120, 155, 100), + Label(16, "tree", 0, 120, 15), + Label(17, "spiney", 30, 143, 100), + Label(18, "forest", 0, 70, 0), + Label(19, "winter_high_vegetation", 90, 180, 170), + Label(20, "ice", 59, 173, 240), + Label(21, "river", 30, 145, 246), + Label(22, "pond", 0, 75, 190), + Label(23, "sea", 0, 55, 105), + Label(24, "swimmingpool", 100, 130, 255), + Label(25, "bridge", 160, 160, 246), + Label(26, "boat", 130, 41, 244), + Label(27, "railways", 75, 20, 132), + Label(28, "road", 141, 91, 210), + Label(29, "private_road", 205, 140, 242), + Label(30, "central_reservation", 163, 127, 180), + Label(31, "parking", 170, 60, 160), + Label(32, "pedestrian", 190, 38, 194), + Label(33, "yard", 255, 175, 200), + Label(34, "sport", 255, 115, 180), + Label(35, "cemetery", 125, 15, 70), + Label(36, "impervious", 219, 20, 123), + Label(37, "terrace", 200, 20, 79), + Label(38, "container", 255, 65, 75), + Label(39, "storage_tank", 195, 85, 0), + Label(40, "greenhouse", 255, 150, 85), + Label(41, "building", 240, 0, 0), + Label(42, "high_building", 127, 1, 0), + Label(43, "pipeline", 35, 85, 85), + Label(44, "unknown", 250, 250, 150) }; -const unsigned char LABEL_OTHER = 12; +const unsigned char LABEL_OTHER = 44; + +const unsigned char LABEL_RAIL = 27; +const unsigned char LABEL_WATER = 21; +const unsigned char LABEL_ROAD = 28; #endif /* !LABEL_H_ */ diff --git a/path.cpp b/path.cpp index 41641c7..373ba03 100644 --- a/path.cpp +++ b/path.cpp @@ -107,7 +107,7 @@ std::map> compute_path_ if (filtered_sm.number_of_faces() > 0) { int lab = label[*(CGAL::faces(filtered_sm).first)]; - if (lab == 3 || lab == 8 || lab == 9) { + if (lab == LABEL_WATER || lab == LABEL_RAIL || lab == LABEL_ROAD) { Arrangement_2 arr; std::map point_map; diff --git a/raster.cpp b/raster.cpp index bf1cc3f..5288884 100644 --- a/raster.cpp +++ b/raster.cpp @@ -96,7 +96,7 @@ void Raster::fill_holes() { std::list>>> holes; for (int L = 1; L < ySize - 1; L++) { for (int P = 1; P < xSize -1; P++) { - if ((land_cover[L][P] >= 1 && land_cover[L][P] <= 3) || land_cover[L][P] >= 6) { + if (land_cover[L][P] == LABEL_RAIL || land_cover[L][P] == LABEL_ROAD || land_cover[L][P] == LABEL_WATER) { if ((dsm[L][P] <= dsm[L+1][P]) && (dsm[L][P] <= dsm[L-1][P]) && (dsm[L][P] <= dsm[L][P+1]) && (dsm[L][P] <= dsm[L][P-1])) { holes.push_back(std::pair>>(dsm[L][P], {std::pair(P,L)})); } @@ -192,7 +192,7 @@ void Raster::fill_holes() { std::list>>> holes; for (int L = 1; L < ySize - 1; L++) { for (int P = 1; P < xSize -1; P++) { - if ((land_cover[L][P] >= 1 && land_cover[L][P] <= 3) || land_cover[L][P] >= 6) { + if (land_cover[L][P] == LABEL_RAIL || land_cover[L][P] == LABEL_ROAD || land_cover[L][P] == LABEL_WATER) { if ((dsm[L][P] >= dsm[L+1][P]) && (dsm[L][P] >= dsm[L-1][P]) && (dsm[L][P] >= dsm[L][P+1]) && (dsm[L][P] >= dsm[L][P-1])) { holes.push_back(std::pair>>(dsm[L][P], {std::pair(P,L)})); }