Skip to content

Commit

Permalink
fixed memory usage problems, better texture reconstruction
Browse files Browse the repository at this point in the history
  • Loading branch information
edin45 committed Mar 7, 2023
1 parent cde0168 commit 1c300af
Show file tree
Hide file tree
Showing 46 changed files with 578 additions and 99 deletions.
37 changes: 37 additions & 0 deletions LICENSES_EXTERNAL_SOFTWARE
Original file line number Diff line number Diff line change
Expand Up @@ -699,3 +699,40 @@ OpenMVS:
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU AGPL, see
<http://www.gnu.org/licenses/>.


mvs-texturing:

All source files are distributed under the BSD 3-Clause License unless
otherwise noted in the source file.

Software License Agreement (BSD 3-Clause License)
---------------------------------------------------------------------------

Copyright (c) 2015, Nils Moehrle and others
TU Darmstadt - Graphics, Capture and Massively Parallel Computing
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.

This software is provided by the copyright holders and contributors "as is"
and any express or implied warranties, including, but not limited to, the
implied warranties of merchantability and fitness for a particular purpose
are disclaimed. In no event shall the copyright holder or contributors be
liable for any direct, indirect, incidental, special, exemplary, or
consequential damages (including, but not limited to, procurement of
substitute goods or services; loss of use, data, or profits; or business
interruption) however caused and on any theory of liability, whether in
contract, strict liability, or tort (including negligence or otherwise)
arising in any way out of the use of this software, even if advised of the
possibility of such damage.
2 changes: 1 addition & 1 deletion lib/runCommand.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ runCommand(String command, List<String> attr) async {
err = "permission_denied";
}
print('command_out: ${results.stdout}');
return err;
return err == "" ? results.stdout : err;
});
}
218 changes: 124 additions & 94 deletions lib/scanningScreen/scanningScreenModel.dart

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions lib/scanningScreen/scanningScreenView.dart
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class _ScanningScreenViewState extends State<ScanningScreenView> {
)
],
),
const Padding(padding: EdgeInsets.all(8)),
/*const Padding(padding: EdgeInsets.all(8)),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Expand All @@ -114,7 +114,7 @@ class _ScanningScreenViewState extends State<ScanningScreenView> {
color: colorScheme.onPrimary,
),
onTap: (selected) {
reconstructAndTextureMesh = selected ?? false;
reconstructAndTextureMesh = (selected ?? false);
setState(() {});
},
),
Expand All @@ -124,7 +124,7 @@ class _ScanningScreenViewState extends State<ScanningScreenView> {
style: TextStyle(color: colorScheme.onBackground, fontWeight: FontWeight.normal),
)
],
),
),*/
const Padding(padding: EdgeInsets.all(10.0)),
Row(
mainAxisAlignment: MainAxisAlignment.center,
Expand Down Expand Up @@ -294,7 +294,8 @@ class _ScanningScreenViewState extends State<ScanningScreenView> {
children: [
linkWidget("1. Colmap", "https://colmap.github.io/"),
linkWidget("2. OpenMVS", "https://github.com/cdcseacave/openMVS"),
linkWidget("3. pointcloudToMesh", "https://github.com/danielTobon43/pointcloudToMesh"),
linkWidget("3. mvs-texturing", "https://github.com/nmoehrle/mvs-texturing"),
linkWidget("4. pymeshlab", "https://github.com/cnr-isti-vclab/PyMeshLab"),
],
),
);
Expand Down
Binary file added mvs-texturing/texrecon.exe
Binary file not shown.
Binary file added openmvs/DensifyPointCloud.exe
Binary file not shown.
Binary file added openmvs/InterfaceCOLMAP.exe
Binary file not shown.
Binary file added openmvs/InterfaceMVSNet.exe
Binary file not shown.
Binary file added openmvs/InterfaceMetashape.exe
Binary file not shown.
Binary file added openmvs/ReconstructMesh.exe
Binary file not shown.
Binary file added openmvs/RefineMesh.exe
Binary file not shown.
Binary file added openmvs/Tests.exe
Binary file not shown.
Binary file added openmvs/TextureMesh.exe
Binary file not shown.
Binary file added openmvs/TransformScene.exe
Binary file not shown.
Binary file added openmvs/Viewer.exe
Binary file not shown.
Binary file added openmvs/boost_iostreams-vc143-mt-x64-1_80.dll
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added openmvs/bz2.dll
Binary file not shown.
Binary file added openmvs/glew32.dll
Binary file not shown.
Binary file added openmvs/glfw3.dll
Binary file not shown.
Binary file added openmvs/gmp-10.dll
Binary file not shown.
Binary file added openmvs/jpeg62.dll
Binary file not shown.
Binary file added openmvs/liblzma.dll
Binary file not shown.
Binary file added openmvs/libpng16.dll
Binary file not shown.
Binary file added openmvs/opencv_calib3d4.dll
Binary file not shown.
Binary file added openmvs/opencv_core4.dll
Binary file not shown.
Binary file added openmvs/opencv_features2d4.dll
Binary file not shown.
Binary file added openmvs/opencv_flann4.dll
Binary file not shown.
Binary file added openmvs/opencv_highgui4.dll
Binary file not shown.
Binary file added openmvs/opencv_imgcodecs4.dll
Binary file not shown.
Binary file added openmvs/opencv_imgproc4.dll
Binary file not shown.
Binary file added openmvs/opencv_videoio4.dll
Binary file not shown.
Binary file added openmvs/tiff.dll
Binary file not shown.
Binary file added openmvs/webp.dll
Binary file not shown.
Binary file added openmvs/webpdecoder.dll
Binary file not shown.
Binary file added openmvs/zlib1.dll
Binary file not shown.
Binary file added openmvs/zstd.dll
Binary file not shown.
56 changes: 56 additions & 0 deletions pubspec.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
packages:
args:
dependency: transitive
description:
name: args
sha256: "4cab82a83ffef80b262ddedf47a0a8e56ee6fbf7fe21e6e768b02792034dd440"
url: "https://pub.dev"
source: hosted
version: "2.4.0"
async:
dependency: transitive
description:
Expand All @@ -25,6 +33,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.2.1"
charcode:
dependency: transitive
description:
name: charcode
sha256: fb98c0f6d12c920a02ee2d998da788bca066ca5f148492b7085ee23372b12306
url: "https://pub.dev"
source: hosted
version: "1.3.1"
clock:
dependency: transitive
description:
Expand Down Expand Up @@ -152,6 +168,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "4.0.2"
isolate_current_directory:
dependency: "direct main"
description:
name: isolate_current_directory
sha256: "522dfcf5ef765b1e60c8d20398cdc1d2c3189f5430dcbe78979094b88f2fcc74"
url: "https://pub.dev"
source: hosted
version: "1.2.0"
js:
dependency: transitive
description:
Expand Down Expand Up @@ -280,6 +304,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "4.2.4"
process_run:
dependency: "direct dev"
description:
name: process_run
sha256: "1142d7f4f0c3f36393a1319406efcf481def2b6d862b2bf600c8ae8fa74d5bd8"
url: "https://pub.dev"
source: hosted
version: "0.12.5+2"
provider:
dependency: "direct main"
description:
Expand All @@ -288,6 +320,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "6.0.5"
pub_semver:
dependency: transitive
description:
name: pub_semver
sha256: "307de764d305289ff24ad257ad5c5793ce56d04947599ad68b3baa124105fc17"
url: "https://pub.dev"
source: hosted
version: "2.1.3"
roundcheckbox:
dependency: "direct main"
description:
Expand Down Expand Up @@ -333,6 +373,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.2.0"
synchronized:
dependency: transitive
description:
name: synchronized
sha256: "33b31b6beb98100bf9add464a36a8dd03eb10c7a8cf15aeec535e9b054aaf04b"
url: "https://pub.dev"
source: hosted
version: "3.0.1"
system_info2:
dependency: "direct main"
description:
Expand Down Expand Up @@ -469,6 +517,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.0.0"
yaml:
dependency: transitive
description:
name: yaml
sha256: "23812a9b125b48d4007117254bca50abb6c712352927eece9e155207b1db2370"
url: "https://pub.dev"
source: hosted
version: "3.1.1"
sdks:
dart: ">=2.19.2 <3.0.0"
flutter: ">=3.4.0-17.0.pre"
2 changes: 2 additions & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ dependencies:
roundcheckbox: ^2.0.5
system_info2: ^3.0.1
url_launcher: ^6.1.10
isolate_current_directory: ^1.2.0

