diff --git a/pkgs/applications/graphics/meshroom/default.nix b/pkgs/applications/graphics/meshroom/default.nix new file mode 100644 index 0000000000000..0ec10c516b055 --- /dev/null +++ b/pkgs/applications/graphics/meshroom/default.nix @@ -0,0 +1,123 @@ +{ lib +, fetchFromGitHub +, callPackage +, alice-vision +, python3 +, qtbase +, qtdeclarative +, qttools +, qtquickcontrols +, qtquickcontrols2 +, qtgraphicaleffects +, qt3d +, qtlocation +, qtcharts +, wrapQtAppsHook +, makeWrapper +}: + +let + validLocalVersion = s: builtins.match "^[a-zA-Z0-9.]+$" s != null; + mkLocalVersion = s: let s' = lib.replaceStrings ["-"] ["."] s; in lib.throwIfNot (validLocalVersion s') "invalid local version ${s'}" s'; + qtalicevision = callPackage ./qtalicevision.nix { }; + qmlalembic = callPackage ./qmlalembic.nix { }; + +in +python3.pkgs.buildPythonApplication rec { + pname = "meshroom"; + version = "unstable-2023-02-09"; + + src = fetchFromGitHub { + owner = "alicevision"; + repo = pname; + rev = "334bfc8b00b6f82e8405a3c7537c8936abace124"; + hash = "sha256-RjayS1SfG17T5Xn5P6JBg5nNGZVSLuZ7X5aAWrlHVPg="; + }; + + format = "pyproject"; + + ppl = '' + [tool.poetry] + name = "${pname}" + version = "2021.1.0+${mkLocalVersion version}" + description = "Meshroom" + authors = ["nobody"] + readme = "README.md" + packages = [{include = "meshroom"}] + + [tool.poetry.dependencies] + python = "^3.7" + psutil = "^5.9" + PySide2 = "^5.11" + + [tool.poetry.scripts] + meshroom = 'meshroom.ui.__main__:main' + + [build-system] + requires = ["poetry-core"] + build-backend = "poetry.core.masonry.api" + ''; + # markdown = "^2.4" + + + passAsFile = [ "ppl" ]; + + postPatch = '' + rm setup.py + cp $pplPath pyproject.toml + + sed -i 's/^/ /' meshroom/ui/__main__.py + sed -i '1 i\def main():''\n' meshroom/ui/__main__.py + ''; + + makeWrapperArgs = [ + "--set ALICEVISION_ROOT ${alice-vision.dev}" + "--set MESHROOM_OUTPUT_QML_WARNINGS 1" + "\${qtWrapperArgs[@]}" + ]; + + nativeBuildInputs = [ + python3.pkgs.poetry-core + + makeWrapper + + wrapQtAppsHook + + qtbase + qttools + qtdeclarative + qtquickcontrols + qtquickcontrols2 + qtgraphicaleffects + qt3d + qtlocation + qtcharts + + qmlalembic + qtalicevision + ]; + + propagatedBuildInputs = with python3.pkgs; [ + # cx_Freeze + pyside2 + psutil + requests + markdown2 + qtpy + pysideShiboken + ]; + + nativeCheckInputs = [ + python3.pkgs.pytestCheckHook + ]; + + meta = { + description = "3D Reconstruction Software"; + homepage = "https://github.com/alicevision/meshroom"; + license = lib.licenses.mpl20; + platforms = lib.platforms.all; + maintainers = with lib.maintainers; [ tmarkus ]; + }; +} + + diff --git a/pkgs/applications/graphics/meshroom/qmlalembic.nix b/pkgs/applications/graphics/meshroom/qmlalembic.nix new file mode 100644 index 0000000000000..0bda7a0316dd4 --- /dev/null +++ b/pkgs/applications/graphics/meshroom/qmlalembic.nix @@ -0,0 +1,46 @@ +{ lib +, stdenv +, cmake +, fetchFromGitHub +, alembic +, qtbase +, qtdeclarative +, qt3d +, wrapQtAppsHook +}: + +stdenv.mkDerivation rec { + pname = "qmlalembic"; + version = "unstable-2023-02-08"; + + src = fetchFromGitHub { + owner = "alicevision"; + repo = pname; + rev = "e9ca28118d649ad4e937a85b1c9d33acc178f533"; + hash = "sha256-5FoQTEEOrfljigo69ucX9Sugu3psbJ6A7aSGsFCmsr4="; + }; + + cmakeFlags = [ + "-DCMAKE_INSTALL_PREFIX=${placeholder "out"}/${qtbase.qtQmlPrefix}/.." + ]; + + nativeBuildInputs = [ + cmake + wrapQtAppsHook + ]; + + buildInputs = [ + alembic.dev + qtbase + qtdeclarative + qt3d + ]; + + meta = { + description = "3D Reconstruction Software"; + homepage = "https://github.com/alicevision/meshroom"; + license = lib.licenses.mpl20; + platforms = lib.platforms.all; + maintainers = with lib.maintainers; [ tmarkus ]; + }; +} diff --git a/pkgs/applications/graphics/meshroom/qtalicevision.nix b/pkgs/applications/graphics/meshroom/qtalicevision.nix new file mode 100644 index 0000000000000..9acf65c7464fb --- /dev/null +++ b/pkgs/applications/graphics/meshroom/qtalicevision.nix @@ -0,0 +1,51 @@ +{ lib +, stdenv +, cmake +, fetchFromGitHub +, alice-vision +, qtbase +, qtdeclarative +, qt3d +, qtcharts +, qttools +, wrapQtAppsHook +}: + +stdenv.mkDerivation rec { + pname = "qtalicevision"; + version = "unstable-2023-01-18"; + + src = fetchFromGitHub { + owner = "alicevision"; + repo = pname; + rev = "cba5efc6fc933206c147a10f079c427534bf2599"; + hash = "sha256-2nZctjGxTHK9mq8yOgqCpPwe/+KS7e7sML4F++a89GI="; + }; + + cmakeFlags = [ + "-DCMAKE_INSTALL_PREFIX=${placeholder "out"}/${qtbase.qtQmlPrefix}/.." + ]; + + nativeBuildInputs = [ + cmake + wrapQtAppsHook + qttools + ]; + + buildInputs = [ + alice-vision + qtbase + qtdeclarative + qt3d + qtcharts + # tbb_2021_8 + ]; + + meta = { + description = "3D Reconstruction Software"; + homepage = "https://github.com/alicevision/meshroom"; + license = lib.licenses.mpl20; + platforms = lib.platforms.all; + maintainers = with lib.maintainers; [ tmarkus ]; + }; +} diff --git a/pkgs/development/libraries/alice-vision/FindClp.cmake b/pkgs/development/libraries/alice-vision/FindClp.cmake new file mode 100644 index 0000000000000..c669f682ef3ae --- /dev/null +++ b/pkgs/development/libraries/alice-vision/FindClp.cmake @@ -0,0 +1,21 @@ +find_package(PkgConfig QUIET) +if(PKG_CONFIG_FOUND) + pkg_check_modules(PC_CLP IMPORTED_TARGET clp) + + add_library(Coin::Clp ALIAS PkgConfig::PC_CLP) +endif() + +find_path(CLP_INCLUDE_DIRS + NAMES ClpConfig.h + HINTS ${PC_CLP_INCLUDE_DIRS}) + +if (EXISTS "${CLP_INCLUDE_DIRS}/ClpConfig.h") + file(STRINGS "${CLP_INCLUDE_DIRS}/ClpConfig.h" clp_version_str REGEX "^#define[\t ]+CLP_VERSION[\t ]+\".*\"") + string(REGEX REPLACE "^#define[\t ]+CLP_VERSION[\t ]+\"([^\"]*)\".*" "\\1" Clp_VERSION "${clp_version_str}") +endif() + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Clp + REQUIRED_VARS CLP_INCLUDE_DIRS + VERSION_VAR Clp_VERSION + ) diff --git a/pkgs/development/libraries/alice-vision/FindCoinUtils.cmake b/pkgs/development/libraries/alice-vision/FindCoinUtils.cmake new file mode 100644 index 0000000000000..93e0aec630cfc --- /dev/null +++ b/pkgs/development/libraries/alice-vision/FindCoinUtils.cmake @@ -0,0 +1,21 @@ +find_package(PkgConfig QUIET) +if(PKG_CONFIG_FOUND) + pkg_check_modules(PC_COINUTILS IMPORTED_TARGET coinutils) + + add_library(Coin::CoinUtils ALIAS PkgConfig::PC_COINUTILS) +endif() + +find_path(COINUTILS_INCLUDE_DIRS + NAMES CoinUtilsConfig.h + HINTS ${PC_COINUTILS_INCLUDE_DIRS}) + +if (EXISTS "${COINUTILS_INCLUDE_DIRS}/CoinUtilsConfig.h") + file(STRINGS "${COINUTILS_INCLUDE_DIRS}/CoinUtilsConfig.h" coinutils_version_str REGEX "^#define[\t ]+COINUTILS_VERSION[\t ]+\".*\"") + string(REGEX REPLACE "^#define[\t ]+COINUTILS_VERSION[\t ]+\"([^\"]*)\".*" "\\1" CoinUtils_VERSION "${coinutils_version_str}") +endif() + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(CoinUtils + REQUIRED_VARS COINUTILS_INCLUDE_DIRS + VERSION_VAR CoinUtils_VERSION + ) diff --git a/pkgs/development/libraries/alice-vision/FindOsi.cmake b/pkgs/development/libraries/alice-vision/FindOsi.cmake new file mode 100644 index 0000000000000..1aa5fa8d41ba6 --- /dev/null +++ b/pkgs/development/libraries/alice-vision/FindOsi.cmake @@ -0,0 +1,22 @@ +find_package(PkgConfig QUIET) +if(PKG_CONFIG_FOUND) + pkg_check_modules(PC_OSI IMPORTED_TARGET osi) + + add_library(Coin::Osi ALIAS PkgConfig::PC_OSI) +endif() + +find_path(OSI_INCLUDE_DIRS + NAMES OsiConfig.h + HINTS ${PC_OSI_INCLUDE_DIRS}) + +if (EXISTS "${OSI_INCLUDE_DIRS}/OsiConfig.h") + file(STRINGS "${OSI_INCLUDE_DIRS}/OsiConfig.h" osi_version_str REGEX "^#define[\t ]+OSI_VERSION[\t ]+\".*\"") + string(REGEX REPLACE "^#define[\t ]+OSI_VERSION[\t ]+\"([^\"]*)\".*" "\\1" Osi_VERSION "${osi_version_str}") +endif() + + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Osi + REQUIRED_VARS OSI_INCLUDE_DIRS + VERSION_VAR Osi_VERSION + ) diff --git a/pkgs/development/libraries/alice-vision/cmake-disable-optimize-for-architecture.patch b/pkgs/development/libraries/alice-vision/cmake-disable-optimize-for-architecture.patch new file mode 100644 index 0000000000000..737bf0c65eafd --- /dev/null +++ b/pkgs/development/libraries/alice-vision/cmake-disable-optimize-for-architecture.patch @@ -0,0 +1,12 @@ +diff --git a/nix/store/ipz4izl82p822flysklls9bnm686ay14-source/src/CMakeLists.txt b/pkgs/applications/graphics/alice-vision/CMakeLists.txt +index 118281d65cb..85b15586452 100644 +--- a/src/CMakeLists.txt ++++ b/src/CMakeLists.txt +@@ -178,7 +178,6 @@ endif() + set(CMAKE_MODULE_PATH + ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake) + include(OptimizeForArchitecture) +-OptimizeForArchitecture() + set(ALICEVISION_HAVE_SSE 0) + if(SSE2_FOUND OR TARGET_ARCHITECTURE STREQUAL "native") + if(MSVC AND NOT ${CMAKE_CL_64}) diff --git a/pkgs/development/libraries/alice-vision/default.nix b/pkgs/development/libraries/alice-vision/default.nix new file mode 100644 index 0000000000000..cb18597de92c1 --- /dev/null +++ b/pkgs/development/libraries/alice-vision/default.nix @@ -0,0 +1,144 @@ +{ lib +, stdenv +, fetchFromGitHub +, cmake +, pkg-config + +, alembic +, assimp +, boost +, ceres-solver +, clp +, cctag +, eigen +, flann +, geogram +, lemon-graph +, nanoflann +, opencv +, openexr +, openimageio +, zlib +}: + +stdenv.mkDerivation rec { + pname = "alice-vision"; + version = "unstable-2023-02-07"; + + outputs = [ "lib" "dev" "out" ]; + + src = fetchFromGitHub { + owner = "alicevision"; + repo = "AliceVision"; + rev = "ad8f3c2b6b32fa64153d98f6d293219011086b1d"; + hash = "sha256-iCN7mvlLlKn0Ub0jhgvk6nxXbMo6VcMZD4EWy3xu50o="; + }; + + # Instead of using dependencies from Git submodules, we use Nix packages + # This speeds up fetching and reduces the source archive size + # + # Upstream uses patched Clp/Osi/CoinUtils containing CMake build scripts. + # Instead of the patched versions, we re-use our packages and add CMake + # find modules that use the pkg-config files already generated by those + # dependencies. + postPatch = + let + findModules = [ + ./FindClp.cmake + ./FindOsi.cmake + ./FindCoinUtils.cmake + ]; + in + '' + rmdir src/dependencies/nanoflann + ln -s ${nanoflann} src/dependencies/nanoflann + + mkdir modules + cp ${./FindClp.cmake} modules/FindClp.cmake + cp ${./FindOsi.cmake} modules/FindOsi.cmake + cp ${./FindCoinUtils.cmake} modules/FindCoinUtils.cmake + + substituteInPlace src/CMakeLists.txt \ + --replace 'cmake_minimum_required(VERSION 3.11)' 'cmake_minimum_required(VERSION 3.11)''\nlist(PREPEND CMAKE_MODULE_PATH ''${CMAKE_CURRENT_SOURCE_DIR}/../modules)' \ + ''; + + patches = [ + # Don't optimize for the host processor (could lead to reproducibility issues) + ./cmake-disable-optimize-for-architecture.patch + ]; + + cmakeFlags = [ + # Disable most binaries - most of them don't build due to compile errors + "-DALICEVISION_BUILD_DOC=OFF" + "-DALICEVISION_BUILD_TESTS=OFF" + "-DALICEVISION_BUILD_EXAMPLES=OFF" + "-DALICEVISION_BUILD_SOFTWARE=OFF" + + "-DALICEVISION_USE_OPENCV=ON" + "-DALICEVISION_USE_OPENCV_CONTRIB=ON" + "-DALICEVISION_USE_CCTAG=ON" + # Could be enabled, but does not compile as of v2.4.0 (upstream bug) + # "-DALICEVISION_USE_OCVSIFT=ON" + "-DALICEVISION_USE_ALEMBIC=ON" + + "-DALICEVISION_USE_UNCERTAINTYTE=OFF" + "-DALICEVISION_USE_APRILTAG=OFF" + "-DALICEVISION_USE_CUDA=OFF" + "-DALICEVISION_USE_MESHSDFILTER=OFF" + "-DALICEVISION_USE_POPSIFT=OFF" + "-DALICEVISION_USE_OPENGV=OFF" + + "-DALICEVISION_REQUIRE_CERES_WITH_SUITESPARSE=ON" + + # Note: Don't explicitly set ALICEVISION_USE_INTERNAL_FLANN or ALICEVISION_USE_INTERNAL_LEMON + # to OFF, as that will cause the opposite effect since the CMake script only checks whether these + # variables are defined (instead of picking up their value). + + "-DFLANN_INCLUDE_DIR_HINTS=${flann}" + "-DLEMON_INCLUDE_DIR_HINTS=${lemon-graph}" + ]; + + # Remove third-party dependency headers + postInstall = '' + mv $out/share $dev + mv $out/include/aliceVision/* $dev/include/aliceVision + mv $out/include/aliceVision_dependencies $dev/include + rmdir $out/include/aliceVision + rmdir $out/include + ''; + + nativeBuildInputs = [ + cmake + pkg-config + ]; + + buildInputs = [ + assimp + eigen + flann + geogram + lemon-graph + nanoflann + openexr + ]; + + propagatedBuildInputs = [ + alembic + boost + cctag + ceres-solver + clp + opencv + openimageio + zlib + ]; + + meta = with lib; { + description = "Photogrammetric Computer Vision Framework which provides a 3D Reconstruction and Camera Tracking algorithms"; + homepage = "https://alicevision.org"; + downloadPage = "https://github.com/alicevision/AliceVision"; + license = with licenses; [ mpl20 mit ]; + maintainers = with maintainers; [ tmarkus ]; + }; +} + diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index ec05450002f13..2c84f50f9ffff 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -19224,6 +19224,8 @@ with pkgs; alass = callPackage ../applications/video/alass { }; + alice-vision = callPackage ../development/libraries/alice-vision { }; + allegro = allegro4; allegro4 = callPackage ../development/libraries/allegro { }; allegro5 = callPackage ../development/libraries/allegro/5.nix { }; @@ -39768,4 +39770,6 @@ with pkgs; zf = callPackage ../tools/misc/zf { }; isolate = callPackage ../tools/security/isolate { }; + + meshroom = libsForQt5.callPackage ../applications/graphics/meshroom { }; }