Merge pull request #829 from pierotofy/binply

Binary PLY output in odm_georef, remove normals
pull/831/head
Stephen Mather 2018-05-25 19:09:58 -04:00 zatwierdzone przez GitHub
commit 59ef6f13a8
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
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);
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" });
@ -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';
@ -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();