1{ lib
2, stdenv
3, buildPythonPackage
4, fetchFromGitHub
5, fetchpatch
6, cmake
7, opencv4
8, ceres-solver
9, suitesparse
10, metis
11, eigen
12, pkg-config
13, pybind11
14, numpy
15, pyyaml
16, lapack
17, gtest
18, gflags
19, glog
20, pytestCheckHook
21, networkx
22, pillow
23, exifread
24, gpxpy
25, pyproj
26, python-dateutil
27, joblib
28, repoze_lru
29, xmltodict
30, cloudpickle
31, scipy
32, sphinx
33, matplotlib
34, fpdf
35,
36}:
37
38let
39 ceresSplit = (builtins.length ceres-solver.outputs) > 1;
40 ceres' =
41 if ceresSplit
42 then ceres-solver.dev
43 else ceres-solver;
44in
45buildPythonPackage rec {
46 pname = "OpenSfM";
47 version = "unstable-2022-03-10";
48
49 src = fetchFromGitHub {
50 owner = "mapillary";
51 repo = pname;
52 rev = "536b6e1414c8a93f0815dbae85d03749daaa5432";
53 sha256 = "Nfl20dFF2PKOkIvHbRxu1naU+qhz4whLXJvX5c5Wnwo=";
54 };
55 patches = [
56 ./0002-cmake-find-system-distributed-gtest.patch
57 ./0003-cmake-use-system-pybind11.patch
58 ./0004-pybind_utils.h-conflicts-with-nixpkgs-pybind.patch
59 ./fix-scripts.patch
60 ];
61 postPatch = ''
62 rm opensfm/src/cmake/FindGlog.cmake
63 rm opensfm/src/cmake/FindGflags.cmake
64
65 # HAHOG is the default descriptor.
66 # We'll test both HAHOG and SIFT because this is
67 # where segfaults might be introduced in future
68 echo 'feature_type: SIFT' >> data/berlin/config.yaml
69 echo 'feature_type: HAHOG' >> data/lund/config.yaml
70 '';
71
72 nativeBuildInputs = [ cmake pkg-config sphinx ];
73 buildInputs = [
74 ceres'
75 suitesparse
76 metis
77 eigen
78 lapack
79 gflags
80 gtest
81 glog
82 pybind11
83 ];
84 propagatedBuildInputs = [
85 numpy
86 scipy
87 pyyaml
88 opencv4
89 networkx
90 pillow
91 matplotlib
92 fpdf
93 exifread
94 gpxpy
95 pyproj
96 python-dateutil
97 joblib
98 repoze_lru
99 xmltodict
100 cloudpickle
101 ];
102 checkInputs = [ pytestCheckHook ];
103
104 dontUseCmakeBuildDir = true;
105 cmakeFlags = [
106 "-Bcmake_build"
107 "-Sopensfm/src"
108 ];
109
110 disabledTests = lib.optionals stdenv.isDarwin [
111 "test_reconstruction_incremental"
112 "test_reconstruction_triangulation"
113 ];
114
115 pythonImportsCheck = [ "opensfm" ];
116
117 meta = {
118 broken = stdenv.isDarwin;
119 maintainers = [ lib.maintainers.SomeoneSerge ];
120 license = lib.licenses.bsd2;
121 changelog = "https://github.com/mapillary/OpenSfM/blob/${src.rev}/CHANGELOG.md";
122 description = "Open source Structure-from-Motion pipeline from Mapillary";
123 homepage = "https://opensfm.org/";
124 };
125}