Binary PLY output in odm_georef, remove normals

pull/829/head
Piero Toffanin 2018-05-25 13:37:59 -04:00
rodzic 5195187911
commit 997729f1d1
1 zmienionych plików z 14 dodań i 11 usunięć

Wyświetl plik

@ -1411,20 +1411,20 @@ void Georef::transformPointCloud(const char *inputFile, const Eigen::Transform<S
file.parse_header(ss); file.parse_header(ss);
std::shared_ptr<PlyData> vertices = file.request_properties_from_element("vertex", { "x", "y", "z" }); 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; std::shared_ptr<PlyData> colors;
// Not all point clouds have normals and colors // Not all point clouds have normals and colors
// and different naming conventions apply // and different naming conventions apply
try{ // try{
normals = file.request_properties_from_element("vertex", { "nx", "ny", "nz" }); // normals = file.request_properties_from_element("vertex", { "nx", "ny", "nz" });
}catch(const std::exception &){} // }catch(const std::exception &){}
if (!normals){ // if (!normals){
try{ // try{
normals = file.request_properties_from_element("vertex", { "normal_x", "normal_y", "normal_z" }); // normals = file.request_properties_from_element("vertex", { "normal_x", "normal_y", "normal_z" });
}catch(const std::exception &){} // }catch(const std::exception &){}
} // }
try{ try{
colors = file.request_properties_from_element("vertex", { "diffuse_red", "diffuse_green", "diffuse_blue" }); colors = file.request_properties_from_element("vertex", { "diffuse_red", "diffuse_green", "diffuse_blue" });
@ -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].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].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)); 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'; log_ << '\n';
@ -1484,11 +1487,11 @@ void Georef::transformPointCloud(const char *inputFile, const Eigen::Transform<S
PlyFile outFile; 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); 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); 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.get_comments().push_back("generated by OpenDroneMap");
outFile.write(outputStream, false); outFile.write(outputStream, true);
fb.close(); fb.close();