dev_dependencies:
flutter_test:
Expand All @@ -55,6 +56,7 @@ dev_dependencies:
flutter_lints: ^2.0.0
dynamic_color: ^1.6.2
file_picker: ^5.2.5
process_run: ^0.12.5+2

# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec
Expand Down
19 changes: 19 additions & 0 deletions python/decimateMesh.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import os
import pymeshlab
import optparse

parser = optparse.OptionParser()
parser.add_option("-m","--mesh",action="store",help="To be textured mesh")
parser.add_option("-o","--output_folder",action="store",help="Folder where Results are stored")
parser.add_option("-t","--face_reduction_factor",action="store",help="face reduction factor (0 = disabled)")
options, args = parser.parse_args()
output_folder = options.output_folder
mesh = options.mesh
face_reduction_factor = float(options.face_reduction_factor)

ms = pymeshlab.MeshSet()
print('reading...')
ms.load_new_mesh(mesh)
ms.meshing_decimation_quadric_edge_collapse(targetfacenum=int(ms.current_mesh().face_number()/face_reduction_factor))
print('saving')
ms.save_current_mesh(os.path.join(output_folder,"model_surface_decimated.ply"))
139 changes: 139 additions & 0 deletions python/reconstructMesh/reconstructMesh.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
import optparse
import open3d as o3d
import numpy as np
import pymeshlab

parser = optparse.OptionParser()
parser.add_option("-i","--input_pointcloud",action="store",help="Input Pointcloud")
parser.add_option("-o","--output_folder",action="store",help="Folder where Results are stored")
parser.add_option("-d","--recon_depth",action="store",help="Reconstruction Depth")
options, args = parser.parse_args()
input_pointcloud_path = options.input_pointcloud
output_folder = options.output_folder
recon_depth = options.recon_depth







