diff --git a/modules/odm_georef/src/Georef.cpp b/modules/odm_georef/src/Georef.cpp index f5d3bb19..58bbd1c1 100644 --- a/modules/odm_georef/src/Georef.cpp +++ b/modules/odm_georef/src/Georef.cpp @@ -1377,9 +1377,31 @@ void Georef::transformPointCloud(const char *inputFile, const Eigen::Transform vertices = file.request_properties_from_element("vertex", { "x", "y", "z" }); - std::shared_ptr normals = file.request_properties_from_element("vertex", { "nx", "ny", "nz" }); - std::shared_ptr colors = file.request_properties_from_element("vertex", { "diffuse_red", "diffuse_green", "diffuse_blue" }); + std::shared_ptr normals; + std::shared_ptr colors; + // Not all point clouds have normals and colors + // and different naming conventions apply + try{ + normals = file.request_properties_from_element("vertex", { "nx", "ny", "nz" }); + }catch(const std::exception &){} + + if (!normals){ + try{ + normals = file.request_properties_from_element("vertex", { "normal_x", "normal_y", "normal_z" }); + }catch(const std::exception &){} + } + + try{ + colors = file.request_properties_from_element("vertex", { "diffuse_red", "diffuse_green", "diffuse_blue" }); + }catch(const std::exception &){} + + if (!colors){ + try{ + colors = file.request_properties_from_element("vertex", { "red", "green", "blue" }); + }catch(const std::exception &){} + } + file.read(ss); log_ << "Successfully loaded " << vertices->count << " points with corresponding normals from file.\n"; @@ -1424,8 +1446,8 @@ void Georef::transformPointCloud(const char *inputFile, const Eigen::Transform(verts.data()), Type::INVALID, 0); - outFile.add_properties_to_element("vertex", { "nx", "ny", "nz" }, Type::FLOAT32, verts.size() * 3, reinterpret_cast(normals->buffer.get()), Type::INVALID, 0); - outFile.add_properties_to_element("vertex", { "red", "green", "blue" }, Type::UINT8, verts.size() * 3, reinterpret_cast(colors->buffer.get()), Type::INVALID, 0); + if (normals) outFile.add_properties_to_element("vertex", { "nx", "ny", "nz" }, Type::FLOAT32, verts.size() * 3, reinterpret_cast(normals->buffer.get()), Type::INVALID, 0); + if (colors) outFile.add_properties_to_element("vertex", { "red", "green", "blue" }, Type::UINT8, verts.size() * 3, reinterpret_cast(colors->buffer.get()), Type::INVALID, 0); outFile.get_comments().push_back("generated by OpenDroneMap"); outFile.write(outputStream, false); diff --git a/scripts/odm_georeferencing.py b/scripts/odm_georeferencing.py index 2b8d32d7..9b7a7547 100644 --- a/scripts/odm_georeferencing.py +++ b/scripts/odm_georeferencing.py @@ -129,8 +129,6 @@ class ODMGeoreferencingCell(ecto.Cell): 'provided a GCP file. ') doPointCloudGeo = False # skip the rest of the georeferencing - odm_georeferencing_model_ply_geo = os.path.join(tree.odm_georeferencing, - tree.odm_georeferencing_model_ply_geo) if doPointCloudGeo: # update images metadata geo_ref = reconstruction.georef