| 345 | } |
| 346 | |
| 347 | bool Planar_Mapping_module::create_new_plane(eigen_alloc_unord_map<long, data::Plane *> &colorToPlanes) |
| 348 | { |
| 349 | if (_setVerbose) |
| 350 | { |
| 351 | spdlog::info("-- PlanarMapping -- trying to create plane"); |
| 352 | } |
| 353 | |
| 354 | auto before = std::chrono::high_resolution_clock::now(); |
| 355 | |
| 356 | bool hasNewPlanes = false; |
| 357 | for (auto &color_plane_pair : colorToPlanes) |
| 358 | { |
| 359 | if (color_plane_pair.second->get_num_landmarks() < MIN_NUMBER_POINTS_BEFORE_RANSAC) // 12 |
| 360 | { |
| 361 | delete color_plane_pair.second; |
| 362 | color_plane_pair.second = nullptr; |
| 363 | continue; |
| 364 | } |
| 365 | |
| 366 | // Conditional ternary operator |
| 367 | if (_use_graph_cut |
| 368 | ? estimate_plane_sequential_Graph_cut_RANSAC(color_plane_pair.second) |
| 369 | : estimate_plane_sequential_RANSAC(color_plane_pair.second)) |
| 370 | { |
| 371 | hasNewPlanes = true; |
| 372 | color_plane_pair.second->set_valid(); // set valid, but plane need to be refined |
| 373 | |
| 374 | if (_setVerbose) |
| 375 | { |
| 376 | double a, b, c, d; |
| 377 | color_plane_pair.second->get_equation(a, b, c, d); |
| 378 | spdlog::info("\t \t | new plane detected: ({}, {}, {}, {})", a, b, c, d); |
| 379 | } |
| 380 | |
| 381 | // save to map database |
| 382 | _map_db->add_landmark_plane(color_plane_pair.second); |
| 383 | } |
| 384 | else |
| 385 | { |
| 386 | color_plane_pair.second->remove_landmarks_ownership(); |
| 387 | |
| 388 | // delete pointer first, then set as null |
| 389 | delete color_plane_pair.second; |
| 390 | color_plane_pair.second = nullptr; |
| 391 | |
| 392 | if (_setVerbose) |
| 393 | { |
| 394 | spdlog::info("\t \t | estimate plane through RANSAC failed"); |
| 395 | } |
| 396 | } |
| 397 | } |
| 398 | |
| 399 | colorToPlanes.clear(); |
| 400 | |
| 401 | auto after = std::chrono::high_resolution_clock::now(); |
| 402 | auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(after - before).count(); |
| 403 | |
| 404 | if (_setVerbose) |
nothing calls this directly
no test coverage detected