#pcd.normals = o3d.utility.Vector3dVector(np.zeros(
# (1, 3))) # invalidate existing normals

#pcd.estimate_normals()

#print("Meshing")
#radii = [0.005, 0.01, 0.02, 0.04]
#rec_mesh = o3d.geometry.TriangleMesh.create_from_point_cloud_ball_pivoting(inlier_cloud, /#o3d.utility.DoubleVector(radii))

input_pointcloud = o3d.io.read_point_cloud(input_pointcloud_path)

#input_pointcloud.normals = o3d.utility.Vector3dVector(np.zeros(
# (1, 3))) # invalidate existing normals

#input_pointcloud.estimate_normals()
#print("filtering...")
#cl, ind = input_pointcloud.remove_statistical_outlier(nb_neighbors=50, std_ratio=0.1)
#cl, ind = pcd.remove_radius_outlier(nb_points=16, radius=0.05)



#inlier_cloud = input_pointcloud.select_by_index(ind)

#scale = 0.1
#generate_sampling_voronoi
pcd = input_pointcloud.voxel_down_sample(voxel_size=0.005)
pcd.estimate_normals()
# o3d.geometry.estimate_normals(pcd,search_param=o3d.geometry.KDTreeSearchParamHybrid(radius=0.1,max_nn=30))
# print(f"saving...")
o3d.io.write_point_cloud(output_folder + f"/downsampled.ply", pcd, write_ascii=False)
print('recon')

#Alpha shapes
# mesh = o3d.geometry.TriangleMesh.create_from_point_cloud_alpha_shape(pcd, 0.01)
# mesh.compute_vertex_normals()

# #BPA:

# radii = [0.009]
# mesh = o3d.geometry.TriangleMesh.create_from_point_cloud_ball_pivoting(
# pcd, o3d.utility.DoubleVector(radii))

# print('saving')
# o3d.io.write_triangle_mesh(output_folder + f"/bpa_recon.ply", mesh, write_ascii=False)

#while(scale < 2.0):

# print("meshing...")
# print('run Poisson surface reconstruction')
# with o3d.utility.VerbosityContextManager(
# o3d.utility.VerbosityLevel.Debug) as cm:
# mesh, densities = o3d.geometry.TriangleMesh.create_from_point_cloud_poisson(
# input_pointcloud, depth=int(recon_depth), scale=0.9)

# with o3d.utility.VerbosityContextManager(
# o3d.utility.VerbosityLevel.Debug) as cm:
# triangle_clusters, cluster_n_triangles, cluster_area = (
# mesh.cluster_connected_triangles())
# triangle_clusters = np.asarray(triangle_clusters)
# cluster_n_triangles = np.asarray(cluster_n_triangles)
# cluster_area = np.asarray(cluster_area)

# triangles_to_remove = cluster_n_triangles[triangle_clusters] < 100
# mesh.remove_triangles_by_mask(triangles_to_remove)

# print(f"saving...")
# o3d.io.write_triangle_mesh(output_folder + f"/meshed_poisson_cleanup.ply", mesh, write_ascii=False)


# scale+=0.1





print("cleaning & reconstructing")

ms = pymeshlab.MeshSet()

print('reading...')
ms.load_new_mesh(output_folder + "/downsampled.ply")
# texturesize
#ms.
# ms.generate_surface_reconstruction_ball_pivoting()

# ms.generate_marching_cubes_apss(filterscale=5)
# print('estimating_normals...')
# ms.compute_normal_for_point_clouds()
# print('remove outliers')
# ms.compute_selection_point_cloud_outliers()
# ms.meshing_remove_selected_vertices()
# print('reconstructing...')
# ms.generate_surface_reconstruction_screened_poisson(depth=int(recon_depth))
# print('remove_connected_componet_by_diameter...')
# ms.meshing_remove_connected_component_by_diameter()
# ms.meshing_remove_connected_component_by_face_number(mincomponentsize=100)
# print('compute_selection_by_edge_length...')
# # ms.meshing_remove_connected_component_by_diameter()
# ms.compute_selection_by_edge_length(threshold=0.1)
# print('meshing_remove_selected_faces...')
# ms.meshing_remove_selected_faces()
# print('dilate...')
# ms.apply_selection_dilatation()
# ms.apply_selection_dilatation()
# ms.apply_selection_dilatation()
# ms.apply_selection_dilatation()
# ms.apply_selection_dilatation()
# print('select_small_disconnected_components...')
# ms.compute_selection_by_small_disconnected_components_per_face()
# print('remove_selected_faces...')
# ms.meshing_remove_selected_faces()
# print('repair_non_manifold_edges...')
# ms.meshing_repair_non_manifold_edges()
# print('close_holes...')
# ms.meshing_close_holes()
# print('repair non manifold...')
# ms.meshing_repair_non_manifold_edges()
# print('saving...')
ms.save_current_mesh(output_folder + "/cleaned_up.ply")
Loading

0 comments on commit 1c300af

Please sign in to comment.