File openMVS.spec of Package openMVS

#
# spec file for package openMVS
#
# Copyright (c) 2024 SUSE LLC
# Copyright (c) 2018-2019 Malcolm J Lewis <malcolmlewis@opensuse.org>
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via https://bugs.opensuse.org/
#


%bcond_with pybindings

Name:           openMVS
Version:        2.3.0
Release:        0
Summary:        Multi-View Stereo reconstruction library
License:        AGPL-3.0-or-later
URL:            https://cdcseacave.github.io/
Source0:        https://github.com/cdcseacave/openMVS/archive/refs/tags/v%{version}.tar.gz#/%{name}-%{version}.tar.xz
# PATCH-FIX-UPSTREAM - Fix building when ceres is not found
Patch0:         0001-Fix-building-without-Ceres.patch
# PATCH-FIX-UPSTREAM
Patch1:         0002-Fix-buffer-overflow-in-formatTime-utility-method.patch
BuildRequires:  cmake
BuildRequires:  eigen3-devel >= 3.4.0
BuildRequires:  fdupes
BuildRequires:  gcc-c++
BuildRequires:  libboost_iostreams-devel >= 1.56.0
BuildRequires:  libboost_program_options-devel >= 1.56.0
BuildRequires:  libboost_serialization-devel >= 1.56.0
BuildRequires:  libboost_system-devel >= 1.56.0
BuildRequires:  libceres-devel > 1.10.0
BuildRequires:  libjpeg8-devel
BuildRequires:  libpng16-devel
BuildRequires:  libtiff-devel
BuildRequires:  opencv-devel > 2.4.0
BuildRequires:  vcglib-devel >= 2022.03
BuildRequires:  cmake(CGAL)
BuildRequires:  cmake(glfw3)
BuildRequires:  pkgconfig(gl)
BuildRequires:  pkgconfig(glew)
%if %{with pybindings}
BuildRequires:  pkgconfig(python3)
%endif
Recommends:     openMVG
# Only support x86
ExcludeArch:    i586

%description
Library for computer-vision scientists and especially targeted to the Multi-View
Stereo reconstruction community. While there are mature and complete open-source
projects targeting Structure-from-Motion pipelines (like OpenMVG) which recover
camera poses and a sparse 3D point-cloud from an input set of images, there are
none addressing the last part of the photogrammetry chain-flow. OpenMVS aims at
filling that gap by providing a complete set of algorithms to recover the full
surface of the scene to be reconstructed. The input is a set of camera poses plus
the sparse point-cloud and the output is a textured mesh.

The main topics covered by this project are:
- dense point-cloud reconstruction for obtaining a complete and accurate as possible
  point-cloud
- mesh reconstruction for estimating a mesh surface that explains the best the input
  point-cloud
- mesh refinement for recovering all fine details
- mesh texturing for computing a sharp and accurate texture to color the mesh

%package static-devel
Summary:        Multi-View Stereo reconstruction library

%description static-devel
Library for computer-vision scientists and especially targeted to the Multi-View
Stereo reconstruction community. While there are mature and complete open-source
projects targeting Structure-from-Motion pipelines (like OpenMVG) which recover
camera poses and a sparse 3D point-cloud from an input set of images, there are
none addressing the last part of the photogrammetry chain-flow. OpenMVS aims at
filling that gap by providing a complete set of algorithms to recover the full
surface of the scene to be reconstructed. The input is a set of camera poses plus
the sparse point-cloud and the output is a textured mesh.

The main topics covered by this project are:
- dense point-cloud reconstruction for obtaining a complete and accurate as possible
  point-cloud
- mesh reconstruction for estimating a mesh surface that explains the best the input
  point-cloud
- mesh refinement for recovering all fine details
- mesh texturing for computing a sharp and accurate texture to color the mesh

%prep
%autosetup -p1

%build
%global __builddir obs_builddir
%global _lto_cflags %{_lto_cflags} -ffat-lto-objects

%cmake \
%ifnarch x86_64 %{ix86}
       -DOpenMVS_USE_SSE=OFF \
%endif
       -DBUILD_SHARED_LIBS:BOOL=OFF \
       -DOpenMVS_USE_BREAKPAD:BOOL=OFF \
       -DOpenMVS_USE_CERES:BOOL=ON \
       -DOpenMVS_USE_CUDA:BOOL=OFF \
       -DOpenMVS_USE_PYTHON:BOOL=%{?with_pybindings:ON}%{!?with_pybindings:OFF} \
       -DCMAKE_CXX_FLAGS:STRING="%{optflags}" \
       -DINSTALL_LIB_DIR:STRING=%{_lib}/ \
       -DINSTALL_CMAKE_DIR:STRING=%{_lib}/cmake/ \
       %{nil}

%cmake_build

%install
%cmake_install
mv %{buildroot}%{_bindir}/OpenMVS/* %{buildroot}%{_bindir}
rmdir %{buildroot}%{_bindir}/OpenMVS
rm %{buildroot}%{_bindir}/Tests

%fdupes %{buildroot}

%check
%ctest

%files
%license LICENSE
%{_bindir}/DensifyPointCloud
%{_bindir}/InterfaceCOLMAP
%{_bindir}/InterfaceMetashape
%{_bindir}/InterfaceMVSNet
%{_bindir}/InterfacePolycam
%{_bindir}/ReconstructMesh
%{_bindir}/RefineMesh
%{_bindir}/TextureMesh
%{_bindir}/TransformScene
%{_bindir}/Viewer

%files static-devel
%{_includedir}/OpenMVS
%{_libdir}/cmake/OpenMVS
%dir %{_libdir}/OpenMVS
%{_libdir}/OpenMVS/*.a

%changelog
openSUSE Build Service is sponsored by