forked from weisui-ad/ImageBasedModellingEdu
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from weisui-ad/main
pull from upstream
- Loading branch information
Showing
519 changed files
with
1,392,266 additions
and
77 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# | ||
# Try to find GLEW library and include path. | ||
# Once done this will define | ||
# | ||
# GLEW_FOUND | ||
# GLEW_INCLUDE_PATH | ||
# GLEW_LIBRARY | ||
# | ||
|
||
IF (WIN32) | ||
FIND_PATH( GLEW_INCLUDE_PATH GL/glew.h | ||
$ENV{PROGRAMFILES}/GLEW/include | ||
${GLEW_ROOT_DIR}/include | ||
DOC "The directory where GL/glew.h resides") | ||
|
||
IF (NV_SYSTEM_PROCESSOR STREQUAL "AMD64") | ||
FIND_LIBRARY( GLEW_LIBRARY | ||
NAMES glew64 glew64s | ||
PATHS | ||
$ENV{PROGRAMFILES}/GLEW/lib | ||
${PROJECT_SOURCE_DIR}/src/nvgl/glew/bin | ||
${PROJECT_SOURCE_DIR}/src/nvgl/glew/lib | ||
DOC "The GLEW library (64-bit)" | ||
) | ||
ELSE(NV_SYSTEM_PROCESSOR STREQUAL "AMD64") | ||
FIND_LIBRARY( GLEW_LIBRARY | ||
NAMES glew GLEW glew32 glew32s | ||
PATHS | ||
$ENV{PROGRAMFILES}/GLEW/lib | ||
${PROJECT_SOURCE_DIR}/src/nvgl/glew/bin | ||
${PROJECT_SOURCE_DIR}/src/nvgl/glew/lib | ||
DOC "The GLEW library" | ||
) | ||
ENDIF(NV_SYSTEM_PROCESSOR STREQUAL "AMD64") | ||
ELSE (WIN32) | ||
FIND_PATH( GLEW_INCLUDE_PATH GL/glew.h | ||
/usr/include | ||
/usr/local/include | ||
/sw/include | ||
/opt/local/include | ||
${GLEW_ROOT_DIR}/include | ||
DOC "The directory where GL/glew.h resides") | ||
|
||
FIND_LIBRARY( GLEW_LIBRARY | ||
NAMES GLEW glew | ||
PATHS | ||
/usr/lib64 | ||
/usr/lib | ||
/usr/local/lib64 | ||
/usr/local/lib | ||
/sw/lib | ||
/opt/local/lib | ||
${GLEW_ROOT_DIR}/lib | ||
DOC "The GLEW library") | ||
ENDIF (WIN32) | ||
|
||
SET(GLEW_FOUND "NO") | ||
IF (GLEW_INCLUDE_PATH AND GLEW_LIBRARY) | ||
SET(GLEW_LIBRARIES ${GLEW_LIBRARY}) | ||
SET(GLEW_FOUND "YES") | ||
ENDIF (GLEW_INCLUDE_PATH AND GLEW_LIBRARY) | ||
|
||
|
||
include(FindPackageHandleStandardArgs) | ||
find_package_handle_standard_args(GLEW DEFAULT_MSG GLEW_LIBRARY GLEW_INCLUDE_PATH) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
project(class6) | ||
set(CMAKE_CXX_STANDARD 11) | ||
set(CMAKE_CXX_FLAGS "-fPIC") | ||
|
||
include_directories("../..") | ||
|
||
|
||
set(SURFACE_RECONSTRUCTION_SOURCES | ||
task6-1_surface_reconstruction.cc) | ||
|
||
set(MESH_CLEAN_SOURCES | ||
task6-2_meshclean.cc) | ||
|
||
add_executable(task6-1_surface_reconstruction ${SURFACE_RECONSTRUCTION_SOURCES}) | ||
target_link_libraries(task6-1_surface_reconstruction mvs util core surface) | ||
|
||
add_executable(task6-2_meshclean ${MESH_CLEAN_SOURCES}) | ||
target_link_libraries(task6-2_meshclean mvs util core surface) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,189 @@ | ||
/* | ||
* Copyright (C) 2015, Simon Fuhrmann | ||
* TU Darmstadt - Graphics, Capture and Massively Parallel Computing | ||
* All rights reserved. | ||
* | ||
* This software may be modified and distributed under the terms | ||
* of the BSD 3-Clause license. See the LICENSE.txt file for details. | ||
*/ | ||
|
||
#include <cstdlib> | ||
#include <iostream> | ||
#include <string> | ||
|
||
#include "util/system.h" | ||
#include "util/timer.h" | ||
#include "util/arguments.h" | ||
#include "core/mesh.h" | ||
#include "core/mesh_io.h" | ||
#include "core/mesh_io_ply.h" | ||
#include "core/mesh_tools.h" | ||
#include "surface/mesh_clean.h" | ||
|
||
struct AppSettings | ||
{ | ||
std::string in_mesh; | ||
std::string out_mesh; | ||
bool clean_degenerated; | ||
bool delete_scale; | ||
bool delete_conf; | ||
bool delete_colors; | ||
float conf_threshold; | ||
int component_size; | ||
}; | ||
|
||
void | ||
remove_low_conf_vertices (core::TriangleMesh::Ptr mesh, float const thres) | ||
{ | ||
core::TriangleMesh::ConfidenceList const& confs = mesh->get_vertex_confidences(); | ||
std::vector<bool> delete_list(confs.size(), false); | ||
for (std::size_t i = 0; i < confs.size(); ++i) | ||
{ | ||
if (confs[i] > thres) | ||
continue; | ||
delete_list[i] = true; | ||
} | ||
mesh->delete_vertices_fix_faces(delete_list); | ||
} | ||
|
||
int | ||
main (int argc, char** argv) | ||
{ | ||
util::system::register_segfault_handler(); | ||
util::system::print_build_timestamp("MVE FSSR Mesh Cleaning"); | ||
|
||
/* Setup argument parser. */ | ||
util::Arguments args; | ||
args.set_exit_on_error(true); | ||
args.set_nonopt_minnum(2); | ||
args.set_nonopt_maxnum(2); | ||
args.set_helptext_indent(25); | ||
args.set_usage(argv[0], "[ OPTS ] IN_MESH OUT_MESH"); | ||
args.add_option('t', "threshold", true, "Threshold on the geometry confidence [1.0]"); | ||
args.add_option('c', "component-size", true, "Minimum number of vertices per component [1000]"); | ||
args.add_option('n', "no-clean", false, "Prevents cleanup of degenerated faces"); | ||
args.add_option('\0', "delete-scale", false, "Delete scale attribute from mesh"); | ||
args.add_option('\0', "delete-conf", false, "Delete confidence attribute from mesh"); | ||
args.add_option('\0', "delete-color", false, "Delete color attribute from mesh"); | ||
args.set_description("The application cleans degenerated faces resulting " | ||
"from MC-like algorithms. Vertices below a confidence threshold and " | ||
"vertices in small isolated components are deleted as well."); | ||
args.parse(argc, argv); | ||
|
||
/* Init default settings. */ | ||
AppSettings conf; | ||
conf.in_mesh = args.get_nth_nonopt(0); | ||
conf.out_mesh = args.get_nth_nonopt(1); | ||
conf.conf_threshold = 1.0f; | ||
conf.component_size = 1000; | ||
conf.clean_degenerated = true; | ||
conf.delete_scale = false; | ||
conf.delete_conf = false; | ||
conf.delete_colors = false; | ||
|
||
/* Scan arguments. */ | ||
while (util::ArgResult const* arg = args.next_option()) | ||
{ | ||
if (arg->opt->lopt == "threshold") | ||
conf.conf_threshold = arg->get_arg<float>(); | ||
else if (arg->opt->lopt == "component-size") | ||
conf.component_size = arg->get_arg<int>(); | ||
else if (arg->opt->lopt == "no-clean") | ||
conf.clean_degenerated = false; | ||
else if (arg->opt->lopt == "delete-scale") | ||
conf.delete_scale = true; | ||
else if (arg->opt->lopt == "delete-conf") | ||
conf.delete_conf = true; | ||
else if (arg->opt->lopt == "delete-color") | ||
conf.delete_colors = true; | ||
else | ||
{ | ||
std::cerr << "Invalid option: " << arg->opt->sopt << std::endl; | ||
return EXIT_FAILURE; | ||
} | ||
} | ||
|
||
/* Load input mesh. */ | ||
core::TriangleMesh::Ptr mesh; | ||
try | ||
{ | ||
std::cout << "Loading mesh: " << conf.in_mesh << std::endl; | ||
mesh = core::geom::load_mesh(conf.in_mesh); | ||
} | ||
catch (std::exception& e) | ||
{ | ||
std::cerr << "Error loading mesh: " << e.what() << std::endl; | ||
return EXIT_FAILURE; | ||
} | ||
|
||
/* Sanity checks. */ | ||
if (mesh->get_vertices().empty()) | ||
{ | ||
std::cerr << "Error: Mesh is empty!" << std::endl; | ||
return EXIT_FAILURE; | ||
} | ||
|
||
if (!mesh->has_vertex_confidences() && conf.conf_threshold > 0.0f) | ||
{ | ||
std::cerr << "Error: Confidence cleanup requested, but mesh " | ||
"has no confidence values." << std::endl; | ||
return EXIT_FAILURE; | ||
} | ||
|
||
if (mesh->get_faces().empty() | ||
&& (conf.clean_degenerated || conf.component_size > 0)) | ||
{ | ||
std::cerr << "Error: Components/faces cleanup " | ||
"requested, but mesh has no faces." << std::endl; | ||
return EXIT_FAILURE; | ||
} | ||
|
||
/* Remove low-confidence geometry. */ | ||
if (conf.conf_threshold > 0.0f) | ||
{ | ||
std::cout << "Removing low-confidence geometry (threshold " | ||
<< conf.conf_threshold << ")..." << std::endl; | ||
std::size_t num_verts = mesh->get_vertices().size(); | ||
remove_low_conf_vertices(mesh, conf.conf_threshold); | ||
std::size_t new_num_verts = mesh->get_vertices().size(); | ||
std::cout << " Deleted " << (num_verts - new_num_verts) | ||
<< " low-confidence vertices." << std::endl; | ||
} | ||
|
||
/* Remove isolated components if requested. */ | ||
if (conf.component_size > 0) | ||
{ | ||
std::cout << "Removing isolated components below " | ||
<< conf.component_size << " vertices..." << std::endl; | ||
std::size_t num_verts = mesh->get_vertices().size(); | ||
core::geom::mesh_components(mesh, conf.component_size); | ||
std::size_t new_num_verts = mesh->get_vertices().size(); | ||
std::cout << " Deleted " << (num_verts - new_num_verts) | ||
<< " vertices in isolated regions." << std::endl; | ||
} | ||
|
||
/* Remove degenerated faces from the mesh. */ | ||
if (conf.clean_degenerated) | ||
{ | ||
std::cout << "Removing degenerated faces..." << std::endl; | ||
std::size_t num_collapsed = fssr::clean_mc_mesh(mesh); | ||
std::cout << " Collapsed " << num_collapsed << " edges." << std::endl; | ||
} | ||
|
||
/* Write output mesh. */ | ||
std::cout << "Writing mesh: " << conf.out_mesh << std::endl; | ||
if (util::string::right(conf.out_mesh, 4) == ".ply") | ||
{ | ||
core::geom::SavePLYOptions ply_opts; | ||
ply_opts.write_vertex_colors = !conf.delete_colors; | ||
ply_opts.write_vertex_confidences = !conf.delete_conf; | ||
ply_opts.write_vertex_values = !conf.delete_scale; | ||
core::geom::save_ply_mesh(mesh, conf.out_mesh, ply_opts); | ||
} | ||
else | ||
{ | ||
core::geom::save_mesh(mesh, conf.out_mesh); | ||
} | ||
|
||
return EXIT_SUCCESS; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
project(class7) | ||
set(CMAKE_CXX_STANDARD 11) | ||
set(CMAKE_CXX_FLAGS "-fPIC") | ||
|
||
include_directories("../..") | ||
include_directories(../../3rdParty/eigen) | ||
|
||
#set(TBB_INCLUDE_DIRS "/usr/local/Cellar/tbb/2019_U1/include" CACHE PATH "Path to where the TBB include files (tbb/) reside") | ||
#set(TBB_LIBRARY "/usr/local/Cellar/tbb/2019_U1/lib" CACHE PATH "Path to where the TBB library files (libtbb.so etc.) reside") | ||
#list(APPEND CMAKE_MODULE_PATH "../../cmake") | ||
###find_package(TBB COMPONENTS tbbmalloc tbbmalloc_proxy tbb_preview) | ||
|
||
|
||
####find_package(OpenGL REQUIRED) | ||
|
||
set(MESH_CLEAN_SOURCES | ||
task7_1_meshclean.cc) | ||
|
||
add_executable(task7_1_mesh_clean ${MESH_CLEAN_SOURCES}) | ||
target_link_libraries(task7_1_mesh_clean util core surface) | ||
|
||
set(TEXTURING_SOURCES | ||
arguments.h | ||
arguments.cpp | ||
task7_2_texrecon.cpp) | ||
add_executable(task7_2_texturing ${TEXTURING_SOURCES}) | ||
target_link_libraries(task7_2_texturing mvs util core texturing coldet mrf gco) |
Oops, something went wrong.