├── .github └── workflows │ └── main.yml ├── .gitignore ├── Dockerfile ├── LICENSE.txt ├── Makefile ├── Makefile.inc ├── README.md ├── apps ├── Makefile ├── bundle2pset │ ├── Makefile │ └── bundle2pset.cc ├── dmrecon │ ├── Makefile │ ├── dmrecon.cc │ ├── fancy_progress_printer.cc │ └── fancy_progress_printer.h ├── featurerecon │ ├── Makefile │ └── featurerecon.cc ├── fssrecon │ ├── Makefile │ └── fssrecon.cc ├── makescene │ ├── Makefile │ └── makescene.cc ├── mesh2pset │ ├── Makefile │ └── mesh2pset.cc ├── meshalign │ ├── Makefile │ ├── meshalign.cc │ ├── meshlab_alignment.cc │ ├── meshlab_alignment.h │ ├── range_image.h │ ├── stanford_alignment.cc │ └── stanford_alignment.h ├── meshclean │ ├── Makefile │ └── meshclean.cc ├── meshconvert │ ├── Makefile │ └── meshconvert.cc ├── prebundle │ ├── Makefile │ └── prebundle.cc ├── scene2pset │ ├── Makefile │ └── scene2pset.cc ├── sceneupgrade │ ├── Makefile │ └── sceneupgrade.cc ├── sfmrecon │ ├── Makefile │ └── sfmrecon.cc └── umve │ ├── batchoperations.cc │ ├── batchoperations.h │ ├── clickimage.h │ ├── fshelpers.cc │ ├── fshelpers.h │ ├── glwidget.cc │ ├── glwidget.h │ ├── guihelpers.cc │ ├── guihelpers.h │ ├── images │ ├── icon_about.svg │ ├── icon_broken.svg │ ├── icon_clean.svg │ ├── icon_close.svg │ ├── icon_copy.svg │ ├── icon_delete.svg │ ├── icon_exec.svg │ ├── icon_exit.svg │ ├── icon_export.svg │ ├── icon_export_ply.svg │ ├── icon_eye.svg │ ├── icon_file.svg │ ├── icon_folder.svg │ ├── icon_image_inspect.svg │ ├── icon_large_minus.png │ ├── icon_large_plus.png │ ├── icon_new_dir.svg │ ├── icon_new_file.svg │ ├── icon_open_file.svg │ ├── icon_player_eject.svg │ ├── icon_player_end.svg │ ├── icon_player_fwd.svg │ ├── icon_player_pause.svg │ ├── icon_player_play.svg │ ├── icon_player_record.svg │ ├── icon_player_rew.svg │ ├── icon_player_start.svg │ ├── icon_player_stop.svg │ ├── icon_refresh.svg │ ├── icon_revert.svg │ ├── icon_save.svg │ ├── icon_screenshot.svg │ ├── icon_small_minus.png │ ├── icon_small_plus.png │ ├── icon_toolbox.svg │ ├── icon_video.svg │ ├── icon_window.png │ ├── icon_zoom_in.svg │ ├── icon_zoom_out.svg │ ├── icon_zoom_page.svg │ └── icon_zoom_reset.svg │ ├── jobqueue.cc │ ├── jobqueue.h │ ├── mainwindow.cc │ ├── mainwindow.h │ ├── mainwindowtab.cc │ ├── mainwindowtab.h │ ├── plugins │ └── example │ │ ├── example_plugin.cc │ │ ├── example_plugin.h │ │ └── example_plugin.pro │ ├── scene_addins │ ├── addin_aabb_creator.cc │ ├── addin_aabb_creator.h │ ├── addin_axis_renderer.cc │ ├── addin_axis_renderer.h │ ├── addin_base.h │ ├── addin_dm_triangulate.cc │ ├── addin_dm_triangulate.h │ ├── addin_frusta_base.cc │ ├── addin_frusta_base.h │ ├── addin_frusta_scene_renderer.cc │ ├── addin_frusta_scene_renderer.h │ ├── addin_mesh_renderer.cc │ ├── addin_mesh_renderer.h │ ├── addin_offscreen_renderer.cc │ ├── addin_offscreen_renderer.h │ ├── addin_plane_creator.cc │ ├── addin_plane_creator.h │ ├── addin_rephotographer.cc │ ├── addin_rephotographer.h │ ├── addin_selection.cc │ ├── addin_selection.h │ ├── addin_sfm_renderer.cc │ ├── addin_sfm_renderer.h │ ├── addin_sphere_creator.cc │ ├── addin_sphere_creator.h │ ├── addin_state.cc │ ├── addin_state.h │ ├── camera_sequence.cc │ ├── camera_sequence.h │ ├── mesh_list.cc │ └── mesh_list.h │ ├── scene_inspect │ ├── addin_manager.cc │ ├── addin_manager.h │ ├── scene_inspect.cc │ └── scene_inspect.h │ ├── scenemanager.cc │ ├── scenemanager.h │ ├── sceneoverview.cc │ ├── sceneoverview.h │ ├── selectedview.cc │ ├── selectedview.h │ ├── shaders │ ├── overlay_330.frag │ ├── overlay_330.vert │ ├── surface_330.frag │ ├── surface_330.vert │ ├── texture_330.frag │ ├── texture_330.vert │ ├── wireframe_330.frag │ └── wireframe_330.vert │ ├── umve.cc │ ├── umve.pro │ ├── umve.qrc │ └── viewinspect │ ├── imageinspector.cc │ ├── imageinspector.h │ ├── imageoperations.cc │ ├── imageoperations.h │ ├── scrollimage.cc │ ├── scrollimage.h │ ├── tonemapping.cc │ ├── tonemapping.h │ ├── viewinspect.cc │ └── viewinspect.h ├── dist └── snap │ ├── README.md │ ├── gui │ ├── umve.desktop │ └── umve.png │ └── snapcraft.yaml ├── docs ├── Makefile ├── doxygen.html └── doxygen │ └── Doxyfile ├── libs ├── Makefile ├── dmrecon │ ├── Makefile │ ├── defines.h │ ├── dmrecon.cc │ ├── dmrecon.h │ ├── global_view_selection.cc │ ├── global_view_selection.h │ ├── image_pyramid.cc │ ├── image_pyramid.h │ ├── local_view_selection.cc │ ├── local_view_selection.h │ ├── mvs_tools.cc │ ├── mvs_tools.h │ ├── patch_optimization.cc │ ├── patch_optimization.h │ ├── patch_sampler.cc │ ├── patch_sampler.h │ ├── progress.h │ ├── settings.h │ ├── single_view.cc │ ├── single_view.h │ └── view_selection.h ├── fssr │ ├── Makefile │ ├── basis_function.cc │ ├── basis_function.h │ ├── defines.h │ ├── hermite.cc │ ├── hermite.h │ ├── iso_octree.cc │ ├── iso_octree.h │ ├── iso_surface.cc │ ├── iso_surface.h │ ├── mesh_clean.cc │ ├── mesh_clean.h │ ├── octree.cc │ ├── octree.h │ ├── sample.h │ ├── sample_io.cc │ ├── sample_io.h │ ├── triangulation.cc │ ├── triangulation.h │ ├── voxel.cc │ └── voxel.h ├── math │ ├── Makefile │ ├── accum.h │ ├── algo.h │ ├── bezier_curve.h │ ├── bspline.h │ ├── defines.h │ ├── functions.h │ ├── geometry.h │ ├── line.h │ ├── matrix.h │ ├── matrix_qr.h │ ├── matrix_svd.h │ ├── matrix_tools.h │ ├── octree_tools.h │ ├── permute.h │ ├── plane.h │ ├── quaternion.h │ ├── transform.h │ └── vector.h ├── mve │ ├── Makefile │ ├── bundle.cc │ ├── bundle.h │ ├── bundle_io.cc │ ├── bundle_io.h │ ├── camera.cc │ ├── camera.h │ ├── defines.h │ ├── depthmap.cc │ ├── depthmap.h │ ├── image.h │ ├── image_base.h │ ├── image_color.h │ ├── image_drawing.h │ ├── image_exif.cc │ ├── image_exif.h │ ├── image_io.cc │ ├── image_io.h │ ├── image_tools.cc │ ├── image_tools.h │ ├── marching.cc │ ├── marching_cubes.h │ ├── marching_tets.h │ ├── mesh.cc │ ├── mesh.h │ ├── mesh_info.cc │ ├── mesh_info.h │ ├── mesh_io.cc │ ├── mesh_io.h │ ├── mesh_io_glb.cc │ ├── mesh_io_glb.h │ ├── mesh_io_npts.cc │ ├── mesh_io_npts.h │ ├── mesh_io_obj.cc │ ├── mesh_io_obj.h │ ├── mesh_io_off.cc │ ├── mesh_io_off.h │ ├── mesh_io_pbrt.cc │ ├── mesh_io_pbrt.h │ ├── mesh_io_ply.cc │ ├── mesh_io_ply.h │ ├── mesh_io_smf.cc │ ├── mesh_io_smf.h │ ├── mesh_tools.cc │ ├── mesh_tools.h │ ├── scene.cc │ ├── scene.h │ ├── view.cc │ ├── view.h │ ├── volume.cc │ └── volume.h ├── ogl │ ├── Makefile │ ├── camera.h │ ├── camera_2d.cc │ ├── camera_2d.h │ ├── camera_trackball.cc │ ├── camera_trackball.h │ ├── check_gl_error.h │ ├── context.h │ ├── defines.h │ ├── events.cc │ ├── events.h │ ├── key_symbols.h │ ├── mesh_renderer.cc │ ├── mesh_renderer.h │ ├── opengl.h │ ├── render_tools.cc │ ├── render_tools.h │ ├── shader_program.cc │ ├── shader_program.h │ ├── texture.cc │ ├── texture.h │ ├── vertex_array.cc │ ├── vertex_array.h │ ├── vertex_buffer.cc │ └── vertex_buffer.h ├── sfm │ ├── Makefile │ ├── _test_bundle_adjustment.cc │ ├── _test_camera_db.cc │ ├── _test_features.cc │ ├── _test_homography.cc │ ├── _test_matching.cc │ ├── ba_cholesky.h │ ├── ba_conjugate_gradient.h │ ├── ba_dense_vector.h │ ├── ba_linear_solver.cc │ ├── ba_linear_solver.h │ ├── ba_sparse_matrix.h │ ├── ba_types.h │ ├── bundle_adjustment.cc │ ├── bundle_adjustment.h │ ├── bundler_common.cc │ ├── bundler_common.h │ ├── bundler_features.cc │ ├── bundler_features.h │ ├── bundler_incremental.cc │ ├── bundler_incremental.h │ ├── bundler_init_pair.cc │ ├── bundler_init_pair.h │ ├── bundler_intrinsics.cc │ ├── bundler_intrinsics.h │ ├── bundler_matching.cc │ ├── bundler_matching.h │ ├── bundler_tracks.cc │ ├── bundler_tracks.h │ ├── camera_database.cc │ ├── camera_database.h │ ├── camera_pose.h │ ├── cascade_hashing.cc │ ├── cascade_hashing.h │ ├── correspondence.h │ ├── defines.h │ ├── exhaustive_matching.cc │ ├── exhaustive_matching.h │ ├── extract_focal_length.cc │ ├── extract_focal_length.h │ ├── feature_set.cc │ ├── feature_set.h │ ├── fundamental.cc │ ├── fundamental.h │ ├── homography.cc │ ├── homography.h │ ├── matching.cc │ ├── matching.h │ ├── matching_base.h │ ├── nearest_neighbor.cc │ ├── nearest_neighbor.h │ ├── pose_p3p.cc │ ├── pose_p3p.h │ ├── ransac.cc │ ├── ransac.h │ ├── ransac_fundamental.cc │ ├── ransac_fundamental.h │ ├── ransac_homography.cc │ ├── ransac_homography.h │ ├── ransac_pose_p3p.cc │ ├── ransac_pose_p3p.h │ ├── sift.cc │ ├── sift.h │ ├── surf.cc │ ├── surf.h │ ├── triangulate.cc │ ├── triangulate.h │ ├── visualizer.cc │ └── visualizer.h └── util │ ├── Makefile │ ├── aligned_allocator.h │ ├── aligned_memory.h │ ├── arguments.cc │ ├── arguments.h │ ├── defines.h │ ├── exception.h │ ├── file_system.cc │ ├── file_system.h │ ├── frame_timer.h │ ├── ini_parser.cc │ ├── ini_parser.h │ ├── logging.h │ ├── string_utils.h │ ├── system.cc │ ├── system.h │ ├── timer.h │ └── tokenizer.h └── tests ├── Makefile ├── fssr ├── gtest_iso_octree.cc ├── gtest_mesh_clean.cc ├── gtest_octree.cc └── gtest_octree_iterator.cc ├── math ├── gtest_accum.cc ├── gtest_algo.cc ├── gtest_defines.cc ├── gtest_functions.cc ├── gtest_geom.cc ├── gtest_matrix.cc ├── gtest_matrix_qr.cc ├── gtest_matrix_svd.cc ├── gtest_matrix_tools.cc ├── gtest_quaternion.cc └── gtest_vector.cc ├── mve ├── gtest_bundle.cc ├── gtest_camera.cc ├── gtest_image.cc ├── gtest_image_color.cc ├── gtest_image_drawing.cc ├── gtest_image_io.cc ├── gtest_image_tools.cc ├── gtest_mesh_info.cc ├── gtest_mesh_io.cc ├── gtest_mesh_tools.cc ├── gtest_scene.cc ├── gtest_triangle_mesh.cc └── gtest_view.cc ├── sfm ├── gtest_ba_cholesky.cc ├── gtest_ba_conjugate_gradient.cc ├── gtest_ba_dense_vector.cc ├── gtest_ba_sparse_matrix.cc ├── gtest_bundler_tracks.cc ├── gtest_homography.cc ├── gtest_matching.cc ├── gtest_nearest_neighbor.cc ├── gtest_pose.cc ├── gtest_pose_p3p.cc └── gtest_surf.cc └── util ├── gtest_aligned_memory.cc ├── gtest_endian.cc ├── gtest_file_system.cc ├── gtest_string_utils.cc └── gtest_tokenizer.cc /.gitignore: -------------------------------------------------------------------------------- 1 | # compiled objects 2 | *.o 3 | 4 | # compiled archives 5 | *.a 6 | 7 | # generated makefiles 8 | *.dep 9 | 10 | # apps 11 | apps/bundle2pset/bundle2pset 12 | apps/dmrecon/dmrecon 13 | apps/featurerecon/featurerecon 14 | apps/fssrecon/fssrecon 15 | apps/makescene/makescene 16 | apps/mesh2pset/mesh2pset 17 | apps/meshalign/meshalign 18 | apps/meshclean/meshclean 19 | apps/meshconvert/meshconvert 20 | apps/prebundle/prebundle 21 | apps/scene2pset/scene2pset 22 | apps/sceneupgrade/sceneupgrade 23 | apps/sfmrecon/sfmrecon 24 | apps/umve/umve 25 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | ARG ALPINE_VERSION=3.10 2 | FROM alpine:${ALPINE_VERSION} 3 | 4 | COPY . /mve 5 | 6 | RUN apk add --no-cache \ 7 | make \ 8 | g++ \ 9 | jpeg-dev \ 10 | libpng-dev \ 11 | tiff-dev \ 12 | mesa-dev \ 13 | && cd /mve \ 14 | && mkdir bin \ 15 | && make all 16 | 17 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Software License Agreement (BSD 3-Clause License) 2 | --------------------------------------------------------------------------- 3 | 4 | Copyright (c) 2015, Simon Fuhrmann and others 5 | TU Darmstadt - Graphics, Capture and Massively Parallel Computing 6 | All rights reserved. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are met: 10 | 11 | 1. Redistributions of source code must retain the above copyright notice, 12 | this list of conditions and the following disclaimer. 13 | 2. Redistributions in binary form must reproduce the above copyright notice, 14 | this list of conditions and the following disclaimer in the documentation 15 | and/or other materials provided with the distribution. 16 | 3. Neither the name of the copyright holder nor the names of its contributors 17 | may be used to endorse or promote products derived from this software 18 | without specific prior written permission. 19 | 20 | This software is provided by the copyright holders and contributors "as is" 21 | and any express or implied warranties, including, but not limited to, the 22 | implied warranties of merchantability and fitness for a particular purpose 23 | are disclaimed. In no event shall the copyright holder or contributors be 24 | liable for any direct, indirect, incidental, special, exemplary, or 25 | consequential damages (including, but not limited to, procurement of 26 | substitute goods or services; loss of use, data, or profits; or business 27 | interruption) however caused and on any theory of liability, whether in 28 | contract, strict liability, or tort (including negligence or otherwise) 29 | arising in any way out of the use of this software, even if advised of the 30 | possibility of such damage. 31 | 32 | 33 | Non-free Software Disclaimer 34 | --------------------------------------------------------------------------- 35 | 36 | The Structure-from-Motion library 'sfm' contains algorithms that may be 37 | patented in some countries or have some other limitations on the use. Make 38 | sure you are permitted to use the code in the following files: 39 | 40 | - libs/sfm/sift.cc 41 | - libs/sfm/surf.cc 42 | 43 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # Builds libs and all apps except umve 2 | all: 3 | $(MAKE) -C libs 4 | $(MAKE) -C apps 5 | 6 | # Builds Doxygen documentation 7 | doc: 8 | $(MAKE) -C docs 9 | 10 | # Builds the tests, execute with ./tests/test 11 | test: 12 | $(MAKE) -C tests 13 | 14 | # Cleans all libs and apps except umve 15 | clean: 16 | $(MAKE) -C apps $@ 17 | $(MAKE) -C libs $@ 18 | $(MAKE) -C tests $@ 19 | 20 | # Creates symbolic links to all apps in $HOME/bin/ 21 | links: 22 | $(MAKE) -C apps $@ 23 | 24 | .PHONY: all doc test clean links 25 | -------------------------------------------------------------------------------- /Makefile.inc: -------------------------------------------------------------------------------- 1 | # Default values. 2 | CXX ?= g++ 3 | CXXWARNINGS ?= -Wall -Wextra -Wundef -pedantic 4 | CXXINTRINSICS ?= -march=native 5 | CXXFEATURES ?= -funsafe-math-optimizations -fno-math-errno -std=c++14 6 | CXXFLAGS ?= ${CXXWARNINGS} ${CXXINTRINSICS} ${CXXFEATURES} -g -O3 7 | 8 | # Delete this if OpenMP is not available (e.g., OS X without gcc) 9 | OPENMP ?= -fopenmp 10 | 11 | # Always compile programs and libs with multi-threading. 12 | CXXFLAGS += -pthread 13 | 14 | UNAME = $(shell uname) 15 | ifeq (${UNAME},Darwin) 16 | CXXFLAGS += -DGL_SILENCE_DEPRECATION=1 17 | OPENMP = 18 | endif 19 | 20 | LIBJPEG_CFLAGS = `pkg-config --cflags libjpeg` 21 | LIBJPEG_LDFLAGS = `pkg-config --libs libjpeg` 22 | 23 | LIBPNG_CFLAGS = `pkg-config --cflags libpng` 24 | LIBPNG_LDFLAGS = `pkg-config --libs libpng` 25 | 26 | LIBTIFF_CFLAGS = `pkg-config --cflags libtiff-4` 27 | LIBTIFF_LDFLAGS = `pkg-config --libs libtiff-4` 28 | 29 | COMPILE.cc = ${CXX} ${CXXFLAGS} ${CPPFLAGS} -c 30 | LINK.o = ${CXX} ${LDFLAGS} 31 | .DEFAULT_GOAL := ${TARGET} 32 | 33 | # How to link example from example.o and other files. 34 | %: %.o 35 | ${LINK.o} -o $@ $^ ${LDLIBS} 36 | 37 | # How to compile example.o from example.cc. 38 | %.o: %.cc 39 | ${COMPILE.cc} -o $@ $< 40 | 41 | # Library paths. 42 | vpath libmve_dmrecon.a ${MVE_ROOT}/libs/dmrecon/ 43 | vpath libmve_math.a ${MVE_ROOT}/libs/math/ 44 | vpath libmve.a ${MVE_ROOT}/libs/mve/ 45 | vpath libmve_ogl.a ${MVE_ROOT}/libs/ogl/ 46 | vpath libmve_util.a ${MVE_ROOT}/libs/util/ 47 | vpath libmve_sfm.a ${MVE_ROOT}/libs/sfm/ 48 | vpath libmve_fssr.a ${MVE_ROOT}/libs/fssr/ 49 | 50 | # Autogenerate dependencies. 51 | Makefile.dep: [^_]*.cc 52 | ${COMPILE.cc} -MM $^ >$@ 53 | 54 | -include Makefile.dep 55 | -------------------------------------------------------------------------------- /apps/Makefile: -------------------------------------------------------------------------------- 1 | all: 2 | $(MAKE) -C bundle2pset 3 | $(MAKE) -C dmrecon 4 | $(MAKE) -C makescene 5 | $(MAKE) -C meshconvert 6 | $(MAKE) -C scene2pset 7 | $(MAKE) -C sfmrecon 8 | $(MAKE) -C featurerecon 9 | $(MAKE) -C fssrecon 10 | $(MAKE) -C mesh2pset 11 | $(MAKE) -C meshalign 12 | $(MAKE) -C meshclean 13 | $(MAKE) -C sceneupgrade 14 | $(MAKE) -C prebundle 15 | 16 | clean: 17 | $(MAKE) -C bundle2pset $@ 18 | $(MAKE) -C dmrecon $@ 19 | $(MAKE) -C makescene $@ 20 | $(MAKE) -C meshconvert $@ 21 | $(MAKE) -C scene2pset $@ 22 | $(MAKE) -C sfmrecon $@ 23 | $(MAKE) -C featurerecon $@ 24 | $(MAKE) -C fssrecon $@ 25 | $(MAKE) -C mesh2pset $@ 26 | $(MAKE) -C meshalign $@ 27 | $(MAKE) -C meshclean $@ 28 | $(MAKE) -C sceneupgrade $@ 29 | $(MAKE) -C prebundle $@ 30 | 31 | BINDIR ?= $(HOME)/bin/ 32 | APPDIR := $(shell pwd) 33 | 34 | links: 35 | ln -si $(APPDIR)/bundle2pset/bundle2pset $(BINDIR) 36 | ln -si $(APPDIR)/dmrecon/dmrecon $(BINDIR) 37 | ln -si $(APPDIR)/makescene/makescene $(BINDIR) 38 | ln -si $(APPDIR)/meshconvert/meshconvert $(BINDIR) 39 | ln -si $(APPDIR)/scene2pset/scene2pset $(BINDIR) 40 | ln -si $(APPDIR)/sfmrecon/sfmrecon $(BINDIR) 41 | ln -si $(APPDIR)/featurerecon/featurerecon $(BINDIR) 42 | ln -si $(APPDIR)/fssrecon/fssrecon $(BINDIR) 43 | ln -si $(APPDIR)/mesh2pset/mesh2pset $(BINDIR) 44 | ln -si $(APPDIR)/meshalign/meshalign $(BINDIR) 45 | ln -si $(APPDIR)/meshclean/meshclean $(BINDIR) 46 | ln -si $(APPDIR)/sceneupgrade/sceneupgrade $(BINDIR) 47 | ln -si $(APPDIR)/prebundle/prebundle $(BINDIR) 48 | ln -si $(APPDIR)/umve/umve $(BINDIR) 49 | 50 | .PHONY: all clean links 51 | -------------------------------------------------------------------------------- /apps/bundle2pset/Makefile: -------------------------------------------------------------------------------- 1 | MVE_ROOT := ../.. 2 | TARGET := $(shell basename `pwd`) 3 | include ${MVE_ROOT}/Makefile.inc 4 | 5 | CXXFLAGS += -I${MVE_ROOT}/libs ${OPENMP} 6 | LDLIBS += ${LIBJPEG_LDFLAGS} ${LIBPNG_LDFLAGS} ${LIBTIFF_LDFLAGS} ${OPENMP} 7 | 8 | SOURCES := $(wildcard [^_]*.cc) 9 | ${TARGET}: ${SOURCES:.cc=.o} libmve.a libmve_util.a 10 | $(LINK.o) $^ $(LDLIBS) -o $@ 11 | 12 | clean: 13 | ${RM} ${TARGET} *.o Makefile.dep 14 | 15 | .PHONY: clean 16 | -------------------------------------------------------------------------------- /apps/dmrecon/Makefile: -------------------------------------------------------------------------------- 1 | MVE_ROOT := ../.. 2 | TARGET := $(shell basename `pwd`) 3 | include ${MVE_ROOT}/Makefile.inc 4 | 5 | CXXFLAGS += -I${MVE_ROOT}/libs ${OPENMP} 6 | LDLIBS += ${LIBJPEG_LDFLAGS} ${LIBPNG_LDFLAGS} ${LIBTIFF_LDFLAGS} ${OPENMP} 7 | 8 | SOURCES := $(wildcard [^_]*.cc) 9 | ${TARGET}: ${SOURCES:.cc=.o} libmve_dmrecon.a libmve.a libmve_util.a 10 | $(LINK.o) $^ $(LDLIBS) -o $@ 11 | 12 | clean: 13 | ${RM} ${TARGET} *.o Makefile.dep 14 | 15 | .PHONY: clean 16 | -------------------------------------------------------------------------------- /apps/dmrecon/fancy_progress_printer.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, Simon Fuhrmann 3 | * TU Darmstadt - Graphics, Capture and Massively Parallel Computing 4 | * All rights reserved. 5 | * 6 | * This software may be modified and distributed under the terms 7 | * of the BSD 3-Clause license. See the LICENSE.txt file for details. 8 | */ 9 | 10 | #include 11 | 12 | #include "fancy_progress_printer.h" 13 | #include "util/system.h" 14 | 15 | #define ANSI_CURSOR_RESET "\x1B[H" 16 | #define ANSI_CLEAR_SCREEN "\x1B[2J" 17 | 18 | #define ANSI_STYLE_RESET "\x1B[0m" 19 | #define ANSI_STYLE_BOLD "\x1B[1m" 20 | 21 | #define ANSI_STYLE_BLACK "\x1B[30m" 22 | #define ANSI_STYLE_RED "\x1B[31m" 23 | #define ANSI_STYLE_GREEN "\x1B[32m" 24 | #define ANSI_STYLE_YELLOW "\x1B[33m" 25 | #define ANSI_STYLE_BLUE "\x1B[34m" 26 | #define ANSI_STYLE_MAGENTA "\x1B[35m" 27 | #define ANSI_STYLE_CYAN "\x1B[36m" 28 | #define ANSI_STYLE_WHITE "\x1B[37m" 29 | 30 | void 31 | FancyProgressPrinter::start() 32 | { 33 | thread = std::thread(&FancyProgressPrinter::run, this); 34 | thread.detach(); 35 | } 36 | 37 | void 38 | FancyProgressPrinter::run() 39 | { 40 | this->isRunning = true; 41 | while (this->isRunning) 42 | { 43 | std::this_thread::sleep_for(std::chrono::seconds(2)); 44 | 45 | this->print(); 46 | } 47 | } 48 | 49 | void 50 | FancyProgressPrinter::print() 51 | { 52 | std::lock_guard lock(this->mutex); 53 | 54 | std::cout << ANSI_CURSOR_RESET << ANSI_CLEAR_SCREEN; 55 | std::cout << "Reconstructing " << this->basePath << "\n\n "; 56 | 57 | for (std::vector::iterator it = this->viewStatus.begin(); 58 | it != this->viewStatus.end(); ++it) 59 | { 60 | switch (*it) 61 | { 62 | case STATUS_IGNORED: 63 | std::cout << ANSI_STYLE_WHITE << '_'; 64 | break; 65 | case STATUS_QUEUED: 66 | std::cout << ANSI_STYLE_WHITE << '.'; 67 | break; 68 | case STATUS_IN_PROGRESS: 69 | std::cout << ANSI_STYLE_BOLD << ANSI_STYLE_YELLOW << '@'; 70 | break; 71 | case STATUS_DONE: 72 | std::cout << ANSI_STYLE_BOLD << ANSI_STYLE_GREEN << '!'; 73 | break; 74 | case STATUS_FAILED: 75 | std::cout << ANSI_STYLE_BOLD << ANSI_STYLE_RED << '!'; 76 | break; 77 | } 78 | 79 | std::cout << ANSI_STYLE_RESET; 80 | } 81 | 82 | std::cout << "\n\n"; 83 | 84 | for (std::set::iterator it = this->runningRecons.begin(); 85 | it != this->runningRecons.end(); ++it) 86 | { 87 | mvs::Progress const &p = (*it)->getProgress(); 88 | std::cout << "View #" << (*it)->getRefViewNr() 89 | << ": filled " << p.filled 90 | << " of " << (p.filled + p.queueSize) << '\n'; 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /apps/featurerecon/Makefile: -------------------------------------------------------------------------------- 1 | MVE_ROOT := ../.. 2 | TARGET := $(shell basename `pwd`) 3 | include ${MVE_ROOT}/Makefile.inc 4 | 5 | CXXFLAGS += -I${MVE_ROOT}/libs ${OPENMP} 6 | LDLIBS += ${LIBJPEG_LDFLAGS} ${LIBPNG_LDFLAGS} ${LIBTIFF_LDFLAGS} ${OPENMP} 7 | 8 | SOURCES := $(wildcard [^_]*.cc) 9 | ${TARGET}: ${SOURCES:.cc=.o} libmve_sfm.a libmve.a libmve_util.a 10 | $(LINK.o) $^ $(LDLIBS) -o $@ 11 | 12 | clean: 13 | ${RM} ${TARGET} *.o Makefile.dep 14 | 15 | .PHONY: clean 16 | -------------------------------------------------------------------------------- /apps/fssrecon/Makefile: -------------------------------------------------------------------------------- 1 | MVE_ROOT := ../.. 2 | TARGET := $(shell basename `pwd`) 3 | include ${MVE_ROOT}/Makefile.inc 4 | 5 | CXXFLAGS += -I${MVE_ROOT}/libs ${OPENMP} 6 | LDLIBS += ${LIBJPEG_LDFLAGS} ${LIBPNG_LDFLAGS} ${LIBTIFF_LDFLAGS} ${OPENMP} 7 | 8 | SOURCES := $(wildcard [^_]*.cc) 9 | ${TARGET}: ${SOURCES:.cc=.o} libmve_fssr.a libmve.a libmve_util.a 10 | 11 | clean: 12 | ${RM} ${TARGET} *.o Makefile.dep 13 | 14 | .PHONY: clean 15 | -------------------------------------------------------------------------------- /apps/makescene/Makefile: -------------------------------------------------------------------------------- 1 | MVE_ROOT := ../.. 2 | TARGET := $(shell basename `pwd`) 3 | include ${MVE_ROOT}/Makefile.inc 4 | 5 | CXXFLAGS += -I${MVE_ROOT}/libs ${OPENMP} 6 | LDLIBS += ${LIBJPEG_LDFLAGS} ${LIBPNG_LDFLAGS} ${LIBTIFF_LDFLAGS} ${OPENMP} 7 | 8 | SOURCES := $(wildcard [^_]*.cc) 9 | ${TARGET}: ${SOURCES:.cc=.o} libmve.a libmve_util.a 10 | $(LINK.o) $^ $(LDLIBS) -o $@ 11 | 12 | clean: 13 | ${RM} ${TARGET} *.o Makefile.dep 14 | 15 | .PHONY: clean 16 | -------------------------------------------------------------------------------- /apps/mesh2pset/Makefile: -------------------------------------------------------------------------------- 1 | MVE_ROOT := ../.. 2 | TARGET := $(shell basename `pwd`) 3 | include ${MVE_ROOT}/Makefile.inc 4 | 5 | CXXFLAGS += -I${MVE_ROOT}/libs ${OPENMP} 6 | LDLIBS += ${LIBJPEG_LDFLAGS} ${LIBPNG_LDFLAGS} ${LIBTIFF_LDFLAGS} ${OPENMP} 7 | 8 | SOURCES := $(wildcard [^_]*.cc) 9 | ${TARGET}: ${SOURCES:.cc=.o} libmve_fssr.a libmve.a libmve_util.a 10 | 11 | clean: 12 | ${RM} ${TARGET} *.o Makefile.dep 13 | 14 | .PHONY: clean 15 | -------------------------------------------------------------------------------- /apps/meshalign/Makefile: -------------------------------------------------------------------------------- 1 | MVE_ROOT := ../.. 2 | TARGET := $(shell basename `pwd`) 3 | include ${MVE_ROOT}/Makefile.inc 4 | 5 | CXXFLAGS += -I${MVE_ROOT}/libs ${OPENMP} 6 | LDLIBS += ${LIBJPEG_LDFLAGS} ${LIBPNG_LDFLAGS} ${LIBTIFF_LDFLAGS} ${OPENMP} 7 | 8 | SOURCES := $(wildcard [^_]*.cc) 9 | ${TARGET}: ${SOURCES:.cc=.o} libmve_fssr.a libmve.a libmve_util.a 10 | 11 | clean: 12 | ${RM} ${TARGET} *.o Makefile.dep 13 | 14 | .PHONY: clean 15 | -------------------------------------------------------------------------------- /apps/meshalign/meshlab_alignment.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, Simon Fuhrmann 3 | * TU Darmstadt - Graphics, Capture and Massively Parallel Computing 4 | * All rights reserved. 5 | * 6 | * This software may be modified and distributed under the terms 7 | * of the BSD 3-Clause license. See the LICENSE.txt file for details. 8 | */ 9 | 10 | #ifndef MESHLAB_DATASET_HEADER 11 | #define MESHLAB_DATASET_HEADER 12 | 13 | #include 14 | 15 | #include "mve/mesh.h" 16 | #include "range_image.h" 17 | 18 | /** 19 | * Reads a Meshlab alignment file and performs the transformation. 20 | * Meshlab alignment file format: 21 | * 22 | * NUM_MESHES 23 | * 24 | * MESH_FILE_NAME 25 | * R1 R2 R3 T1 26 | * R4 R5 R6 T2 27 | * R7 R8 R9 T3 28 | * 0 0 0 1 29 | * 30 | * MESH_FILE_NAME 31 | * ... 32 | */ 33 | class MeshlabAlignment 34 | { 35 | public: 36 | typedef std::vector RangeImages; 37 | 38 | public: 39 | MeshlabAlignment (void); 40 | 41 | void read_alignment (std::string const& filename); 42 | RangeImages const& get_range_images (void) const; 43 | mve::TriangleMesh::Ptr get_mesh (RangeImage const& ri) const; 44 | 45 | private: 46 | RangeImages images; 47 | }; 48 | 49 | /* ---------------------------------------------------------------- */ 50 | 51 | inline 52 | MeshlabAlignment::MeshlabAlignment (void) 53 | { 54 | } 55 | 56 | inline MeshlabAlignment::RangeImages const& 57 | MeshlabAlignment::get_range_images (void) const 58 | { 59 | return this->images; 60 | } 61 | 62 | #endif // MESHLAB_DATASET_H 63 | -------------------------------------------------------------------------------- /apps/meshalign/range_image.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, Simon Fuhrmann 3 | * TU Darmstadt - Graphics, Capture and Massively Parallel Computing 4 | * All rights reserved. 5 | * 6 | * This software may be modified and distributed under the terms 7 | * of the BSD 3-Clause license. See the LICENSE.txt file for details. 8 | */ 9 | 10 | #ifndef RANGE_IMAGE_HEADER 11 | #define RANGE_IMAGE_HEADER 12 | 13 | #include 14 | 15 | #include "math/vector.h" 16 | #include "math/matrix.h" 17 | 18 | /** 19 | * Meta-information of a range image. It contains the filename to the range 20 | * image as well as the camera to world transformation. A vertex in camera 21 | * coordinates is transformed to world coordinates by: 22 | * 23 | * v' = R * v + t 24 | */ 25 | struct RangeImage 26 | { 27 | std::string filename; 28 | std::string fullpath; 29 | math::Vec3f translation; 30 | math::Matrix3f rotation; 31 | math::Vec3f campos; 32 | math::Vec3f viewdir; 33 | }; 34 | 35 | #endif /* RANGE_IMAGE_HEADER */ 36 | -------------------------------------------------------------------------------- /apps/meshalign/stanford_alignment.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, Simon Fuhrmann 3 | * TU Darmstadt - Graphics, Capture and Massively Parallel Computing 4 | * All rights reserved. 5 | * 6 | * This software may be modified and distributed under the terms 7 | * of the BSD 3-Clause license. See the LICENSE.txt file for details. 8 | */ 9 | 10 | #ifndef DMFUSION_STANFORD_HEADER 11 | #define DMFUSION_STANFORD_HEADER 12 | 13 | #include 14 | #include 15 | 16 | #include "mve/mesh.h" 17 | #include "mve/image.h" 18 | 19 | #include "range_image.h" 20 | 21 | /** 22 | * Reads the Stanford alignment file and performs the transformation. 23 | * Stanford alignment file format: 24 | * 25 | * camera T1 T2 T3 Q1 Q2 Q3 Q4 26 | * bmesh FILE_NAME T1 T2 T3 Q1 Q2 Q3 Q4 27 | * bmesh ... 28 | */ 29 | class StanfordAlignment 30 | { 31 | public: 32 | typedef std::vector RangeImages; 33 | 34 | public: 35 | StanfordAlignment (void); 36 | 37 | void read_alignment (std::string const& conffile); 38 | RangeImages const& get_range_images (void) const; 39 | mve::TriangleMesh::Ptr get_mesh (RangeImage const& ri); 40 | 41 | private: 42 | RangeImages images; 43 | }; 44 | 45 | /* ---------------------------------------------------------------- */ 46 | 47 | inline 48 | StanfordAlignment::StanfordAlignment (void) 49 | { 50 | } 51 | 52 | inline StanfordAlignment::RangeImages const& 53 | StanfordAlignment::get_range_images (void) const 54 | { 55 | return this->images; 56 | } 57 | 58 | #endif /* DMFUSION_STANFORD_HEADER */ 59 | -------------------------------------------------------------------------------- /apps/meshclean/Makefile: -------------------------------------------------------------------------------- 1 | MVE_ROOT := ../.. 2 | TARGET := $(shell basename `pwd`) 3 | include ${MVE_ROOT}/Makefile.inc 4 | 5 | CXXFLAGS += -I${MVE_ROOT}/libs ${OPENMP} 6 | LDLIBS += ${LIBJPEG_LDFLAGS} ${LIBPNG_LDFLAGS} ${LIBTIFF_LDFLAGS} ${OPENMP} 7 | 8 | SOURCES := $(wildcard [^_]*.cc) 9 | ${TARGET}: ${SOURCES:.cc=.o} libmve_fssr.a libmve.a libmve_util.a 10 | 11 | clean: 12 | ${RM} ${TARGET} *.o Makefile.dep 13 | 14 | .PHONY: clean 15 | -------------------------------------------------------------------------------- /apps/meshconvert/Makefile: -------------------------------------------------------------------------------- 1 | MVE_ROOT := ../.. 2 | TARGET := $(shell basename `pwd`) 3 | include ${MVE_ROOT}/Makefile.inc 4 | 5 | CXXFLAGS += -I${MVE_ROOT}/libs ${OPENMP} 6 | LDLIBS += ${LIBJPEG_LDFLAGS} ${LIBPNG_LDFLAGS} ${LIBTIFF_LDFLAGS} ${OPENMP} 7 | 8 | SOURCES := $(wildcard [^_]*.cc) 9 | ${TARGET}: ${SOURCES:.cc=.o} libmve.a libmve_util.a 10 | $(LINK.o) $^ $(LDLIBS) -o $@ 11 | 12 | clean: 13 | ${RM} ${TARGET} *.o Makefile.dep 14 | 15 | .PHONY: clean 16 | -------------------------------------------------------------------------------- /apps/prebundle/Makefile: -------------------------------------------------------------------------------- 1 | MVE_ROOT := ../.. 2 | TARGET := $(shell basename `pwd`) 3 | include ${MVE_ROOT}/Makefile.inc 4 | 5 | CXXFLAGS += -I${MVE_ROOT}/libs ${OPENMP} 6 | LDLIBS += ${LIBJPEG_LDFLAGS} ${LIBPNG_LDFLAGS} ${LIBTIFF_LDFLAGS} ${OPENMP} 7 | 8 | SOURCES := $(wildcard [^_]*.cc) 9 | ${TARGET}: ${SOURCES:.cc=.o} libmve_sfm.a libmve.a libmve_util.a 10 | $(LINK.o) $^ $(LDLIBS) -o $@ 11 | 12 | clean: 13 | ${RM} ${TARGET} *.o Makefile.dep 14 | 15 | .PHONY: clean 16 | -------------------------------------------------------------------------------- /apps/scene2pset/Makefile: -------------------------------------------------------------------------------- 1 | MVE_ROOT := ../.. 2 | TARGET := $(shell basename `pwd`) 3 | include ${MVE_ROOT}/Makefile.inc 4 | 5 | CXXFLAGS += -I${MVE_ROOT}/libs ${OPENMP} 6 | LDLIBS += ${LIBJPEG_LDFLAGS} ${LIBPNG_LDFLAGS} ${LIBTIFF_LDFLAGS} ${OPENMP} 7 | 8 | SOURCES := $(wildcard [^_]*.cc) 9 | ${TARGET}: ${SOURCES:.cc=.o} libmve.a libmve_util.a 10 | $(LINK.o) $^ $(LDLIBS) -o $@ 11 | 12 | clean: 13 | ${RM} ${TARGET} *.o Makefile.dep 14 | 15 | .PHONY: clean 16 | -------------------------------------------------------------------------------- /apps/sceneupgrade/Makefile: -------------------------------------------------------------------------------- 1 | MVE_ROOT := ../.. 2 | TARGET := $(shell basename `pwd`) 3 | include ${MVE_ROOT}/Makefile.inc 4 | 5 | CXXFLAGS += -I${MVE_ROOT}/libs ${OPENMP} 6 | LDLIBS += ${LIBJPEG_LDFLAGS} ${LIBPNG_LDFLAGS} ${LIBTIFF_LDFLAGS} ${OPENMP} 7 | 8 | SOURCES := $(wildcard [^_]*.cc) 9 | ${TARGET}: ${SOURCES:.cc=.o} libmve_sfm.a libmve.a libmve_util.a 10 | $(LINK.o) $^ $(LDLIBS) -o $@ 11 | 12 | clean: 13 | ${RM} ${TARGET} *.o Makefile.dep 14 | 15 | .PHONY: clean 16 | -------------------------------------------------------------------------------- /apps/sfmrecon/Makefile: -------------------------------------------------------------------------------- 1 | MVE_ROOT := ../.. 2 | TARGET := $(shell basename `pwd`) 3 | include ${MVE_ROOT}/Makefile.inc 4 | 5 | CXXFLAGS += -I${MVE_ROOT}/libs ${OPENMP} 6 | LDLIBS += ${LIBJPEG_LDFLAGS} ${LIBPNG_LDFLAGS} ${LIBTIFF_LDFLAGS} ${OPENMP} 7 | 8 | SOURCES := $(wildcard [^_]*.cc) 9 | ${TARGET}: ${SOURCES:.cc=.o} libmve_sfm.a libmve.a libmve_util.a 10 | $(LINK.o) $^ $(LDLIBS) -o $@ 11 | 12 | clean: 13 | ${RM} ${TARGET} *.o Makefile.dep 14 | 15 | .PHONY: clean 16 | -------------------------------------------------------------------------------- /apps/umve/fshelpers.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, Simon Fuhrmann 3 | * TU Darmstadt - Graphics, Capture and Massively Parallel Computing 4 | * All rights reserved. 5 | * 6 | * This software may be modified and distributed under the terms 7 | * of the BSD 3-Clause license. See the LICENSE.txt file for details. 8 | */ 9 | 10 | #include 11 | #include 12 | 13 | #if defined(_WIN32) 14 | # include 15 | #endif 16 | 17 | #include "util/file_system.h" 18 | #include "fshelpers.h" 19 | 20 | void 21 | get_search_paths (std::vector* paths_out, 22 | std::string const& suffix) 23 | { 24 | std::string binary_dir = util::fs::dirname(util::fs::get_binary_path()); 25 | std::string app_data_dir = util::fs::get_app_data_dir(); 26 | std::string long_suffix = util::fs::join_path("umve", suffix); 27 | 28 | /* Appending the program name is not necessary for the binary dir. */ 29 | paths_out->push_back(util::fs::join_path(binary_dir, suffix)); 30 | 31 | /* System paths need the long suffix. */ 32 | paths_out->push_back(util::fs::join_path(app_data_dir, long_suffix)); 33 | #ifndef _WIN32 34 | paths_out->push_back(util::fs::join_path("/usr/local/share", long_suffix)); 35 | paths_out->push_back(util::fs::join_path("/usr/share", long_suffix)); 36 | #endif 37 | } 38 | -------------------------------------------------------------------------------- /apps/umve/fshelpers.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, Simon Fuhrmann 3 | * TU Darmstadt - Graphics, Capture and Massively Parallel Computing 4 | * All rights reserved. 5 | * 6 | * This software may be modified and distributed under the terms 7 | * of the BSD 3-Clause license. See the LICENSE.txt file for details. 8 | */ 9 | 10 | #ifndef UMVE_FSHELPERS_HEADER 11 | #define UMVE_FSHELPERS_HEADER 12 | 13 | #include 14 | #include 15 | 16 | /** 17 | * Returns a vector of (OS-specific) search paths: 18 | * - Binary directory 19 | * - User home directory 20 | * - A global/system-wide directory 21 | * - QT resource path Calling 22 | * 23 | * get_search_paths(..., "X") returns a vector containing: 24 | * On Linux: 25 | * /X 26 | * /.local/share/umve/X 27 | * /usr/local/share/umve/X 28 | * /usr/share/umve/X 29 | * 30 | * On Windows: 31 | * /X 32 | * /Application Data/umve/X 33 | */ 34 | void get_search_paths (std::vector* paths_out, 35 | std::string const& suffix); 36 | 37 | #endif /* UMVE_FSHELPERS_HEADER */ 38 | -------------------------------------------------------------------------------- /apps/umve/glwidget.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, Simon Fuhrmann 3 | * TU Darmstadt - Graphics, Capture and Massively Parallel Computing 4 | * All rights reserved. 5 | * 6 | * This software may be modified and distributed under the terms 7 | * of the BSD 3-Clause license. See the LICENSE.txt file for details. 8 | */ 9 | 10 | #ifndef UMVE_GL_WIDGET_HEADER 11 | #define UMVE_GL_WIDGET_HEADER 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | #include "ogl/context.h" 19 | 20 | class GLWidget : public QOpenGLWidget 21 | { 22 | Q_OBJECT 23 | 24 | public: 25 | GLWidget(QWidget* parent = nullptr); 26 | ~GLWidget(); 27 | 28 | void set_context (ogl::Context* context); 29 | 30 | QSize minimumSizeHint() const; 31 | QSize sizeHint() const; 32 | 33 | public slots: 34 | void repaint_gl (void); 35 | void repaint_async (void); 36 | void gl_context (void); 37 | 38 | public: 39 | static void debug_event (ogl::MouseEvent const& event); 40 | static void debug_event (ogl::KeyboardEvent const& event); 41 | 42 | protected: 43 | void initializeGL (void); 44 | void paintGL (void); 45 | void resizeGL (int width, int height); 46 | 47 | void mousePressEvent (QMouseEvent *event); 48 | void mouseReleaseEvent (QMouseEvent *event); 49 | void mouseMoveEvent (QMouseEvent *event); 50 | void keyPressEvent (QKeyEvent* event); 51 | void keyReleaseEvent (QKeyEvent* event); 52 | void wheelEvent (QWheelEvent* event); 53 | 54 | private: 55 | ogl::Context* context; 56 | int gl_width; 57 | int gl_height; 58 | qreal device_pixel_ratio; 59 | bool cx_init; 60 | std::set init_set; 61 | QTimer* repaint_timer; 62 | }; 63 | 64 | /* ---------------------------------------------------------------- */ 65 | 66 | inline QSize 67 | GLWidget::minimumSizeHint() const 68 | { 69 | return QSize(50, 50); 70 | } 71 | 72 | inline QSize 73 | GLWidget::sizeHint() const 74 | { 75 | return QSize(400, 400); 76 | } 77 | 78 | inline void 79 | GLWidget::repaint_gl (void) 80 | { 81 | } 82 | 83 | inline void 84 | GLWidget::repaint_async (void) 85 | { 86 | /* Don't issue an immediate repaint but let the timer trigger 87 | * a repaint after all events have been processed. */ 88 | 89 | if (this->repaint_timer->isActive()) 90 | return; 91 | 92 | this->repaint_timer->start(); 93 | } 94 | 95 | inline void 96 | GLWidget::gl_context (void) 97 | { 98 | this->makeCurrent(); 99 | } 100 | 101 | #endif /* UMVE_GL_WIDGET_HEADER */ 102 | -------------------------------------------------------------------------------- /apps/umve/guihelpers.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, Simon Fuhrmann 3 | * TU Darmstadt - Graphics, Capture and Massively Parallel Computing 4 | * All rights reserved. 5 | * 6 | * This software may be modified and distributed under the terms 7 | * of the BSD 3-Clause license. See the LICENSE.txt file for details. 8 | */ 9 | 10 | #ifndef GUI_HELPERS_HEADER 11 | #define GUI_HELPERS_HEADER 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include "mve/image.h" 18 | 19 | #include "selectedview.h" 20 | 21 | QPixmap get_pixmap_from_image (mve::ByteImage::ConstPtr img); 22 | QWidget* get_separator (void); 23 | QWidget* get_expander (void); 24 | QWidget* get_wrapper (QLayout* layout, int margin = 0); 25 | 26 | void set_qt_style (char const* style_name); 27 | 28 | /* ---------------------------------------------------------------- */ 29 | 30 | /** 31 | * Dialog that asks the user for depthmap, confidence map, 32 | * normal image and color image. 33 | */ 34 | class PlyExportDialog : public QDialog 35 | { 36 | public: 37 | SelectedView selected_view; 38 | 39 | std::string depthmap; 40 | std::string confidence; 41 | std::string colorimage; 42 | 43 | QComboBox depthmap_cb; 44 | QComboBox confidence_cb; 45 | QComboBox colorimage_cb; 46 | 47 | public: 48 | PlyExportDialog (mve::View::Ptr view, QWidget* parent = nullptr); 49 | void accept (void); 50 | }; 51 | 52 | /* ---------------------------------------------------------------- */ 53 | 54 | /** Widget that displays a header and collapsible content. */ 55 | class QCollapsible : public QWidget 56 | { 57 | Q_OBJECT 58 | 59 | private: 60 | QPushButton* collapse_but; 61 | QWidget* content; 62 | QWidget* content_indent; 63 | QWidget* content_wrapper; 64 | 65 | private slots: 66 | void on_toggle_collapse (void); 67 | 68 | public: 69 | QCollapsible (QString title, QWidget* content); 70 | void set_collapsed (bool value); 71 | void set_collapsible (bool value); 72 | void set_content_indent (int pixels); 73 | }; 74 | 75 | /* ---------------------------------------------------------------- */ 76 | 77 | /** File or directory selector button. */ 78 | class FileSelector : public QPushButton 79 | { 80 | Q_OBJECT 81 | 82 | private: 83 | bool dironly; 84 | std::string filename; 85 | std::size_t ellipsize; 86 | 87 | private slots: 88 | void on_clicked (void); 89 | 90 | public: 91 | FileSelector (QWidget* parent = nullptr); 92 | void set_directory_mode (void); 93 | void set_ellipsize (std::size_t chars); 94 | std::string const& get_filename (void) const; 95 | }; 96 | 97 | #endif /* GUI_HELPERS_HEADER */ 98 | -------------------------------------------------------------------------------- /apps/umve/images/icon_large_minus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/simonfuhrmann/mve/d4bc2ee02a6b57130751c012a8893b3bd4d6540c/apps/umve/images/icon_large_minus.png -------------------------------------------------------------------------------- /apps/umve/images/icon_large_plus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/simonfuhrmann/mve/d4bc2ee02a6b57130751c012a8893b3bd4d6540c/apps/umve/images/icon_large_plus.png -------------------------------------------------------------------------------- /apps/umve/images/icon_small_minus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/simonfuhrmann/mve/d4bc2ee02a6b57130751c012a8893b3bd4d6540c/apps/umve/images/icon_small_minus.png -------------------------------------------------------------------------------- /apps/umve/images/icon_small_plus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/simonfuhrmann/mve/d4bc2ee02a6b57130751c012a8893b3bd4d6540c/apps/umve/images/icon_small_plus.png -------------------------------------------------------------------------------- /apps/umve/images/icon_window.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/simonfuhrmann/mve/d4bc2ee02a6b57130751c012a8893b3bd4d6540c/apps/umve/images/icon_window.png -------------------------------------------------------------------------------- /apps/umve/jobqueue.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, Simon Fuhrmann 3 | * TU Darmstadt - Graphics, Capture and Massively Parallel Computing 4 | * All rights reserved. 5 | * 6 | * This software may be modified and distributed under the terms 7 | * of the BSD 3-Clause license. See the LICENSE.txt file for details. 8 | */ 9 | 10 | #ifndef JOB_QUEUE_HEADER 11 | #define JOB_QUEUE_HEADER 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | struct JobProgress 21 | { 22 | virtual ~JobProgress (void) {} 23 | virtual char const* get_name (void) = 0; 24 | virtual char const* get_message (void) = 0; 25 | virtual bool is_completed (void) = 0; 26 | virtual bool has_progress (void) = 0; 27 | virtual float get_progress (void) = 0; 28 | virtual void cancel_job (void) = 0; 29 | }; 30 | 31 | /* ---------------------------------------------------------------- */ 32 | 33 | struct JobQueueEntry 34 | { 35 | JobProgress* progress; 36 | QListWidgetItem* item; 37 | int finished; 38 | 39 | JobQueueEntry (void) : progress(nullptr), item(nullptr), finished(0) {} 40 | }; 41 | 42 | /* ---------------------------------------------------------------- */ 43 | 44 | class JobQueue : public QWidget 45 | { 46 | Q_OBJECT 47 | 48 | /* Singleton implementation. */ 49 | public: 50 | static JobQueue* get (void); 51 | 52 | protected slots: 53 | void on_update (void); 54 | void on_item_activated(QListWidgetItem* item); 55 | void add_fake_job (void); 56 | void update_job (JobQueueEntry& job); 57 | 58 | protected: 59 | JobQueue (void); 60 | 61 | private: 62 | typedef std::vector JobQueueList; 63 | 64 | QListWidget* jobs_list; 65 | QDockWidget* dock; 66 | QTimer* update_timer; 67 | JobQueueList jobs; 68 | 69 | public: 70 | /* Note: job object is deleted when queue entry is removed. */ 71 | void add_job (JobProgress* job); 72 | 73 | /* QT stuff. */ 74 | QSize sizeHint (void) const; 75 | void set_dock_widget (QDockWidget* dock); 76 | 77 | bool is_empty (void) const; 78 | }; 79 | 80 | /* -------------------------- Implementation ---------------------- */ 81 | 82 | inline QSize 83 | JobQueue::sizeHint (void) const 84 | { 85 | return QSize(175, 0); 86 | } 87 | 88 | inline void 89 | JobQueue::set_dock_widget (QDockWidget* dock) 90 | { 91 | this->dock = dock; 92 | } 93 | 94 | inline bool 95 | JobQueue::is_empty (void) const 96 | { 97 | bool empty = true; 98 | for (std::size_t i = 0; i < this->jobs.size(); ++i) 99 | if (this->jobs[i].finished == 0) 100 | empty = false; 101 | return empty; 102 | } 103 | 104 | #endif /* JOB_QUEUE_HEADER */ 105 | -------------------------------------------------------------------------------- /apps/umve/mainwindowtab.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, Simon Fuhrmann 3 | * TU Darmstadt - Graphics, Capture and Massively Parallel Computing 4 | * All rights reserved. 5 | * 6 | * This software may be modified and distributed under the terms 7 | * of the BSD 3-Clause license. See the LICENSE.txt file for details. 8 | */ 9 | 10 | #include 11 | 12 | #include "mainwindowtab.h" 13 | 14 | MainWindowTab::MainWindowTab (QWidget *parent) 15 | : QWidget(parent) 16 | { 17 | } 18 | 19 | MainWindowTab::~MainWindowTab (void) 20 | { 21 | } 22 | 23 | void 24 | MainWindowTab::set_tab_active (bool active) 25 | { 26 | this->is_tab_active = active; 27 | if (active) 28 | emit this->tab_activated(); 29 | } 30 | -------------------------------------------------------------------------------- /apps/umve/mainwindowtab.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, Simon Fuhrmann 3 | * TU Darmstadt - Graphics, Capture and Massively Parallel Computing 4 | * All rights reserved. 5 | * 6 | * This software may be modified and distributed under the terms 7 | * of the BSD 3-Clause license. See the LICENSE.txt file for details. 8 | */ 9 | 10 | #ifndef MAIN_WINDOW_TAB_HEADER 11 | #define MAIN_WINDOW_TAB_HEADER 12 | 13 | #include 14 | 15 | class MainWindowTab : public QWidget 16 | { 17 | Q_OBJECT 18 | 19 | protected: 20 | bool is_tab_active; 21 | 22 | signals: 23 | void tab_activated (void); 24 | 25 | public: 26 | MainWindowTab (QWidget* parent); 27 | virtual ~MainWindowTab (void); 28 | 29 | /* title of this tab when added to a QTabWidget */ 30 | virtual QString get_title (void) = 0; 31 | 32 | /* should be called when the parent QTabWidget switches to this tab */ 33 | void set_tab_active (bool tab_active); 34 | }; 35 | 36 | #define MainWindowTab_iid "de.tu-darmstadt.informatik.gris.UMVE.MainWindowTab" 37 | Q_DECLARE_INTERFACE(MainWindowTab, MainWindowTab_iid) 38 | 39 | #endif // MAIN_WINDOW_TAB_HEADER 40 | -------------------------------------------------------------------------------- /apps/umve/plugins/example/example_plugin.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, Benjamin Richter 3 | * TU Darmstadt - Graphics, Capture and Massively Parallel Computing 4 | * All rights reserved. 5 | * 6 | * This software may be modified and distributed under the terms 7 | * of the BSD 3-Clause license. See the LICENSE.txt file for details. 8 | */ 9 | 10 | #include 11 | 12 | #include "example_plugin.h" 13 | 14 | ExamplePlugin::ExamplePlugin (QWidget* parent) 15 | : MainWindowTab(parent) 16 | { 17 | } 18 | 19 | ExamplePlugin::~ExamplePlugin() 20 | { 21 | } 22 | 23 | QString 24 | ExamplePlugin::get_title (void) 25 | { 26 | return tr("Hello World"); 27 | } 28 | 29 | #if QT_VERSION < 0x050000 30 | Q_EXPORT_PLUGIN2(ExamplePlugin, ExamplePlugin) 31 | #endif 32 | -------------------------------------------------------------------------------- /apps/umve/plugins/example/example_plugin.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, Benjamin Richter 3 | * TU Darmstadt - Graphics, Capture and Massively Parallel Computing 4 | * All rights reserved. 5 | * 6 | * This software may be modified and distributed under the terms 7 | * of the BSD 3-Clause license. See the LICENSE.txt file for details. 8 | */ 9 | 10 | #ifndef HELLO_WORLD_TAB_HEADER 11 | #define HELLO_WORLD_TAB_HEADER 12 | 13 | #include 14 | 15 | #include "mainwindowtab.h" 16 | 17 | class ExamplePlugin : public MainWindowTab 18 | { 19 | Q_OBJECT 20 | #if QT_VERSION >= 0x050000 21 | Q_PLUGIN_METADATA(IID MainWindowTab_iid) 22 | #endif 23 | Q_INTERFACES(MainWindowTab) 24 | 25 | public: 26 | ExamplePlugin (QWidget* parent = nullptr); 27 | virtual ~ExamplePlugin (void); 28 | virtual QString get_title (void); 29 | }; 30 | 31 | #endif /* HELLO_WORLD_TAB_HEADER */ 32 | -------------------------------------------------------------------------------- /apps/umve/plugins/example/example_plugin.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = lib 2 | 3 | MVE_ROOT = ../../../../ 4 | 5 | CONFIG += qt opengl plugin 6 | QT += opengl 7 | 8 | QMAKE_CXXFLAGS += -fPIC 9 | QMAKE_LFLAGS += -rdynamic 10 | 11 | SOURCES += [^_]*.cc 12 | HEADERS += *.h 13 | TARGET = $$qtLibraryTarget(HelloWorldTab) 14 | 15 | target.path = $$(HOME)/.local/share/umve/plugins/ 16 | INSTALLS += target 17 | 18 | INCLUDEPATH += $${MVE_ROOT}/libs ../.. 19 | DEPENDPATH += $${MVE_ROOT}/libs 20 | LIBS = $${MVE_ROOT}/libs/dmrecon/libmve_dmrecon.a $${MVE_ROOT}/libs/mve/libmve.a $${MVE_ROOT}/libs/ogl/libmve_ogl.a $${MVE_ROOT}/libs/util/libmve_util.a -lpng -ljpeg -ltiff -lGLEW 21 | QMAKE_LIBDIR_QT = 22 | 23 | OBJECTS_DIR = build 24 | MOC_DIR = build 25 | RCC_DIR = build 26 | -------------------------------------------------------------------------------- /apps/umve/scene_addins/addin_aabb_creator.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, Simon Fuhrmann 3 | * TU Darmstadt - Graphics, Capture and Massively Parallel Computing 4 | * All rights reserved. 5 | * 6 | * This software may be modified and distributed under the terms 7 | * of the BSD 3-Clause license. See the LICENSE.txt file for details. 8 | */ 9 | 10 | #ifndef UMVE_ADDIN_AABB_CREATOR_HEADER 11 | #define UMVE_ADDIN_AABB_CREATOR_HEADER 12 | 13 | #include 14 | #include 15 | 16 | #include "scene_addins/addin_base.h" 17 | 18 | class AddinAABBCreator : public AddinBase 19 | { 20 | Q_OBJECT 21 | 22 | public: 23 | AddinAABBCreator (void); 24 | QWidget* get_sidebar_widget (void); 25 | 26 | private slots: 27 | void on_create_clicked (void); 28 | 29 | private: 30 | QFormLayout* layout; 31 | QDoubleSpinBox* spins[6]; 32 | }; 33 | 34 | #endif /* UMVE_ADDIN_AABB_CREATOR_HEADER */ 35 | -------------------------------------------------------------------------------- /apps/umve/scene_addins/addin_axis_renderer.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, Simon Fuhrmann 3 | * TU Darmstadt - Graphics, Capture and Massively Parallel Computing 4 | * All rights reserved. 5 | * 6 | * This software may be modified and distributed under the terms 7 | * of the BSD 3-Clause license. See the LICENSE.txt file for details. 8 | */ 9 | 10 | #include "ogl/render_tools.h" 11 | 12 | #include "scene_addins/addin_axis_renderer.h" 13 | 14 | AddinAxisRenderer::AddinAxisRenderer (void) 15 | { 16 | this->render_cb = new QCheckBox("Draw world axis"); 17 | this->render_cb->setChecked(true); 18 | this->connect(this->render_cb, SIGNAL(clicked()), 19 | this, SLOT(repaint())); 20 | } 21 | 22 | QWidget* 23 | AddinAxisRenderer::get_sidebar_widget (void) 24 | { 25 | return this->render_cb; 26 | } 27 | 28 | void 29 | AddinAxisRenderer::paint_impl (void) 30 | { 31 | if (this->render_cb->isChecked()) 32 | { 33 | if (this->axis_renderer == nullptr) 34 | this->axis_renderer = ogl::create_axis_renderer 35 | (this->state->wireframe_shader); 36 | 37 | this->state->wireframe_shader->bind(); 38 | this->state->wireframe_shader->send_uniform("ccolor", math::Vec4f(0.0f)); 39 | this->axis_renderer->draw(); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /apps/umve/scene_addins/addin_axis_renderer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, Simon Fuhrmann 3 | * TU Darmstadt - Graphics, Capture and Massively Parallel Computing 4 | * All rights reserved. 5 | * 6 | * This software may be modified and distributed under the terms 7 | * of the BSD 3-Clause license. See the LICENSE.txt file for details. 8 | */ 9 | 10 | #ifndef UMVE_ADDIN_AXIS_RENDERER_HEADER 11 | #define UMVE_ADDIN_AXIS_RENDERER_HEADER 12 | 13 | #include 14 | 15 | #include "ogl/vertex_array.h" 16 | 17 | #include "scene_addins/addin_base.h" 18 | 19 | class AddinAxisRenderer : public AddinBase 20 | { 21 | public: 22 | AddinAxisRenderer (void); 23 | QWidget* get_sidebar_widget (void); 24 | 25 | protected: 26 | void paint_impl (void); 27 | 28 | private: 29 | QCheckBox* render_cb; 30 | ogl::VertexArray::Ptr axis_renderer; 31 | }; 32 | 33 | #endif /* UMVE_ADDIN_AXIS_RENDERER_HEADER */ 34 | -------------------------------------------------------------------------------- /apps/umve/scene_addins/addin_dm_triangulate.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, Simon Fuhrmann 3 | * TU Darmstadt - Graphics, Capture and Massively Parallel Computing 4 | * All rights reserved. 5 | * 6 | * This software may be modified and distributed under the terms 7 | * of the BSD 3-Clause license. See the LICENSE.txt file for details. 8 | */ 9 | 10 | #ifndef UMVE_ADDIN_DM_TRIANGULATE_HEADER 11 | #define UMVE_ADDIN_DM_TRIANGULATE_HEADER 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | #include "selectedview.h" 20 | 21 | #include "scene_addins/addin_base.h" 22 | 23 | class AddinDMTriangulate : public AddinBase 24 | { 25 | Q_OBJECT 26 | 27 | public: 28 | AddinDMTriangulate (void); 29 | void set_selected_view (SelectedView* view); 30 | QWidget* get_sidebar_widget (void); 31 | 32 | private slots: 33 | void on_triangulate_clicked (void); 34 | void on_select_colorimage (QString name); 35 | void on_view_selected (void); 36 | 37 | private: 38 | SelectedView* view; 39 | QFormLayout* dm_form; 40 | QComboBox* dm_depthmap_cb; 41 | QComboBox* dm_colorimage_cb; 42 | QDoubleSpinBox* dm_depth_disc; 43 | QPushButton* dm_triangulate_but; 44 | }; 45 | 46 | #endif /* UMVE_ADDIN_DM_TRIANGULATE_HEADER */ 47 | -------------------------------------------------------------------------------- /apps/umve/scene_addins/addin_frusta_base.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, Simon Fuhrmann 3 | * TU Darmstadt - Graphics, Capture and Massively Parallel Computing 4 | * All rights reserved. 5 | * 6 | * This software may be modified and distributed under the terms 7 | * of the BSD 3-Clause license. See the LICENSE.txt file for details. 8 | */ 9 | 10 | #ifndef UMVE_ADDIN_FRUSTA_BASE_HEADER 11 | #define UMVE_ADDIN_FRUSTA_BASE_HEADER 12 | 13 | #include "mve/camera.h" 14 | #include "mve/mesh.h" 15 | 16 | void add_camera_to_mesh (mve::CameraInfo const& camera, 17 | float size, mve::TriangleMesh::Ptr mesh); 18 | 19 | #endif /* UMVE_ADDIN_FRUSTA_BASE_HEADER */ 20 | -------------------------------------------------------------------------------- /apps/umve/scene_addins/addin_frusta_scene_renderer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, Simon Fuhrmann 3 | * TU Darmstadt - Graphics, Capture and Massively Parallel Computing 4 | * All rights reserved. 5 | * 6 | * This software may be modified and distributed under the terms 7 | * of the BSD 3-Clause license. See the LICENSE.txt file for details. 8 | */ 9 | 10 | #ifndef UMVE_ADDIN_FRUSTA_SCENE_RENDERER_HEADER 11 | #define UMVE_ADDIN_FRUSTA_SCENE_RENDERER_HEADER 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | #include "mve/view.h" 19 | #include "ogl/mesh_renderer.h" 20 | 21 | #include "scene_addins/addin_base.h" 22 | 23 | class AddinFrustaSceneRenderer : public AddinBase 24 | { 25 | Q_OBJECT 26 | 27 | public: 28 | AddinFrustaSceneRenderer (void); 29 | QWidget* get_sidebar_widget (void); 30 | 31 | protected: 32 | void create_frusta_renderer (void); 33 | void create_viewdir_renderer (void); 34 | void paint_impl (void); 35 | 36 | protected slots: 37 | void reset_viewdir_renderer (void); 38 | void reset_frusta_renderer (void); 39 | 40 | private: 41 | QFormLayout* render_frusta_form; 42 | QCheckBox* render_frusta_cb; 43 | QCheckBox* render_viewdir_cb; 44 | QSlider* frusta_size_slider; 45 | ogl::MeshRenderer::Ptr frusta_renderer; 46 | ogl::MeshRenderer::Ptr viewdir_renderer; 47 | }; 48 | 49 | #endif /* UMVE_ADDIN_FRUSTA_SCENE_RENDERER_HEADER */ 50 | -------------------------------------------------------------------------------- /apps/umve/scene_addins/addin_mesh_renderer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, Simon Fuhrmann 3 | * TU Darmstadt - Graphics, Capture and Massively Parallel Computing 4 | * All rights reserved. 5 | * 6 | * This software may be modified and distributed under the terms 7 | * of the BSD 3-Clause license. See the LICENSE.txt file for details. 8 | */ 9 | 10 | #ifndef UMVE_ADDIN_MESHES_RENDERER_HEADER 11 | #define UMVE_ADDIN_MESHES_RENDERER_HEADER 12 | 13 | #include 14 | 15 | #include 16 | #include 17 | #include 18 | 19 | #include "mve/mesh.h" 20 | 21 | #include "scene_addins/mesh_list.h" 22 | #include "scene_addins/addin_base.h" 23 | 24 | class AddinMeshesRenderer : public AddinBase 25 | { 26 | Q_OBJECT 27 | 28 | public: 29 | AddinMeshesRenderer (void); 30 | QWidget* get_sidebar_widget (void); 31 | 32 | void add_mesh (std::string const& name, 33 | mve::TriangleMesh::Ptr mesh, 34 | std::string const& filename = "", 35 | ogl::Texture::Ptr texture = nullptr); 36 | 37 | void load_mesh (std::string const& filename); 38 | 39 | protected: 40 | void paint_impl (void); 41 | 42 | private: 43 | QVBoxLayout* render_meshes_box; 44 | QCheckBox* render_lighting_cb; 45 | QCheckBox* render_wireframe_cb; 46 | QCheckBox* render_color_cb; 47 | QMeshList* mesh_list; 48 | }; 49 | 50 | #endif /* UMVE_ADDIN_MESHES_RENDERER_HEADER */ 51 | -------------------------------------------------------------------------------- /apps/umve/scene_addins/addin_offscreen_renderer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, Simon Fuhrmann 3 | * TU Darmstadt - Graphics, Capture and Massively Parallel Computing 4 | * All rights reserved. 5 | * 6 | * This software may be modified and distributed under the terms 7 | * of the BSD 3-Clause license. See the LICENSE.txt file for details. 8 | */ 9 | 10 | #ifndef UMVE_ADDIN_OFFSCREEN_RENDERER_HEADER 11 | #define UMVE_ADDIN_OFFSCREEN_RENDERER_HEADER 12 | 13 | #include 14 | #include 15 | #include 16 | 17 | #include "mve/image.h" 18 | #include "ogl/camera.h" 19 | 20 | #include "guihelpers.h" 21 | #include "scene_addins/addin_base.h" 22 | 23 | class AddinOffscreenRenderer : public AddinBase 24 | { 25 | Q_OBJECT 26 | 27 | public: 28 | AddinOffscreenRenderer (void); 29 | QWidget* get_sidebar_widget (void); 30 | void set_scene_camera (ogl::Camera* camera); 31 | 32 | private slots: 33 | void on_snapshot (void); 34 | void on_render_sequence (void); 35 | void on_play_sequence (bool save = false); 36 | void on_display_sequence (void); 37 | 38 | private: 39 | mve::ByteImage::Ptr get_offscreen_image (void); 40 | 41 | private: 42 | ogl::Camera* camera; 43 | QVBoxLayout* main_box; 44 | FileSelector* sequence_file; 45 | FileSelector* output_frame_dir; 46 | QPushButton* play_but; 47 | QSpinBox* width_spin; 48 | QSpinBox* height_spin; 49 | bool working_flag; 50 | }; 51 | 52 | #endif /* UMVE_ADDIN_OFFSCREEN_RENDERER_HEADER */ 53 | -------------------------------------------------------------------------------- /apps/umve/scene_addins/addin_plane_creator.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, Simon Fuhrmann 3 | * TU Darmstadt - Graphics, Capture and Massively Parallel Computing 4 | * All rights reserved. 5 | * 6 | * This software may be modified and distributed under the terms 7 | * of the BSD 3-Clause license. See the LICENSE.txt file for details. 8 | */ 9 | 10 | #ifndef UVME_ADDIN_PLANE_CREATOR_HEADER 11 | #define UVME_ADDIN_PLANE_CREATOR_HEADER 12 | 13 | #include 14 | #include 15 | 16 | #include "scene_addins/addin_base.h" 17 | 18 | class AddinPlaneCreator : public AddinBase 19 | { 20 | Q_OBJECT 21 | 22 | public: 23 | AddinPlaneCreator (void); 24 | QWidget* get_sidebar_widget (void); 25 | 26 | private slots: 27 | void on_create_clicked (void); 28 | 29 | private: 30 | QFormLayout* layout; 31 | QDoubleSpinBox* spins[6]; 32 | }; 33 | 34 | #endif /* UVME_ADDIN_PLANE_CREATOR_HEADER */ 35 | -------------------------------------------------------------------------------- /apps/umve/scene_addins/addin_rephotographer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, Simon Fuhrmann 3 | * TU Darmstadt - Graphics, Capture and Massively Parallel Computing 4 | * All rights reserved. 5 | * 6 | * This software may be modified and distributed under the terms 7 | * of the BSD 3-Clause license. See the LICENSE.txt file for details. 8 | */ 9 | 10 | #ifndef UMVE_ADDIN_REPHOTOGRAPHER_HEADER 11 | #define UMVE_ADDIN_REPHOTOGRAPHER_HEADER 12 | 13 | #include 14 | #include 15 | #include 16 | 17 | #include "mve/view.h" 18 | #include "ogl/camera.h" 19 | 20 | #include "scene_addins/addin_base.h" 21 | 22 | class AddinRephotographer : public AddinBase 23 | { 24 | Q_OBJECT 25 | 26 | public: 27 | AddinRephotographer (void); 28 | QWidget* get_sidebar_widget (void); 29 | void set_scene_camera (ogl::Camera* camera); 30 | 31 | protected: 32 | ogl::Camera* camera; 33 | QFormLayout* rephoto_form; 34 | QLineEdit* rephoto_source; 35 | QLineEdit* rephoto_color_dest; 36 | QLineEdit* rephoto_depth_dest; 37 | 38 | protected slots: 39 | void on_rephoto (void); 40 | void on_rephoto_view (mve::View::Ptr view); 41 | void on_rephoto_all (void); 42 | }; 43 | 44 | #endif /* UMVE_ADDIN_REPHOTOGRAPHER_HEADER */ 45 | -------------------------------------------------------------------------------- /apps/umve/scene_addins/addin_selection.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, Simon Fuhrmann 3 | * TU Darmstadt - Graphics, Capture and Massively Parallel Computing 4 | * All rights reserved. 5 | * 6 | * This software may be modified and distributed under the terms 7 | * of the BSD 3-Clause license. See the LICENSE.txt file for details. 8 | */ 9 | 10 | #ifndef UMVE_ADDIN_SELECTION 11 | #define UMVE_ADDIN_SELECTION 12 | 13 | #include 14 | 15 | #include "ogl/vertex_array.h" 16 | 17 | #include "scene_addins/addin_base.h" 18 | 19 | class AddinSelection : public AddinBase 20 | { 21 | public: 22 | AddinSelection (void); 23 | virtual bool mouse_event (ogl::MouseEvent const& event); 24 | virtual void redraw_gui(); 25 | 26 | void set_scene_camera (ogl::Camera* camera); 27 | 28 | private: 29 | bool selection_active; 30 | 31 | int rect_start_x; 32 | int rect_start_y; 33 | int rect_current_x; 34 | int rect_current_y; 35 | 36 | ogl::Camera *camera; 37 | 38 | void show_selection_info (float left, float right, float top, float bottom); 39 | }; 40 | 41 | #endif /* UMVE_ADDIN_SELECTION */ 42 | -------------------------------------------------------------------------------- /apps/umve/scene_addins/addin_sfm_renderer.cc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "scenemanager.h" 4 | #include "scene_addins/addin_sfm_renderer.h" 5 | 6 | AddinSfmRenderer::AddinSfmRenderer (void) 7 | { 8 | this->first_create_renderer = true; 9 | this->render_cb = new QCheckBox("Draw SfM points"); 10 | this->render_cb->setChecked(true); 11 | this->connect(this->render_cb, SIGNAL(clicked()), 12 | this, SLOT(repaint())); 13 | this->connect(&SceneManager::get(), SIGNAL(scene_bundle_changed()), 14 | this, SLOT(reset_scene_bundle())); 15 | this->connect(&SceneManager::get(), SIGNAL(scene_selected(mve::Scene::Ptr)), 16 | this, SLOT(reset_scene_bundle())); 17 | } 18 | 19 | QWidget* 20 | AddinSfmRenderer::get_sidebar_widget (void) 21 | { 22 | return this->render_cb; 23 | } 24 | 25 | void 26 | AddinSfmRenderer::paint_impl (void) 27 | { 28 | if (this->render_cb->isChecked()) 29 | { 30 | /* Try to create renderer. */ 31 | if (this->sfm_renderer == nullptr) 32 | this->create_renderer(!this->first_create_renderer); 33 | this->first_create_renderer = false; 34 | 35 | /* Try to render. */ 36 | if (this->sfm_renderer != nullptr) 37 | { 38 | this->state->wireframe_shader->bind(); 39 | this->state->wireframe_shader->send_uniform("ccolor", math::Vec4f(0.0f)); 40 | this->sfm_renderer->draw(); 41 | } 42 | } 43 | } 44 | 45 | void 46 | AddinSfmRenderer::create_renderer (bool raise_error_on_failure) 47 | { 48 | if (this->state->scene == nullptr) 49 | return; 50 | 51 | try 52 | { 53 | mve::Bundle::ConstPtr bundle(this->state->scene->get_bundle()); 54 | mve::TriangleMesh::Ptr mesh(bundle->get_features_as_mesh()); 55 | this->sfm_renderer = ogl::MeshRenderer::create(mesh); 56 | this->sfm_renderer->set_shader(this->state->wireframe_shader); 57 | this->sfm_renderer->set_primitive(GL_POINTS); 58 | } 59 | catch (std::exception& e) 60 | { 61 | std::cerr << "Error reading bundle: " << e.what() << std::endl; 62 | this->render_cb->setChecked(false); 63 | if (raise_error_on_failure) 64 | this->show_error_box("Error reading bundle", e.what()); 65 | return; 66 | } 67 | } 68 | 69 | void 70 | AddinSfmRenderer::reset_scene_bundle (void) 71 | { 72 | this->sfm_renderer.reset(); 73 | this->first_create_renderer = true; 74 | } 75 | -------------------------------------------------------------------------------- /apps/umve/scene_addins/addin_sfm_renderer.h: -------------------------------------------------------------------------------- 1 | #ifndef UMVE_ADDIN_SFM_RENDERER_HEADER 2 | #define UMVE_ADDIN_SFM_RENDERER_HEADER 3 | 4 | #include 5 | 6 | #include "ogl/mesh_renderer.h" 7 | 8 | #include "scene_addins/addin_base.h" 9 | 10 | class AddinSfmRenderer : public AddinBase 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | AddinSfmRenderer (void); 16 | QWidget* get_sidebar_widget (void); 17 | 18 | protected: 19 | void paint_impl (void); 20 | void create_renderer (bool raise_error_on_failure); 21 | 22 | protected slots: 23 | void reset_scene_bundle (void); 24 | 25 | private: 26 | QCheckBox* render_cb; 27 | bool first_create_renderer; 28 | ogl::MeshRenderer::Ptr sfm_renderer; 29 | }; 30 | 31 | #endif // UMVE_ADDIN_SFM_RENDERER_HEADER 32 | -------------------------------------------------------------------------------- /apps/umve/scene_addins/addin_sphere_creator.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, Simon Fuhrmann 3 | * TU Darmstadt - Graphics, Capture and Massively Parallel Computing 4 | * All rights reserved. 5 | * 6 | * This software may be modified and distributed under the terms 7 | * of the BSD 3-Clause license. See the LICENSE.txt file for details. 8 | */ 9 | 10 | #ifndef UVME_ADDIN_SPHERE_CREATOR_HEADER 11 | #define UVME_ADDIN_SPHERE_CREATOR_HEADER 12 | 13 | #include 14 | #include 15 | 16 | #include "scene_addins/addin_base.h" 17 | 18 | class AddinSphereCreator : public AddinBase 19 | { 20 | Q_OBJECT 21 | 22 | public: 23 | AddinSphereCreator (void); 24 | QWidget* get_sidebar_widget (void); 25 | 26 | private slots: 27 | void on_create_clicked (void); 28 | 29 | private: 30 | QFormLayout* layout; 31 | QDoubleSpinBox* spins[4]; 32 | }; 33 | 34 | #endif /* UVME_ADDIN_SPHERE_CREATOR_HEADER */ 35 | -------------------------------------------------------------------------------- /apps/umve/scene_addins/addin_state.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, Simon Fuhrmann 3 | * TU Darmstadt - Graphics, Capture and Massively Parallel Computing 4 | * All rights reserved. 5 | * 6 | * This software may be modified and distributed under the terms 7 | * of the BSD 3-Clause license. See the LICENSE.txt file for details. 8 | */ 9 | 10 | #ifndef UMVE_ADDIN_STATE_HEADER 11 | #define UMVE_ADDIN_STATE_HEADER 12 | 13 | #include "mve/scene.h" 14 | #include "mve/view.h" 15 | #include "mve/image.h" 16 | #include "ogl/shader_program.h" 17 | #include "ogl/camera.h" 18 | #include "ogl/texture.h" 19 | #include "ogl/vertex_array.h" 20 | 21 | #include "glwidget.h" 22 | 23 | struct AddinState 24 | { 25 | public: 26 | GLWidget* gl_widget; 27 | ogl::ShaderProgram::Ptr surface_shader; 28 | ogl::ShaderProgram::Ptr wireframe_shader; 29 | ogl::ShaderProgram::Ptr texture_shader; 30 | ogl::ShaderProgram::Ptr overlay_shader; 31 | mve::Scene::Ptr scene; 32 | mve::View::Ptr view; 33 | 34 | /* UI overlay. */ 35 | mve::ByteImage::Ptr ui_image; 36 | ogl::Texture::Ptr gui_texture; 37 | ogl::VertexArray::Ptr gui_renderer; 38 | bool ui_needs_redraw; 39 | 40 | public: 41 | AddinState (void); 42 | void load_shaders (void); 43 | void send_uniform (ogl::Camera const& cam); 44 | 45 | void repaint (void); 46 | void make_current_context (void); 47 | void init_ui (void); 48 | void clear_ui (int width, int height); 49 | }; 50 | 51 | #endif // UMVE_ADDIN_STATE_HEADER 52 | -------------------------------------------------------------------------------- /apps/umve/scene_inspect/scene_inspect.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, Simon Fuhrmann 3 | * TU Darmstadt - Graphics, Capture and Massively Parallel Computing 4 | * All rights reserved. 5 | * 6 | * This software may be modified and distributed under the terms 7 | * of the BSD 3-Clause license. See the LICENSE.txt file for details. 8 | */ 9 | 10 | #ifndef UMVE_SCENE_INSPECT_HEADER 11 | #define UMVE_SCENE_INSPECT_HEADER 12 | 13 | #include "ogl/opengl.h" 14 | 15 | #include 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | #include "mve/scene.h" 24 | #include "mve/view.h" 25 | 26 | #include "mainwindowtab.h" 27 | #include "glwidget.h" 28 | #include "scene_inspect/addin_manager.h" 29 | 30 | class SceneInspect : public MainWindowTab 31 | { 32 | Q_OBJECT 33 | 34 | public: 35 | SceneInspect (QWidget* parent = nullptr); 36 | 37 | /* Loads a mesh from file and adds to mesh list. */ 38 | void load_file (std::string const& filename); 39 | 40 | /* Removes references to the scene. */ 41 | void reset (void); 42 | 43 | virtual QString get_title (void); 44 | 45 | private: 46 | void create_actions (QToolBar* toolbar); 47 | 48 | private slots: 49 | void on_open_mesh (void); 50 | void on_reload_shaders (void); 51 | void on_details_toggled (void); 52 | void on_save_screenshot (void); 53 | void on_scene_selected (mve::Scene::Ptr scene); 54 | void on_view_selected (mve::View::Ptr view); 55 | void on_tab_activated (void); 56 | 57 | private: 58 | std::string last_mesh_dir; 59 | mve::View::Ptr next_view; 60 | 61 | QTabWidget* tab_widget; 62 | AddinManager* addin_manager; 63 | GLWidget* gl_widget; 64 | QAction* action_open_mesh; 65 | QAction* action_reload_shaders; 66 | QAction* action_show_details; 67 | QAction* action_save_screenshot; 68 | }; 69 | 70 | #endif /* UMVE_SCENE_INSPECT_HEADER */ 71 | -------------------------------------------------------------------------------- /apps/umve/scenemanager.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, Simon Fuhrmann 3 | * TU Darmstadt - Graphics, Capture and Massively Parallel Computing 4 | * All rights reserved. 5 | * 6 | * This software may be modified and distributed under the terms 7 | * of the BSD 3-Clause license. See the LICENSE.txt file for details. 8 | */ 9 | 10 | #include "scenemanager.h" 11 | 12 | SceneManager::SceneManager (void) 13 | { 14 | } 15 | 16 | SceneManager::~SceneManager (void) 17 | { 18 | } 19 | 20 | SceneManager& 21 | SceneManager::get (void) 22 | { 23 | static SceneManager instance; 24 | return instance; 25 | } 26 | -------------------------------------------------------------------------------- /apps/umve/sceneoverview.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, Simon Fuhrmann 3 | * TU Darmstadt - Graphics, Capture and Massively Parallel Computing 4 | * All rights reserved. 5 | * 6 | * This software may be modified and distributed under the terms 7 | * of the BSD 3-Clause license. See the LICENSE.txt file for details. 8 | */ 9 | 10 | #ifndef SCENE_OVERVIEW_HEADER 11 | #define SCENE_OVERVIEW_HEADER 12 | 13 | #include 14 | #include 15 | 16 | #include "mve/scene.h" 17 | 18 | class SceneOverview : public QWidget 19 | { 20 | Q_OBJECT 21 | 22 | protected slots: 23 | void on_scene_changed (mve::Scene::Ptr scene); 24 | void on_row_changed (int id); 25 | void on_filter_changed (void); 26 | void on_clear_filter (void); 27 | 28 | private: 29 | void add_view_to_layout (std::size_t id, mve::View::Ptr view); 30 | 31 | private: 32 | QToolBar* toolbar; 33 | QListWidget* viewlist; 34 | QLineEdit* filter; 35 | 36 | public: 37 | SceneOverview (QWidget* parent); 38 | 39 | QSize sizeHint (void) const; 40 | void add_toolbar_action (QAction* action); 41 | void add_toolbar_spacer (void); 42 | }; 43 | 44 | /* ---------------------------------------------------------------- */ 45 | 46 | inline QSize 47 | SceneOverview::sizeHint (void) const 48 | { 49 | return QSize(175, 0); 50 | } 51 | 52 | inline void 53 | SceneOverview::add_toolbar_action (QAction* action) 54 | { 55 | this->toolbar->addAction(action); 56 | } 57 | 58 | inline void 59 | SceneOverview::add_toolbar_spacer (void) 60 | { 61 | this->toolbar->addSeparator(); 62 | } 63 | 64 | #endif /* SCENE_OVERVIEW_HEADER */ 65 | -------------------------------------------------------------------------------- /apps/umve/selectedview.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, Simon Fuhrmann 3 | * TU Darmstadt - Graphics, Capture and Massively Parallel Computing 4 | * All rights reserved. 5 | * 6 | * This software may be modified and distributed under the terms 7 | * of the BSD 3-Clause license. See the LICENSE.txt file for details. 8 | */ 9 | 10 | #ifndef UMVE_SELECTEDVIEW_HEADER 11 | #define UMVE_SELECTEDVIEW_HEADER 12 | 13 | #include 14 | #include 15 | #include 16 | 17 | #include "mve/view.h" 18 | 19 | class SelectedView : public QFrame 20 | { 21 | Q_OBJECT 22 | 23 | private: 24 | mve::View::Ptr view; 25 | 26 | QLabel* viewname; 27 | QLabel* image; 28 | QLabel* viewinfo; 29 | 30 | private: 31 | void reset_view (void); 32 | 33 | public: 34 | SelectedView (void); 35 | 36 | void set_view (mve::View::Ptr view); 37 | mve::View::Ptr get_view (void) const; 38 | 39 | void fill_embeddings (QComboBox& cb, mve::ImageType type, 40 | std::string const& default_name = "") const; 41 | 42 | signals: 43 | void view_selected (mve::View::Ptr view); 44 | }; 45 | 46 | /* ---------------------------------------------------------------- */ 47 | 48 | inline mve::View::Ptr 49 | SelectedView::get_view (void) const 50 | { 51 | return this->view; 52 | } 53 | 54 | #endif /* UMVE_SELECTEDVIEW_HEADER */ 55 | -------------------------------------------------------------------------------- /apps/umve/shaders/overlay_330.frag: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | in vec3 onormal; 4 | smooth in vec2 otexuv; 5 | 6 | uniform vec3 light1 = vec3(0.0, 0.0, 5.0); 7 | uniform sampler2D texunit; 8 | uniform vec4 ccolor = vec4(0.7, 0.7, 0.7, 1.0); 9 | 10 | layout(location=0) out vec4 frag_color; 11 | 12 | void main(void) 13 | { 14 | frag_color = texture(texunit, otexuv); 15 | } 16 | -------------------------------------------------------------------------------- /apps/umve/shaders/overlay_330.vert: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | in vec4 pos; 4 | in vec3 normal; 5 | in vec2 texuv; 6 | 7 | out vec3 onormal; 8 | smooth out vec2 otexuv; 9 | 10 | void main(void) 11 | { 12 | onormal = normal; 13 | otexuv = texuv; 14 | gl_Position = pos; 15 | } 16 | -------------------------------------------------------------------------------- /apps/umve/shaders/surface_330.frag: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | /* Fragment Shader Special Variables 4 | * 5 | * in vec4 gl_FragCoord; 6 | * in bool gl_FrontFacing; 7 | * in float gl_ClipDistance[]; 8 | * out vec4 gl_FragColor; // deprecated 9 | * out vec4 gl_FragData[gl_MaxDrawBuffers]; // deprecated 10 | * out float gl_FragDepth; 11 | * in vec2 gl_PointCoord; 12 | * in int gl_PrimitiveID; 13 | */ 14 | 15 | in vec3 onormal; 16 | in vec4 ocolor; 17 | 18 | layout(location=0) out vec4 frag_color; 19 | 20 | uniform mat4 viewmat; 21 | uniform mat4 projmat; 22 | uniform vec4 ccolor = vec4(0.7, 0.7, 0.7, 1.0); 23 | 24 | uniform int lighting = 0; 25 | uniform vec3 light1 = vec3(0.0, 0.0, 5.0); 26 | 27 | void main(void) 28 | { 29 | /* Assign material albedo. */ 30 | vec4 albedo = ccolor; 31 | if (ccolor.a == 0.0) 32 | albedo = ocolor; 33 | 34 | /* Enable backface culling. */ 35 | //if (!gl_FrontFacing) 36 | // albedo = albedo * 0.2; 37 | 38 | gl_FragDepth = gl_FragCoord.z; 39 | if (lighting == 1) 40 | { 41 | /* Compute shading from normal and lights. */ 42 | vec4 normal = viewmat * vec4(onormal, 0); 43 | vec4 light_vector = vec4(normalize(light1), 0); 44 | float light_factor = dot(normal, light_vector); 45 | if (light_factor < 0.0) 46 | light_factor = -light_factor / 2.0; 47 | frag_color = albedo * light_factor; 48 | } 49 | else 50 | { 51 | frag_color = albedo; 52 | } 53 | } 54 | 55 | -------------------------------------------------------------------------------- /apps/umve/shaders/surface_330.vert: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | /* Vertex shader special variables 4 | * 5 | * in int gl_VertexID; 6 | * in int gl_InstanceID; 7 | * out gl_PerVertex { 8 | * vec4 gl_Position; 9 | * float gl_PointSize; 10 | * float gl_ClipDistance[]; 11 | * }; 12 | */ 13 | 14 | in vec4 pos; 15 | in vec4 color; 16 | in vec3 normal; 17 | 18 | out vec4 ocolor; 19 | out vec3 onormal; 20 | 21 | uniform mat4 viewmat; 22 | uniform mat4 projmat; 23 | 24 | void main(void) 25 | { 26 | ocolor = color; 27 | onormal = normal; 28 | gl_Position = projmat * (viewmat * pos); 29 | } 30 | 31 | -------------------------------------------------------------------------------- /apps/umve/shaders/texture_330.frag: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | in vec4 onormal; 4 | smooth in vec2 otexuv; 5 | 6 | uniform int lighting = 0; 7 | uniform vec3 light1 = vec3(0.0, 0.0, 5.0); 8 | uniform sampler2D texunit; 9 | uniform vec4 ccolor = vec4(0.7, 0.7, 0.7, 1.0); 10 | 11 | layout(location=0) out vec4 frag_color; 12 | 13 | void main(void) 14 | { 15 | vec4 albedo = texture(texunit, otexuv); 16 | 17 | if (lighting == 1) 18 | { 19 | /* Compute shading from normal and lights. */ 20 | vec4 light1_hom = vec4(normalize(light1), 0); 21 | float light_factor = dot(onormal, light1_hom); 22 | if (light_factor < 0.0) 23 | light_factor = -light_factor / 2.0; 24 | frag_color = albedo * light_factor; 25 | } 26 | else 27 | { 28 | frag_color = albedo; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /apps/umve/shaders/texture_330.vert: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | in vec4 pos; 4 | in vec3 normal; 5 | in vec2 texuv; 6 | 7 | out vec4 onormal; 8 | smooth out vec2 otexuv; 9 | 10 | uniform mat4 viewmat; 11 | uniform mat4 projmat; 12 | 13 | void main(void) 14 | { 15 | onormal = viewmat * vec4(normal, 0); 16 | otexuv = texuv; 17 | gl_Position = projmat * (viewmat * pos); 18 | } 19 | -------------------------------------------------------------------------------- /apps/umve/shaders/wireframe_330.frag: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | /* Fragment Shader Special Variables 4 | * 5 | * in vec4 gl_FragCoord; 6 | * in bool gl_FrontFacing; 7 | * in float gl_ClipDistance[]; 8 | * out vec4 gl_FragColor; // deprecated 9 | * out vec4 gl_FragData[gl_MaxDrawBuffers]; // deprecated 10 | * out float gl_FragDepth; 11 | * in vec2 gl_PointCoord; 12 | * in int gl_PrimitiveID; 13 | */ 14 | 15 | in vec4 ocolor; 16 | 17 | layout(location=0) out vec4 frag_color; 18 | 19 | uniform vec4 ccolor = vec4(0.5, 0.5, 0.5, 1.0); 20 | 21 | void main(void) 22 | { 23 | /* Enable backface culling for wireframe. */ 24 | //if (!gl_FrontFacing) discard; 25 | 26 | gl_FragDepth = gl_FragCoord.z; 27 | if (ccolor.a == 0.0) 28 | frag_color = ocolor; 29 | else 30 | frag_color = ccolor; 31 | } 32 | -------------------------------------------------------------------------------- /apps/umve/shaders/wireframe_330.vert: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | in vec4 pos; 4 | in vec4 color; 5 | 6 | out vec4 ocolor; 7 | 8 | uniform mat4 viewmat; 9 | uniform mat4 projmat; 10 | 11 | void main(void) 12 | { 13 | ocolor = color; 14 | gl_Position = projmat * (viewmat * pos); 15 | } 16 | 17 | -------------------------------------------------------------------------------- /apps/umve/umve.pro: -------------------------------------------------------------------------------- 1 | MVE_ROOT = ../.. 2 | 3 | CONFIG += link_pkgconfig qt release c++14 4 | PKGCONFIG += libjpeg libpng libtiff-4 5 | QT += concurrent opengl 6 | 7 | QMAKE_LFLAGS += -rdynamic -fopenmp 8 | QMAKE_CXXFLAGS += -fPIC -fopenmp 9 | 10 | SOURCES += [^_]*.cc viewinspect/*.cc scene_inspect/*.cc scene_addins/*.cc 11 | HEADERS += *.h viewinspect/*.h scene_inspect/*.h scene_addins/*.h 12 | RESOURCES = umve.qrc 13 | TARGET = umve 14 | 15 | INCLUDEPATH += $${MVE_ROOT}/libs 16 | DEPENDPATH += $${MVE_ROOT}/libs 17 | LIBS = $${MVE_ROOT}/libs/dmrecon/libmve_dmrecon.a $${MVE_ROOT}/libs/mve/libmve.a $${MVE_ROOT}/libs/ogl/libmve_ogl.a $${MVE_ROOT}/libs/util/libmve_util.a 18 | QMAKE_LIBDIR_QT = 19 | 20 | OBJECTS_DIR = build 21 | MOC_DIR = build 22 | RCC_DIR = build 23 | 24 | # Options specific to OS X. 25 | macx { 26 | QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.9 27 | CONFIG -= app_bundle 28 | QMAKE_LFLAGS += -L/usr/local/lib 29 | QMAKE_LFLAGS -= -fopenmp 30 | INCLUDEPATH += /usr/local/include 31 | QMAKE_CXXFLAGS -= -fopenmp 32 | } 33 | 34 | # Options specific to Windows. 35 | win32 { 36 | LIBS += -lGLEW 37 | } 38 | 39 | exists(umve.priv.pro) : include(umve.priv.pro) 40 | -------------------------------------------------------------------------------- /apps/umve/umve.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | images/icon_exit.svg 4 | images/icon_copy.svg 5 | images/icon_delete.svg 6 | images/icon_save.svg 7 | images/icon_about.svg 8 | images/icon_revert.svg 9 | images/icon_open_file.svg 10 | images/icon_image_inspect.svg 11 | images/icon_export_ply.svg 12 | images/icon_zoom_in.svg 13 | images/icon_zoom_out.svg 14 | images/icon_zoom_reset.svg 15 | images/icon_zoom_page.svg 16 | images/icon_exec.svg 17 | images/icon_new_dir.svg 18 | images/icon_close.svg 19 | images/icon_broken.svg 20 | images/icon_toolbox.svg 21 | images/icon_clean.svg 22 | images/icon_export.svg 23 | images/icon_small_minus.png 24 | images/icon_small_plus.png 25 | images/icon_large_minus.png 26 | images/icon_large_plus.png 27 | images/icon_screenshot.svg 28 | images/icon_file.svg 29 | images/icon_folder.svg 30 | images/icon_player_eject.svg 31 | images/icon_player_end.svg 32 | images/icon_player_fwd.svg 33 | images/icon_player_pause.svg 34 | images/icon_player_play.svg 35 | images/icon_player_record.svg 36 | images/icon_player_rew.svg 37 | images/icon_player_start.svg 38 | images/icon_player_stop.svg 39 | images/icon_eye.svg 40 | images/icon_video.svg 41 | images/icon_refresh.svg 42 | images/icon_new_file.svg 43 | images/icon_window.png 44 | shaders/surface_330.frag 45 | shaders/surface_330.vert 46 | shaders/texture_330.frag 47 | shaders/texture_330.vert 48 | shaders/wireframe_330.frag 49 | shaders/wireframe_330.vert 50 | shaders/overlay_330.frag 51 | shaders/overlay_330.vert 52 | 53 | 54 | -------------------------------------------------------------------------------- /apps/umve/viewinspect/imageinspector.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, Simon Fuhrmann 3 | * TU Darmstadt - Graphics, Capture and Massively Parallel Computing 4 | * All rights reserved. 5 | * 6 | * This software may be modified and distributed under the terms 7 | * of the BSD 3-Clause license. See the LICENSE.txt file for details. 8 | */ 9 | 10 | #ifndef IMAGE_INSPECTOR_HEADER 11 | #define IMAGE_INSPECTOR_HEADER 12 | 13 | #include "mve/image.h" 14 | 15 | #include "clickimage.h" 16 | 17 | #if 0 18 | # define MAGNIFY_LARGE_PATCH 35 19 | # define MAGNIFY_LARGE_SCALE 3 20 | # define MAGNIFY_MEDIUM_PATCH 15 21 | # define MAGNIFY_MEDIUM_SCALE 7 22 | # define MAGNIFY_SMALL_PATCH 5 23 | # define MAGNIFY_SMALL_SCALE 21 24 | #else 25 | # define MAGNIFY_LARGE_PATCH 55 26 | # define MAGNIFY_LARGE_SCALE 3 27 | # define MAGNIFY_MEDIUM_PATCH 15 28 | # define MAGNIFY_MEDIUM_SCALE 11 29 | # define MAGNIFY_SMALL_PATCH 5 30 | # define MAGNIFY_SMALL_SCALE 33 31 | #endif 32 | 33 | class ImageInspectorWidget : public QWidget 34 | { 35 | Q_OBJECT 36 | 37 | private: 38 | mve::ByteImage::ConstPtr byte_image; 39 | mve::ImageBase::ConstPtr orig_image; 40 | 41 | QLabel* label_dimension; 42 | QLabel* label_channels; 43 | QLabel* label_memory; 44 | QLabel* label_clickpos; 45 | QLabel* label_values; 46 | 47 | ClickImage* image_widget1; 48 | ClickImage* image_widget2; 49 | ClickImage* image_widget3; 50 | 51 | int inspect_x, inspect_y; 52 | 53 | private slots: 54 | void on_large_image_clicked (int x, int y, QMouseEvent* event); 55 | void on_medium_image_clicked (int x, int y, QMouseEvent* event); 56 | void on_small_image_clicked (int x, int y, QMouseEvent* event); 57 | 58 | private: 59 | QImage get_magnified (int x, int y, int size, int scale); 60 | unsigned int get_image_color (int x, int y); 61 | void update_value_label (int x, int y); 62 | void reset_images (void); 63 | void image_click (int x, int y, QMouseEvent* event, int scale, int size); 64 | 65 | public: 66 | ImageInspectorWidget (void); 67 | 68 | void set_image (mve::ByteImage::ConstPtr byte_image, 69 | mve::ImageBase::ConstPtr orig_image); 70 | void magnify (int x, int y); 71 | void reset (void); 72 | }; 73 | 74 | /* ---------------------------------------------------------------- */ 75 | 76 | inline void 77 | ImageInspectorWidget::reset (void) 78 | { 79 | this->reset_images(); 80 | this->byte_image.reset(); 81 | this->orig_image.reset(); 82 | } 83 | 84 | #endif /* IMAGE_INSPECTOR_HEADER */ 85 | -------------------------------------------------------------------------------- /apps/umve/viewinspect/imageoperations.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, Simon Fuhrmann 3 | * TU Darmstadt - Graphics, Capture and Massively Parallel Computing 4 | * All rights reserved. 5 | * 6 | * This software may be modified and distributed under the terms 7 | * of the BSD 3-Clause license. See the LICENSE.txt file for details. 8 | */ 9 | 10 | #ifndef IMAGE_OPERATIONS_HEADER 11 | #define IMAGE_OPERATIONS_HEADER 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | #include "dmrecon/progress.h" 20 | #include "mve/scene.h" 21 | #include "mve/view.h" 22 | 23 | #include "selectedview.h" 24 | 25 | struct JobDMRecon; 26 | 27 | class ImageOperationsWidget : public QWidget 28 | { 29 | Q_OBJECT 30 | 31 | private: 32 | SelectedView* selected_view; 33 | 34 | /* Depthmap cleanup settings. */ 35 | QComboBox dmclean_src_image; 36 | QLineEdit dmclean_dst_image; 37 | QSpinBox dmclean_island_size; 38 | 39 | /* MVS settings. */ 40 | QSpinBox mvs_amount_gvs; 41 | QSpinBox mvs_scale; 42 | QComboBox mvs_color_image; 43 | QCheckBox mvs_color_scale; 44 | QCheckBox mvs_write_ply; 45 | QCheckBox mvs_dz_map; 46 | QCheckBox mvs_conf_map; 47 | QCheckBox mvs_auto_save; 48 | 49 | private: 50 | void start_dmrecon_job (mve::View::Ptr view); 51 | void threaded_dmrecon (JobDMRecon* job); 52 | 53 | signals: 54 | void signal_reload_embeddings (void); 55 | void signal_select_embedding (QString const& name); 56 | 57 | private slots: 58 | void exec_dmrecon (void); 59 | void exec_dmclean (void); 60 | void exec_dmrecon_batch (void); 61 | void on_view_selected (mve::View::Ptr view); 62 | 63 | public: 64 | ImageOperationsWidget (void); 65 | }; 66 | 67 | #endif /* IMAGE_OPERATIONS_HEADER */ 68 | -------------------------------------------------------------------------------- /dist/snap/README.md: -------------------------------------------------------------------------------- 1 | Snap is a cross-distribution packaging format for Linux. See 2 | https://snapcraft.io for more information. 3 | 4 | How to build 5 | ------------ 6 | Just type 7 | ``` 8 | snapcraft 9 | ``` 10 | from the *parent* directory: that is, not from the directory containing this 11 | README file, but from its parent directory. This snap has been successfully 12 | built in Ubuntu 16.04; more recent Ubuntu versions should work as well. Note 13 | that, regardless of the environment used to build it, the generated snap 14 | package will work on any distribution where snap is installed. 15 | 16 | How to test the snap 17 | -------------------- 18 | The generated snap can be installed by typing 19 | ``` 20 | snap install --dangerous ./mve*.snap 21 | ``` 22 | The `--dangerous` flag is needed because the snap has not been verified by the 23 | store. 24 | 25 | How to upload the snap to the store 26 | ----------------------------------- 27 | A thorough guide can be found at the [snapcraft.io 28 | site](https://snapcraft.io/docs/build-snaps/publish). 29 | 30 | -------------------------------------------------------------------------------- /dist/snap/gui/umve.desktop: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Type=Application 3 | Name=UMVE - Ultimate MVE 4 | Comment=Ultimate Multi-View Environment 5 | Exec=mve.umve 6 | Terminal=false 7 | Categories=Graphics; 8 | Icon=${SNAP}/meta/gui/umve.png 9 | 10 | -------------------------------------------------------------------------------- /dist/snap/gui/umve.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/simonfuhrmann/mve/d4bc2ee02a6b57130751c012a8893b3bd4d6540c/dist/snap/gui/umve.png -------------------------------------------------------------------------------- /dist/snap/snapcraft.yaml: -------------------------------------------------------------------------------- 1 | name: mve 2 | version: '20170210-1' 3 | summary: Multi-View Environment 4 | description: | 5 | The Multi-View Environment, MVE, is an implementation of a complete 6 | end-to-end pipeline for image-based geometry reconstruction. It features 7 | Structure-from-Motion, Multi-View Stereo and Surface Reconstruction. 8 | icon: snap/gui/umve.png 9 | 10 | grade: stable 11 | confinement: strict 12 | 13 | apps: 14 | umve: 15 | command: desktop-launch umve 16 | plugs: [home, x11, mir, opengl, unity7, removable-media] 17 | bundle2pset: 18 | command: bundle2pset 19 | plugs: [home, removable-media] 20 | dmrecon: 21 | command: dmrecon 22 | plugs: [home, removable-media] 23 | fssrecon: 24 | command: fssrecon 25 | plugs: [home, removable-media] 26 | makescene: 27 | command: makescene 28 | plugs: [home, removable-media] 29 | mesh2pset: 30 | command: mesh2pset 31 | plugs: [home, removable-media] 32 | meshalign: 33 | command: meshalign 34 | plugs: [home, removable-media] 35 | meshclean: 36 | command: meshclean 37 | plugs: [home, removable-media] 38 | meshconvert: 39 | command: meshconvert 40 | plugs: [home, removable-media] 41 | scene2pset: 42 | command: scene2pset 43 | plugs: [home, removable-media] 44 | sceneupgrade: 45 | command: sceneupgrade 46 | plugs: [home, removable-media] 47 | sfmrecon: 48 | command: sfmrecon 49 | plugs: [home, removable-media] 50 | 51 | parts: 52 | mve: 53 | after: [desktop-qt5] 54 | plugin: make 55 | source: https://github.com/simonfuhrmann/mve.git 56 | source-commit: 2cfae0a430de965070e54e58a0da89173f7061ef 57 | build-packages: 58 | - g++ 59 | - libjpeg8-dev 60 | - libpng12-dev 61 | - libqt5opengl5-dev 62 | - libtiff5-dev 63 | - mesa-common-dev 64 | - qt5-default 65 | build: | 66 | unset CXXFLAGS 67 | make -j8 68 | cd apps/umve 69 | qmake 70 | make -j8 71 | install: | 72 | mkdir -p $SNAPCRAFT_PART_INSTALL/bin 73 | cd apps 74 | for prog in bundle2pset dmrecon fssrecon makescene mesh2pset meshalign \ 75 | meshclean meshconvert scene2pset sceneupgrade sfmrecon umve 76 | do 77 | cp "$prog/$prog" $SNAPCRAFT_PART_INSTALL/bin/ 78 | done 79 | cp -a umve/shaders/ $SNAPCRAFT_PART_INSTALL/bin/ 80 | 81 | -------------------------------------------------------------------------------- /docs/Makefile: -------------------------------------------------------------------------------- 1 | doxygen: 2 | doxygen doxygen/Doxyfile 3 | 4 | clean: 5 | rm -rf doxygen/html/ 6 | 7 | .PHONY: clean doxygen 8 | -------------------------------------------------------------------------------- /docs/doxygen.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /libs/Makefile: -------------------------------------------------------------------------------- 1 | all: 2 | ${MAKE} -C math 3 | ${MAKE} -C util 4 | ${MAKE} -C mve 5 | ${MAKE} -C sfm 6 | ${MAKE} -C dmrecon 7 | $(MAKE) -C fssr 8 | ${MAKE} -C ogl 9 | 10 | clean: 11 | ${MAKE} -C math $@ 12 | ${MAKE} -C util $@ 13 | ${MAKE} -C mve $@ 14 | ${MAKE} -C sfm $@ 15 | ${MAKE} -C dmrecon $@ 16 | $(MAKE) -C fssr $@ 17 | ${MAKE} -C ogl $@ 18 | 19 | .PHONY: all clean 20 | -------------------------------------------------------------------------------- /libs/dmrecon/Makefile: -------------------------------------------------------------------------------- 1 | MVE_ROOT = ../.. 2 | TARGET := libmve_dmrecon.a 3 | include ${MVE_ROOT}/Makefile.inc 4 | 5 | # Position independent code (-fPIC) is required for the UMVE plugin system. 6 | CXXFLAGS += -fPIC -I${MVE_ROOT}/libs 7 | 8 | SOURCES := $(wildcard [^_]*.cc) 9 | ${TARGET}: ${SOURCES:.cc=.o} 10 | $(AR) rcs $@ $^ 11 | 12 | clean: 13 | ${RM} ${TARGET} *.o Makefile.dep 14 | 15 | .PHONY: clean 16 | 17 | -------------------------------------------------------------------------------- /libs/dmrecon/defines.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, Simon Fuhrmann 3 | * TU Darmstadt - Graphics, Capture and Massively Parallel Computing 4 | * All rights reserved. 5 | * 6 | * This software may be modified and distributed under the terms 7 | * of the BSD 3-Clause license. See the LICENSE.txt file for details. 8 | */ 9 | 10 | #ifndef DMRECON_DEFINES_H 11 | #define DMRECON_DEFINES_H 12 | 13 | #include 14 | #include 15 | 16 | #include "math/vector.h" 17 | 18 | #define MVS_NAMESPACE_BEGIN namespace mvs { 19 | #define MVS_NAMESPACE_END } 20 | 21 | /** Multi-View Stereo implementation of [Goesele '07, ICCV]. */ 22 | MVS_NAMESPACE_BEGIN 23 | 24 | typedef std::set< std::size_t > IndexSet; 25 | typedef std::vector< math::Vec3f > Samples; 26 | typedef std::vector< math::Vec2f > PixelCoords; 27 | 28 | const float pi = 3.141592653589793f; 29 | 30 | template 31 | inline const T sqr(const T& a) 32 | { 33 | return (a)*(a); 34 | } 35 | 36 | MVS_NAMESPACE_END 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /libs/dmrecon/dmrecon.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, Ronny Klowsky, Simon Fuhrmann 3 | * TU Darmstadt - Graphics, Capture and Massively Parallel Computing 4 | * All rights reserved. 5 | * 6 | * This software may be modified and distributed under the terms 7 | * of the BSD 3-Clause license. See the LICENSE.txt file for details. 8 | */ 9 | 10 | #ifndef DMRECON_DMRECON_H 11 | #define DMRECON_DMRECON_H 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | #include "mve/bundle.h" 19 | #include "mve/image.h" 20 | #include "mve/scene.h" 21 | #include "dmrecon/defines.h" 22 | #include "dmrecon/patch_optimization.h" 23 | #include "dmrecon/single_view.h" 24 | #include "dmrecon/progress.h" 25 | 26 | MVS_NAMESPACE_BEGIN 27 | 28 | struct QueueData 29 | { 30 | int x; 31 | int y; 32 | float confidence; 33 | float depth; 34 | float dz_i, dz_j; 35 | IndexSet localViewIDs; 36 | 37 | bool operator< (const QueueData& rhs) const; 38 | }; 39 | 40 | class DMRecon 41 | { 42 | public: 43 | DMRecon(mve::Scene::Ptr scene, Settings const& settings); 44 | 45 | std::size_t getRefViewNr() const; 46 | Progress const& getProgress() const; 47 | Progress& getProgress(); 48 | void start(); 49 | 50 | private: 51 | mve::Scene::Ptr scene; 52 | mve::Bundle::ConstPtr bundle; 53 | std::vector views; 54 | 55 | Settings settings; 56 | std::priority_queue prQueue; 57 | IndexSet neighViews; 58 | std::vector imgNeighbors; 59 | int width; 60 | int height; 61 | Progress progress; 62 | 63 | void analyzeFeatures(); 64 | void globalViewSelection(); 65 | void processFeatures(); 66 | void processQueue(); 67 | void refillQueueFromLowRes(); 68 | }; 69 | 70 | /* ------------------------- Implementation ----------------------- */ 71 | 72 | inline bool 73 | QueueData::operator< (const QueueData& rhs) const 74 | { 75 | return (confidence < rhs.confidence); 76 | } 77 | 78 | inline const Progress& 79 | DMRecon::getProgress() const 80 | { 81 | return progress; 82 | } 83 | 84 | inline Progress& 85 | DMRecon::getProgress() 86 | { 87 | return progress; 88 | } 89 | 90 | inline std::size_t 91 | DMRecon::getRefViewNr() const 92 | { 93 | return settings.refViewNr; 94 | } 95 | 96 | MVS_NAMESPACE_END 97 | 98 | #endif 99 | -------------------------------------------------------------------------------- /libs/dmrecon/global_view_selection.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, Ronny Klowsky, Simon Fuhrmann 3 | * TU Darmstadt - Graphics, Capture and Massively Parallel Computing 4 | * All rights reserved. 5 | * 6 | * This software may be modified and distributed under the terms 7 | * of the BSD 3-Clause license. See the LICENSE.txt file for details. 8 | */ 9 | 10 | #ifndef DMRECON_GLOBAL_VIEW_SELECTION_H 11 | #define DMRECON_GLOBAL_VIEW_SELECTION_H 12 | 13 | #include 14 | 15 | #include "mve/bundle.h" 16 | #include "dmrecon/single_view.h" 17 | #include "dmrecon/view_selection.h" 18 | 19 | MVS_NAMESPACE_BEGIN 20 | 21 | class GlobalViewSelection : public ViewSelection 22 | { 23 | public: 24 | GlobalViewSelection(std::vector const& views, 25 | mve::Bundle::Features const& features, 26 | Settings const& settings); 27 | void performVS(); 28 | 29 | private: 30 | float benefitFromView(std::size_t i); 31 | 32 | std::vector const& views; 33 | mve::Bundle::Features const& features; 34 | }; 35 | 36 | MVS_NAMESPACE_END 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /libs/dmrecon/image_pyramid.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, Benjamin Richter, Simon Fuhrmann 3 | * TU Darmstadt - Graphics, Capture and Massively Parallel Computing 4 | * All rights reserved. 5 | * 6 | * This software may be modified and distributed under the terms 7 | * of the BSD 3-Clause license. See the LICENSE.txt file for details. 8 | */ 9 | 10 | #ifndef DMRECON_IMAGE_PYRAMID_H 11 | #define DMRECON_IMAGE_PYRAMID_H 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | #include "mve/scene.h" 19 | #include "mve/view.h" 20 | #include "mve/image_base.h" 21 | 22 | #include "mve/camera.h" 23 | #include "math/matrix.h" 24 | #include "dmrecon/defines.h" 25 | 26 | MVS_NAMESPACE_BEGIN 27 | 28 | struct ImagePyramidLevel 29 | { 30 | int width, height; 31 | mve::ByteImage::ConstPtr image; 32 | math::Matrix3f proj; 33 | math::Matrix3f invproj; 34 | 35 | ImagePyramidLevel(); 36 | ImagePyramidLevel(mve::CameraInfo const& _cam, int width, int height); 37 | }; 38 | 39 | inline 40 | ImagePyramidLevel::ImagePyramidLevel() 41 | : width(0) 42 | , height(0) 43 | { 44 | } 45 | 46 | inline 47 | ImagePyramidLevel::ImagePyramidLevel(mve::CameraInfo const& cam, 48 | int _width, int _height) 49 | : width(_width) 50 | , height(_height) 51 | { 52 | cam.fill_calibration(*proj, width, height); 53 | cam.fill_inverse_calibration(*invproj, width, height); 54 | } 55 | 56 | /** 57 | * Image pyramids are represented as vectors of pyramid levels, 58 | * where the presence of an image in a specific level indicates 59 | * that all levels with higher indices also contain images. 60 | */ 61 | class ImagePyramid : public std::vector 62 | { 63 | public: 64 | typedef std::shared_ptr Ptr; 65 | typedef std::shared_ptr ConstPtr; 66 | }; 67 | 68 | class ImagePyramidCache 69 | { 70 | public: 71 | static ImagePyramid::ConstPtr get(mve::Scene::Ptr scene, 72 | mve::View::Ptr view, std::string embeddingName, int minLevel); 73 | static void cleanup(); 74 | 75 | private: 76 | static std::mutex metadataMutex; 77 | static mve::Scene::Ptr cachedScene; 78 | static std::string cachedEmbedding; 79 | 80 | static std::map entries; 81 | }; 82 | 83 | MVS_NAMESPACE_END 84 | 85 | #endif 86 | -------------------------------------------------------------------------------- /libs/dmrecon/local_view_selection.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, Simon Fuhrmann 3 | * TU Darmstadt - Graphics, Capture and Massively Parallel Computing 4 | * All rights reserved. 5 | * 6 | * This software may be modified and distributed under the terms 7 | * of the BSD 3-Clause license. See the LICENSE.txt file for details. 8 | */ 9 | 10 | #ifndef DMRECON_LOCAL_VIEW_SELECTION_H 11 | #define DMRECON_LOCAL_VIEW_SELECTION_H 12 | 13 | #include "dmrecon/view_selection.h" 14 | #include "dmrecon/patch_sampler.h" 15 | #include "dmrecon/single_view.h" 16 | 17 | MVS_NAMESPACE_BEGIN 18 | 19 | class LocalViewSelection : public ViewSelection 20 | { 21 | public: 22 | LocalViewSelection( 23 | std::vector const& views, 24 | Settings const& settings, 25 | IndexSet const& globalViews, 26 | IndexSet const& propagated, 27 | PatchSampler::Ptr sampler); 28 | void performVS(); 29 | void replaceViews(IndexSet const& toBeReplaced); 30 | 31 | bool success; 32 | 33 | private: 34 | std::vector const& views; 35 | PatchSampler::Ptr sampler; 36 | }; 37 | 38 | MVS_NAMESPACE_END 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /libs/dmrecon/mvs_tools.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, Ronny Klowsky, Simon Fuhrmann 3 | * TU Darmstadt - Graphics, Capture and Massively Parallel Computing 4 | * All rights reserved. 5 | * 6 | * This software may be modified and distributed under the terms 7 | * of the BSD 3-Clause license. See the LICENSE.txt file for details. 8 | */ 9 | 10 | #ifndef DMRECON_MVS_TOOLS_H 11 | #define DMRECON_MVS_TOOLS_H 12 | 13 | #include 14 | 15 | #include "math/matrix.h" 16 | #include "math/vector.h" 17 | #include "mve/image.h" 18 | #include "dmrecon/defines.h" 19 | #include "dmrecon/single_view.h" 20 | 21 | MVS_NAMESPACE_BEGIN 22 | 23 | /** interpolate color and derivative at given sample positions */ 24 | void colAndExactDeriv(mve::ByteImage const& img, 25 | PixelCoords const& imgPos, PixelCoords const& gradDir, 26 | Samples& color, Samples& deriv); 27 | 28 | /** get color at given pixel positions (no interpolation) */ 29 | void getXYZColorAtPix(mve::ByteImage const& img, 30 | std::vector const& imgPos, Samples* color); 31 | 32 | /** interpolate only color at given sample positions */ 33 | void getXYZColorAtPos(mve::ByteImage const& img, 34 | PixelCoords const& imgPos, Samples* color); 35 | 36 | /** Computes the parallax between two views with respect to some 3D point p */ 37 | float parallax(math::Vec3f p, mvs::SingleView::Ptr v1, mvs::SingleView::Ptr v2); 38 | 39 | /** Turns a parallax value (0 <= p <= 180) into a weight according 40 | to a bilateral Gaussian (see [Furukawa 2010] for details) */ 41 | float parallaxToWeight(float p); 42 | 43 | /* ------------------------- Implementation ----------------------- */ 44 | 45 | inline float 46 | parallax(math::Vec3f p, mvs::SingleView::Ptr v1, mvs::SingleView::Ptr v2) 47 | { 48 | math::Vec3f dir1 = (p - v1->camPos).normalized(); 49 | math::Vec3f dir2 = (p - v2->camPos).normalized(); 50 | float dp = std::max(std::min(dir1.dot(dir2), 1.f), -1.f); 51 | float plx = std::acos(dp) * 180.f / pi; 52 | return plx; 53 | } 54 | 55 | inline float 56 | parallaxToWeight(float p) 57 | { 58 | if (p < 0.f || p > 180.f) { 59 | std::cerr << "ERROR: invalid parallax value." << std::endl; 60 | return 0.f; 61 | } 62 | float sigma; 63 | if (p <= 20.f) 64 | sigma = 5.f; 65 | else 66 | sigma = 15.f; 67 | float mean = 20.f; 68 | return exp(- sqr(p - mean) / (2 * sigma * sigma)); 69 | } 70 | 71 | MVS_NAMESPACE_END 72 | 73 | #endif 74 | -------------------------------------------------------------------------------- /libs/dmrecon/patch_optimization.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, Ronny Klowsky, Simon Fuhrmann 3 | * TU Darmstadt - Graphics, Capture and Massively Parallel Computing 4 | * All rights reserved. 5 | * 6 | * This software may be modified and distributed under the terms 7 | * of the BSD 3-Clause license. See the LICENSE.txt file for details. 8 | */ 9 | 10 | #ifndef DMRECON_PATCH_OPTIMIZATION_H 11 | #define DMRECON_PATCH_OPTIMIZATION_H 12 | 13 | #include 14 | 15 | #include "math/vector.h" 16 | #include "dmrecon/defines.h" 17 | #include "dmrecon/patch_sampler.h" 18 | #include "dmrecon/single_view.h" 19 | #include "dmrecon/local_view_selection.h" 20 | 21 | MVS_NAMESPACE_BEGIN 22 | 23 | struct Status 24 | { 25 | std::size_t iterationCount; 26 | bool converged; 27 | bool optiSuccess; 28 | }; 29 | 30 | class PatchOptimization 31 | { 32 | public: 33 | PatchOptimization( 34 | std::vector const& _views, 35 | Settings const& _settings, 36 | int _x, // Pixel position 37 | int _y, 38 | float _depth, 39 | float _dzI, 40 | float _dzJ, 41 | IndexSet const& _globalViewIDs, 42 | IndexSet const& _localViewIDs); 43 | 44 | void computeColorScale(); 45 | float computeConfidence(); 46 | float derivNorm(); 47 | void doAutoOptimization(); 48 | float getDepth() const; 49 | float getDzI() const; 50 | float getDzJ() const; 51 | IndexSet const& getLocalViewIDs() const; 52 | math::Vec3f getNormal() const; 53 | float objFunValue(); 54 | void optimizeDepthOnly(); 55 | void optimizeDepthAndNormal(); 56 | 57 | private: 58 | std::vector const& views; 59 | Settings const& settings; 60 | // initial values and settings 61 | const int midx; 62 | const int midy; 63 | 64 | float depth; 65 | float dzI, dzJ; // represents patch normal 66 | std::map > colorScale; 67 | Status status; 68 | 69 | PatchSampler::Ptr sampler; 70 | std::vector ii, jj; 71 | std::vector pixel_weight; 72 | LocalViewSelection localVS; 73 | }; 74 | 75 | inline float 76 | PatchOptimization::getDepth() const 77 | { 78 | return depth; 79 | } 80 | 81 | inline float 82 | PatchOptimization::getDzI() const 83 | { 84 | return dzI; 85 | } 86 | 87 | inline float 88 | PatchOptimization::getDzJ() const 89 | { 90 | return dzJ; 91 | } 92 | 93 | inline IndexSet const& 94 | PatchOptimization::getLocalViewIDs() const 95 | { 96 | return localVS.getSelectedIDs(); 97 | } 98 | 99 | inline math::Vec3f 100 | PatchOptimization::getNormal() const 101 | { 102 | return sampler->getPatchNormal(); 103 | } 104 | 105 | MVS_NAMESPACE_END 106 | 107 | #endif 108 | -------------------------------------------------------------------------------- /libs/dmrecon/progress.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, Ronny Klowsky, Simon Fuhrmann 3 | * TU Darmstadt - Graphics, Capture and Massively Parallel Computing 4 | * All rights reserved. 5 | * 6 | * This software may be modified and distributed under the terms 7 | * of the BSD 3-Clause license. See the LICENSE.txt file for details. 8 | */ 9 | 10 | #ifndef DMRECON_PROGRESS_H 11 | #define DMRECON_PROGRESS_H 12 | 13 | #include "dmrecon/defines.h" 14 | 15 | MVS_NAMESPACE_BEGIN 16 | 17 | enum ReconStatus 18 | { 19 | RECON_IDLE, 20 | RECON_GLOBALVS, 21 | RECON_FEATURES, 22 | RECON_QUEUE, 23 | RECON_SAVING, 24 | RECON_CANCELLED 25 | }; 26 | 27 | struct Progress 28 | { 29 | ReconStatus status; ///< current status of MVS algorithm 30 | std::size_t filled; ///< amount of pixels with reconstructed depth value 31 | std::size_t queueSize; ///< current size of MVS pixel queue 32 | std::size_t start_time; ///< start time of MVS reconstruction, or 0 33 | bool cancelled; ///< set from extern to true to cancel reconstruction 34 | 35 | Progress() 36 | : status(RECON_IDLE) 37 | , filled(0) 38 | , queueSize(0) 39 | , start_time(0) 40 | , cancelled(false) 41 | { 42 | } 43 | }; 44 | 45 | MVS_NAMESPACE_END 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /libs/dmrecon/settings.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, Simon Fuhrmann 3 | * TU Darmstadt - Graphics, Capture and Massively Parallel Computing 4 | * All rights reserved. 5 | * 6 | * This software may be modified and distributed under the terms 7 | * of the BSD 3-Clause license. See the LICENSE.txt file for details. 8 | */ 9 | 10 | #ifndef DMRECON_SETTINGS_H 11 | #define DMRECON_SETTINGS_H 12 | 13 | #include 14 | #include 15 | #include 16 | 17 | #include "math/vector.h" 18 | #include "dmrecon/defines.h" 19 | 20 | MVS_NAMESPACE_BEGIN 21 | 22 | struct Settings 23 | { 24 | /** The reference view ID to reconstruct. */ 25 | std::size_t refViewNr = 0; 26 | 27 | /** Input image emebdding. */ 28 | std::string imageEmbedding = "undistorted"; 29 | 30 | /** Size of the patch is width * width, defaults to 5x5. */ 31 | unsigned int filterWidth = 5; 32 | float minNCC = 0.3f; 33 | float minParallax = 10.0f; 34 | float acceptNCC = 0.6f; 35 | float minRefineDiff = 0.001f; 36 | unsigned int maxIterations = 20; 37 | unsigned int nrReconNeighbors = 4; 38 | unsigned int globalVSMax = 20; 39 | int scale = 0; 40 | bool useColorScale = true; 41 | bool writePlyFile = false; 42 | 43 | /** Features outside the AABB are ignored. */ 44 | math::Vec3f aabbMin = math::Vec3f(-std::numeric_limits::max()); 45 | math::Vec3f aabbMax = math::Vec3f(std::numeric_limits::max()); 46 | 47 | std::string plyPath; 48 | 49 | bool keepDzMap = false; 50 | bool keepConfidenceMap = false; 51 | bool quiet = false; 52 | }; 53 | 54 | MVS_NAMESPACE_END 55 | 56 | #endif /* DMRECON_SETTINGS_H */ 57 | -------------------------------------------------------------------------------- /libs/dmrecon/view_selection.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, Ronny Klowsky, Simon Fuhrmann 3 | * TU Darmstadt - Graphics, Capture and Massively Parallel Computing 4 | * All rights reserved. 5 | * 6 | * This software may be modified and distributed under the terms 7 | * of the BSD 3-Clause license. See the LICENSE.txt file for details. 8 | */ 9 | 10 | #ifndef DMRECON_VIEW_SELECTION_H 11 | #define DMRECON_VIEW_SELECTION_H 12 | 13 | #include 14 | 15 | #include "dmrecon/defines.h" 16 | #include "dmrecon/settings.h" 17 | 18 | MVS_NAMESPACE_BEGIN 19 | 20 | class ViewSelection 21 | { 22 | public: 23 | typedef std::shared_ptr Ptr; 24 | 25 | ViewSelection(); 26 | ViewSelection(Settings const& settings); 27 | 28 | public: 29 | IndexSet const& getSelectedIDs() const; 30 | 31 | protected: 32 | Settings const& settings; 33 | std::vector available; 34 | IndexSet selected; 35 | }; 36 | 37 | 38 | inline 39 | ViewSelection::ViewSelection(Settings const& settings) 40 | : 41 | settings(settings) 42 | { 43 | } 44 | 45 | inline IndexSet const& 46 | ViewSelection::getSelectedIDs() const 47 | { 48 | return selected; 49 | } 50 | 51 | MVS_NAMESPACE_END 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /libs/fssr/Makefile: -------------------------------------------------------------------------------- 1 | MVE_ROOT := ../.. 2 | TARGET := libmve_fssr.a 3 | include ${MVE_ROOT}/Makefile.inc 4 | 5 | CXXFLAGS += -fPIC -I${MVE_ROOT}/libs ${OPENMP} 6 | LDLIBS += ${LIBJPEG_LDFLAGS} ${LIBPNG_LDFLAGS} ${LIBTIFF_LDFLAGS} ${OPENMP} 7 | 8 | SOURCES := $(wildcard [^_]*.cc) 9 | ${TARGET}: ${SOURCES:.cc=.o} 10 | $(AR) rcs $@ $^ 11 | 12 | clean: 13 | ${RM} $(TARGET) *.o Makefile.dep 14 | 15 | .PHONY: clean 16 | -------------------------------------------------------------------------------- /libs/fssr/defines.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, Simon Fuhrmann 3 | * TU Darmstadt - Graphics, Capture and Massively Parallel Computing 4 | * All rights reserved. 5 | * 6 | * This software may be modified and distributed under the terms 7 | * of the BSD 3-Clause license. See the LICENSE.txt file for details. 8 | */ 9 | 10 | #ifndef FSSR_DEFINES_HEADER 11 | #define FSSR_DEFINES_HEADER 12 | 13 | #define FSSR_NAMESPACE_BEGIN namespace fssr { 14 | #define FSSR_NAMESPACE_END } 15 | 16 | /* Use new weighting function with continuous derivative. */ 17 | #define FSSR_NEW_WEIGHT_FUNCTION 1 18 | 19 | /* Use derivatives for more precise isovertex interpolation. */ 20 | #define FSSR_USE_DERIVATIVES 1 21 | 22 | /* 23 | * Using the new weighting function is strongly recommended when using 24 | * derivatives, as the old weighting function derivative is discontinuous. 25 | */ 26 | #if FSSR_USE_DERIVATIVES && !FSSR_NEW_WEIGHT_FUNCTION 27 | # error "FSSR_USE_DERIVATIVES requires FSSR_NEW_WEIGHT_FUNCTION" 28 | #endif 29 | 30 | #endif /* FSSR_DEFINES_HEADER */ 31 | -------------------------------------------------------------------------------- /libs/fssr/hermite.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, Simon Fuhrmann 3 | * TU Darmstadt - Graphics, Capture and Massively Parallel Computing 4 | * All rights reserved. 5 | * 6 | * This software may be modified and distributed under the terms 7 | * of the BSD 3-Clause license. See the LICENSE.txt file for details. 8 | */ 9 | 10 | #ifndef FSSR_HERMITE_HEADER 11 | #define FSSR_HERMITE_HEADER 12 | 13 | #include "fssr/defines.h" 14 | 15 | FSSR_NAMESPACE_BEGIN 16 | 17 | enum InterpolationType 18 | { 19 | INTERPOLATION_LINEAR, 20 | INTERPOLATION_SCALING, 21 | INTERPOLATION_LSDERIV, 22 | INTERPOLATION_CUBIC 23 | }; 24 | 25 | /** 26 | * Finds the root of a linear function f(x) = a0 + a1(x). 27 | * The method produces unstable results if a1 ~ 0. 28 | */ 29 | double 30 | find_root_linear (double a0, double a1); 31 | 32 | /** 33 | * Finds the root of a quadratic function f(x) = a0 + a1 * x + a2 * x^2. 34 | * The code assumes a root in [0, 1] and the root closer to 0.5 is returned. 35 | */ 36 | double 37 | find_root_square (double a0, double a1, double a2); 38 | 39 | /** 40 | * Finds the root of a cubic function f(x) = a0 + a1 * x + a2 * x^2 + a3 * x^3. 41 | * The code assumes a single root in [0, 1]. If [0, 1] contains more than one 42 | * root, linear interpolation is used. In the case with two distinct roots 43 | * (one single, one double root), the double root is ignored. 44 | */ 45 | double 46 | find_root_cubic (double a0, double a1, double a2, double a3); 47 | 48 | /** 49 | * Interpolates the root of an unknown function f(x) given value and 50 | * derivative constraints: f(0) = v0, f(1) = v1, f'(0) = d0, f'(1) = d1. 51 | * First, a polynomial function is fit to the constraints, then the root 52 | * in the interval [0, 1] is determined. 53 | */ 54 | double 55 | interpolate_root (double v0, double v1, double d0, double d1, 56 | InterpolationType type = INTERPOLATION_CUBIC); 57 | 58 | FSSR_NAMESPACE_END 59 | 60 | #endif /* FSSR_HERMITE_HEADER */ 61 | -------------------------------------------------------------------------------- /libs/fssr/iso_octree.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, Simon Fuhrmann 3 | * TU Darmstadt - Graphics, Capture and Massively Parallel Computing 4 | * All rights reserved. 5 | * 6 | * This software may be modified and distributed under the terms 7 | * of the BSD 3-Clause license. See the LICENSE.txt file for details. 8 | */ 9 | 10 | #ifndef FSSR_ISO_OCTREE_HEADER 11 | #define FSSR_ISO_OCTREE_HEADER 12 | 13 | #include 14 | 15 | #include "fssr/defines.h" 16 | #include "fssr/voxel.h" 17 | #include "fssr/octree.h" 18 | 19 | FSSR_NAMESPACE_BEGIN 20 | 21 | /** 22 | * This class computes the implicit function by querying function values 23 | * at the octree primal vertices of the leaf nodes, called voxels. 24 | */ 25 | class IsoOctree : public Octree 26 | { 27 | public: 28 | typedef std::vector > VoxelVector; 29 | 30 | public: 31 | IsoOctree (void); 32 | 33 | /** Resets the octree to its initial state. */ 34 | void clear (void); 35 | 36 | /** Clears the voxel data, keeps samples and hierarchy. */ 37 | void clear_voxel_data (void); 38 | 39 | /** Evaluate the implicit function for all voxels on all leaf nodes. */ 40 | void compute_voxels (void); 41 | 42 | /** Returns the map of computed voxels. */ 43 | VoxelVector const& get_voxels (void) const; 44 | 45 | private: 46 | void compute_all_voxels (void); 47 | VoxelData sample_ifn (math::Vec3d const& voxel_pos); 48 | void print_progress (std::size_t voxels_done, std::size_t voxels_total); 49 | 50 | private: 51 | VoxelVector voxels; 52 | }; 53 | 54 | FSSR_NAMESPACE_END 55 | 56 | /* ------------------------- Implementation ---------------------------- */ 57 | 58 | FSSR_NAMESPACE_BEGIN 59 | 60 | inline 61 | IsoOctree::IsoOctree (void) 62 | { 63 | } 64 | 65 | inline void 66 | IsoOctree::clear (void) 67 | { 68 | this->clear_voxel_data(); 69 | this->Octree::clear(); 70 | } 71 | 72 | inline void 73 | IsoOctree::clear_voxel_data (void) 74 | { 75 | this->voxels.clear(); 76 | } 77 | 78 | inline IsoOctree::VoxelVector const& 79 | IsoOctree::get_voxels (void) const 80 | { 81 | return this->voxels; 82 | } 83 | 84 | FSSR_NAMESPACE_END 85 | 86 | #endif /* FSSR_ISO_OCTREE_HEADER */ 87 | -------------------------------------------------------------------------------- /libs/fssr/mesh_clean.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, Simon Fuhrmann 3 | * TU Darmstadt - Graphics, Capture and Massively Parallel Computing 4 | * All rights reserved. 5 | * 6 | * This software may be modified and distributed under the terms 7 | * of the BSD 3-Clause license. See the LICENSE.txt file for details. 8 | */ 9 | 10 | #ifndef FSSR_MESH_CLEAN_HEADER 11 | #define FSSR_MESH_CLEAN_HEADER 12 | 13 | #include "fssr/defines.h" 14 | #include "mve/mesh.h" 15 | 16 | FSSR_NAMESPACE_BEGIN 17 | 18 | /** 19 | * Cleans needles from the mesh by collapsing short edges of degenerated 20 | * triangles. The number of successful edge collapses is returned. 21 | */ 22 | std::size_t 23 | clean_needles (mve::TriangleMesh::Ptr mesh, float needle_ratio_thres); 24 | 25 | /** 26 | * Cleans caps from the mesh by removing vertices with only three 27 | * adjacent triangles. The number of successful edge collapses is returned. 28 | */ 29 | std::size_t 30 | clean_caps (mve::TriangleMesh::Ptr mesh); 31 | 32 | /** 33 | * Removes degenerated triangles from the mesh typical for Marching Cubes. 34 | * The routine first cleans needles, then caps, then remaining needles. 35 | */ 36 | std::size_t 37 | clean_mc_mesh (mve::TriangleMesh::Ptr mesh, float needle_ratio_thres = 0.4f); 38 | 39 | FSSR_NAMESPACE_END 40 | 41 | #endif /* FSSR_MESH_CLEAN_HEADER */ 42 | -------------------------------------------------------------------------------- /libs/fssr/sample.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, Simon Fuhrmann 3 | * TU Darmstadt - Graphics, Capture and Massively Parallel Computing 4 | * All rights reserved. 5 | * 6 | * This software may be modified and distributed under the terms 7 | * of the BSD 3-Clause license. See the LICENSE.txt file for details. 8 | */ 9 | 10 | #ifndef FSSR_SAMPLE_HEADER 11 | #define FSSR_SAMPLE_HEADER 12 | 13 | #include 14 | 15 | #include "math/vector.h" 16 | #include "fssr/defines.h" 17 | 18 | FSSR_NAMESPACE_BEGIN 19 | 20 | /** Representation of a point sample. */ 21 | struct Sample 22 | { 23 | math::Vec3f pos; 24 | math::Vec3f normal; 25 | math::Vec3f color; 26 | float scale; 27 | float confidence; 28 | }; 29 | 30 | /** Representation of a list of samples. */ 31 | typedef std::vector SampleList; 32 | 33 | /** Comparator that orders samples according to scale. */ 34 | bool 35 | sample_scale_compare (Sample const* s1, Sample const* s2); 36 | 37 | FSSR_NAMESPACE_END 38 | 39 | /* ------------------------- Implementation ---------------------------- */ 40 | 41 | FSSR_NAMESPACE_BEGIN 42 | 43 | inline bool 44 | sample_scale_compare (Sample const* s1, Sample const* s2) 45 | { 46 | return s1->scale < s2->scale; 47 | } 48 | 49 | FSSR_NAMESPACE_END 50 | 51 | #endif // FSSR_SAMPLE_HEADER 52 | -------------------------------------------------------------------------------- /libs/fssr/triangulation.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, Simon Fuhrmann 3 | * TU Darmstadt - Graphics, Capture and Massively Parallel Computing 4 | * All rights reserved. 5 | * 6 | * This software may be modified and distributed under the terms 7 | * of the BSD 3-Clause license. See the LICENSE.txt file for details. 8 | */ 9 | 10 | #ifndef FSSR_TRIANGULATION_HEADER 11 | #define FSSR_TRIANGULATION_HEADER 12 | 13 | #include 14 | 15 | #include "math/vector.h" 16 | #include "fssr/defines.h" 17 | 18 | FSSR_NAMESPACE_BEGIN 19 | 20 | /** 21 | * Computes the minimum area triangulation of a polygon. 22 | * The algorithm is described in the paper: 23 | * 24 | * Unconstrained Isosurface Extraction on Arbitrary Octrees 25 | * Michael Kazhdan, Allison Klein, Ketan Dalal, Hugues Hoppe 26 | */ 27 | class MinAreaTriangulation 28 | { 29 | public: 30 | void triangulate (std::vector const& verts, 31 | std::vector* indices); 32 | 33 | private: 34 | float compute_table (std::vector const& verts, 35 | int start_id, int end_id); 36 | void compute_triangulation (std::vector* indices, 37 | int start_id, int end_id, int num_verts); 38 | 39 | private: 40 | std::vector min_area_table; 41 | std::vector mid_point_table; 42 | }; 43 | 44 | /* 45 | * TODO: Triangulation that creates a center vertex. 46 | */ 47 | 48 | FSSR_NAMESPACE_END 49 | 50 | #endif /* FSSR_TRIANGULATION_HEADER */ 51 | -------------------------------------------------------------------------------- /libs/fssr/voxel.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, Simon Fuhrmann 3 | * TU Darmstadt - Graphics, Capture and Massively Parallel Computing 4 | * All rights reserved. 5 | * 6 | * This software may be modified and distributed under the terms 7 | * of the BSD 3-Clause license. See the LICENSE.txt file for details. 8 | */ 9 | 10 | #include 11 | 12 | #include "math/vector.h" 13 | #include "fssr/voxel.h" 14 | 15 | FSSR_NAMESPACE_BEGIN 16 | 17 | void 18 | VoxelIndex::from_path_and_corner (uint8_t level, uint64_t path, int corner) 19 | { 20 | /* Compute node index from the node path. */ 21 | math::Vector coords(0, 0, 0); 22 | for (int l = level - 1; l >= 0; --l) 23 | { 24 | uint64_t index = (path >> (3 * l)) & 7; 25 | for (int i = 0; i < 3; ++i) 26 | { 27 | coords[i] = coords[i] << 1; 28 | coords[i] += (index & (1 << i)) >> i; 29 | } 30 | } 31 | 32 | /* Convert node index to voxel index. */ 33 | for (int i = 0; i < 3; ++i) 34 | { 35 | coords[i] += (corner >> i) & 1; 36 | coords[i] = coords[i] << (20 - level); 37 | } 38 | 39 | /* Compute voxel ID. */ 40 | this->index = coords[0] | coords[1] << 21 | coords[2] << 42; 41 | } 42 | 43 | math::Vec3d 44 | VoxelIndex::compute_position (math::Vec3d const& center, double size) const 45 | { 46 | double const dim_max = static_cast(1 << 20); 47 | double const fx = static_cast(this->get_offset_x()) / dim_max; 48 | double const fy = static_cast(this->get_offset_y()) / dim_max; 49 | double const fz = static_cast(this->get_offset_z()) / dim_max; 50 | return center - size / 2.0 + math::Vec3d(fx, fy, fz) * size; 51 | } 52 | 53 | int32_t 54 | VoxelIndex::get_offset_x (void) const 55 | { 56 | return static_cast((this->index >> 0) & 0x1fffff); 57 | } 58 | 59 | int32_t 60 | VoxelIndex::get_offset_y (void) const 61 | { 62 | return static_cast((this->index >> 21) & 0x1fffff); 63 | } 64 | 65 | int32_t 66 | VoxelIndex::get_offset_z (void) const 67 | { 68 | return static_cast((this->index >> 42) & 0x1fffff); 69 | } 70 | 71 | /* ---------------------------------------------------------------- */ 72 | 73 | VoxelData 74 | interpolate_voxel (VoxelData const& d1, float w1, VoxelData const& d2, float w2) 75 | { 76 | VoxelData ret; 77 | ret.value = w1 * d1.value + w2 * d2.value; 78 | ret.conf = std::min(d1.conf, d2.conf); 79 | ret.scale = w1 * d1.scale + w2 * d2.scale; 80 | ret.color = w1 * d1.color + w2 * d2.color; 81 | return ret; 82 | } 83 | 84 | FSSR_NAMESPACE_END 85 | -------------------------------------------------------------------------------- /libs/math/Makefile: -------------------------------------------------------------------------------- 1 | MVE_ROOT := ../.. 2 | TARGET := libmve_math.a 3 | include ${MVE_ROOT}/Makefile.inc 4 | 5 | # Position independent code (-fPIC) is required for the UMVE plugin system. 6 | CXXFLAGS += -fPIC -I${MVE_ROOT}/libs 7 | 8 | SOURCES := $(wildcard [^_]*.cc) 9 | ${TARGET}: ${SOURCES:.cc=.o} 10 | #$(AR) rcs $@ $^ 11 | 12 | clean: 13 | ${RM} ${TARGET} *.o Makefile.dep 14 | 15 | .PHONY: clean 16 | -------------------------------------------------------------------------------- /libs/math/line.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, Simon Fuhrmann 3 | * TU Darmstadt - Graphics, Capture and Massively Parallel Computing 4 | * All rights reserved. 5 | * 6 | * This software may be modified and distributed under the terms 7 | * of the BSD 3-Clause license. See the LICENSE.txt file for details. 8 | */ 9 | 10 | #ifndef MATH_LINE_HEADER 11 | #define MATH_LINE_HEADER 12 | 13 | #include "math/defines.h" 14 | #include "math/vector.h" 15 | 16 | MATH_NAMESPACE_BEGIN 17 | 18 | template class Line3; 19 | typedef Line3 Line3f; 20 | typedef Line3 Line3d; 21 | 22 | /** 23 | * Class that represents a line using a point and a vector. 24 | * The normal is expected to have unit length. 25 | */ 26 | template 27 | class Line3 28 | { 29 | public: 30 | /** Creates an uninitialized line. */ 31 | Line3 (void); 32 | 33 | /** Creates a line with normal n and distance d from the origin. */ 34 | Line3 (math::Vector const& d, math::Vector const& p); 35 | 36 | public: 37 | math::Vector d; 38 | math::Vector p; 39 | }; 40 | 41 | /* ---------------------------------------------------------------- */ 42 | 43 | template 44 | inline 45 | Line3::Line3 (void) 46 | { 47 | } 48 | 49 | template 50 | inline 51 | Line3::Line3 (math::Vector const& d, math::Vector const& p) 52 | : d(d), p(p) 53 | { 54 | } 55 | 56 | MATH_NAMESPACE_END 57 | 58 | #endif /* MATH_LINE_HEADER */ 59 | -------------------------------------------------------------------------------- /libs/mve/Makefile: -------------------------------------------------------------------------------- 1 | MVE_ROOT := ../.. 2 | TARGET := libmve.a 3 | include ${MVE_ROOT}/Makefile.inc 4 | 5 | # Position independent code (-fPIC) is required for the UMVE plugin system. 6 | CXXFLAGS += -fPIC -I${MVE_ROOT}/libs ${LIBJPEG_CFLAGS} ${LIBPNG_CFLAGS} ${LIBTIFF_CFLAGS} 7 | LDLIBS += ${LIBJPEG_LDFLAGS} ${LIBPNG_LDFLAGS} ${LIBTIFF_LDFLAGS} 8 | 9 | SOURCES := $(wildcard [^_]*.cc) 10 | ${TARGET}: ${SOURCES:.cc=.o} 11 | $(AR) rcs $@ $^ 12 | 13 | _test%: _test%.o libmve.a libmve_util.a 14 | ${LINK.cc} -o $@ $^ ${LDLIBS} 15 | 16 | clean: 17 | ${RM} ${TARGET} *.o Makefile.dep 18 | 19 | .PHONY: clean 20 | -------------------------------------------------------------------------------- /libs/mve/defines.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, Simon Fuhrmann 3 | * TU Darmstadt - Graphics, Capture and Massively Parallel Computing 4 | * All rights reserved. 5 | * 6 | * This software may be modified and distributed under the terms 7 | * of the BSD 3-Clause license. See the LICENSE.txt file for details. 8 | */ 9 | 10 | #ifndef MVE_DEFINES_HEADER 11 | #define MVE_DEFINES_HEADER 12 | 13 | #define MVE_NAMESPACE_BEGIN namespace mve { 14 | #define MVE_NAMESPACE_END } 15 | 16 | #define MVE_IMAGE_NAMESPACE_BEGIN namespace image { 17 | #define MVE_IMAGE_NAMESPACE_END } 18 | 19 | #define MVE_GEOM_NAMESPACE_BEGIN namespace geom { 20 | #define MVE_GEOM_NAMESPACE_END } 21 | 22 | #ifndef STD_NAMESPACE_BEGIN 23 | # define STD_NAMESPACE_BEGIN namespace std { 24 | # define STD_NAMESPACE_END } 25 | #endif 26 | 27 | /** Multi-View Environment library. */ 28 | MVE_NAMESPACE_BEGIN 29 | /** Image tools, loading and processing functions. */ 30 | MVE_IMAGE_NAMESPACE_BEGIN MVE_IMAGE_NAMESPACE_END 31 | /** Geometric tools, loading and processing functions. */ 32 | MVE_GEOM_NAMESPACE_BEGIN MVE_GEOM_NAMESPACE_END 33 | MVE_NAMESPACE_END 34 | 35 | #endif /* MVE_DEFINES_HEADER */ 36 | -------------------------------------------------------------------------------- /libs/mve/mesh_io.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, Simon Fuhrmann 3 | * TU Darmstadt - Graphics, Capture and Massively Parallel Computing 4 | * All rights reserved. 5 | * 6 | * This software may be modified and distributed under the terms 7 | * of the BSD 3-Clause license. See the LICENSE.txt file for details. 8 | */ 9 | 10 | #include 11 | 12 | #include "util/string_utils.h" 13 | #include "mve/mesh.h" 14 | #include "mve/mesh_io.h" 15 | #include "mve/mesh_io_ply.h" 16 | #include "mve/mesh_io_off.h" 17 | #include "mve/mesh_io_npts.h" 18 | #include "mve/mesh_io_pbrt.h" 19 | #include "mve/mesh_io_smf.h" 20 | #include "mve/mesh_io_obj.h" 21 | #include "mve/mesh_io_glb.h" 22 | 23 | MVE_NAMESPACE_BEGIN 24 | MVE_GEOM_NAMESPACE_BEGIN 25 | 26 | TriangleMesh::Ptr 27 | load_mesh (std::string const& filename) 28 | { 29 | if (util::string::right(filename, 4) == ".off") 30 | return load_off_mesh(filename); 31 | else if (util::string::right(filename, 4) == ".ply") 32 | return load_ply_mesh(filename); 33 | else if (util::string::right(filename, 5) == ".npts") 34 | return load_npts_mesh(filename, false); 35 | else if (util::string::right(filename, 6) == ".bnpts") 36 | return load_npts_mesh(filename, true); 37 | else if (util::string::right(filename, 4) == ".smf") 38 | return load_smf_mesh(filename); 39 | else if (util::string::right(filename, 4) == ".obj") 40 | return load_obj_mesh(filename); 41 | else 42 | throw std::runtime_error("Extension not recognized"); 43 | } 44 | 45 | /* ---------------------------------------------------------------- */ 46 | 47 | void 48 | save_mesh (TriangleMesh::ConstPtr mesh, std::string const& filename) 49 | { 50 | if (util::string::right(filename, 4) == ".off") 51 | save_off_mesh(mesh, filename); 52 | else if (util::string::right(filename, 4) == ".ply") 53 | save_ply_mesh(mesh, filename); 54 | else if (util::string::right(filename, 5) == ".pbrt") 55 | save_pbrt_mesh(mesh, filename); 56 | else if (util::string::right(filename, 5) == ".npts") 57 | save_npts_mesh(mesh, filename, false); 58 | else if (util::string::right(filename, 6) == ".bnpts") 59 | save_npts_mesh(mesh, filename, true); 60 | else if (util::string::right(filename, 4) == ".smf") 61 | save_smf_mesh(mesh, filename); 62 | else if (util::string::right(filename, 4) == ".obj") 63 | save_obj_mesh(mesh, filename); 64 | else if (util::string::right(filename, 4) == ".glb") 65 | save_glb_mesh(mesh, filename); 66 | else 67 | throw std::runtime_error("Extension not recognized"); 68 | } 69 | 70 | MVE_GEOM_NAMESPACE_END 71 | MVE_NAMESPACE_END 72 | -------------------------------------------------------------------------------- /libs/mve/mesh_io.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, Simon Fuhrmann 3 | * TU Darmstadt - Graphics, Capture and Massively Parallel Computing 4 | * All rights reserved. 5 | * 6 | * This software may be modified and distributed under the terms 7 | * of the BSD 3-Clause license. See the LICENSE.txt file for details. 8 | */ 9 | 10 | #ifndef MVE_MESH_IO_HEADER 11 | #define MVE_MESH_IO_HEADER 12 | 13 | #include 14 | 15 | #include "mve/defines.h" 16 | #include "mve/mesh.h" 17 | 18 | MVE_NAMESPACE_BEGIN 19 | MVE_GEOM_NAMESPACE_BEGIN 20 | 21 | /** 22 | * Auto-detects filetype from extension and delegates to readers. 23 | */ 24 | TriangleMesh::Ptr 25 | load_mesh (std::string const& filename); 26 | 27 | /** 28 | * Auto-detects filetype from extension and delegates to writers. 29 | */ 30 | void 31 | save_mesh (TriangleMesh::ConstPtr mesh, std::string const& filename); 32 | 33 | MVE_GEOM_NAMESPACE_END 34 | MVE_NAMESPACE_END 35 | 36 | #endif /* MVE_MESH_IO_HEADER */ 37 | -------------------------------------------------------------------------------- /libs/mve/mesh_io_glb.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024, Andre Schulz 3 | * TU Darmstadt - Graphics, Capture and Massively Parallel Computing 4 | * All rights reserved. 5 | * 6 | * This software may be modified and distributed under the terms 7 | * of the BSD 3-Clause license. See the LICENSE.txt file for details. 8 | */ 9 | 10 | #ifndef MVE_MESH_IO_GLB_HEADER 11 | #define MVE_MESH_IO_GLB_HEADER 12 | 13 | #include 14 | 15 | #include "mve/defines.h" 16 | #include "mve/mesh.h" 17 | 18 | MVE_NAMESPACE_BEGIN 19 | MVE_GEOM_NAMESPACE_BEGIN 20 | 21 | /** Saves a triangle mesh as a Binary glTF 2.0 file. */ 22 | void 23 | save_glb_mesh (TriangleMesh::ConstPtr mesh, std::string const& filename); 24 | 25 | MVE_GEOM_NAMESPACE_END 26 | MVE_NAMESPACE_END 27 | 28 | #endif /* MVE_MESH_IO_GLB_HEADER */ 29 | -------------------------------------------------------------------------------- /libs/mve/mesh_io_npts.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, Simon Fuhrmann 3 | * TU Darmstadt - Graphics, Capture and Massively Parallel Computing 4 | * All rights reserved. 5 | * 6 | * This software may be modified and distributed under the terms 7 | * of the BSD 3-Clause license. See the LICENSE.txt file for details. 8 | */ 9 | 10 | #ifndef MVE_MESH_IO_NPTS_HEADER 11 | #define MVE_MESH_IO_NPTS_HEADER 12 | 13 | #include 14 | 15 | #include "mve/defines.h" 16 | #include "mve/mesh.h" 17 | 18 | MVE_NAMESPACE_BEGIN 19 | MVE_GEOM_NAMESPACE_BEGIN 20 | 21 | /** 22 | * Simple importer for Kazhdan's .npts ASCII and binary files. 23 | */ 24 | TriangleMesh::Ptr 25 | load_npts_mesh (std::string const& filename, bool format_binary = false); 26 | 27 | /** 28 | * Simple exporter for Kazhdan's .npts ASCII and binary files. 29 | */ 30 | void 31 | save_npts_mesh (TriangleMesh::ConstPtr mesh, 32 | std::string const& filename, bool format_binary = false); 33 | 34 | MVE_GEOM_NAMESPACE_END 35 | MVE_NAMESPACE_END 36 | 37 | #endif /* MVE_MESH_IO_NPTS_HEADER */ 38 | -------------------------------------------------------------------------------- /libs/mve/mesh_io_obj.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, Simon Fuhrmann, Nils Moehrle 3 | * TU Darmstadt - Graphics, Capture and Massively Parallel Computing 4 | * All rights reserved. 5 | * 6 | * This software may be modified and distributed under the terms 7 | * of the BSD 3-Clause license. See the LICENSE.txt file for details. 8 | */ 9 | 10 | #ifndef MVE_MESH_IO_OBJ_HEADER 11 | #define MVE_MESH_IO_OBJ_HEADER 12 | 13 | #include 14 | 15 | #include "mve/mesh.h" 16 | #include "mve/defines.h" 17 | 18 | MVE_NAMESPACE_BEGIN 19 | MVE_GEOM_NAMESPACE_BEGIN 20 | 21 | struct ObjModelPart 22 | { 23 | mve::TriangleMesh::Ptr mesh; 24 | std::string texture_filename; 25 | }; 26 | 27 | /** Loads a triangle mesh from an OBJ model file. */ 28 | mve::TriangleMesh::Ptr 29 | load_obj_mesh (std::string const& filename); 30 | 31 | /** Loads all groups from an OBJ model file. */ 32 | void 33 | load_obj_mesh (std::string const& filename, 34 | std::vector* obj_model_parts); 35 | 36 | /** Saves a triangle mesh to an OBJ model file. */ 37 | void 38 | save_obj_mesh (TriangleMesh::ConstPtr mesh, std::string const& filename); 39 | 40 | MVE_GEOM_NAMESPACE_END 41 | MVE_NAMESPACE_END 42 | 43 | #endif /* MVE_MESH_IO_OBJ_HEADER */ 44 | -------------------------------------------------------------------------------- /libs/mve/mesh_io_off.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, Simon Fuhrmann 3 | * TU Darmstadt - Graphics, Capture and Massively Parallel Computing 4 | * All rights reserved. 5 | * 6 | * This software may be modified and distributed under the terms 7 | * of the BSD 3-Clause license. See the LICENSE.txt file for details. 8 | */ 9 | 10 | #ifndef MVE_OFF_FILE_HEADER 11 | #define MVE_OFF_FILE_HEADER 12 | 13 | #include 14 | 15 | #include "mve/defines.h" 16 | #include "mve/mesh.h" 17 | 18 | MVE_NAMESPACE_BEGIN 19 | MVE_GEOM_NAMESPACE_BEGIN 20 | 21 | /** Loads a triangle mesh from an OFF model file. */ 22 | TriangleMesh::Ptr 23 | load_off_mesh (std::string const& filename); 24 | 25 | /** Saves a triangle mesh to an OFF model file. */ 26 | void 27 | save_off_mesh (TriangleMesh::ConstPtr mesh, std::string const& filename); 28 | 29 | MVE_GEOM_NAMESPACE_END 30 | MVE_NAMESPACE_END 31 | 32 | #endif /* MVE_OFF_FILE_HEADER */ 33 | -------------------------------------------------------------------------------- /libs/mve/mesh_io_pbrt.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, Simon Fuhrmann 3 | * TU Darmstadt - Graphics, Capture and Massively Parallel Computing 4 | * All rights reserved. 5 | * 6 | * This software may be modified and distributed under the terms 7 | * of the BSD 3-Clause license. See the LICENSE.txt file for details. 8 | */ 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | #include "util/exception.h" 17 | #include "mve/mesh_io_pbrt.h" 18 | 19 | MVE_NAMESPACE_BEGIN 20 | MVE_GEOM_NAMESPACE_BEGIN 21 | 22 | void 23 | save_pbrt_mesh (TriangleMesh::ConstPtr mesh, std::string const& filename) 24 | { 25 | if (mesh == nullptr) 26 | throw std::invalid_argument("Null mesh given"); 27 | if (filename.empty()) 28 | throw std::invalid_argument("No filename given"); 29 | 30 | mve::TriangleMesh::VertexList const& verts(mesh->get_vertices()); 31 | mve::TriangleMesh::NormalList const& vnormals(mesh->get_vertex_normals()); 32 | mve::TriangleMesh::FaceList const& faces(mesh->get_faces()); 33 | 34 | /* Open output file. */ 35 | std::ofstream out(filename.c_str(), std::ios::binary); 36 | if (!out.good()) 37 | throw util::FileException(filename, std::strerror(errno)); 38 | 39 | out << "Translate 0 0 0" << std::endl; 40 | out << "Shape \"trianglemesh\"" << std::endl; 41 | 42 | /* Issue vertices. */ 43 | out << "\"point P\" [" << std::endl; 44 | for (std::size_t i = 0; i < verts.size(); ++i) 45 | { 46 | out << " " 47 | << verts[i][0] << " " 48 | << verts[i][1] << " " 49 | << verts[i][2] << std::endl; 50 | } 51 | out << "]" << std::endl << std::endl; 52 | 53 | /* Issue normals. */ 54 | if (vnormals.size() == verts.size()) 55 | { 56 | out << "\"normal N\" [" << std::endl; 57 | for (std::size_t i = 0; i < vnormals.size(); ++i) 58 | { 59 | out << " " 60 | << vnormals[i][0] << " " 61 | << vnormals[i][1] << " " 62 | << vnormals[i][2] << std::endl; 63 | } 64 | out << "]" << std::endl << std::endl; 65 | } 66 | 67 | /* Issue face indices. */ 68 | out << "\"integer indices\" [" << std::endl; 69 | for (std::size_t i = 0 ; i < faces.size() ; ++i) 70 | { 71 | if (!(i % 3)) 72 | out << " "; 73 | else 74 | out << " "; 75 | out << faces[i]; 76 | if ((i % 3) == 2) 77 | out << std::endl; 78 | } 79 | out << "]" << std::endl; 80 | 81 | /* Close output file. */ 82 | out.close(); 83 | } 84 | 85 | 86 | MVE_GEOM_NAMESPACE_END 87 | MVE_NAMESPACE_END 88 | -------------------------------------------------------------------------------- /libs/mve/mesh_io_pbrt.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, Simon Fuhrmann 3 | * TU Darmstadt - Graphics, Capture and Massively Parallel Computing 4 | * All rights reserved. 5 | * 6 | * This software may be modified and distributed under the terms 7 | * of the BSD 3-Clause license. See the LICENSE.txt file for details. 8 | */ 9 | 10 | #ifndef MVE_PBRTFILE_HEADER 11 | #define MVE_PBRTFILE_HEADER 12 | 13 | #include "mve/mesh.h" 14 | 15 | MVE_NAMESPACE_BEGIN 16 | MVE_GEOM_NAMESPACE_BEGIN 17 | 18 | /** 19 | * Saves a PBRT compatible mesh from a triangle mesh. 20 | */ 21 | void 22 | save_pbrt_mesh (TriangleMesh::ConstPtr mesh, std::string const& filename); 23 | 24 | MVE_GEOM_NAMESPACE_END 25 | MVE_NAMESPACE_END 26 | 27 | #endif /* MVE_PBRTFILE_HEADER */ 28 | -------------------------------------------------------------------------------- /libs/mve/mesh_io_smf.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, Simon Fuhrmann 3 | * TU Darmstadt - Graphics, Capture and Massively Parallel Computing 4 | * All rights reserved. 5 | * 6 | * This software may be modified and distributed under the terms 7 | * of the BSD 3-Clause license. See the LICENSE.txt file for details. 8 | */ 9 | 10 | #ifndef MVE_MESH_IO_SMF_HEADER 11 | #define MVE_MESH_IO_SMF_HEADER 12 | 13 | #include 14 | 15 | #include "mve/mesh.h" 16 | #include "mve/defines.h" 17 | 18 | MVE_NAMESPACE_BEGIN 19 | MVE_GEOM_NAMESPACE_BEGIN 20 | 21 | /** 22 | * Loads a triangle mesh from a SMF file format. 23 | */ 24 | TriangleMesh::Ptr 25 | load_smf_mesh (std::string const& filename); 26 | 27 | /** 28 | * Saves a triangle mesh to a file in SMF file format. 29 | */ 30 | void 31 | save_smf_mesh (mve::TriangleMesh::ConstPtr mesh, std::string const& filename); 32 | 33 | MVE_GEOM_NAMESPACE_END 34 | MVE_NAMESPACE_END 35 | 36 | #endif /* MVE_MESH_IO_SMF_HEADER */ 37 | -------------------------------------------------------------------------------- /libs/mve/mesh_tools.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, Simon Fuhrmann 3 | * TU Darmstadt - Graphics, Capture and Massively Parallel Computing 4 | * All rights reserved. 5 | * 6 | * This software may be modified and distributed under the terms 7 | * of the BSD 3-Clause license. See the LICENSE.txt file for details. 8 | */ 9 | 10 | #ifndef MVE_MESH_TOOLS_HEADER 11 | #define MVE_MESH_TOOLS_HEADER 12 | 13 | #include "math/vector.h" 14 | #include "math/matrix.h" 15 | #include "mve/defines.h" 16 | #include "mve/mesh.h" 17 | 18 | MVE_NAMESPACE_BEGIN 19 | MVE_GEOM_NAMESPACE_BEGIN 20 | 21 | /** 22 | * Transforms the vertices and normals of the mesh using the 23 | * specified rotation matrix. Transformation is IN-PLACE. 24 | */ 25 | void 26 | mesh_transform (TriangleMesh::Ptr mesh, math::Matrix3f const& rot); 27 | 28 | /** 29 | * Transforms the vertices of the mesh using the specified transformation 30 | * matrix and rotates the normals of the mesh using the roation matrix 31 | * of the transformation. Transformation is IN-PLACE. 32 | */ 33 | void 34 | mesh_transform (TriangleMesh::Ptr mesh, math::Matrix4f const& trans); 35 | 36 | /** 37 | * Merges the first given mesh with the second one, modifying the second one. 38 | * All vertex and face attributes are copied, faces itself are copied and 39 | * indices are offsetted accordingly. Note that this method will FAIL 40 | * if, for example, one mesh with a certain property is merged with a mesh 41 | * without that property (e.g. vertex color). 42 | */ 43 | void 44 | mesh_merge (TriangleMesh::ConstPtr mesh1, TriangleMesh::Ptr mesh2); 45 | 46 | /** 47 | * Discards isolated components with a vertex count below a threshold. 48 | * Passing 0 does nothing. Passing 1 or 2 deletes isolated vertices. 49 | * Passing 3 deletes isolated faces, and so on. 50 | */ 51 | void 52 | mesh_components (TriangleMesh::Ptr mesh, std::size_t vertex_threshold); 53 | 54 | /** 55 | * Scales the mesh such that it fits into a cube with length 1 56 | * and centers the mesh in the coordinate origin. 57 | */ 58 | void 59 | mesh_scale_and_center (TriangleMesh::Ptr mesh, 60 | bool scale = true, bool center = true); 61 | 62 | /** 63 | * Inverts the orientation of all faces in the mesh. 64 | */ 65 | void 66 | mesh_invert_faces (TriangleMesh::Ptr mesh); 67 | 68 | /** 69 | * Calculates the mesh axis-aligned bounding box (AABB). 70 | * This is done by iterating over all vertices. 71 | */ 72 | void 73 | mesh_find_aabb (TriangleMesh::ConstPtr mesh, 74 | math::Vec3f& aabb_min, math::Vec3f& aabb_max); 75 | 76 | /** 77 | * Cleans unreferenced vertices from the mesh. 78 | * Returns the number of deleted vertices. 79 | */ 80 | std::size_t 81 | mesh_delete_unreferenced (TriangleMesh::Ptr mesh); 82 | 83 | MVE_GEOM_NAMESPACE_END 84 | MVE_NAMESPACE_END 85 | 86 | #endif /* MVE_MESH_TOOLS_HEADER */ 87 | -------------------------------------------------------------------------------- /libs/ogl/Makefile: -------------------------------------------------------------------------------- 1 | MVE_ROOT = ../.. 2 | TARGET := libmve_ogl.a 3 | include ${MVE_ROOT}/Makefile.inc 4 | 5 | # Position independent code (-fPIC) is required for the UMVE plugin system. 6 | CXXFLAGS += -fPIC -I${MVE_ROOT}/libs 7 | 8 | SOURCES := $(wildcard [^_]*.cc) 9 | ${TARGET}: ${SOURCES:.cc=.o} 10 | $(AR) rcs $@ $^ 11 | 12 | clean: 13 | ${RM} ${TARGET} *.o Makefile.dep 14 | 15 | .PHONY: clean 16 | -------------------------------------------------------------------------------- /libs/ogl/camera_2d.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, Simon Fuhrmann 3 | * TU Darmstadt - Graphics, Capture and Massively Parallel Computing 4 | * All rights reserved. 5 | * 6 | * This software may be modified and distributed under the terms 7 | * of the BSD 3-Clause license. See the LICENSE.txt file for details. 8 | */ 9 | 10 | #include 11 | 12 | #include "math/matrix_tools.h" 13 | #include "ogl/opengl.h" 14 | #include "ogl/camera_2d.h" 15 | 16 | OGL_NAMESPACE_BEGIN 17 | 18 | Cam2D::Cam2D(void) 19 | { 20 | this->radius = 1.0f; 21 | this->center = math::Vec3f(0.0f); 22 | this->mousePos = math::Vec2f(0.0f); 23 | this->tocam = math::Vec3f(0.0f, 0.0f, 1.0f); 24 | this->upvec = math::Vec3f(0.0f, 1.0f, 0.0f); 25 | } 26 | 27 | void 28 | Cam2D::consume_event(const MouseEvent &event) 29 | { 30 | if (event.type == MOUSE_EVENT_PRESS) 31 | { 32 | if (event.button == MOUSE_BUTTON_LEFT) 33 | { 34 | this->mousePos[0] = event.x; 35 | this->mousePos[1] = event.y; 36 | } 37 | } 38 | else if (event.type == MOUSE_EVENT_MOVE) 39 | { 40 | // Center is translated by the position difference (in pixel) 41 | // TODO Make this Viewport dependent? 42 | // Conflict between projective/orthographic assumptions 43 | if (event.button_mask & MOUSE_BUTTON_LEFT) 44 | { 45 | this->center[0] += (this->mousePos[0] - event.x); 46 | this->center[1] += (this->mousePos[1] - event.y); 47 | this->mousePos[0] = event.x; 48 | this->mousePos[1] = event.y; 49 | } 50 | } 51 | else if (event.type == MOUSE_EVENT_WHEEL_UP) 52 | { 53 | this->radius += this->radius / 10.0f; 54 | this->radius = std::min(40.0f, this->radius); 55 | } 56 | else if (event.type == MOUSE_EVENT_WHEEL_DOWN) 57 | { 58 | this->radius -= this->radius / 10.0f; 59 | this->radius = std::max(0.01f, this->radius); 60 | } 61 | 62 | } 63 | 64 | void 65 | Cam2D::consume_event(KeyboardEvent const& /*event*/) 66 | { 67 | } 68 | 69 | math::Vec3f Cam2D::get_campos() 70 | { 71 | return this->center + this->tocam * this->radius; 72 | } 73 | 74 | math::Vec3f Cam2D::get_viewdir() 75 | { 76 | return -this->tocam; 77 | } 78 | 79 | math::Vec3f Cam2D::get_upvec() 80 | { 81 | return this->upvec; 82 | } 83 | 84 | void Cam2D::set_camera (Camera *camera) 85 | { 86 | this->cam = camera; 87 | } 88 | 89 | OGL_NAMESPACE_END 90 | -------------------------------------------------------------------------------- /libs/ogl/camera_2d.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, Simon Fuhrmann 3 | * TU Darmstadt - Graphics, Capture and Massively Parallel Computing 4 | * All rights reserved. 5 | * 6 | * This software may be modified and distributed under the terms 7 | * of the BSD 3-Clause license. See the LICENSE.txt file for details. 8 | */ 9 | 10 | #ifndef OPENGL_CAMERA_2D_HEADER 11 | #define OPENGL_CAMERA_2D_HEADER 12 | 13 | #include "math/vector.h" 14 | #include "ogl/defines.h" 15 | #include "ogl/events.h" 16 | #include "ogl/camera.h" 17 | 18 | OGL_NAMESPACE_BEGIN 19 | 20 | class Cam2D 21 | { 22 | public: 23 | Cam2D(void); 24 | 25 | void set_camera (Camera* camera); 26 | void consume_event (MouseEvent const& event); 27 | void consume_event(KeyboardEvent const& event); 28 | math::Vec3f get_campos(void); 29 | math::Vec3f get_viewdir(void); 30 | math::Vec3f get_upvec(void); 31 | 32 | private: 33 | /* Camera information. */ 34 | Camera* cam; 35 | 36 | float radius; 37 | math::Vec3f center; 38 | math::Vec2f mousePos; 39 | math::Vec3f tocam; 40 | math::Vec3f upvec; 41 | }; 42 | 43 | OGL_NAMESPACE_END 44 | 45 | #endif /* OPENGL_CAMERA_2D_HEADER */ 46 | -------------------------------------------------------------------------------- /libs/ogl/camera_trackball.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, Simon Fuhrmann 3 | * TU Darmstadt - Graphics, Capture and Massively Parallel Computing 4 | * All rights reserved. 5 | * 6 | * This software may be modified and distributed under the terms 7 | * of the BSD 3-Clause license. See the LICENSE.txt file for details. 8 | */ 9 | 10 | #ifndef OGL_CAM_TRACKBALL_HEADER 11 | #define OGL_CAM_TRACKBALL_HEADER 12 | 13 | #include "math/vector.h" 14 | #include "ogl/defines.h" 15 | #include "ogl/events.h" 16 | #include "ogl/camera.h" 17 | 18 | OGL_NAMESPACE_BEGIN 19 | 20 | /** 21 | * A trackball camera control that consumes mouse events 22 | * and delivers viewing parameters for the camera. 23 | */ 24 | class CamTrackball 25 | { 26 | public: 27 | CamTrackball (void); 28 | 29 | void set_camera (Camera* camera); 30 | bool consume_event (MouseEvent const& event); 31 | bool consume_event (KeyboardEvent const& event); 32 | 33 | void set_camera_params (math::Vec3f const& center, 34 | math::Vec3f const& lookat, math::Vec3f const& upvec); 35 | 36 | math::Vec3f get_campos (void) const; 37 | math::Vec3f get_viewdir (void) const; 38 | math::Vec3f const& get_upvec (void) const; 39 | 40 | private: 41 | math::Vec3f get_center (int x, int y); 42 | void handle_tb_rotation (int x, int y); 43 | math::Vec3f get_ball_normal (int x, int y); 44 | 45 | private: 46 | /* Camera information. */ 47 | Camera* cam; 48 | 49 | /* Current trackball configuration. */ 50 | float tb_radius; 51 | math::Vec3f tb_center; 52 | math::Vec3f tb_tocam; 53 | math::Vec3f tb_upvec; 54 | 55 | /* Variables to calculate rotation and zoom. */ 56 | int rot_mouse_x; 57 | int rot_mouse_y; 58 | math::Vec3f rot_tb_tocam; 59 | math::Vec3f rot_tb_upvec; 60 | 61 | float zoom_tb_radius; 62 | int zoom_mouse_y; 63 | }; 64 | 65 | /* ---------------------------------------------------------------- */ 66 | 67 | inline void 68 | CamTrackball::set_camera (Camera* camera) 69 | { 70 | this->cam = camera; 71 | } 72 | 73 | inline math::Vec3f 74 | CamTrackball::get_campos (void) const 75 | { 76 | return this->tb_center + this->tb_tocam * this->tb_radius; 77 | } 78 | 79 | inline math::Vec3f 80 | CamTrackball::get_viewdir (void) const 81 | { 82 | return -this->tb_tocam; 83 | } 84 | 85 | inline math::Vec3f const& 86 | CamTrackball::get_upvec (void) const 87 | { 88 | return this->tb_upvec; 89 | } 90 | 91 | OGL_NAMESPACE_END 92 | 93 | #endif /* OGL_CAM_TRACKBALL_HEADER */ 94 | -------------------------------------------------------------------------------- /libs/ogl/check_gl_error.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, Simon Fuhrmann 3 | * TU Darmstadt - Graphics, Capture and Massively Parallel Computing 4 | * All rights reserved. 5 | * 6 | * This software may be modified and distributed under the terms 7 | * of the BSD 3-Clause license. See the LICENSE.txt file for details. 8 | */ 9 | 10 | #ifndef OGL_CHECK_GL_ERROR_HEADER 11 | #define OGL_CHECK_GL_ERROR_HEADER 12 | 13 | #include 14 | 15 | #include "ogl/defines.h" 16 | #include "ogl/opengl.h" 17 | #include "util/string_utils.h" 18 | 19 | OGL_NAMESPACE_BEGIN 20 | 21 | inline void 22 | check_gl_error() 23 | { 24 | GLenum err = glGetError(); 25 | if (err != GL_NO_ERROR) 26 | throw std::runtime_error("GL error: " + util::string::get(err)); 27 | } 28 | 29 | OGL_NAMESPACE_END 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /libs/ogl/defines.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, Simon Fuhrmann 3 | * TU Darmstadt - Graphics, Capture and Massively Parallel Computing 4 | * All rights reserved. 5 | * 6 | * This software may be modified and distributed under the terms 7 | * of the BSD 3-Clause license. See the LICENSE.txt file for details. 8 | */ 9 | 10 | #ifndef OGL_DEFINES_HEADER 11 | #define OGL_DEFINES_HEADER 12 | 13 | #define OGL_NAMESPACE_BEGIN namespace ogl { 14 | #define OGL_NAMESPACE_END } 15 | 16 | /** Wrappers and helpers for the OpenGL graphics API. */ 17 | OGL_NAMESPACE_BEGIN OGL_NAMESPACE_END 18 | 19 | #endif /* OGL_DEFINES_HEADER */ 20 | -------------------------------------------------------------------------------- /libs/ogl/events.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, Simon Fuhrmann 3 | * TU Darmstadt - Graphics, Capture and Massively Parallel Computing 4 | * All rights reserved. 5 | * 6 | * This software may be modified and distributed under the terms 7 | * of the BSD 3-Clause license. See the LICENSE.txt file for details. 8 | */ 9 | 10 | #include 11 | 12 | #include "ogl/defines.h" 13 | #include "ogl/events.h" 14 | 15 | OGL_NAMESPACE_BEGIN 16 | 17 | void 18 | event_debug_print (ogl::MouseEvent const& event) 19 | { 20 | std::cout << "Mouse event "; 21 | switch (event.type) 22 | { 23 | case ogl::MOUSE_EVENT_MOVE: std::cout << "MOVE"; break; 24 | case ogl::MOUSE_EVENT_PRESS: std::cout << "PRESS"; break; 25 | case ogl::MOUSE_EVENT_RELEASE: std::cout << "RELEASE"; break; 26 | case ogl::MOUSE_EVENT_WHEEL_UP: std::cout << "WHEELUP"; break; 27 | case ogl::MOUSE_EVENT_WHEEL_DOWN: std::cout << "WHEELDOWN"; break; 28 | default: std::cout << "UNKNOWN"; break; 29 | } 30 | 31 | std::cout << ", button "; 32 | switch (event.button) 33 | { 34 | case ogl::MOUSE_BUTTON_NONE: std::cout << "NONE"; break; 35 | case ogl::MOUSE_BUTTON_LEFT: std::cout << "LEFT"; break; 36 | case ogl::MOUSE_BUTTON_RIGHT: std::cout << "RIGHT"; break; 37 | case ogl::MOUSE_BUTTON_MIDDLE: std::cout << "MIDDLE"; break; 38 | case ogl::MOUSE_BUTTON_X1: std::cout << "X1BUT"; break; 39 | case ogl::MOUSE_BUTTON_X2: std::cout << "X2BUT"; break; 40 | default:std::cout << "UNKNOWN"; 41 | } 42 | 43 | std::cout << " at (" << event.x << "," << event.y << ")" << std::endl; 44 | } 45 | 46 | /* ---------------------------------------------------------------- */ 47 | 48 | void 49 | event_debug_print (ogl::KeyboardEvent const& event) 50 | { 51 | std::cout << "Keyboard event "; 52 | switch (event.type) 53 | { 54 | case ogl::KEYBOARD_EVENT_PRESS: std::cout << "PRESS"; break; 55 | case ogl::KEYBOARD_EVENT_RELEASE: std::cout << "RELEASE"; break; 56 | default: std::cout << "UNKNOWN"; break; 57 | } 58 | 59 | std::cout << ", keycode " << event.keycode << std::endl; 60 | } 61 | 62 | OGL_NAMESPACE_END 63 | -------------------------------------------------------------------------------- /libs/ogl/events.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, Simon Fuhrmann 3 | * TU Darmstadt - Graphics, Capture and Massively Parallel Computing 4 | * All rights reserved. 5 | * 6 | * This software may be modified and distributed under the terms 7 | * of the BSD 3-Clause license. See the LICENSE.txt file for details. 8 | */ 9 | 10 | #ifndef OGL_EVENTS_HEADER 11 | #define OGL_EVENTS_HEADER 12 | 13 | #include "ogl/defines.h" 14 | 15 | OGL_NAMESPACE_BEGIN 16 | 17 | /** Mouse event types. */ 18 | enum MouseEventType 19 | { 20 | MOUSE_EVENT_PRESS, 21 | MOUSE_EVENT_RELEASE, 22 | MOUSE_EVENT_MOVE, 23 | MOUSE_EVENT_WHEEL_UP, 24 | MOUSE_EVENT_WHEEL_DOWN 25 | }; 26 | 27 | /** Mouse button types. */ 28 | enum MouseButton 29 | { 30 | MOUSE_BUTTON_NONE = 0, 31 | MOUSE_BUTTON_LEFT = 1 << 0, 32 | MOUSE_BUTTON_RIGHT = 1 << 1, 33 | MOUSE_BUTTON_MIDDLE = 1 << 2, 34 | MOUSE_BUTTON_X1 = 1 << 3, 35 | MOUSE_BUTTON_X2 = 1 << 4 36 | }; 37 | 38 | /** Mouse event. */ 39 | struct MouseEvent 40 | { 41 | MouseEventType type; ///< Type of event 42 | MouseButton button; ///< Button that caused the event 43 | int button_mask; ///< Button state when event was generated 44 | int x; ///< Mouse X-position 45 | int y; ///< Mouse Y-position 46 | }; 47 | 48 | /** Keyboard event type. */ 49 | enum KeyboardEventType 50 | { 51 | KEYBOARD_EVENT_PRESS, 52 | KEYBOARD_EVENT_RELEASE 53 | }; 54 | 55 | /** Keyboard event. */ 56 | struct KeyboardEvent 57 | { 58 | KeyboardEventType type; ///< Type of event 59 | int keycode; ///< Key that caused the event (depends on generating system) 60 | }; 61 | 62 | /* ---------------------------------------------------------------- */ 63 | 64 | /** Prints debug information for mouse event 'e' to STDOUT. */ 65 | void 66 | event_debug_print (MouseEvent const& e); 67 | 68 | /** Prints debug information for keyboard event 'e' to STDOUT. */ 69 | void 70 | event_debug_print (KeyboardEvent const& e); 71 | 72 | OGL_NAMESPACE_END 73 | 74 | #endif /* OGL_EVENTS_HEADER */ 75 | -------------------------------------------------------------------------------- /libs/ogl/mesh_renderer.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, Simon Fuhrmann 3 | * TU Darmstadt - Graphics, Capture and Massively Parallel Computing 4 | * All rights reserved. 5 | * 6 | * This software may be modified and distributed under the terms 7 | * of the BSD 3-Clause license. See the LICENSE.txt file for details. 8 | */ 9 | 10 | #include "ogl/opengl.h" 11 | #include "ogl/mesh_renderer.h" 12 | 13 | OGL_NAMESPACE_BEGIN 14 | 15 | void 16 | MeshRenderer::set_mesh (mve::TriangleMesh::ConstPtr mesh) 17 | { 18 | if (mesh == nullptr) 19 | throw std::invalid_argument("Got null mesh"); 20 | 21 | /* Clean previous content. */ 22 | this->reset_vertex_array(); 23 | 24 | mve::TriangleMesh::VertexList const& verts(mesh->get_vertices()); 25 | mve::TriangleMesh::FaceList const& faces(mesh->get_faces()); 26 | mve::TriangleMesh::NormalList const& vnormals(mesh->get_vertex_normals()); 27 | mve::TriangleMesh::ColorList const& vcolors(mesh->get_vertex_colors()); 28 | mve::TriangleMesh::TexCoordList const& vtexuv(mesh->get_vertex_texcoords()); 29 | 30 | /* Init vertex VBO. */ 31 | { 32 | VertexBuffer::Ptr vbo = VertexBuffer::create(); 33 | vbo->set_data(&verts[0][0], (GLsizei)verts.size(), 3); 34 | this->set_vertex_vbo(vbo); 35 | } 36 | 37 | /* Init index VBO if faces are given. */ 38 | if (!faces.empty()) 39 | { 40 | VertexBuffer::Ptr vbo = ogl::VertexBuffer::create(); 41 | vbo->set_indices(&faces[0], (GLsizei)faces.size()); 42 | this->set_index_vbo(vbo); 43 | } 44 | 45 | /* Init normal VBO if normals are given. */ 46 | if (!vnormals.empty()) 47 | { 48 | VertexBuffer::Ptr vbo = ogl::VertexBuffer::create(); 49 | vbo->set_data(&vnormals[0][0], (GLsizei)vnormals.size(), 3); 50 | this->add_vbo(vbo, OGL_ATTRIB_NORMAL); 51 | } 52 | 53 | /* Init color VBO if colors are given. */ 54 | if (!vcolors.empty()) 55 | { 56 | VertexBuffer::Ptr vbo = ogl::VertexBuffer::create(); 57 | vbo->set_data(&vcolors[0][0], (GLsizei)vcolors.size(), 4); 58 | this->add_vbo(vbo, OGL_ATTRIB_COLOR); 59 | } 60 | 61 | /* Init UV VBO if texture coordinates are given. */ 62 | if (!vtexuv.empty()) 63 | { 64 | VertexBuffer::Ptr vbo = ogl::VertexBuffer::create(); 65 | vbo->set_data(&vtexuv[0][0], (GLsizei)vtexuv.size(), 2); 66 | this->add_vbo(vbo, OGL_ATTRIB_TEXCOORD); 67 | } 68 | } 69 | 70 | OGL_NAMESPACE_END 71 | -------------------------------------------------------------------------------- /libs/ogl/mesh_renderer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, Simon Fuhrmann 3 | * TU Darmstadt - Graphics, Capture and Massively Parallel Computing 4 | * All rights reserved. 5 | * 6 | * This software may be modified and distributed under the terms 7 | * of the BSD 3-Clause license. See the LICENSE.txt file for details. 8 | */ 9 | 10 | #ifndef OGL_MESH_RENDERER_HEADER 11 | #define OGL_MESH_RENDERER_HEADER 12 | 13 | #include 14 | 15 | #include "mve/mesh.h" 16 | #include "ogl/defines.h" 17 | #include "ogl/opengl.h" 18 | #include "ogl/shader_program.h" 19 | #include "ogl/vertex_array.h" 20 | #include "ogl/vertex_buffer.h" 21 | 22 | OGL_NAMESPACE_BEGIN 23 | 24 | /** 25 | * OpenGL renderer that takes a mesh and automatically creates 26 | * the appropriate VBOs and a vertex array object. 27 | */ 28 | class MeshRenderer : public VertexArray 29 | { 30 | public: 31 | typedef std::shared_ptr Ptr; 32 | typedef std::shared_ptr ConstPtr; 33 | 34 | public: 35 | static Ptr create (void); 36 | static Ptr create (mve::TriangleMesh::ConstPtr mesh); 37 | void set_mesh (mve::TriangleMesh::ConstPtr mesh); 38 | 39 | private: 40 | MeshRenderer (void); 41 | MeshRenderer (mve::TriangleMesh::ConstPtr mesh); 42 | }; 43 | 44 | /* ---------------------------------------------------------------- */ 45 | 46 | inline MeshRenderer::Ptr 47 | MeshRenderer::create (void) 48 | { 49 | return Ptr(new MeshRenderer()); 50 | } 51 | 52 | inline MeshRenderer::Ptr 53 | MeshRenderer::create (mve::TriangleMesh::ConstPtr mesh) 54 | { 55 | return Ptr(new MeshRenderer(mesh)); 56 | } 57 | 58 | inline 59 | MeshRenderer::MeshRenderer (void) 60 | { 61 | } 62 | 63 | inline 64 | MeshRenderer::MeshRenderer (mve::TriangleMesh::ConstPtr mesh) 65 | { 66 | this->set_mesh(mesh); 67 | } 68 | 69 | OGL_NAMESPACE_END 70 | 71 | #endif /* OGL_MESH_RENDERER_HEADER */ 72 | -------------------------------------------------------------------------------- /libs/ogl/opengl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, Simon Fuhrmann 3 | * TU Darmstadt - Graphics, Capture and Massively Parallel Computing 4 | * All rights reserved. 5 | * 6 | * This software may be modified and distributed under the terms 7 | * of the BSD 3-Clause license. See the LICENSE.txt file for details. 8 | * 9 | * This file solely exists to include the OpenGL API header file(s). 10 | * 11 | * Since this may vary depending on the specific application, this 12 | * file may be modified according to user demands. The default 13 | * implementation expects that GLEW is installed system-wide and 14 | * is initialized before any OpenGL API function is called. 15 | */ 16 | 17 | #ifndef OGL_OPEN_GL_HEADER 18 | #define OGL_OPEN_GL_HEADER 19 | 20 | #if defined(OGL_USE_OSMESA) 21 | # define GL_GLEXT_PROTOTYPES 22 | # include 23 | #elif defined(__APPLE__) 24 | # include 25 | #elif defined(_WIN32) 26 | # include 27 | #else 28 | # define GL_GLEXT_PROTOTYPES 29 | # include 30 | # include 31 | #endif 32 | 33 | #endif /* OGL_OPEN_GL_HEADER */ 34 | -------------------------------------------------------------------------------- /libs/ogl/render_tools.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, Simon Fuhrmann 3 | * TU Darmstadt - Graphics, Capture and Massively Parallel Computing 4 | * All rights reserved. 5 | * 6 | * This software may be modified and distributed under the terms 7 | * of the BSD 3-Clause license. See the LICENSE.txt file for details. 8 | */ 9 | 10 | #ifndef OGL_RENDERTOOLS_HEADER 11 | #define OGL_RENDERTOOLS_HEADER 12 | 13 | #include "ogl/defines.h" 14 | #include "ogl/vertex_array.h" 15 | #include "ogl/shader_program.h" 16 | 17 | OGL_NAMESPACE_BEGIN 18 | 19 | /** 20 | * Generates a vertex array for visualizing the three world coordinate axis. 21 | * You need to specify your own shader, where you can also apply additional 22 | * transformations, for example to visualize local coordinate system. 23 | */ 24 | VertexArray::Ptr 25 | create_axis_renderer (ShaderProgram::Ptr shader); 26 | 27 | /** 28 | * Generates a full screen quad renderer in OpenGL unit coordinates. 29 | * The quad vertices have coordiantes (+-1, +-1, 0) with 30 | * normals (0, 0, 1) and texture coordiantes (0/1, 0/1). 31 | */ 32 | VertexArray::Ptr 33 | create_fullscreen_quad (ShaderProgram::Ptr shader); 34 | 35 | OGL_NAMESPACE_END 36 | 37 | #endif /* OGL_RENDERTOOLS_HEADER */ 38 | -------------------------------------------------------------------------------- /libs/ogl/texture.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, Simon Fuhrmann 3 | * TU Darmstadt - Graphics, Capture and Massively Parallel Computing 4 | * All rights reserved. 5 | * 6 | * This software may be modified and distributed under the terms 7 | * of the BSD 3-Clause license. See the LICENSE.txt file for details. 8 | */ 9 | 10 | #include "ogl/texture.h" 11 | 12 | OGL_NAMESPACE_BEGIN 13 | 14 | void 15 | Texture::upload (mve::ByteImage::ConstPtr image) 16 | { 17 | 18 | GLint level = 0; 19 | GLint int_format = GL_RGBA; 20 | GLsizei w(image->width()), h(image->height()), c(image->channels()); 21 | GLint border = 0; 22 | 23 | /* Set image properties. */ 24 | void* data = (void*)const_cast(image->get_data_pointer()); 25 | GLint type = GL_UNSIGNED_BYTE; 26 | GLint format = GL_RGBA; 27 | switch (c) 28 | { 29 | case 1: format = GL_RED; break; 30 | case 2: format = GL_RG; break; 31 | case 3: format = GL_RGB; break; 32 | case 4: format = GL_RGBA; break; 33 | default: 34 | throw std::invalid_argument("Invalid amount of image channels"); 35 | } 36 | 37 | #if 0 38 | std::cout << "Level: " << level << ", internal format: " << int_format 39 | << ", size: " << w << "x" << h << ", format: " << format 40 | << std::endl; 41 | #endif 42 | 43 | this->bind(); 44 | glTexImage2D(GL_TEXTURE_2D, level, int_format, w, h, 45 | border, format, type, data); 46 | glGenerateMipmap(GL_TEXTURE_2D); 47 | } 48 | 49 | OGL_NAMESPACE_END 50 | -------------------------------------------------------------------------------- /libs/ogl/texture.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, Simon Fuhrmann 3 | * TU Darmstadt - Graphics, Capture and Massively Parallel Computing 4 | * All rights reserved. 5 | * 6 | * This software may be modified and distributed under the terms 7 | * of the BSD 3-Clause license. See the LICENSE.txt file for details. 8 | */ 9 | 10 | #ifndef OGL_TEXTURE_HEADER 11 | #define OGL_TEXTURE_HEADER 12 | 13 | #include 14 | 15 | #include "mve/image.h" 16 | #include "ogl/defines.h" 17 | #include "ogl/opengl.h" 18 | 19 | OGL_NAMESPACE_BEGIN 20 | 21 | /** 22 | * OpenGL texture abstraction. 2D textures are supported only. 23 | */ 24 | class Texture 25 | { 26 | public: 27 | typedef std::shared_ptr Ptr; 28 | typedef std::shared_ptr ConstPtr; 29 | 30 | public: 31 | /** Creates a new texture object without image data. */ 32 | Texture (void); 33 | /** Creates a new texture object from an MVE image. */ 34 | Texture (mve::ByteImage::ConstPtr image); 35 | 36 | /** Creates a smart pointered texture object. */ 37 | static Ptr create (void); 38 | 39 | /** Destroys the texture object, releasing OpenGL resources. */ 40 | ~Texture (void); 41 | 42 | /** Makes this texture the active texture. */ 43 | void bind (void); 44 | 45 | /** Uploads the given image to OpenGL. */ 46 | void upload (mve::ByteImage::ConstPtr image); 47 | 48 | private: 49 | GLuint tex_id; 50 | }; 51 | 52 | /* ---------------------------------------------------------------- */ 53 | 54 | inline 55 | Texture::Texture (void) 56 | { 57 | glGenTextures(1, &this->tex_id); 58 | } 59 | 60 | inline 61 | Texture::Texture (mve::ByteImage::ConstPtr image) 62 | { 63 | glGenTextures(1, &this->tex_id); 64 | this->upload(image); 65 | } 66 | 67 | inline Texture::Ptr 68 | Texture::create (void) 69 | { 70 | return Ptr(new Texture); 71 | } 72 | 73 | inline 74 | Texture::~Texture (void) 75 | { 76 | glDeleteTextures(1, &this->tex_id); 77 | } 78 | 79 | inline void 80 | Texture::bind (void) 81 | { 82 | glBindTexture(GL_TEXTURE_2D, this->tex_id); 83 | } 84 | 85 | OGL_NAMESPACE_END 86 | 87 | #endif /* OGL_TEXTURE_HEADER */ 88 | -------------------------------------------------------------------------------- /libs/ogl/vertex_buffer.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, Simon Fuhrmann 3 | * TU Darmstadt - Graphics, Capture and Massively Parallel Computing 4 | * All rights reserved. 5 | * 6 | * This software may be modified and distributed under the terms 7 | * of the BSD 3-Clause license. See the LICENSE.txt file for details. 8 | */ 9 | 10 | #include "ogl/vertex_buffer.h" 11 | 12 | OGL_NAMESPACE_BEGIN 13 | 14 | VertexBuffer::VertexBuffer (void) 15 | { 16 | glGenBuffers(1, &this->vbo_id); 17 | check_gl_error(); 18 | this->vbo_target = GL_ARRAY_BUFFER; 19 | this->datatype = GL_FLOAT; 20 | this->usage = GL_STATIC_DRAW; 21 | this->bytes = 0; 22 | this->vpv = 0; 23 | this->elems = 0; 24 | this->stride = 0; 25 | } 26 | 27 | /* ---------------------------------------------------------------- */ 28 | 29 | void 30 | VertexBuffer::set_data (GLfloat const* data, GLsizei elems, GLint vpv) 31 | { 32 | this->vbo_target = GL_ARRAY_BUFFER; 33 | this->datatype = GL_FLOAT; 34 | this->bytes = elems * vpv * sizeof(GLfloat); 35 | this->vpv = vpv; 36 | this->elems = elems; 37 | 38 | this->bind(); 39 | glBufferData(this->vbo_target, this->bytes, data, this->usage); 40 | check_gl_error(); 41 | } 42 | 43 | /* ---------------------------------------------------------------- */ 44 | 45 | void 46 | VertexBuffer::set_data (GLubyte const* data, GLsizei elems, GLint vpv) 47 | { 48 | this->vbo_target = GL_ARRAY_BUFFER; 49 | this->datatype = GL_UNSIGNED_BYTE; 50 | this->bytes = elems * vpv * sizeof(GLubyte); 51 | this->vpv = vpv; 52 | this->elems = elems; 53 | 54 | this->bind(); 55 | glBufferData(this->vbo_target, this->bytes, data, this->usage); 56 | check_gl_error(); 57 | } 58 | 59 | /* ---------------------------------------------------------------- */ 60 | 61 | void 62 | VertexBuffer::set_indices (GLuint const* data, GLsizei num_indices) 63 | { 64 | this->vbo_target = GL_ELEMENT_ARRAY_BUFFER; 65 | this->datatype = GL_UNSIGNED_INT; 66 | this->bytes = num_indices * sizeof(unsigned int); 67 | this->vpv = 3; 68 | this->elems = num_indices; 69 | 70 | this->bind(); 71 | glBufferData(this->vbo_target, this->bytes, data, this->usage); 72 | check_gl_error(); 73 | } 74 | 75 | OGL_NAMESPACE_END 76 | -------------------------------------------------------------------------------- /libs/sfm/Makefile: -------------------------------------------------------------------------------- 1 | MVE_ROOT := ../.. 2 | TARGET := libmve_sfm.a 3 | include ${MVE_ROOT}/Makefile.inc 4 | 5 | CXXFLAGS += -I${MVE_ROOT}/libs ${OPENMP} 6 | LDLIBS += ${LIBJPEG_LDFLAGS} ${LIBPNG_LDFLAGS} ${LIBTIFF_LDFLAGS} 7 | 8 | SOURCES := $(wildcard [^_]*.cc) 9 | ${TARGET}: ${SOURCES:.cc=.o} 10 | $(AR) rcs $@ $^ 11 | 12 | _test%: _test%.o libmve_sfm.a libmve.a libmve_util.a 13 | ${LINK.cc} -o $@ $^ ${LDLIBS} 14 | 15 | clean: 16 | ${RM} ${TARGET} *.o Makefile.dep 17 | 18 | .PHONY: clean 19 | -------------------------------------------------------------------------------- /libs/sfm/_test_camera_db.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, Simon Fuhrmann 3 | * TU Darmstadt - Graphics, Capture and Massively Parallel Computing 4 | * All rights reserved. 5 | * 6 | * This software may be modified and distributed under the terms 7 | * of the BSD 3-Clause license. See the LICENSE.txt file for details. 8 | */ 9 | 10 | #include 11 | #include 12 | 13 | #include "mve/image.h" 14 | #include "mve/image_io.h" 15 | #include "mve/image_exif.h" 16 | #include "sfm/camera_database.h" 17 | #include "sfm/extract_focal_length.h" 18 | 19 | int main (void) 20 | { 21 | std::string filename = "/tmp/Nexus-4-camera-sample-2.jpg"; 22 | std::cout << filename << std::endl; 23 | std::string exif_str; 24 | mve::image::load_jpg_file(filename, &exif_str); 25 | mve::image::ExifInfo exif = mve::image::exif_extract(exif_str.c_str(), exif_str.size(), false); 26 | 27 | sfm::FocalLengthEstimate fl = sfm::extract_focal_length(exif); 28 | std::cout << fl.first << " " << fl.second << std::endl; 29 | 30 | return 1; 31 | } 32 | -------------------------------------------------------------------------------- /libs/sfm/ba_types.h: -------------------------------------------------------------------------------- 1 | #ifndef SFM_BA_TYPES_HEADER 2 | #define SFM_BA_TYPES_HEADER 3 | 4 | #include 5 | 6 | #include "sfm/defines.h" 7 | 8 | SFM_NAMESPACE_BEGIN 9 | SFM_BA_NAMESPACE_BEGIN 10 | 11 | /** Camera representation for bundle adjustment. */ 12 | struct Camera 13 | { 14 | Camera (void); 15 | 16 | double focal_length = 0.0; 17 | double distortion[2]; 18 | double translation[3]; 19 | double rotation[9]; 20 | bool is_constant = false; 21 | }; 22 | 23 | /** 3D point representation for bundle adjustment. */ 24 | struct Point3D 25 | { 26 | double pos[3]; 27 | bool is_constant = false; 28 | }; 29 | 30 | /** Observation of a 3D point for a camera. */ 31 | struct Observation 32 | { 33 | double pos[2]; 34 | int camera_id; 35 | int point_id; 36 | }; 37 | 38 | /* ------------------------ Implementation ------------------------ */ 39 | 40 | inline 41 | Camera::Camera (void) 42 | { 43 | std::fill(this->distortion, this->distortion + 2, 0.0); 44 | std::fill(this->translation, this->translation + 3, 0.0); 45 | std::fill(this->rotation, this->rotation + 9, 0.0); 46 | } 47 | 48 | SFM_BA_NAMESPACE_END 49 | SFM_NAMESPACE_END 50 | 51 | #endif /* SFM_BA_TYPES_HEADER */ 52 | 53 | -------------------------------------------------------------------------------- /libs/sfm/bundler_features.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, Simon Fuhrmann 3 | * TU Darmstadt - Graphics, Capture and Massively Parallel Computing 4 | * All rights reserved. 5 | * 6 | * This software may be modified and distributed under the terms 7 | * of the BSD 3-Clause license. See the LICENSE.txt file for details. 8 | */ 9 | 10 | #ifndef SFM_BUNDLER_FEATURES_HEADER 11 | #define SFM_BUNDLER_FEATURES_HEADER 12 | 13 | #include 14 | #include 15 | 16 | #include "mve/scene.h" 17 | #include "sfm/feature_set.h" 18 | #include "sfm/bundler_common.h" 19 | #include "sfm/defines.h" 20 | 21 | SFM_NAMESPACE_BEGIN 22 | SFM_BUNDLER_NAMESPACE_BEGIN 23 | 24 | /** 25 | * Bundler Component: Computes image features for every view in the scene 26 | * and stores the features in the viewports. 27 | */ 28 | class Features 29 | { 30 | public: 31 | struct Options 32 | { 33 | Options (void); 34 | 35 | /** The image for which features are to be computed. */ 36 | std::string image_embedding; 37 | /** The maximum image size given in number of pixels. */ 38 | int max_image_size; 39 | /** Feature set options. */ 40 | FeatureSet::Options feature_options; 41 | }; 42 | 43 | public: 44 | explicit Features (Options const& options); 45 | 46 | /** Computes features for all images in the scene. */ 47 | void compute (mve::Scene::Ptr scene, ViewportList* viewports); 48 | 49 | private: 50 | Options opts; 51 | }; 52 | 53 | /* ------------------------ Implementation ------------------------ */ 54 | 55 | inline 56 | Features::Options::Options (void) 57 | : image_embedding("original") 58 | , max_image_size(std::numeric_limits::max()) 59 | { 60 | } 61 | 62 | inline 63 | Features::Features (Options const& options) 64 | : opts(options) 65 | { 66 | } 67 | 68 | SFM_BUNDLER_NAMESPACE_END 69 | SFM_NAMESPACE_END 70 | 71 | #endif /* SFM_BUNDLER_FEATURES_HEADER */ 72 | -------------------------------------------------------------------------------- /libs/sfm/bundler_intrinsics.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, Simon Fuhrmann 3 | * TU Darmstadt - Graphics, Capture and Massively Parallel Computing 4 | * All rights reserved. 5 | * 6 | * This software may be modified and distributed under the terms 7 | * of the BSD 3-Clause license. See the LICENSE.txt file for details. 8 | */ 9 | 10 | #ifndef SFM_BUNDLER_INTRINSICS_HEADER 11 | #define SFM_BUNDLER_INTRINSICS_HEADER 12 | 13 | #include 14 | #include 15 | 16 | #include "mve/scene.h" 17 | #include "sfm/bundler_common.h" 18 | #include "sfm/defines.h" 19 | 20 | SFM_NAMESPACE_BEGIN 21 | SFM_BUNDLER_NAMESPACE_BEGIN 22 | 23 | /** 24 | * Bundler Component: Obtains initial intrinsic paramters for the viewports 25 | * from either the EXIF embeddings or from the MVE views. 26 | */ 27 | class Intrinsics 28 | { 29 | public: 30 | /** Data source for camera intrinsic estimates. */ 31 | enum Source 32 | { 33 | FROM_EXIF, 34 | FROM_VIEWS 35 | }; 36 | 37 | struct Options 38 | { 39 | Options (void); 40 | 41 | /** Data source for camera intrinsic estimates. */ 42 | Source intrinsics_source; 43 | 44 | /** The embedding name in which EXIF tags are stored. */ 45 | std::string exif_embedding; 46 | }; 47 | 48 | public: 49 | explicit Intrinsics (Options const& options); 50 | 51 | /** Obtains camera intrinsics for all viewports. */ 52 | void compute (mve::Scene::Ptr scene, ViewportList* viewports); 53 | 54 | private: 55 | void init_from_exif (mve::View::Ptr view, Viewport* viewport); 56 | void init_from_views (mve::View::Ptr view, Viewport* viewport); 57 | void fallback_focal_length (Viewport* viewport); 58 | 59 | private: 60 | Options opts; 61 | std::map unknown_cameras; 62 | }; 63 | 64 | /* ------------------------ Implementation ------------------------ */ 65 | 66 | inline 67 | Intrinsics::Options::Options (void) 68 | : intrinsics_source(FROM_EXIF) 69 | , exif_embedding("exif") 70 | { 71 | } 72 | 73 | inline 74 | Intrinsics::Intrinsics (Options const& options) 75 | : opts(options) 76 | { 77 | } 78 | 79 | SFM_BUNDLER_NAMESPACE_END 80 | SFM_NAMESPACE_END 81 | 82 | #endif /* SFM_BUNDLER_INTRINSICS_HEADER */ 83 | -------------------------------------------------------------------------------- /libs/sfm/bundler_tracks.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, Simon Fuhrmann 3 | * TU Darmstadt - Graphics, Capture and Massively Parallel Computing 4 | * All rights reserved. 5 | * 6 | * This software may be modified and distributed under the terms 7 | * of the BSD 3-Clause license. See the LICENSE.txt file for details. 8 | */ 9 | 10 | #ifndef SFM_BUNDLER_TRACKS_HEADER 11 | #define SFM_BUNDLER_TRACKS_HEADER 12 | 13 | #include "mve/scene.h" 14 | #include "sfm/bundler_matching.h" 15 | #include "sfm/defines.h" 16 | 17 | SFM_NAMESPACE_BEGIN 18 | SFM_BUNDLER_NAMESPACE_BEGIN 19 | 20 | /** 21 | * Bundler Component: Generation of tracks from pairwise matching result. 22 | * 23 | * As input this component requires all the pairwise matching results. 24 | * Additionally, to color the tracks, a color for each feature must be set. 25 | */ 26 | class Tracks 27 | { 28 | public: 29 | struct Options 30 | { 31 | Options (void); 32 | 33 | /** Produce status messages on the console. */ 34 | bool verbose_output; 35 | }; 36 | 37 | public: 38 | explicit Tracks (Options const& options); 39 | 40 | /** 41 | * Computes viewport connectivity information by propagating track IDs. 42 | * Computation requires feature positions and colors in the viewports. 43 | * A color for each track is computed as the average color from features. 44 | * Per-feature track IDs are added to the viewports. 45 | */ 46 | void compute (PairwiseMatching const& matching, 47 | ViewportList* viewports, TrackList* tracks); 48 | 49 | private: 50 | int remove_invalid_tracks (ViewportList* viewports, TrackList* tracks); 51 | 52 | private: 53 | Options opts; 54 | }; 55 | 56 | /* ------------------------ Implementation ------------------------ */ 57 | 58 | inline 59 | Tracks::Options::Options (void) 60 | : verbose_output(false) 61 | { 62 | } 63 | 64 | inline 65 | Tracks::Tracks (Options const& options) 66 | : opts(options) 67 | { 68 | } 69 | 70 | SFM_BUNDLER_NAMESPACE_END 71 | SFM_NAMESPACE_END 72 | 73 | #endif /* SFM_BUNDLER_TRACKS_HEADER */ 74 | -------------------------------------------------------------------------------- /libs/sfm/camera_database.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, Simon Fuhrmann 3 | * TU Darmstadt - Graphics, Capture and Massively Parallel Computing 4 | * All rights reserved. 5 | * 6 | * This software may be modified and distributed under the terms 7 | * of the BSD 3-Clause license. See the LICENSE.txt file for details. 8 | */ 9 | 10 | #ifndef SFM_CAMERA_DATABASE_HEADER 11 | #define SFM_CAMERA_DATABASE_HEADER 12 | 13 | #include 14 | #include 15 | 16 | #include "sfm/defines.h" 17 | 18 | SFM_NAMESPACE_BEGIN 19 | 20 | /** 21 | * Representation of a digital camera. 22 | */ 23 | struct CameraModel 24 | { 25 | /** The manufacturer for the camera. */ 26 | std::string maker; 27 | /** The model of the camera. */ 28 | std::string model; 29 | /** The width of the sensor in milli meters. */ 30 | float sensor_width_mm; 31 | /** The height of the sensor in milli meters. */ 32 | float sensor_height_mm; 33 | /** The width of the sensor in pixels. */ 34 | int sensor_width_px; 35 | /** The height of the sensor in pixels. */ 36 | int sensor_height_px; 37 | }; 38 | 39 | /* ---------------------------------------------------------------- */ 40 | 41 | /** 42 | * Camera database which, given a maker and model string, will look for 43 | * a camera model in the database and return the model on successful lookup. 44 | * If the lookup fails, a null pointer is returned. 45 | */ 46 | class CameraDatabase 47 | { 48 | public: 49 | /** Access to the singleton object. */ 50 | static CameraDatabase* get (void); 51 | 52 | /** Lookup of a camera model. Returns null on failure. */ 53 | CameraModel const* lookup (std::string const& maker, 54 | std::string const& model) const; 55 | 56 | private: 57 | CameraDatabase (void); 58 | void add (std::string const& maker, std::string const& model, 59 | float sensor_width_mm, float sensor_height_mm, 60 | int sensor_width_px, int sensor_height_px); 61 | 62 | private: 63 | static CameraDatabase* instance; 64 | std::vector data; 65 | }; 66 | 67 | /* ------------------------ Implementation ------------------------ */ 68 | 69 | inline CameraDatabase* 70 | CameraDatabase::get (void) 71 | { 72 | if (CameraDatabase::instance == nullptr) 73 | CameraDatabase::instance = new CameraDatabase(); 74 | return CameraDatabase::instance; 75 | } 76 | 77 | SFM_NAMESPACE_END 78 | 79 | #endif /* SFM_CAMERA_DATABASE_HEADER */ 80 | -------------------------------------------------------------------------------- /libs/sfm/correspondence.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, Simon Fuhrmann 3 | * TU Darmstadt - Graphics, Capture and Massively Parallel Computing 4 | * All rights reserved. 5 | * 6 | * This software may be modified and distributed under the terms 7 | * of the BSD 3-Clause license. See the LICENSE.txt file for details. 8 | */ 9 | 10 | #ifndef SFM_CORRESPONDENCE_HEADER 11 | #define SFM_CORRESPONDENCE_HEADER 12 | 13 | #include 14 | 15 | #include "math/matrix.h" 16 | #include "sfm/defines.h" 17 | 18 | SFM_NAMESPACE_BEGIN 19 | 20 | struct Correspondence2D2D; 21 | typedef std::vector Correspondences2D2D; 22 | 23 | struct Correspondence2D3D; 24 | typedef std::vector Correspondences2D3D; 25 | 26 | /** The IDs of a matching feature pair in two images. */ 27 | typedef std::pair CorrespondenceIndex; 28 | /** A list of all matching feature pairs in two images. */ 29 | typedef std::vector CorrespondenceIndices; 30 | 31 | /** 32 | * Two image coordinates which correspond to each other in terms of observing 33 | * the same point in the scene. 34 | * TODO: Rename this to Correspondence2D2D. 35 | */ 36 | struct Correspondence2D2D 37 | { 38 | double p1[2]; 39 | double p2[2]; 40 | }; 41 | 42 | /** 43 | * A 3D point and an image coordinate which correspond to each other in terms 44 | * of the image observing this 3D point in the scene. 45 | */ 46 | struct Correspondence2D3D 47 | { 48 | double p3d[3]; 49 | double p2d[2]; 50 | }; 51 | 52 | SFM_NAMESPACE_END 53 | 54 | #endif // SFM_CORRESPONDENCE_HEADER 55 | -------------------------------------------------------------------------------- /libs/sfm/defines.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, Simon Fuhrmann 3 | * TU Darmstadt - Graphics, Capture and Massively Parallel Computing 4 | * All rights reserved. 5 | * 6 | * This software may be modified and distributed under the terms 7 | * of the BSD 3-Clause license. See the LICENSE.txt file for details. 8 | */ 9 | 10 | #ifndef SFM_DEFINES_HEADER 11 | #define SFM_DEFINES_HEADER 12 | 13 | #define SFM_NAMESPACE_BEGIN namespace sfm { 14 | #define SFM_NAMESPACE_END } 15 | 16 | #define SFM_BUNDLER_NAMESPACE_BEGIN namespace bundler { 17 | #define SFM_BUNDLER_NAMESPACE_END } 18 | 19 | #define SFM_PBA_NAMESPACE_BEGIN namespace pba { 20 | #define SFM_PBA_NAMESPACE_END } 21 | 22 | #define SFM_BA_NAMESPACE_BEGIN namespace ba { 23 | #define SFM_BA_NAMESPACE_END } 24 | 25 | #ifndef STD_NAMESPACE_BEGIN 26 | # define STD_NAMESPACE_BEGIN namespace std { 27 | # define STD_NAMESPACE_END } 28 | #endif 29 | 30 | /** Structure-from-Motion library. */ 31 | SFM_NAMESPACE_BEGIN 32 | /** SfM bundler components. */ 33 | SFM_BUNDLER_NAMESPACE_BEGIN SFM_BUNDLER_NAMESPACE_END 34 | /** Parallel Bundle Adjustment components. */ 35 | SFM_PBA_NAMESPACE_BEGIN SFM_PBA_NAMESPACE_END 36 | SFM_NAMESPACE_END 37 | 38 | #endif /* MVE_DEFINES_HEADER */ 39 | -------------------------------------------------------------------------------- /libs/sfm/exhaustive_matching.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, Simon Fuhrmann 3 | * TU Darmstadt - Graphics, Capture and Massively Parallel Computing 4 | * All rights reserved. 5 | * 6 | * This software may be modified and distributed under the terms 7 | * of the BSD 3-Clause license. See the LICENSE.txt file for details. 8 | */ 9 | 10 | #ifndef SFM_EXHAUSTIVE_MATCHING_HEADER 11 | #define SFM_EXHAUSTIVE_MATCHING_HEADER 12 | 13 | #include "sfm/bundler_common.h" 14 | #include "sfm/defines.h" 15 | #include "sfm/matching_base.h" 16 | #include "sfm/nearest_neighbor.h" 17 | #include "sfm/sift.h" 18 | #include "sfm/surf.h" 19 | 20 | /* Whether to use floating point or 8-bit descriptors for matching. */ 21 | #define DISCRETIZE_DESCRIPTORS 1 22 | 23 | SFM_NAMESPACE_BEGIN 24 | 25 | class ExhaustiveMatching : public MatchingBase 26 | { 27 | public: 28 | ~ExhaustiveMatching (void) override = default; 29 | 30 | /** Initialize matcher by preprocessing given SIFT/SURF features. */ 31 | void init (bundler::ViewportList* viewports) override; 32 | 33 | /** Matches all feature types yielding a single matching result. */ 34 | void pairwise_match (int view_1_id, int view_2_id, 35 | Matching::Result* result) const override; 36 | 37 | /** 38 | * Matches the N lowest resolution features and returns the number of 39 | * matches. Can be used as a guess for full matchability. Useful values 40 | * are at most 3 matches for 500 features, or 2 matches with 300 features. 41 | */ 42 | int pairwise_match_lowres (int view_1_id, int view_2_id, 43 | std::size_t num_features) const override; 44 | 45 | protected: 46 | #if DISCRETIZE_DESCRIPTORS 47 | typedef util::AlignedMemory SiftDescriptors; 48 | typedef util::AlignedMemory SurfDescriptors; 49 | #else 50 | typedef util::AlignedMemory SiftDescriptors; 51 | typedef util::AlignedMemory SurfDescriptors; 52 | #endif 53 | 54 | /** Internal initialization methods for SIFT/SURF features. */ 55 | void init_sift (SiftDescriptors* dst, Sift::Descriptors const& src); 56 | void init_surf (SurfDescriptors* dst, Surf::Descriptors const& src); 57 | 58 | struct ProcessedFeatureSet 59 | { 60 | SiftDescriptors sift_descr; 61 | SurfDescriptors surf_descr; 62 | }; 63 | typedef std::vector ProcessedFeatureSets; 64 | ProcessedFeatureSets processed_feature_sets; 65 | }; 66 | 67 | SFM_NAMESPACE_END 68 | 69 | #endif /* SFM_EXHAUSTIVE_MATCHING_HEADER */ 70 | 71 | -------------------------------------------------------------------------------- /libs/sfm/extract_focal_length.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, Simon Fuhrmann 3 | * TU Darmstadt - Graphics, Capture and Massively Parallel Computing 4 | * All rights reserved. 5 | * 6 | * This software may be modified and distributed under the terms 7 | * of the BSD 3-Clause license. See the LICENSE.txt file for details. 8 | */ 9 | 10 | #include 11 | #include 12 | 13 | #include "sfm/camera_database.h" 14 | #include "sfm/extract_focal_length.h" 15 | 16 | SFM_NAMESPACE_BEGIN 17 | 18 | std::pair 19 | extract_focal_length (mve::image::ExifInfo const& exif) 20 | { 21 | /* Step 1: Check for focal length info in EXIF and database entry. */ 22 | float focal_length = exif.focal_length; 23 | std::string camera_maker = exif.camera_maker; 24 | std::string camera_model = exif.camera_model; 25 | float sensor_size = -1.0f; 26 | if (focal_length > 0.0f && !camera_model.empty()) 27 | { 28 | CameraDatabase const* db = CameraDatabase::get(); 29 | CameraModel const* model = db->lookup(camera_maker, camera_model); 30 | if (model != nullptr) 31 | sensor_size = model->sensor_width_mm; 32 | } 33 | if (focal_length > 0.0f && sensor_size > 0.0f) 34 | { 35 | float flen = focal_length / sensor_size; 36 | return std::make_pair(flen, FOCAL_LENGTH_AND_DATABASE); 37 | } 38 | 39 | /* Step 2: Check for 35mm equivalent focal length. */ 40 | float focal_length_35mm = exif.focal_length_35mm; 41 | if (focal_length_35mm > 0.0f) 42 | { 43 | float flen = focal_length_35mm / 35.0f; 44 | return std::make_pair(flen, FOCAL_LENGTH_35MM_EQUIV); 45 | } 46 | 47 | /* Step 3: Fall back to default value. */ 48 | return std::make_pair(1.0f, FOCAL_LENGTH_FALLBACK_VALUE); 49 | } 50 | 51 | SFM_NAMESPACE_END 52 | -------------------------------------------------------------------------------- /libs/sfm/extract_focal_length.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, Simon Fuhrmann 3 | * TU Darmstadt - Graphics, Capture and Massively Parallel Computing 4 | * All rights reserved. 5 | * 6 | * This software may be modified and distributed under the terms 7 | * of the BSD 3-Clause license. See the LICENSE.txt file for details. 8 | */ 9 | 10 | #ifndef SFM_EXTRACT_FOCAL_LENGTH_HEADER 11 | #define SFM_EXTRACT_FOCAL_LENGTH_HEADER 12 | 13 | #include 14 | 15 | #include "mve/image_exif.h" 16 | #include "sfm/defines.h" 17 | 18 | SFM_NAMESPACE_BEGIN 19 | 20 | /** 21 | * Indicator which focal length estimation has been used. 22 | */ 23 | enum FocalLengthMethod 24 | { 25 | FOCAL_LENGTH_AND_DATABASE, 26 | FOCAL_LENGTH_35MM_EQUIV, 27 | FOCAL_LENGTH_FALLBACK_VALUE 28 | }; 29 | 30 | /** 31 | * Datatype for the focal length estimate which reports the normalized 32 | * focal length as well as the method used to obtain the value. 33 | */ 34 | typedef std::pair FocalLengthEstimate; 35 | 36 | /** 37 | * Extracts the focal length from the EXIF tags of an image. 38 | * 39 | * The algorithm first checks for the availability of the "focal length" 40 | * in EXIF tags and computes the effective focal length using a database 41 | * of camera sensor sizes. If the camera model is unknown to the database, 42 | * the "focal length 35mm equivalent" EXIF tag is used. If this information 43 | * is also not available, a default value is used. 44 | * 45 | * This estimation can fail in numerous situations: 46 | * - The image contains no EXIF tags (default value is used) 47 | * - The camera did not specify the focal length in EXIF 48 | * - The lens specifies the wrong focal length due to lens incompatibility 49 | * - The camera is not in the database and the 35mm equivalent is missing 50 | * - The camera used digital zoom changing the effective focal length 51 | * 52 | * The resulting focal length is in normalized format, that is the quotient 53 | * of the image focal length by the sensor size. E.g. a photo taken at 70mm 54 | * with a 35mm sensor size will result in a normalized focal length of 2. 55 | */ 56 | FocalLengthEstimate 57 | extract_focal_length (mve::image::ExifInfo const& exif); 58 | 59 | SFM_NAMESPACE_END 60 | 61 | #endif /* SFM_EXTRACT_FOCAL_LENGTH_HEADER */ 62 | -------------------------------------------------------------------------------- /libs/sfm/homography.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, Simon Fuhrmann 3 | * TU Darmstadt - Graphics, Capture and Massively Parallel Computing 4 | * All rights reserved. 5 | * 6 | * This software may be modified and distributed under the terms 7 | * of the BSD 3-Clause license. See the LICENSE.txt file for details. 8 | */ 9 | 10 | #ifndef SFM_HOMOGRAPHY_HEADER 11 | #define SFM_HOMOGRAPHY_HEADER 12 | 13 | #include "math/matrix.h" 14 | #include "sfm/defines.h" 15 | #include "sfm/correspondence.h" 16 | 17 | SFM_NAMESPACE_BEGIN 18 | 19 | typedef math::Matrix3d HomographyMatrix; 20 | 21 | /** 22 | * Direct linear transformation algorithm to compute the homography matrix from 23 | * image correspondences. This algorithm computes the least squares solution for 24 | * the homography matrix from at least 4 correspondences. 25 | */ 26 | bool 27 | homography_dlt (Correspondences2D2D const& matches, HomographyMatrix* result); 28 | 29 | /** 30 | * Computes the symmetric transfer error for an image correspondence given the 31 | * homography matrix between two views. 32 | */ 33 | double 34 | symmetric_transfer_error(HomographyMatrix const& homography, 35 | Correspondence2D2D const& match); 36 | 37 | SFM_NAMESPACE_END 38 | 39 | #endif // SFM_HOMOGRAPHY_HEADER 40 | -------------------------------------------------------------------------------- /libs/sfm/matching_base.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, Simon Fuhrmann 3 | * TU Darmstadt - Graphics, Capture and Massively Parallel Computing 4 | * All rights reserved. 5 | * 6 | * This software may be modified and distributed under the terms 7 | * of the BSD 3-Clause license. See the LICENSE.txt file for details. 8 | */ 9 | 10 | #ifndef SFM_MATCHING_BASE_HEADER 11 | #define SFM_MATCHING_BASE_HEADER 12 | 13 | #include 14 | 15 | #include "sfm/bundler_common.h" 16 | #include "sfm/defines.h" 17 | #include "sfm/matching.h" 18 | #include "sfm/matching_base.h" 19 | 20 | SFM_NAMESPACE_BEGIN 21 | 22 | class MatchingBase 23 | { 24 | public: 25 | struct Options 26 | { 27 | Matching::Options sift_matching_opts{ 128, 0.8f, 28 | std::numeric_limits::max() }; 29 | Matching::Options surf_matching_opts{ 64, 0.7f, 30 | std::numeric_limits::max() }; 31 | }; 32 | 33 | virtual ~MatchingBase (void) = default; 34 | 35 | /** 36 | * Initialize the matcher. This is used for preprocessing the features 37 | * of the given viewports. For example, in the exhaustive matcher the 38 | * features are discretized. 39 | */ 40 | virtual void init (bundler::ViewportList* viewports) = 0; 41 | 42 | /** Matches all feature types yielding a single matching result. */ 43 | virtual void pairwise_match (int view_1_id, int view_2_id, 44 | Matching::Result* result) const = 0; 45 | 46 | /** 47 | * Matches the N lowest resolution features and returns the number of 48 | * matches. Can be used as a guess for full matchability. Useful values 49 | * are at most 3 matches for 500 features, or 2 matches with 300 features. 50 | */ 51 | virtual int pairwise_match_lowres (int view_1_id, int view_2_id, 52 | std::size_t num_features) const = 0; 53 | 54 | Options opts; 55 | }; 56 | 57 | SFM_NAMESPACE_END 58 | 59 | #endif /* SFM_MATCHING_BASE_HEADER */ 60 | 61 | -------------------------------------------------------------------------------- /libs/sfm/pose_p3p.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, Simon Fuhrmann 3 | * TU Darmstadt - Graphics, Capture and Massively Parallel Computing 4 | * All rights reserved. 5 | * 6 | * This software may be modified and distributed under the terms 7 | * of the BSD 3-Clause license. See the LICENSE.txt file for details. 8 | * 9 | * Kneips original code is available here: 10 | * http://www.laurentkneip.de/research.html 11 | */ 12 | 13 | #ifndef SFM_POSE_P3P_HEADER 14 | #define SFM_POSE_P3P_HEADER 15 | 16 | #include 17 | 18 | #include "math/matrix.h" 19 | #include "sfm/defines.h" 20 | 21 | SFM_NAMESPACE_BEGIN 22 | 23 | /** 24 | * Implementation of the perspective three point (P3P) algorithm. The 25 | * algorithm computes the pose of a camera given three 2D-3D correspondences. 26 | * The implementation closely follows the implementation of Kneip et al. 27 | * and is described in: 28 | * 29 | * "A Novel Parametrization of the Perspective-Three-Point Problem for a 30 | * Direct Computation of Absolute Camera Position and Orientation", 31 | * by Laurent Kneip, Davide Scaramuzza and Roland Siegwart, CVPR 2011. 32 | * http://www.laurentkneip.de/research.html 33 | * 34 | * The algorithm assumes a given camera calibration and takes as input 35 | * three 3D points 'p' and three 2D points. Instead of 2D points, the three 36 | * directions 'f' to the given points computed in the camera frame. Four 37 | * solutions [R | t] are returned. If the points are co-linear, no solution 38 | * is returned. The correct solution can be found by back-projecting a 39 | * forth point in the camera. 40 | */ 41 | void 42 | pose_p3p_kneip ( 43 | math::Vec3d p1, math::Vec3d p2, math::Vec3d p3, 44 | math::Vec3d f1, math::Vec3d f2, math::Vec3d f3, 45 | std::vector >* solutions); 46 | 47 | SFM_NAMESPACE_END 48 | 49 | #endif /* SFM_POSE_P3P_HEADER */ 50 | -------------------------------------------------------------------------------- /libs/sfm/ransac.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, Simon Fuhrmann 3 | * TU Darmstadt - Graphics, Capture and Massively Parallel Computing 4 | * All rights reserved. 5 | * 6 | * This software may be modified and distributed under the terms 7 | * of the BSD 3-Clause license. See the LICENSE.txt file for details. 8 | */ 9 | 10 | #include 11 | 12 | #include "math/functions.h" 13 | #include "sfm/ransac.h" 14 | 15 | SFM_NAMESPACE_BEGIN 16 | 17 | int 18 | compute_ransac_iterations (double inlier_ratio, 19 | int num_samples, 20 | double desired_success_rate) 21 | { 22 | double prob_all_good = math::fastpow(inlier_ratio, num_samples); 23 | double num_iterations = std::log(1.0 - desired_success_rate) 24 | / std::log(1.0 - prob_all_good); 25 | return static_cast(math::round(num_iterations)); 26 | } 27 | 28 | SFM_NAMESPACE_END 29 | -------------------------------------------------------------------------------- /libs/sfm/ransac.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, Simon Fuhrmann 3 | * TU Darmstadt - Graphics, Capture and Massively Parallel Computing 4 | * All rights reserved. 5 | * 6 | * This software may be modified and distributed under the terms 7 | * of the BSD 3-Clause license. See the LICENSE.txt file for details. 8 | */ 9 | 10 | #ifndef SFM_RANSAC_HEADER 11 | #define SFM_RANSAC_HEADER 12 | 13 | #include "sfm/defines.h" 14 | 15 | SFM_NAMESPACE_BEGIN 16 | 17 | /** 18 | * The function returns the required number of iterations for a desired 19 | * RANSAC success rate. If w is the probability of choosing one good sample 20 | * (the inlier ratio), then w^n is the probability that all n samples are 21 | * inliers. Then k is the number of iterations required to draw only inliers 22 | * with a certain probability of success, p: 23 | * 24 | * log(1 - p) 25 | * k = ------------ 26 | * log(1 - w^n) 27 | * 28 | * Example: For w = 50%, p = 99%, n = 8: k = log(0.001) / log(0.99609) = 1176. 29 | * Thus, it requires 1176 iterations for RANSAC to succeed with a 99% chance. 30 | */ 31 | int 32 | compute_ransac_iterations (double inlier_ratio, 33 | int num_samples, 34 | double desired_success_rate = 0.99); 35 | 36 | SFM_NAMESPACE_END 37 | 38 | #endif /* SFM_RANSAC_HEADER */ 39 | -------------------------------------------------------------------------------- /libs/sfm/visualizer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, Simon Fuhrmann 3 | * TU Darmstadt - Graphics, Capture and Massively Parallel Computing 4 | * All rights reserved. 5 | * 6 | * This software may be modified and distributed under the terms 7 | * of the BSD 3-Clause license. See the LICENSE.txt file for details. 8 | */ 9 | 10 | #ifndef SFM_VISUALIZER_HEADER 11 | #define SFM_VISUALIZER_HEADER 12 | 13 | #include 14 | #include 15 | 16 | #include "mve/image.h" 17 | #include "sfm/defines.h" 18 | #include "sfm/correspondence.h" 19 | 20 | SFM_NAMESPACE_BEGIN 21 | 22 | class Visualizer 23 | { 24 | public: 25 | struct Keypoint 26 | { 27 | float x; 28 | float y; 29 | float radius; 30 | float orientation; 31 | }; 32 | 33 | enum KeypointStyle 34 | { 35 | RADIUS_BOX_ORIENTATION, 36 | RADIUS_CIRCLE_ORIENTATION, 37 | SMALL_CIRCLE_STATIC, 38 | SMALL_DOT_STATIC 39 | }; 40 | 41 | public: 42 | /** 43 | * Draws a single feature on the image. 44 | */ 45 | static void draw_keypoint (mve::ByteImage& image, 46 | Keypoint const& keypoint, KeypointStyle style, uint8_t const* color); 47 | 48 | /** 49 | * Draws a list of features on a grayscale version of the image. 50 | */ 51 | static mve::ByteImage::Ptr draw_keypoints (mve::ByteImage::ConstPtr image, 52 | std::vector const& matches, KeypointStyle style); 53 | 54 | /** 55 | * Places images next to each other and draws a list of matches. 56 | */ 57 | static mve::ByteImage::Ptr draw_matches (mve::ByteImage::ConstPtr image1, 58 | mve::ByteImage::ConstPtr image2, Correspondences2D2D const& matches); 59 | }; 60 | 61 | SFM_NAMESPACE_END 62 | 63 | #endif /* SFM_VISUALIZER_HEADER */ 64 | -------------------------------------------------------------------------------- /libs/util/Makefile: -------------------------------------------------------------------------------- 1 | MVE_ROOT := ../.. 2 | TARGET := libmve_util.a 3 | include ${MVE_ROOT}/Makefile.inc 4 | 5 | # Position independent code (-fPIC) is required for the UMVE plugin system. 6 | CXXFLAGS += -fPIC -I${MVE_ROOT}/libs 7 | 8 | SOURCES := $(wildcard [^_]*.cc) 9 | ${TARGET}: ${SOURCES:.cc=.o} 10 | $(AR) rcs $@ $^ 11 | 12 | _test%: _test%.o libmve.a libmve_util.a 13 | ${LINK.cc} -o $@ $^ ${LDLIBS} 14 | 15 | clean: 16 | ${RM} ${TARGET} *.o Makefile.dep 17 | 18 | .PHONY: clean 19 | -------------------------------------------------------------------------------- /libs/util/aligned_memory.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, Benjamin Richter, Simon Fuhrmann 3 | * TU Darmstadt - Graphics, Capture and Massively Parallel Computing 4 | * All rights reserved. 5 | * 6 | * This software may be modified and distributed under the terms 7 | * of the BSD 3-Clause license. See the LICENSE.txt file for details. 8 | */ 9 | 10 | #ifndef UTIL_ALIGNED_MEMORY_HEADER 11 | #define UTIL_ALIGNED_MEMORY_HEADER 12 | 13 | #include 14 | #include 15 | 16 | #include "util/defines.h" 17 | #include "util/aligned_allocator.h" 18 | 19 | UTIL_NAMESPACE_BEGIN 20 | 21 | template 22 | using AlignedMemory = std::vector>; 23 | 24 | UTIL_NAMESPACE_END 25 | 26 | #endif /* UTIL_ALIGNED_MEMORY_HEADER */ 27 | -------------------------------------------------------------------------------- /libs/util/defines.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, Simon Fuhrmann 3 | * TU Darmstadt - Graphics, Capture and Massively Parallel Computing 4 | * All rights reserved. 5 | * 6 | * This software may be modified and distributed under the terms 7 | * of the BSD 3-Clause license. See the LICENSE.txt file for details. 8 | */ 9 | 10 | #ifndef UTIL_DEFINES_HEADER 11 | #define UTIL_DEFINES_HEADER 12 | 13 | #define UTIL_NAMESPACE_BEGIN namespace util { 14 | #define UTIL_NAMESPACE_END } 15 | 16 | #define UTIL_FS_NAMESPACE_BEGIN namespace fs { 17 | #define UTIL_FS_NAMESPACE_END } 18 | 19 | #define UTIL_STRING_NAMESPACE_BEGIN namespace string { 20 | #define UTIL_STRING_NAMESPACE_END } 21 | 22 | #define UTIL_SYSTEM_NAMESPACE_BEGIN namespace system { 23 | #define UTIL_SYSTEM_NAMESPACE_END } 24 | 25 | #ifndef STD_NAMESPACE_BEGIN 26 | # define STD_NAMESPACE_BEGIN namespace std { 27 | # define STD_NAMESPACE_END } 28 | #endif 29 | 30 | /** Parser, tokenizer, timer, smart pointer, threads, etc. */ 31 | UTIL_NAMESPACE_BEGIN 32 | /** Cross-platform file system functions. */ 33 | UTIL_FS_NAMESPACE_BEGIN UTIL_FS_NAMESPACE_END 34 | /** String conversions and helper functions. */ 35 | UTIL_STRING_NAMESPACE_BEGIN UTIL_STRING_NAMESPACE_END 36 | /** Cross-platform operating system related functions. */ 37 | UTIL_SYSTEM_NAMESPACE_BEGIN UTIL_SYSTEM_NAMESPACE_END 38 | UTIL_NAMESPACE_END 39 | 40 | #endif /* UTIL_DEFINES_HEADER */ 41 | -------------------------------------------------------------------------------- /libs/util/exception.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, Simon Fuhrmann 3 | * TU Darmstadt - Graphics, Capture and Massively Parallel Computing 4 | * All rights reserved. 5 | * 6 | * This software may be modified and distributed under the terms 7 | * of the BSD 3-Clause license. See the LICENSE.txt file for details. 8 | */ 9 | 10 | #ifndef UTIL_EXCEPTION_HEADER 11 | #define UTIL_EXCEPTION_HEADER 12 | 13 | #include 14 | #include 15 | 16 | #include "util/defines.h" 17 | 18 | UTIL_NAMESPACE_BEGIN 19 | 20 | /** 21 | * Universal, simple exception class. 22 | */ 23 | class Exception : public std::exception, public std::string 24 | { 25 | public: 26 | Exception (void) throw() 27 | { } 28 | 29 | Exception (std::string const& msg) throw() : std::string(msg) 30 | { } 31 | 32 | Exception (std::string const& msg, char const* msg2) throw() 33 | : std::string(msg) 34 | { this->append(msg2); } 35 | 36 | Exception (std::string const& msg, std::string const& msg2) throw() 37 | : std::string(msg) 38 | { this->append(msg2); } 39 | 40 | virtual ~Exception (void) throw() 41 | { } 42 | 43 | virtual const char* what (void) const throw() 44 | { return this->c_str(); } 45 | }; 46 | 47 | /* ---------------------------------------------------------------- */ 48 | 49 | /** 50 | * Exception class for file exceptions with additional filename. 51 | */ 52 | class FileException : public Exception 53 | { 54 | public: 55 | FileException(std::string const& filename, std::string const& msg) throw() 56 | : Exception(msg), filename(filename) 57 | { } 58 | 59 | FileException(std::string const& filename, char const* msg) throw() 60 | : Exception(msg), filename(filename) 61 | { } 62 | 63 | virtual ~FileException (void) throw() 64 | { } 65 | 66 | public: 67 | std::string filename; 68 | }; 69 | 70 | UTIL_NAMESPACE_END 71 | 72 | #endif /* UTIL_EXCEPTION_HEADER */ 73 | -------------------------------------------------------------------------------- /libs/util/ini_parser.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, Simon Fuhrmann 3 | * TU Darmstadt - Graphics, Capture and Massively Parallel Computing 4 | * All rights reserved. 5 | * 6 | * This software may be modified and distributed under the terms 7 | * of the BSD 3-Clause license. See the LICENSE.txt file for details. 8 | */ 9 | 10 | #ifndef UTIL_INI_PARSER_HEADER 11 | #define UTIL_INI_PARSER_HEADER 12 | 13 | #include 14 | #include 15 | #include 16 | 17 | #include "util/defines.h" 18 | 19 | UTIL_NAMESPACE_BEGIN 20 | 21 | /** Parses a file in INI format and places key/value pairs in the map. */ 22 | void 23 | parse_ini (std::istream& stream, std::map* map); 24 | 25 | /** 26 | * Writes an INI file for the key/value pairs in the map. 27 | * Section names are part of the key, separated with a dot from the key. 28 | */ 29 | void 30 | write_ini (std::map const& map, std::ostream& stream); 31 | 32 | UTIL_NAMESPACE_END 33 | 34 | #endif /* UTIL_INI_PARSER_HEADER */ 35 | 36 | -------------------------------------------------------------------------------- /libs/util/system.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, Simon Fuhrmann 3 | * TU Darmstadt - Graphics, Capture and Massively Parallel Computing 4 | * All rights reserved. 5 | * 6 | * This software may be modified and distributed under the terms 7 | * of the BSD 3-Clause license. See the LICENSE.txt file for details. 8 | */ 9 | 10 | #include 11 | #include 12 | #include 13 | #if defined(__GLIBC__) && !defined(_WIN32) && !defined(__CYGWIN__) 14 | # include // ::backtrace 15 | #endif 16 | 17 | #include "util/system.h" 18 | 19 | UTIL_NAMESPACE_BEGIN 20 | UTIL_SYSTEM_NAMESPACE_BEGIN 21 | 22 | void 23 | print_build_timestamp (char const* application_name, 24 | char const* date, char const* time) 25 | { 26 | std::cout << application_name << " (built on " 27 | << date << ", " << time << ")" << std::endl; 28 | } 29 | 30 | /* ---------------------------------------------------------------- */ 31 | 32 | void 33 | register_segfault_handler (void) 34 | { 35 | std::signal(SIGSEGV, util::system::signal_segfault_handler); 36 | } 37 | 38 | /* ---------------------------------------------------------------- */ 39 | 40 | void 41 | signal_segfault_handler (int code) 42 | { 43 | if (code != SIGSEGV) 44 | return; 45 | std::cerr << "Received signal SIGSEGV (segmentation fault)" << std::endl; 46 | print_stack_trace(); 47 | } 48 | 49 | /* ---------------------------------------------------------------- */ 50 | 51 | void 52 | print_stack_trace (void) 53 | { 54 | #if defined(__GLIBC__) && !defined(_WIN32) && !defined(__CYGWIN__) 55 | /* Get stack pointers for all frames on the stack. */ 56 | void *array[32]; 57 | int const size = ::backtrace(array, 32); 58 | 59 | /* Print out all the addresses to stderr. */ 60 | std::cerr << "Obtained " << size << " stack frames:"; 61 | for (int i = 0; i < size; ++i) 62 | std::cerr << " " << array[i]; 63 | std::cerr << std::endl; 64 | 65 | /* Print out human readable representation to stderr. */ 66 | ::backtrace_symbols_fd(array, size, 2); // 2 = stderr 67 | #endif 68 | std::cerr << "Segmentation fault" << std::endl; 69 | ::exit(1); 70 | } 71 | 72 | UTIL_SYSTEM_NAMESPACE_END 73 | UTIL_NAMESPACE_END 74 | -------------------------------------------------------------------------------- /tests/Makefile: -------------------------------------------------------------------------------- 1 | MVE_ROOT := .. 2 | TARGET := test 3 | include ${MVE_ROOT}/Makefile.inc 4 | 5 | GTEST_CFLAGS = `pkg-config --cflags gtest_main` 6 | GTEST_LDFLAGS = `pkg-config --libs gtest_main` 7 | 8 | SOURCES = $(wildcard math/gtest_*.cc) $(wildcard mve/gtest_*.cc) $(wildcard sfm/gtest_*.cc) $(wildcard util/gtest_*.cc) $(wildcard fssr/gtest_*.cc) 9 | INCLUDES = -I${MVE_ROOT}/libs ${GTEST_CFLAGS} 10 | CXXWARNINGS = -Wall -Wextra -pedantic -Wno-sign-compare 11 | CXXFLAGS = -std=c++14 -pthread ${CXXWARNINGS} ${INCLUDES} 12 | LDLIBS += ${GTEST_LDFLAGS} ${LIBJPEG_LDFLAGS} ${LIBPNG_LDFLAGS} ${LIBTIFF_LDFLAGS} 13 | 14 | test: ${SOURCES:.cc=.o} libmve_fssr.a libmve_sfm.a libmve.a libmve_util.a 15 | ${LINK.cc} -o $@ $^ ${LDLIBS} 16 | 17 | clean: 18 | ${RM} ${TARGET} mve/*.o util/*.o math/*.o sfm/*.o fssr/*.o Makefile.dep 19 | 20 | .PHONY: test 21 | -------------------------------------------------------------------------------- /tests/fssr/gtest_iso_octree.cc: -------------------------------------------------------------------------------- 1 | // Test cases for ISO octree. 2 | // Written by Simon Fuhrmann. 3 | 4 | #include 5 | #include 6 | 7 | #include "fssr/iso_octree.h" 8 | #include "fssr/sample.h" 9 | 10 | #if 0 11 | TEST(IsoOctreeTest, TempTest) 12 | { 13 | fssr::Octree::NodePath path; 14 | fssr::VoxelIndex index; 15 | 16 | path.level = 0; 17 | path.path = 0; 18 | index.from_path_and_corner(path, 1); 19 | std::cout << index.index << std::endl; 20 | 21 | path.level = 1; 22 | path.path = 1; 23 | index.from_path_and_corner(path, 1); 24 | std::cout << index.index << std::endl; 25 | 26 | path.level = 2; 27 | path.path = 9; 28 | index.from_path_and_corner(path, 1); 29 | std::cout << index.index << std::endl; 30 | 31 | 32 | path.level = 0; 33 | path.path = 0; 34 | index.from_path_and_corner(path, 2); 35 | std::cout << index.index << std::endl; 36 | 37 | path.level = 1; 38 | path.path = 2; 39 | index.from_path_and_corner(path, 2); 40 | std::cout << index.index << std::endl; 41 | 42 | path.level = 2; 43 | path.path = 18; 44 | index.from_path_and_corner(path, 2); 45 | std::cout << index.index << std::endl; 46 | } 47 | 48 | TEST(IsoOctreeTest, Temp2Test) 49 | { 50 | fssr::Octree::NodePath path; 51 | 52 | path.level = 1; 53 | path.path = 0; 54 | fssr::VoxelIndex index1; 55 | index1.from_path_and_corner(path, 7); 56 | std::cout << index1.index << std::endl; 57 | 58 | path.level = 2; 59 | path.path = 14; 60 | fssr::VoxelIndex index2; 61 | index2.from_path_and_corner(path, 6); 62 | std::cout << index2.index << std::endl; 63 | } 64 | #endif 65 | -------------------------------------------------------------------------------- /tests/fssr/gtest_mesh_clean.cc: -------------------------------------------------------------------------------- 1 | // Test cases for mesh decimator. 2 | // Written by Simon Fuhrmann. 3 | 4 | #include 5 | 6 | #include "mve/mesh.h" 7 | #include "mve/mesh_tools.h" 8 | #include "fssr/mesh_clean.h" 9 | 10 | #if 0 11 | TEST(MeshCleanTest, CleanTest1) 12 | { 13 | mve::TriangleMesh::Ptr mesh = mve::TriangleMesh::create(); 14 | mve::TriangleMesh::FaceList& faces = mesh->get_faces(); 15 | mve::TriangleMesh::VertexList& verts = mesh->get_vertices(); 16 | 17 | verts.push_back(math::Vec3f(0,0,0)); 18 | verts.push_back(math::Vec3f(1,0,0)); 19 | verts.push_back(math::Vec3f(2,0,0)); 20 | verts.push_back(math::Vec3f(2,4,0)); 21 | verts.push_back(math::Vec3f(1,4,0)); 22 | verts.push_back(math::Vec3f(0,4,0)); 23 | verts.push_back(math::Vec3f(0.9,2,0)); 24 | verts.push_back(math::Vec3f(1.1,2,0)); 25 | 26 | faces.push_back(0); faces.push_back(1); faces.push_back(6); 27 | faces.push_back(1); faces.push_back(2); faces.push_back(7); 28 | faces.push_back(2); faces.push_back(3); faces.push_back(7); 29 | faces.push_back(3); faces.push_back(4); faces.push_back(7); 30 | faces.push_back(4); faces.push_back(5); faces.push_back(6); 31 | faces.push_back(5); faces.push_back(0); faces.push_back(6); 32 | faces.push_back(1); faces.push_back(7); faces.push_back(6); 33 | faces.push_back(4); faces.push_back(6); faces.push_back(7); 34 | 35 | mve::geom::save_mesh(mesh, "/tmp/testmesh.off"); 36 | fssr::clean_slivers(mesh, 0.1f); 37 | mve::geom::save_mesh(mesh, "/tmp/testmesh_cleaned.off"); 38 | 39 | // TODO: Write some EXPECT tests! 40 | } 41 | #endif 42 | 43 | #if 0 44 | TEST(MeshCleanTest, CleanTest2) 45 | { 46 | mve::TriangleMesh::Ptr mesh = mve::geom::load_mesh("/tmp/camel_mc.off"); 47 | std::size_t num_collapsed = 0; 48 | num_collapsed += fssr::clean_needles(mesh, 0.4f); 49 | mve::geom::save_mesh(mesh, "/tmp/camel_cleaned_1.ply"); 50 | num_collapsed += fssr::clean_caps(mesh); 51 | mve::geom::save_mesh(mesh, "/tmp/camel_cleaned_2.ply"); 52 | num_collapsed += fssr::clean_needles(mesh, 0.4f); 53 | mve::geom::save_mesh(mesh, "/tmp/camel_cleaned_3.ply"); 54 | std::cout << "Collapsed " << num_collapsed << " edges." << std::endl; 55 | } 56 | #endif 57 | -------------------------------------------------------------------------------- /tests/math/gtest_accum.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Test cases for the generic type accumulator. 3 | * Written by Simon Fuhrmann. 4 | */ 5 | 6 | #include 7 | 8 | #include "math/accum.h" 9 | 10 | TEST(AccumTest, TestFloatAccum) 11 | { 12 | math::Accum accum(0.0f); 13 | accum.add(1.0f, 1.0f); 14 | accum.add(2.0f, 1.0f); 15 | accum.add(3.0f, 1.0f); 16 | EXPECT_EQ(2.0f, accum.normalized()); 17 | } 18 | 19 | TEST(AccumTest, TestFloatWeights) 20 | { 21 | math::Accum accum(0.0f); 22 | accum.add(2.0f, 0.5f); 23 | accum.add(10.0f, 0.5f); 24 | accum.add(6.0f, 0.5f); 25 | EXPECT_EQ((1.0f + 5.0f + 3.0f) / 1.5f, accum.normalized()); 26 | } 27 | 28 | TEST(AccumTest, TestUCharRounding) 29 | { 30 | math::Accum accum(0); 31 | accum.add(11, 0.5f); 32 | accum.add(11, 0.5f); 33 | EXPECT_EQ(11, accum.normalized()); 34 | } 35 | 36 | TEST(AccumTest, TestUCharNoOverflow) 37 | { 38 | math::Accum accum(0); 39 | accum.add(100, 1.0f); 40 | accum.add(150, 1.0f); 41 | accum.add(50, 1.0f); 42 | EXPECT_EQ(100, accum.normalized()); 43 | } 44 | 45 | #if 0 46 | TEST(AccumTest, TestIntRounding) 47 | { 48 | // Supposed to fail for now! 49 | math::Accum accum(0); 50 | accum.add(11, 0.5f); 51 | accum.add(11, 0.5f); 52 | EXPECT_EQ(11, accum.normalized()); 53 | } 54 | #endif 55 | -------------------------------------------------------------------------------- /tests/math/gtest_defines.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Test cases for math defines. 3 | * Written by Simon Fuhrmann. 4 | */ 5 | 6 | #include 7 | #include 8 | 9 | #include "math/defines.h" 10 | 11 | TEST(MathDefinesTest, ConstantsTest) 12 | { 13 | EXPECT_NEAR(MATH_PI / 2.0, MATH_PI_2, 1e-30); 14 | EXPECT_NEAR(MATH_PI / 4.0, MATH_PI_4, 1e-30); 15 | EXPECT_NEAR(1.0 / MATH_PI, MATH_1_PI, 1e-30); 16 | EXPECT_NEAR(2.0 / MATH_PI, MATH_2_PI, 1e-30); 17 | // TODO: More constants 18 | } 19 | 20 | TEST(MathDefinesTest, PowerTest) 21 | { 22 | EXPECT_EQ(1, MATH_POW2(1)); 23 | EXPECT_EQ(1, MATH_POW3(1)); 24 | EXPECT_EQ(1, MATH_POW4(1)); 25 | EXPECT_EQ(1, MATH_POW5(1)); 26 | EXPECT_EQ(1, MATH_POW6(1)); 27 | EXPECT_EQ(1, MATH_POW7(1)); 28 | EXPECT_EQ(1, MATH_POW8(1)); 29 | 30 | EXPECT_EQ(4, MATH_POW2(2)); 31 | EXPECT_EQ(8, MATH_POW3(2)); 32 | EXPECT_EQ(16, MATH_POW4(2)); 33 | EXPECT_EQ(32, MATH_POW5(2)); 34 | EXPECT_EQ(64, MATH_POW6(2)); 35 | EXPECT_EQ(128, MATH_POW7(2)); 36 | EXPECT_EQ(256, MATH_POW8(2)); 37 | 38 | EXPECT_EQ(4, MATH_POW2(1 + 1)); 39 | EXPECT_EQ(8, MATH_POW3(1 + 1)); 40 | EXPECT_EQ(16, MATH_POW4(1 + 1)); 41 | EXPECT_EQ(32, MATH_POW5(1 + 1)); 42 | EXPECT_EQ(64, MATH_POW6(1 + 1)); 43 | EXPECT_EQ(128, MATH_POW7(1 + 1)); 44 | EXPECT_EQ(256, MATH_POW8(1 + 1)); 45 | 46 | EXPECT_EQ(4.0f, MATH_POW2(2.0f)); 47 | EXPECT_EQ(8.0f, MATH_POW3(2.0f)); 48 | EXPECT_EQ(16.0f, MATH_POW4(2.0f)); 49 | EXPECT_EQ(32.0f, MATH_POW5(2.0f)); 50 | EXPECT_EQ(64.0f, MATH_POW6(2.0f)); 51 | EXPECT_EQ(128.0f, MATH_POW7(2.0f)); 52 | EXPECT_EQ(256.0f, MATH_POW8(2.0f)); 53 | } 54 | 55 | TEST(MathDefinesTest, InfTest) 56 | { 57 | EXPECT_TRUE(std::isinf(MATH_POS_INF)); 58 | EXPECT_TRUE(std::isinf(MATH_NEG_INF)); 59 | EXPECT_TRUE(MATH_POS_INF > 0.0); 60 | EXPECT_TRUE(MATH_NEG_INF < 0.0); 61 | EXPECT_FALSE(MATH_POS_INF < 0.0); 62 | EXPECT_FALSE(MATH_NEG_INF > 0.0); 63 | } 64 | 65 | TEST(MathDefinesTest, EpsilonComparisonTest) 66 | { 67 | EXPECT_TRUE(MATH_EPSILON_EQ(0.0, 1.0, 1.0)); 68 | EXPECT_TRUE(MATH_EPSILON_EQ(0.0, -1.0, 1.0)); 69 | EXPECT_TRUE(MATH_EPSILON_EQ(0.0, 0.0, 0.0)); 70 | EXPECT_TRUE(MATH_EPSILON_LESS(0.0, 1.0, 0.9999)); 71 | EXPECT_FALSE(MATH_EPSILON_EQ(0.0, 1.0, 0.9999)); 72 | EXPECT_FALSE(MATH_EPSILON_EQ(0.0, -1.0, 0.9999)); 73 | EXPECT_FALSE(MATH_EPSILON_LESS(0.0, 1.0, 1.0)); 74 | EXPECT_FALSE(MATH_EPSILON_LESS(0.0, 1.0, 1.0001)); 75 | } 76 | -------------------------------------------------------------------------------- /tests/math/gtest_geom.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Test cases for geometric routines. 3 | * Written by Simon Fuhrmann. 4 | */ 5 | 6 | #include 7 | 8 | #include "math/vector.h" 9 | #include "math/matrix.h" 10 | #include "math/octree_tools.h" 11 | 12 | TEST(GeomTests, RayRayIntersectTest) 13 | { 14 | math::Vec3d p1, d1, p2,d2; 15 | p1[0] = 0; p1[1] = 0; p1[2] = 0; 16 | d1[0] = 0; d1[1] = 0; d1[2] = 1; 17 | p2[0] = 0; p2[1] = 0; p2[2] = 0; 18 | d2[0] = 0; d2[1] = 1; d2[2] = 0; 19 | 20 | math::Vec2d t = math::geom::ray_ray_intersect(p1,d1,p2,d2); 21 | EXPECT_EQ(math::Vec2d(0.0), t); 22 | 23 | p2[0] = 1.0; 24 | t = math::geom::ray_ray_intersect(p1,d1,p2,d2); 25 | EXPECT_EQ(math::Vec2d(0.0), t); 26 | 27 | p2[0] = 1; p2[1] = 1; p2[2] = 1; 28 | t = math::geom::ray_ray_intersect(p1,d1,p2,d2); 29 | EXPECT_EQ((t[0]*d1+p1), math::Vec3f(0,0,1)); 30 | EXPECT_EQ((t[1]*d2+p2), math::Vec3f(1,0,1)); 31 | } 32 | -------------------------------------------------------------------------------- /tests/math/gtest_quaternion.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Test cases for the quaternion class. 3 | * Written by Nils Moehrle. 4 | */ 5 | 6 | #include 7 | 8 | #include "math/quaternion.h" 9 | 10 | TEST(QuaternionTest, Rotate) 11 | { 12 | using namespace math; 13 | Vec3f x(1.0f, 0.0f, 0.0f); 14 | Vec3f y(0.0f, 1.0f, 0.0f); 15 | Vec3f z(0.0f, 0.0f, 1.0f); 16 | 17 | /* 90 deg ccw rotation around z. */ 18 | Quat4f q(z, M_PI / 2.0f); 19 | 20 | float error = (y - q.rotate(x)).norm(); 21 | EXPECT_TRUE(error < 1e-7f); 22 | } 23 | 24 | TEST(QuaternionTest, ToAndFromRotationMatrix) 25 | { 26 | using namespace math; 27 | Vector rot; 28 | Vec3f x(1.0f, 0.0f, 0.0f); 29 | Vec3f y(0.0f, 1.0f, 0.0f); 30 | Vec3f z(0.0f, 0.0f, 1.0f); 31 | Quat4f q, q_test; 32 | 33 | /* 90 deg ccw rotation around x. */ 34 | q.set(x, M_PI / 2.0f); 35 | q.to_rotation_matrix(*rot); 36 | q_test.set_from_rotation_matrix(*rot); 37 | 38 | EXPECT_NEAR(q[0], q_test[0], 1e-7); 39 | EXPECT_NEAR(q[1], q_test[1], 1e-7); 40 | EXPECT_NEAR(q[2], q_test[2], 1e-7); 41 | EXPECT_NEAR(q[3], q_test[3], 1e-7); 42 | 43 | /* 180 deg ccw rotation around y. */ 44 | q.set(y, M_PI); 45 | q.to_rotation_matrix(*rot); 46 | q_test.set_from_rotation_matrix(*rot); 47 | 48 | EXPECT_NEAR(q[0], q_test[0], 1e-7); 49 | EXPECT_NEAR(q[1], q_test[1], 1e-7); 50 | EXPECT_NEAR(q[2], q_test[2], 1e-7); 51 | EXPECT_NEAR(q[3], q_test[3], 1e-7); 52 | 53 | /* 45 deg ccw rotation around z. */ 54 | q.set(z, M_PI / 4.0f); 55 | q.to_rotation_matrix(*rot); 56 | q_test.set_from_rotation_matrix(*rot); 57 | 58 | EXPECT_NEAR(q[0], q_test[0], 1e-7); 59 | EXPECT_NEAR(q[1], q_test[1], 1e-7); 60 | EXPECT_NEAR(q[2], q_test[2], 1e-7); 61 | EXPECT_NEAR(q[3], q_test[3], 1e-7); 62 | } 63 | -------------------------------------------------------------------------------- /tests/mve/gtest_bundle.cc: -------------------------------------------------------------------------------- 1 | // Test cases for the MVE bundle class. 2 | // Written by Simon Fuhrmann. 3 | 4 | #include 5 | 6 | #include "mve/bundle.h" 7 | 8 | TEST(BundleTest, BundleRemoveCamera) 9 | { 10 | mve::Bundle::Ptr bundle = mve::Bundle::create(); 11 | 12 | mve::Bundle::Cameras& cams = bundle->get_cameras(); 13 | { 14 | mve::CameraInfo cam1, cam2; 15 | cam1.flen = 1.0f; 16 | cam2.flen = 2.0f; 17 | cams.push_back(cam1); 18 | cams.push_back(cam2); 19 | } 20 | 21 | mve::Bundle::Features& features = bundle->get_features(); 22 | { 23 | mve::Bundle::Feature2D f2d_1; 24 | f2d_1.view_id = 0; 25 | f2d_1.feature_id = 0; 26 | mve::Bundle::Feature2D f2d_2; 27 | f2d_2.view_id = 1; 28 | f2d_2.feature_id = 0; 29 | 30 | mve::Bundle::Feature3D f3d_1; 31 | f3d_1.refs.push_back(f2d_1); 32 | f3d_1.refs.push_back(f2d_2); 33 | mve::Bundle::Feature3D f3d_2; 34 | f3d_2.refs.push_back(f2d_1); 35 | mve::Bundle::Feature3D f3d_3; 36 | f3d_3.refs.push_back(f2d_2); 37 | 38 | features.push_back(f3d_1); 39 | features.push_back(f3d_2); 40 | features.push_back(f3d_3); 41 | } 42 | 43 | // Delete a camera. 44 | bundle->delete_camera(1); 45 | 46 | // Check consistent bundle. 47 | ASSERT_EQ(2, cams.size()); 48 | EXPECT_EQ(1.0f, cams[0].flen); 49 | EXPECT_EQ(0.0f, cams[1].flen); 50 | ASSERT_EQ(3, features.size()); 51 | ASSERT_EQ(1, features[0].refs.size()); 52 | ASSERT_EQ(1, features[1].refs.size()); 53 | ASSERT_EQ(0, features[2].refs.size()); 54 | ASSERT_EQ(0, features[0].refs[0].view_id); 55 | ASSERT_EQ(0, features[1].refs[0].view_id); 56 | } 57 | -------------------------------------------------------------------------------- /tests/mve/gtest_camera.cc: -------------------------------------------------------------------------------- 1 | // Test cases for the MVE camera class. 2 | // Written by Simon Fuhrmann. 3 | 4 | #include 5 | 6 | #include "math/matrix.h" 7 | #include "mve/camera.h" 8 | 9 | TEST(MveCameraTest, CalibrationAndInverseTest) 10 | { 11 | /* Test if K * K^-1 = I. */ 12 | mve::CameraInfo cam; 13 | cam.flen = 1.0f; 14 | math::Matrix3f K, Kinv; 15 | cam.fill_calibration(*K, 800, 600); 16 | cam.fill_inverse_calibration(*Kinv, 800, 600); 17 | math::Matrix3f I = K * Kinv; 18 | for (int i = 0; i < 9; ++i) 19 | if (i == 0 || i == 4 || i == 8) 20 | EXPECT_NEAR(1.0f, I[i], 1e-10f); 21 | else 22 | EXPECT_NEAR(0.0f, I[i], 1e-10f); 23 | 24 | I = Kinv * K; 25 | for (int i = 0; i < 9; ++i) 26 | if (i == 0 || i == 4 || i == 8) 27 | EXPECT_NEAR(1.0f, I[i], 1e-10f); 28 | else 29 | EXPECT_NEAR(0.0f, I[i], 1e-10f); 30 | } 31 | -------------------------------------------------------------------------------- /tests/mve/gtest_mesh_tools.cc: -------------------------------------------------------------------------------- 1 | // Test cases for the MVE mesh tools. 2 | // Written by Simon Fuhrmann. 3 | 4 | #include 5 | 6 | #include "mve/mesh.h" 7 | #include "mve/mesh_tools.h" 8 | 9 | TEST(MeshToolsTest, Components) 10 | { 11 | mve::TriangleMesh::Ptr mesh = mve::TriangleMesh::create(); 12 | mve::TriangleMesh::VertexList& verts = mesh->get_vertices(); 13 | verts.insert(verts.end(), 6, math::Vec3f(0.0f)); 14 | mesh->get_faces().push_back(0); 15 | mesh->get_faces().push_back(1); 16 | mesh->get_faces().push_back(2); 17 | 18 | mve::TriangleMesh::Ptr tmp; 19 | tmp = mesh->duplicate(); 20 | mve::geom::mesh_components(tmp, 0); // Deletes nothing. 21 | EXPECT_EQ(6, tmp->get_vertices().size()); 22 | 23 | tmp = mesh->duplicate(); 24 | mve::geom::mesh_components(tmp, 1); // Deletes isolated verts. 25 | EXPECT_EQ(3, tmp->get_vertices().size()); 26 | 27 | tmp = mesh->duplicate(); 28 | mve::geom::mesh_components(tmp, 2); // Deletes isolated verts. 29 | EXPECT_EQ(3, tmp->get_vertices().size()); 30 | 31 | tmp = mesh->duplicate(); 32 | mve::geom::mesh_components(tmp, 3); // Deletes everything here. 33 | EXPECT_EQ(0, tmp->get_vertices().size()); 34 | } 35 | 36 | TEST(MeshToolsTest, DeleteUnreferenced) 37 | { 38 | mve::TriangleMesh::Ptr mesh = mve::TriangleMesh::create(); 39 | mesh->get_vertices().push_back(math::Vec3f(0.0f)); 40 | mesh->get_vertices().push_back(math::Vec3f(1.0f)); 41 | mesh->get_vertices().push_back(math::Vec3f(2.0f)); 42 | mesh->get_vertices().push_back(math::Vec3f(3.0f)); 43 | mesh->get_vertices().push_back(math::Vec3f(4.0f)); 44 | mesh->get_faces().push_back(1); 45 | mesh->get_faces().push_back(2); 46 | mesh->get_faces().push_back(3); 47 | 48 | EXPECT_EQ(2, mve::geom::mesh_delete_unreferenced(mesh)); 49 | EXPECT_EQ(3, mesh->get_vertices().size()); 50 | EXPECT_EQ(math::Vec3f(1.0f), mesh->get_vertices()[0]); 51 | EXPECT_EQ(math::Vec3f(2.0f), mesh->get_vertices()[1]); 52 | EXPECT_EQ(math::Vec3f(3.0f), mesh->get_vertices()[2]); 53 | EXPECT_EQ(3, mesh->get_faces().size()); 54 | EXPECT_EQ(0, mesh->get_faces()[0]); 55 | EXPECT_EQ(1, mesh->get_faces()[1]); 56 | EXPECT_EQ(2, mesh->get_faces()[2]); 57 | } 58 | -------------------------------------------------------------------------------- /tests/sfm/gtest_ba_cholesky.cc: -------------------------------------------------------------------------------- 1 | // Test cases for the Cholesky decomposition. 2 | // Written by Simon Fuhrmann 3 | 4 | #include 5 | 6 | #include "sfm/ba_cholesky.h" 7 | 8 | TEST(CholeskyDecompTest, CholeskyGoldenData1Test) 9 | { 10 | // From wikipedia. 11 | double const matrix[9] = { 4, 12, -16, 12, 37, -43, -16, -43, 98 }; 12 | double const oracle[9] = { 2, 0, 0, 6, 1, 0, -8, 5, 3 }; 13 | double result[9]; 14 | 15 | sfm::ba::cholesky_decomposition(matrix, 3, result); 16 | for (int i = 0; i < 9; ++i) 17 | EXPECT_NEAR(oracle[i], result[i], 1e-18); 18 | } 19 | 20 | TEST(CholeskyDecompTest, CholeskyGoldenData2Test) 21 | { 22 | // From wikipedia. 23 | double const matrix[9] = { 25, 15, -5, 15, 18, 0, -5, 0, 11 }; 24 | double const oracle[9] = { 5, 0, 0, 3, 3, 0, -1, 1, 3 }; 25 | double result[9]; 26 | 27 | sfm::ba::cholesky_decomposition(matrix, 3, result); 28 | for (int i = 0; i < 9; ++i) 29 | EXPECT_NEAR(oracle[i], result[i], 1e-18); 30 | } 31 | 32 | TEST(CholeskyDecompTest, CholeskyInplaceComputationTest) 33 | { 34 | // From wikipedia. 35 | double matrix[9] = { 25, 15, -5, 15, 18, 0, -5, 0, 11 }; 36 | double const oracle[9] = { 5, 0, 0, 3, 3, 0, -1, 1, 3 }; 37 | 38 | sfm::ba::cholesky_decomposition(matrix, 3, matrix); 39 | for (int i = 0; i < 9; ++i) 40 | EXPECT_NEAR(oracle[i], matrix[i], 1e-18); 41 | } 42 | 43 | TEST(CholeskyDecompTest, InvertLDGoldenData1Test) 44 | { 45 | // From wikipedia. 46 | double matrix[9] = { 3, 0, 0, 9, 27, 0, 3, 3, 3 }; 47 | double const oracle[9] = 48 | { 49 | 1.0/3, 0, 0, 50 | -1.0/9, 1.0/27, 0, 51 | -2.0/9, -1.0/27, 1.0/3 52 | }; 53 | 54 | double result[9]; 55 | sfm::ba::invert_lower_diagonal(matrix, 3, result); 56 | for (int i = 0; i < 9; ++i) 57 | EXPECT_NEAR(oracle[i], result[i], 1e-16); 58 | } 59 | 60 | TEST(CholeskyDecompTest, InvertLDGoldenData2Test) 61 | { 62 | double const matrix[9] = { 2, 0, 0, 6, 1, 0, -8, 5, 3 }; 63 | double const oracle[9] = { 1.0/2, 0, 0, -3, 1, 0, 19.0/3, -5.0/3, 1.0/3 }; 64 | 65 | double result[9]; 66 | sfm::ba::invert_lower_diagonal(matrix, 3, result); 67 | for (int i = 0; i < 9; ++i) 68 | EXPECT_NEAR(oracle[i], result[i], 1e-16); 69 | } 70 | 71 | TEST(CholeskyDecompTest, CholeskyInvertGoldenData1Test) 72 | { 73 | double const matrix[9] = { 2, -1, 0, -1, 2, -1, 0, -1, 2 }; 74 | double const oracle[9] = { 3.0/4, 1.0/2, 1.0/4, 1.0/2, 1, 1.0/2, 1.0/4, 1.0/2, 3.0/4 }; 75 | 76 | double result[9]; 77 | sfm::ba::cholesky_invert(matrix, 3, result); 78 | for (int i = 0; i < 9; ++i) 79 | EXPECT_NEAR(oracle[i], result[i], 1e-15); 80 | } 81 | -------------------------------------------------------------------------------- /tests/sfm/gtest_matching.cc: -------------------------------------------------------------------------------- 1 | // Test cases for feature matching. 2 | // Written by Simon Fuhrmann. 3 | 4 | #include 5 | 6 | #include "sfm/matching.h" 7 | 8 | TEST(MatchingTest, RemoveInconsistentMatches) 9 | { 10 | sfm::Matching::Result result; 11 | result.matches_1_2.resize(4, -1); 12 | result.matches_2_1.resize(5, -1); 13 | result.matches_1_2[0] = 1; 14 | result.matches_1_2[2] = 3; 15 | result.matches_1_2[3] = 2; 16 | result.matches_2_1[0] = 3; 17 | result.matches_2_1[1] = 1; 18 | result.matches_2_1[3] = 2; 19 | sfm::Matching::remove_inconsistent_matches(&result); 20 | 21 | EXPECT_EQ(-1, result.matches_1_2[0]); 22 | EXPECT_EQ(-1, result.matches_1_2[1]); 23 | EXPECT_EQ(3, result.matches_1_2[2]); 24 | EXPECT_EQ(-1, result.matches_1_2[3]); 25 | 26 | EXPECT_EQ(-1, result.matches_2_1[0]); 27 | EXPECT_EQ(-1, result.matches_2_1[1]); 28 | EXPECT_EQ(-1, result.matches_2_1[2]); 29 | EXPECT_EQ(2, result.matches_2_1[3]); 30 | EXPECT_EQ(-1, result.matches_2_1[4]); 31 | } 32 | -------------------------------------------------------------------------------- /tests/util/gtest_endian.cc: -------------------------------------------------------------------------------- 1 | // Test cases for endian conversions. 2 | // Written by Simon Fuhrmann. 3 | 4 | #include 5 | 6 | #include "util/system.h" 7 | 8 | TEST(EndianTest, TestByteSwap) 9 | { 10 | short val1 = 0x1234; 11 | util::system::byte_swap<2>(reinterpret_cast(&val1)); 12 | EXPECT_EQ((short)0x3412, val1); 13 | 14 | unsigned short val2 = 0x1234; 15 | util::system::byte_swap<2>(reinterpret_cast(&val2)); 16 | EXPECT_EQ((unsigned short)0x3412, val2); 17 | 18 | int val3 = 0x12345678; 19 | util::system::byte_swap<4>(reinterpret_cast(&val3)); 20 | EXPECT_EQ(static_cast(0x78563412), val3); 21 | 22 | unsigned int val4 = 0x12345678; 23 | util::system::byte_swap<4>(reinterpret_cast(&val4)); 24 | EXPECT_EQ(static_cast(0x78563412), val4); 25 | 26 | long long int val5 = 0x0123456789abcdef; 27 | util::system::byte_swap<8>(reinterpret_cast(&val5)); 28 | EXPECT_EQ(static_cast(0xefcdab8967452301), val5); 29 | 30 | unsigned long long int val6 = 0x0123456789abcdef; 31 | util::system::byte_swap<8>(reinterpret_cast(&val6)); 32 | EXPECT_EQ(static_cast(0xefcdab8967452301), val6); 33 | } 34 | 35 | TEST(EndianTest, DoubleSwaps) 36 | { 37 | short short_val = 0x1234; 38 | int int_val = 0x12345678; 39 | long long int long_val = 0x0123456789abcdef; 40 | 41 | using util::system::letoh; 42 | using util::system::betoh; 43 | EXPECT_EQ(short_val, letoh(letoh(short_val))); 44 | EXPECT_EQ(short_val, betoh(betoh(short_val))); 45 | EXPECT_EQ(int_val, letoh(letoh(int_val))); 46 | EXPECT_EQ(int_val, betoh(betoh(int_val))); 47 | EXPECT_EQ(long_val, letoh(letoh(long_val))); 48 | EXPECT_EQ(long_val, betoh(betoh(long_val))); 49 | } 50 | -------------------------------------------------------------------------------- /tests/util/gtest_tokenizer.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "util/tokenizer.h" 5 | 6 | TEST(TokenizerTest, SimpleTest) 7 | { 8 | std::string str("test1 test2"); 9 | util::Tokenizer tok; 10 | tok.split(str); 11 | ASSERT_EQ(2, tok.size()); 12 | EXPECT_EQ("test1", tok[0]); 13 | EXPECT_EQ("test2", tok[1]); 14 | } 15 | 16 | TEST(TokenizerTest, DoubleDelim) 17 | { 18 | std::string str(":test1::test2:test3::"); 19 | util::Tokenizer tok; 20 | 21 | tok.split(str, ':', true); 22 | ASSERT_EQ(7, tok.size()); 23 | EXPECT_EQ("", tok[0]); 24 | EXPECT_EQ("test1", tok[1]); 25 | EXPECT_EQ("", tok[2]); 26 | EXPECT_EQ("test2", tok[3]); 27 | EXPECT_EQ("test3", tok[4]); 28 | EXPECT_EQ("", tok[5]); 29 | EXPECT_EQ("", tok[6]); 30 | 31 | tok.split(str, ':', false); 32 | ASSERT_EQ(3, tok.size()); 33 | EXPECT_EQ("test1", tok[0]); 34 | EXPECT_EQ("test2", tok[1]); 35 | EXPECT_EQ("test3", tok[2]); 36 | } 37 | --------------------------------------------------------------------------------