summary refs log tree commit diff
path: root/pkgs/development/python-modules/opensfm/default.nix
blob: 65931f770a2f3a78ef28e8d847bd414a770b9340 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
{ lib
, stdenv
, buildPythonPackage
, fetchFromGitHub
, fetchpatch
, cmake
, opencv4
, ceres-solver
, suitesparse
, metis
, eigen
, pkg-config
, pybind11
, numpy
, pyyaml
, lapack
, gtest
, gflags
, glog
, pytestCheckHook
, networkx
, pillow
, exifread
, gpxpy
, pyproj
, python-dateutil
, joblib
, repoze_lru
, xmltodict
, cloudpickle
, scipy
, sphinx
, matplotlib
, fpdf
,
}:

let
  ceresSplit = (builtins.length ceres-solver.outputs) > 1;
  ceres' =
    if ceresSplit
    then ceres-solver.dev
    else ceres-solver;
in
buildPythonPackage rec {
  pname = "OpenSfM";
  version = "unstable-2022-03-10";

  src = fetchFromGitHub {
    owner = "mapillary";
    repo = pname;
    rev = "536b6e1414c8a93f0815dbae85d03749daaa5432";
    sha256 = "Nfl20dFF2PKOkIvHbRxu1naU+qhz4whLXJvX5c5Wnwo=";
  };
  patches = [
    ./0002-cmake-find-system-distributed-gtest.patch
    ./0003-cmake-use-system-pybind11.patch
    ./0004-pybind_utils.h-conflicts-with-nixpkgs-pybind.patch
    ./fix-scripts.patch
  ];
  postPatch = ''
    rm opensfm/src/cmake/FindGlog.cmake
    rm opensfm/src/cmake/FindGflags.cmake

    # HAHOG is the default descriptor.
    # We'll test both HAHOG and SIFT because this is
    # where segfaults might be introduced in future
    echo 'feature_type: SIFT' >> data/berlin/config.yaml
    echo 'feature_type: HAHOG' >> data/lund/config.yaml
  '';

  nativeBuildInputs = [ cmake pkg-config sphinx ];
  buildInputs = [
    ceres'
    suitesparse
    metis
    eigen
    lapack
    gflags
    gtest
    glog
    pybind11
  ];
  propagatedBuildInputs = [
    numpy
    scipy
    pyyaml
    opencv4
    networkx
    pillow
    matplotlib
    fpdf
    exifread
    gpxpy
    pyproj
    python-dateutil
    joblib
    repoze_lru
    xmltodict
    cloudpickle
  ];
  nativeCheckInputs = [ pytestCheckHook ];

  dontUseCmakeBuildDir = true;
  cmakeFlags = [
    "-Bcmake_build"
    "-Sopensfm/src"
  ];

  disabledTests = lib.optionals stdenv.isDarwin [
    "test_reconstruction_incremental"
    "test_reconstruction_triangulation"
  ];

  pythonImportsCheck = [ "opensfm" ];

  meta = {
    broken = stdenv.isDarwin;
    maintainers = [ lib.maintainers.SomeoneSerge ];
    license = lib.licenses.bsd2;
    changelog = "https://github.com/mapillary/OpenSfM/blob/${src.rev}/CHANGELOG.md";
    description = "Open source Structure-from-Motion pipeline from Mapillary";
    homepage = "https://opensfm.org/";
  };
}