Skip to content

Commit

Permalink
Binary PLY output in odm_georef, remove normals
Browse files Browse the repository at this point in the history
  • Loading branch information
pierotofy committed May 25, 2018
1 parent 5195187 commit 997729f
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions modules/odm_georef/src/Georef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1411,20 +1411,20 @@ void Georef::transformPointCloud(const char *inputFile, const Eigen::Transform<S
file.parse_header(ss);

std::shared_ptr<PlyData> vertices = file.request_properties_from_element("vertex", { "x", "y", "z" });
std::shared_ptr<PlyData> normals;
// std::shared_ptr<PlyData> normals;
std::shared_ptr<PlyData> 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 &){}
// 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 &){}
}
// 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" });
Expand Down Expand Up @@ -1470,6 +1470,9 @@ void Georef::transformPointCloud(const char *inputFile, const Eigen::Transform<S
verts[i].x = static_cast<Scalar> (transform (0, 0) * x + transform (0, 1) * y + transform (0, 2) * z + transform (0, 3));
verts[i].y = static_cast<Scalar> (transform (1, 0) * x + transform (1, 1) * y + transform (1, 2) * z + transform (1, 3));
verts[i].z = static_cast<Scalar> (transform (2, 0) * x + transform (2, 1) * y + transform (2, 2) * z + transform (2, 3));

// TODO: normals can be computed using the inverse transpose
// https://paroj.github.io/gltut/Illumination/Tut09%20Normal%20Transformation.html
}

log_ << '\n';
Expand All @@ -1484,11 +1487,11 @@ void Georef::transformPointCloud(const char *inputFile, const Eigen::Transform<S

PlyFile outFile;
outFile.add_properties_to_element("vertex", { "x", "y", "z" }, Type::FLOAT64, verts.size() * 3, reinterpret_cast<uint8_t*>(verts.data()), Type::INVALID, 0);
if (normals) outFile.add_properties_to_element("vertex", { "nx", "ny", "nz" }, Type::FLOAT32, verts.size() * 3, reinterpret_cast<uint8_t*>(normals->buffer.get()), Type::INVALID, 0);
// if (normals) outFile.add_properties_to_element("vertex", { "nx", "ny", "nz" }, Type::FLOAT32, verts.size() * 3, reinterpret_cast<uint8_t*>(normals->buffer.get()), Type::INVALID, 0);
if (colors) outFile.add_properties_to_element("vertex", { "red", "green", "blue" }, Type::UINT8, verts.size() * 3, reinterpret_cast<uint8_t*>(colors->buffer.get()), Type::INVALID, 0);
outFile.get_comments().push_back("generated by OpenDroneMap");

outFile.write(outputStream, false);
outFile.write(outputStream, true);

fb.close();

Expand Down

0 comments on commit 997729f

Please sign in to comment.