Skip to content

Commit d7f0ec3

Browse files
committed
alice-vision: init at 3.0.0
1 parent 8266baf commit d7f0ec3

File tree

5 files changed

+370
-0
lines changed

5 files changed

+370
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
diff --git a/nix/store/ipz4izl82p822flysklls9bnm686ay14-source/src/CMakeLists.txt b/pkgs/applications/graphics/alice-vision/CMakeLists.txt
2+
index 118281d65cb..85b15586452 100644
3+
--- a/src/CMakeLists.txt
4+
+++ b/src/CMakeLists.txt
5+
@@ -178,7 +178,6 @@ endif()
6+
set(CMAKE_MODULE_PATH
7+
${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
8+
include(OptimizeForArchitecture)
9+
-OptimizeForArchitecture()
10+
set(ALICEVISION_HAVE_SSE 0)
11+
if(SSE2_FOUND OR TARGET_ARCHITECTURE STREQUAL "native")
12+
if(MSVC AND NOT ${CMAKE_CL_64})
Lines changed: 208 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,208 @@
1+
{ lib
2+
, stdenv
3+
, fetchFromGitHub
4+
, cmake
5+
, pkg-config
6+
7+
, assimp
8+
, boost
9+
, ceres-solver
10+
, clp
11+
, eigen
12+
, expat
13+
, flann
14+
, geogram
15+
, lemon-graph
16+
, lz4
17+
, nanoflann
18+
, openexr
19+
, openimageio
20+
, zlib
21+
22+
, enableOpenMP ? true
23+
# Separate openmp input only required on Darwin stdenv (LLVM)
24+
, openmp
25+
26+
, enableAlembic ? true, alembic
27+
, enableCctag ? true, cctag
28+
, enableOpenCV ? true, enableOpenCVContrib ? enableOpenCV, opencv
29+
}:
30+
31+
stdenv.mkDerivation rec {
32+
pname = "alice-vision";
33+
version = "3.0.0";
34+
35+
outputs = [ "out" "dev" ];
36+
37+
src = fetchFromGitHub {
38+
owner = "alicevision";
39+
repo = "AliceVision";
40+
rev = "v${version}";
41+
hash = "sha256-rFd2AFtvC1RugKGv4tI2k3rtDqXHjdDC3pgOrqDqIT0=";
42+
};
43+
44+
nativeBuildInputs = [
45+
cmake
46+
pkg-config
47+
];
48+
49+
buildInputs = [
50+
flann
51+
nanoflann
52+
openexr
53+
54+
# Temporary fix until flann 1.9.2 is in Nixpkgs
55+
lz4
56+
];
57+
58+
propagatedBuildInputs = [
59+
assimp
60+
boost
61+
ceres-solver
62+
clp
63+
eigen
64+
expat
65+
geogram
66+
lemon-graph
67+
openimageio
68+
zlib
69+
] ++ lib.optional enableAlembic alembic
70+
++ lib.optional enableCctag cctag
71+
++ lib.optional enableOpenCV opencv
72+
++ lib.optional stdenv.cc.isClang openmp;
73+
74+
patches = [
75+
# Don't optimize for the host processor (could lead to reproducibility issues)
76+
./cmake-disable-optimize-for-architecture.patch
77+
78+
# Upstream uses patched Clp/Osi/CoinUtils containing CMake build scripts.
79+
# Instead of the patched versions, we re-use our packages and add CMake
80+
# find modules that use the pkg-config files already generated by those
81+
# dependencies.
82+
./find-coin-modules.patch
83+
84+
./find-flann.patch
85+
];
86+
87+
# Instead of using dependencies from Git submodules, we use Nix packages
88+
# This speeds up fetching and reduces the source archive size
89+
postPatch = ''
90+
rmdir src/dependencies/nanoflann
91+
ln -s ${nanoflann} src/dependencies/nanoflann
92+
93+
rm -r src/dependencies/lemon
94+
rm -r src/dependencies/flann
95+
96+
rm src/cmake/FindFlann.cmake
97+
98+
substituteInPlace src/CMakeLists.txt \
99+
--replace 'if(NOT EXISTS ''${CMAKE_CURRENT_SOURCE_DIR}/dependencies/flann/src)' 'if(FALSE)'
100+
101+
substituteInPlace src/aliceVision/matching/CMakeLists.txt \
102+
--replace ' ''${FLANN_LIBRARY}' ' flann::flann_cpp' \
103+
--replace \
104+
'alicevision_add_test(matching_test.cpp NAME "matching" LINKS aliceVision_matching)' \
105+
'alicevision_add_test(matching_test.cpp NAME "matching" LINKS aliceVision_matching lz4)'
106+
'';
107+
108+
# Disable warning causing compile error on certain Clang versions
109+
CXXFLAGS = lib.optionalString stdenv.cc.isClang "-Wno-c++11-narrowing";
110+
111+
cmakeFlags =
112+
let
113+
cmakeOption = name: enabled: "-D${name}:BOOL=" + (if enabled then "ON" else "OFF");
114+
in
115+
lib.mapAttrsToList (name: cmakeOption "ALICEVISION_USE_${lib.toUpper (lib.removePrefix "enable" name)}") {
116+
inherit enableAlembic enableCctag enableOpenCV enableOpenMP;
117+
118+
enableApriltag = false;
119+
enableMeshSDFilter = false;
120+
enableOpenGV = false;
121+
122+
enableCuda = false;
123+
enablePopsift = false;
124+
enableUncertaintyTE = false;
125+
126+
enableOpenCV_Contrib = enableOpenCVContrib;
127+
128+
# Could be enabled, but does not compile as of v2.4.0 (upstream bug)
129+
enableOcvsift = false;
130+
} ++ lib.mapAttrsToList cmakeOption {
131+
ALICEVISION_BUILD_DEPENDENCIES = false;
132+
133+
# Disable most binaries - most of them don't build due to compile errors
134+
ALICEVISION_BUILD_DOC = false;
135+
ALICEVISION_BUILD_EXAMPLES = false;
136+
ALICEVISION_BUILD_SOFTWARE = false;
137+
138+
ALICEVISION_BUILD_TESTS = doCheck;
139+
140+
ALICEVISION_REQUIRE_CERES_WITH_SUITESPARSE = true;
141+
} ++ [
142+
# Note: Don't explicitly set ALICEVISION_USE_INTERNAL_FLANN or ALICEVISION_USE_INTERNAL_LEMON
143+
# to OFF, as that will cause the opposite effect since the CMake script only checks whether these
144+
# variables are defined (instead of picking up their value).
145+
146+
"-DFLANN_INCLUDE_DIR_HINTS:PATH=${flann}"
147+
"-DLEMON_INCLUDE_DIR_HINTS:PATH=${lemon-graph}"
148+
];
149+
150+
# Remove third-party dependency headers
151+
postInstall = ''
152+
mv $out/share $dev
153+
mv $out/include/aliceVision/* $dev/include/aliceVision
154+
mv $out/include/aliceVision_dependencies $dev/include
155+
rmdir $out/include/aliceVision
156+
rmdir $out/include
157+
'';
158+
159+
doCheck = true;
160+
161+
checkPhase =
162+
let
163+
disabledTests = [
164+
# sfm_panorama tests hang
165+
"^test_aliceVision_test_sfm_panorama_(radial3|equidistant)(_outliers)?$"
166+
167+
# Broken due to lz4 linking issue
168+
"^test_aliceVision_test_matching$"
169+
170+
# Tests that can take a long time (>30 seconds) to run
171+
"^test_aliceVision_test_hdr_(debevec|laguerre|grossberg)$"
172+
173+
"^test_aliceVision_test_voctree_kmeans$"
174+
] ++ lib.optionals stdenv.isDarwin [
175+
# Regular timeouts
176+
"^test_aliceVision_test_colorHarmonization_gainOffsetConstraintBuilder$"
177+
"^test_aliceVision_test_image$"
178+
"^test_aliceVision_test_features$"
179+
180+
# Fails on Darwin
181+
"^test_aliceVision_test_voctree_vocabularyTree$"
182+
];
183+
excludeRegex = lib.concatStringsSep "|" disabledTests;
184+
exclude = "--exclude-regex ${lib.escapeShellArg excludeRegex}";
185+
in
186+
''
187+
runHook preCheck
188+
189+
${lib.optionalString stdenv.isDarwin ''
190+
export DYLD_LIBRARY_PATH="${lib.getLib geogram}/lib:$(pwd)"
191+
''}
192+
193+
ctest \
194+
--force-new-ctest-process \
195+
--timeout 120 \
196+
${exclude}
197+
198+
runHook postCheck
199+
'';
200+
201+
meta = with lib; {
202+
description = "Photogrammetric Computer Vision Framework which provides a 3D Reconstruction and Camera Tracking algorithms";
203+
homepage = "https://alicevision.org";
204+
downloadPage = "https://github.com/alicevision/AliceVision";
205+
license = with licenses; [ mpl20 mit bsd2 ];
206+
maintainers = with maintainers; [ tmarkus ];
207+
};
208+
}
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
--- a/src/CMakeLists.txt 1970-01-01 01:00:01.000000000 +0100
2+
+++ b/src/CMakeLists.txt 2023-04-03 16:32:16.994922955 +0200
3+
@@ -1,5 +1,7 @@
4+
cmake_minimum_required(VERSION 3.11)
5+
6+
+list(PREPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../modules)
7+
+
8+
# ==============================================================================
9+
# AliceVision version
10+
# ==============================================================================
11+
@@ -433,6 +435,7 @@
12+
find_package(CoinUtils REQUIRED)
13+
find_package(Clp REQUIRED)
14+
find_package(Osi REQUIRED)
15+
+ find_package(OsiClp REQUIRED)
16+
endif()
17+
18+
# ==============================================================================
19+
--- a/src/aliceVision/linearProgramming/CMakeLists.txt 1970-01-01 01:00:01.000000000 +0100
20+
+++ b/src/aliceVision/linearProgramming/CMakeLists.txt 2023-04-03 16:33:09.883053876 +0200
21+
@@ -13,6 +13,7 @@
22+
Coin::Clp # clp + solver wrapper
23+
Coin::CoinUtils # container tools
24+
Coin::Osi # generic LP
25+
+ Coin::OsiClp
26+
)
27+
28+
if (NOT MOSEK_FOUND)
29+
--- /dev/null 2023-03-27 18:27:39.858686170 +0200
30+
+++ b/modules/FindCoinUtils.cmake 2023-04-03 16:12:16.146494958 +0200
31+
@@ -0,0 +1,21 @@
32+
+find_package(PkgConfig REQUIRED)
33+
+if(PKG_CONFIG_FOUND)
34+
+ pkg_check_modules(PC_COINUTILS REQUIRED IMPORTED_TARGET coinutils)
35+
+
36+
+ add_library(Coin::CoinUtils ALIAS PkgConfig::PC_COINUTILS)
37+
+endif()
38+
+
39+
+find_path(COINUTILS_INCLUDE_DIRS
40+
+ NAMES CoinUtilsConfig.h
41+
+ HINTS ${PC_COINUTILS_INCLUDE_DIRS})
42+
+
43+
+if (EXISTS "${COINUTILS_INCLUDE_DIRS}/CoinUtilsConfig.h")
44+
+ file(STRINGS "${COINUTILS_INCLUDE_DIRS}/CoinUtilsConfig.h" coinutils_version_str REGEX "^#define[\t ]+COINUTILS_VERSION[\t ]+\".*\"")
45+
+ string(REGEX REPLACE "^#define[\t ]+COINUTILS_VERSION[\t ]+\"([^\"]*)\".*" "\\1" CoinUtils_VERSION "${coinutils_version_str}")
46+
+endif()
47+
+
48+
+include(FindPackageHandleStandardArgs)
49+
+find_package_handle_standard_args(CoinUtils
50+
+ REQUIRED_VARS COINUTILS_INCLUDE_DIRS
51+
+ VERSION_VAR CoinUtils_VERSION
52+
+ )
53+
--- /dev/null 2023-03-27 18:27:39.858686170 +0200
54+
+++ b/modules/FindClp.cmake 2023-04-03 16:12:16.146494958 +0200
55+
@@ -0,0 +1,21 @@
56+
+find_package(PkgConfig REQUIRED)
57+
+if(PKG_CONFIG_FOUND)
58+
+ pkg_check_modules(PC_CLP REQUIRED IMPORTED_TARGET clp)
59+
+
60+
+ add_library(Coin::Clp ALIAS PkgConfig::PC_CLP)
61+
+endif()
62+
+
63+
+find_path(CLP_INCLUDE_DIRS
64+
+ NAMES ClpConfig.h
65+
+ HINTS ${PC_CLP_INCLUDE_DIRS})
66+
+
67+
+if (EXISTS "${CLP_INCLUDE_DIRS}/ClpConfig.h")
68+
+ file(STRINGS "${CLP_INCLUDE_DIRS}/ClpConfig.h" clp_version_str REGEX "^#define[\t ]+CLP_VERSION[\t ]+\".*\"")
69+
+ string(REGEX REPLACE "^#define[\t ]+CLP_VERSION[\t ]+\"([^\"]*)\".*" "\\1" Clp_VERSION "${clp_version_str}")
70+
+endif()
71+
+
72+
+include(FindPackageHandleStandardArgs)
73+
+find_package_handle_standard_args(Clp
74+
+ REQUIRED_VARS CLP_INCLUDE_DIRS
75+
+ VERSION_VAR Clp_VERSION
76+
+ )
77+
--- /dev/null 2023-03-27 18:27:39.858686170 +0200
78+
+++ b/modules/FindOsi.cmake 2023-04-03 16:12:16.147494961 +0200
79+
@@ -0,0 +1,22 @@
80+
+find_package(PkgConfig REQUIRED)
81+
+if(PKG_CONFIG_FOUND)
82+
+ pkg_check_modules(PC_OSI REQUIRED IMPORTED_TARGET osi)
83+
+
84+
+ add_library(Coin::Osi ALIAS PkgConfig::PC_OSI)
85+
+endif()
86+
+
87+
+find_path(OSI_INCLUDE_DIRS
88+
+ NAMES OsiConfig.h
89+
+ HINTS ${PC_OSI_INCLUDE_DIRS})
90+
+
91+
+if (EXISTS "${OSI_INCLUDE_DIRS}/OsiConfig.h")
92+
+ file(STRINGS "${OSI_INCLUDE_DIRS}/OsiConfig.h" osi_version_str REGEX "^#define[\t ]+OSI_VERSION[\t ]+\".*\"")
93+
+ string(REGEX REPLACE "^#define[\t ]+OSI_VERSION[\t ]+\"([^\"]*)\".*" "\\1" Osi_VERSION "${osi_version_str}")
94+
+endif()
95+
+
96+
+
97+
+include(FindPackageHandleStandardArgs)
98+
+find_package_handle_standard_args(Osi
99+
+ REQUIRED_VARS OSI_INCLUDE_DIRS
100+
+ VERSION_VAR Osi_VERSION
101+
+ )
102+
--- /dev/null 2023-03-27 18:27:39.858686170 +0200
103+
+++ b/modules/FindOsiClp.cmake 2023-04-03 16:31:08.255752799 +0200
104+
@@ -0,0 +1,18 @@
105+
+find_package(PkgConfig REQUIRED)
106+
+if(PKG_CONFIG_FOUND)
107+
+ pkg_check_modules(PC_OSI_CLP REQUIRED IMPORTED_TARGET osi-clp)
108+
+
109+
+ add_library(Coin::OsiClp ALIAS PkgConfig::PC_OSI_CLP)
110+
+
111+
+ set(OsiClp_VERSION ${PC_OSI_CLP_VERSION})
112+
+endif()
113+
+
114+
+find_path(OSI_CLP_INCLUDE_DIRS
115+
+ NAMES OsiSolverInterface.hpp
116+
+ HINTS ${PC_OSI_CLP_INCLUDE_DIRS})
117+
+
118+
+include(FindPackageHandleStandardArgs)
119+
+find_package_handle_standard_args(OsiClp
120+
+ REQUIRED_VARS OSI_CLP_INCLUDE_DIRS
121+
+ VERSION_VAR OsiClp_VERSION
122+
+ )
123+
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
--- /dev/null 2023-04-03 16:53:39.918168848 +0200
2+
+++ b/modules/FindFlann.cmake 2023-04-03 21:33:25.433754406 +0200
3+
@@ -0,0 +1,20 @@
4+
+find_package(PkgConfig REQUIRED)
5+
+if(PKG_CONFIG_FOUND)
6+
+ pkg_check_modules(PC_FLANN REQUIRED IMPORTED_TARGET flann)
7+
+ pkg_check_modules(PC_LZ4 REQUIRED IMPORTED_TARGET liblz4)
8+
+
9+
+ add_library(flann::flann_cpp ALIAS PkgConfig::PC_FLANN)
10+
+ set(FLANN_LIBRARY flann::flann_cpp)
11+
+
12+
+ set(FLANN_VERSION ${PC_FLANN_VERSION})
13+
+endif()
14+
+
15+
+find_path(FLANN_INCLUDE_DIRS
16+
+ NAMES flann/flann.hpp
17+
+ HINTS ${PC_FLANN_INCLUDE_DIRS})
18+
+
19+
+include(FindPackageHandleStandardArgs)
20+
+find_package_handle_standard_args(Flann
21+
+ REQUIRED_VARS FLANN_INCLUDE_DIRS
22+
+ VERSION_VAR FLANN_VERSION
23+
+ )

pkgs/top-level/all-packages.nix

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19537,6 +19537,10 @@ with pkgs;
1953719537

1953819538
alass = callPackage ../applications/video/alass { };
1953919539

19540+
alice-vision = callPackage ../development/libraries/alice-vision {
19541+
inherit (llvmPackages) openmp;
19542+
};
19543+
1954019544
allegro = allegro4;
1954119545
allegro4 = callPackage ../development/libraries/allegro { };
1954219546
allegro5 = callPackage ../development/libraries/allegro/5.nix { };

0 commit comments

Comments
 (0)