Skip to content

Commit 933edf0

Browse files
author
Isidor Zeuner
committed
alice-vision: init at 3.0.0, add 3.1.0
1 parent 3c193c9 commit 933edf0

File tree

5 files changed

+403
-0
lines changed

5 files changed

+403
-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: 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+
+ )
Lines changed: 232 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,232 @@
1+
{ lib
2+
, stdenv
3+
, fetchFromGitHub
4+
, cmake
5+
, pkg-config
6+
7+
, pkgs
8+
9+
, assimp
10+
# use the same boost as in cctag here
11+
, boost179
12+
, ceres-solver
13+
, clp
14+
, eigen
15+
, expat
16+
, flann
17+
, geogram
18+
, lemon-graph
19+
, lz4
20+
, onnxruntime
21+
, openexr
22+
, openimageio
23+
, zlib
24+
25+
, enableOpenMP ? true
26+
# Separate openmp input only required on Darwin stdenv (LLVM)
27+
, openmp
28+
29+
, enableAlembic ? true, alembic
30+
, enableCctag ? true, cctag
31+
, enableOpenCV ? true, enableOpenCVContrib ? enableOpenCV, opencv
32+
}:
33+
34+
let
35+
nanoflann = pkgs.nanoflann.overrideAttrs (
36+
oldAttrs: rec {
37+
version = "1.4.2";
38+
src = fetchFromGitHub {
39+
owner = "jlblancoc";
40+
repo = "nanoflann";
41+
rev = "v${version}";
42+
hash = "sha256-znIX1S0mfOqLYPIcyVziUM1asBjENPEAdafLud1CfFI=";
43+
};
44+
}
45+
);
46+
in
47+
stdenv.mkDerivation rec {
48+
pname = "alice-vision";
49+
version = "3.1.0";
50+
51+
outputs = [ "out" "dev" ];
52+
53+
src = fetchFromGitHub {
54+
owner = "alicevision";
55+
repo = "AliceVision";
56+
rev = "v${version}";
57+
hash = "sha256-9PSXyygBr5cWutt+qnJvDawyxpTHxJFfRYLvyr43IlQ=";
58+
};
59+
60+
nativeBuildInputs = [
61+
cmake
62+
pkg-config
63+
];
64+
65+
buildInputs = [
66+
flann
67+
nanoflann
68+
onnxruntime
69+
openexr
70+
71+
# Temporary fix until flann 1.9.2 is in Nixpkgs
72+
lz4
73+
];
74+
75+
propagatedBuildInputs = [
76+
assimp
77+
boost179
78+
ceres-solver
79+
clp
80+
eigen
81+
expat
82+
geogram
83+
lemon-graph
84+
openimageio
85+
zlib
86+
] ++ lib.optional enableAlembic alembic
87+
++ lib.optional enableCctag cctag
88+
++ lib.optional enableOpenCV opencv
89+
++ lib.optional stdenv.cc.isClang openmp;
90+
91+
patches = [
92+
# Don't optimize for the host processor (could lead to reproducibility issues)
93+
./cmake-disable-optimize-for-architecture.patch
94+
95+
# Upstream uses patched Clp/Osi/CoinUtils containing CMake build scripts.
96+
# Instead of the patched versions, we re-use our packages and add CMake
97+
# find modules that use the pkg-config files already generated by those
98+
# dependencies.
99+
./find-coin-modules.patch
100+
101+
./find-flann.patch
102+
];
103+
104+
# Instead of using dependencies from Git submodules, we use Nix packages
105+
# This speeds up fetching and reduces the source archive size
106+
postPatch = ''
107+
rmdir src/dependencies/nanoflann
108+
ln -s ${nanoflann} src/dependencies/nanoflann
109+
110+
rm -r src/dependencies/lemon
111+
rm -r src/dependencies/flann
112+
113+
rm src/cmake/FindFlann.cmake
114+
115+
substituteInPlace src/CMakeLists.txt \
116+
--replace 'if(NOT EXISTS ''${CMAKE_CURRENT_SOURCE_DIR}/dependencies/flann/src)' 'if(FALSE)'
117+
118+
substituteInPlace src/aliceVision/matching/CMakeLists.txt \
119+
--replace ' ''${FLANN_LIBRARY}' ' flann::flann_cpp' \
120+
--replace \
121+
'alicevision_add_test(matching_test.cpp NAME "matching" LINKS aliceVision_matching)' \
122+
'alicevision_add_test(matching_test.cpp NAME "matching" LINKS aliceVision_matching lz4)'
123+
'';
124+
125+
# Disable warning causing compile error on certain Clang versions
126+
CXXFLAGS = lib.optionalString stdenv.cc.isClang "-Wno-c++11-narrowing";
127+
128+
cmakeFlags =
129+
let
130+
cmakeOption = name: enabled: "-D${name}:BOOL=" + (if enabled then "ON" else "OFF");
131+
in
132+
lib.mapAttrsToList (name: cmakeOption "ALICEVISION_USE_${lib.toUpper (lib.removePrefix "enable" name)}") {
133+
inherit enableAlembic enableCctag enableOpenCV enableOpenMP;
134+
135+
enableApriltag = false;
136+
enableMeshSDFilter = false;
137+
enableOpenGV = false;
138+
139+
enableCuda = false;
140+
enablePopsift = false;
141+
enableUncertaintyTE = false;
142+
143+
enableOpenCV_Contrib = enableOpenCVContrib;
144+
145+
# Could be enabled, but does not compile as of v2.4.0 (upstream bug)
146+
enableOcvsift = false;
147+
} ++ lib.mapAttrsToList cmakeOption {
148+
ALICEVISION_BUILD_DEPENDENCIES = false;
149+
150+
# Disable most binaries - most of them don't build due to compile errors
151+
ALICEVISION_BUILD_DOC = false;
152+
ALICEVISION_BUILD_EXAMPLES = false;
153+
ALICEVISION_BUILD_SOFTWARE = true;
154+
# CCTag package does not support alignment yet, and this must be
155+
# consistent between both packages
156+
AV_EIGEN_MEMORY_ALIGNMENT = ! enableCctag;
157+
158+
ALICEVISION_BUILD_TESTS = doCheck;
159+
160+
ALICEVISION_REQUIRE_CERES_WITH_SUITESPARSE = true;
161+
} ++ [
162+
# Note: Don't explicitly set ALICEVISION_USE_INTERNAL_FLANN or ALICEVISION_USE_INTERNAL_LEMON
163+
# to OFF, as that will cause the opposite effect since the CMake script only checks whether these
164+
# variables are defined (instead of picking up their value).
165+
166+
"-DFLANN_INCLUDE_DIR_HINTS:PATH=${flann}"
167+
"-DLEMON_INCLUDE_DIR_HINTS:PATH=${lemon-graph}"
168+
];
169+
170+
# Remove third-party dependency headers
171+
postInstall = ''
172+
# do not move away the embedded OCIO configuration file to allow the
173+
# binaries to be used
174+
# mv $out/share $dev
175+
mv $out/include/aliceVision/* $dev/include/aliceVision
176+
mv $out/include/aliceVision_dependencies $dev/include
177+
rmdir $out/include/aliceVision
178+
rmdir $out/include
179+
'';
180+
181+
doCheck = true;
182+
183+
checkPhase =
184+
let
185+
disabledTests = [
186+
# sfm_panorama tests hang
187+
"^test_aliceVision_test_sfm_panorama_(radial3|equidistant)(_outliers)?$"
188+
189+
# Broken due to lz4 linking issue
190+
"^test_aliceVision_test_matching$"
191+
192+
# Tests that can take a long time (>30 seconds) to run
193+
"^test_aliceVision_test_hdr_(debevec|laguerre|grossberg)$"
194+
195+
"^test_aliceVision_test_voctree_kmeans$"
196+
197+
] ++ lib.optionals stdenv.isDarwin [
198+
# Regular timeouts
199+
"^test_aliceVision_test_colorHarmonization_gainOffsetConstraintBuilder$"
200+
"^test_aliceVision_test_image$"
201+
"^test_aliceVision_test_features$"
202+
"^test_aliceVision_test_robustEstimation_acRansac$"
203+
204+
# Fails on Darwin
205+
"^test_aliceVision_test_voctree_vocabularyTree$"
206+
];
207+
excludeRegex = lib.concatStringsSep "|" disabledTests;
208+
exclude = "--exclude-regex ${lib.escapeShellArg excludeRegex}";
209+
in
210+
''
211+
runHook preCheck
212+
213+
${lib.optionalString stdenv.isDarwin ''
214+
export DYLD_LIBRARY_PATH="${lib.getLib geogram}/lib:$(pwd)"
215+
''}
216+
217+
ctest \
218+
--force-new-ctest-process \
219+
--timeout 120 \
220+
${exclude}
221+
222+
runHook postCheck
223+
'';
224+
225+
meta = with lib; {
226+
description = "Photogrammetric Computer Vision Framework which provides a 3D Reconstruction and Camera Tracking algorithms";
227+
homepage = "https://alicevision.org";
228+
downloadPage = "https://github.com/alicevision/AliceVision";
229+
license = with licenses; [ mpl20 mit bsd2 ];
230+
maintainers = with maintainers; [ tmarkus gm6k ];
231+
};
232+
}

0 commit comments

Comments
 (0)