gnu: python-deepmerge: Use pyproject-build-system.
[jackhill/guix/guix.git] / gnu / packages / image-processing.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2017 John Darrington <jmd@gnu.org>
3 ;;; Copyright © 2017, 2019, 2022 Ricardo Wurmus <rekado@elephly.net>
4 ;;; Copyright © 2014, 2021-2022 Ludovic Courtès <ludo@gnu.org>
5 ;;; Copyright © 2014 Mark H Weaver <mhw@netris.org>
6 ;;; Copyright © 2016 Eric Bavier <bavier@member.fsf.org>
7 ;;; Copyright © 2018–2021 Tobias Geerinckx-Rice <me@tobias.gr>
8 ;;; Copyright © 2018 Björn Höfling <bjoern.hoefling@bjoernhoefling.de>
9 ;;; Copyright © 2018 Lprndn <guix@lprndn.info>
10 ;;; Copyright © 2019, 2021 Efraim Flashner <efraim@flashner.co.il>
11 ;;; Copyright © 2020 Vincent Legoll <vincent.legoll@gmail.com>
12 ;;; Copyright © 2020, 2021 Vinicius Monego <monego@posteo.net>
13 ;;; Copyright © 2020 Pierre Neidhardt <mail@ambrevar.xyz>
14 ;;; Copyright © 2020 Brendan Tildesley <mail@brendan.scot>
15 ;;; Copyright © 2021 Oleh Malyi <astroclubzp@gmail.com>
16 ;;; Copyright © 2021, 2022 Felix Gruber <felgru@posteo.net>
17 ;;; Copyright © 2021 Andy Tai <atai@atai.org>
18 ;;; Copyright © 2021 Ekaitz Zarraga <ekaitz@elenq.tech>
19 ;;; Copyright © 2021 Paul Garlick <pgarlick@tourbillion-technology.com>
20 ;;; Copyright © 2021 Guillaume Le Vaillant <glv@posteo.net>
21 ;;; Copyright © 2021 Ivan Gankevich <i.gankevich@spbu.ru>
22 ;;; Copyright © 2022 Maxim Cournoyer <maxim.cournoyer@gmail.com>
23 ;;; Copyright © 2022 Tomasz Jeneralczyk <tj@schwi.pl>
24 ;;;
25 ;;; This file is part of GNU Guix.
26 ;;;
27 ;;; GNU Guix is free software; you can redistribute it and/or modify it
28 ;;; under the terms of the GNU General Public License as published by
29 ;;; the Free Software Foundation; either version 3 of the License, or (at
30 ;;; your option) any later version.
31 ;;;
32 ;;; GNU Guix is distributed in the hope that it will be useful, but
33 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
34 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
35 ;;; GNU General Public License for more details.
36 ;;;
37 ;;; You should have received a copy of the GNU General Public License
38 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
39
40 (define-module (gnu packages image-processing)
41 #:use-module ((guix licenses) #:prefix license:)
42 #:use-module (guix packages)
43 #:use-module (guix gexp)
44 #:use-module (guix utils)
45 #:use-module (guix download)
46 #:use-module (guix git-download)
47 #:use-module (guix build-system qt)
48 #:use-module (guix build-system cmake)
49 #:use-module (guix build-system gnu)
50 #:use-module (guix build-system python)
51 #:use-module (gnu packages)
52 #:use-module (gnu packages algebra)
53 #:use-module (gnu packages bison)
54 #:use-module (gnu packages boost)
55 #:use-module (gnu packages check)
56 #:use-module (gnu packages compression)
57 #:use-module (gnu packages curl)
58 #:use-module (gnu packages docbook)
59 #:use-module (gnu packages documentation)
60 #:use-module (gnu packages flex)
61 #:use-module (gnu packages fontutils)
62 #:use-module (gnu packages geo)
63 #:use-module (gnu packages ghostscript)
64 #:use-module (gnu packages gimp)
65 #:use-module (gnu packages gl)
66 #:use-module (gnu packages glib)
67 #:use-module (gnu packages gnome)
68 #:use-module (gnu packages graphics)
69 #:use-module (gnu packages graphviz)
70 #:use-module (gnu packages gstreamer)
71 #:use-module (gnu packages gtk)
72 #:use-module (gnu packages icu4c)
73 #:use-module (gnu packages image)
74 #:use-module (gnu packages imagemagick)
75 #:use-module (gnu packages linux)
76 #:use-module (gnu packages maths)
77 #:use-module (gnu packages pdf)
78 #:use-module (gnu packages perl)
79 #:use-module (gnu packages photo)
80 #:use-module (gnu packages pkg-config)
81 #:use-module (gnu packages protobuf)
82 #:use-module (gnu packages python)
83 #:use-module (gnu packages python-check)
84 #:use-module (gnu packages python-xyz)
85 #:use-module (gnu packages qt)
86 #:use-module (gnu packages serialization)
87 #:use-module (gnu packages sqlite)
88 #:use-module (gnu packages tbb)
89 #:use-module (gnu packages tls)
90 #:use-module (gnu packages version-control)
91 #:use-module (gnu packages video)
92 #:use-module (gnu packages xiph)
93 #:use-module (gnu packages xml)
94 #:use-module (gnu packages xorg)
95 #:use-module (ice-9 match)
96 #:use-module (srfi srfi-1))
97
98 ;; TODO: this is not reproducible.
99 (define-public bart
100 (package
101 (name "bart")
102 (version "0.7.00")
103 (source
104 (origin
105 (method git-fetch)
106 (uri (git-reference
107 (url "https://github.com/mrirecon/bart")
108 (commit "d1b0e576c3f759089915565d5bf57832acf7b03e")))
109 (file-name (git-file-name name version))
110 (sha256
111 (base32 "159rj3agr9pb9lg38b56rnw3d8wcbkmb2n718z26zpy4c6a6d9rn"))))
112 (build-system gnu-build-system)
113 (arguments
114 (list
115 #:test-target "utest"
116 #:make-flags #~(list
117 (string-append "PREFIX=" #$output)
118 "OPENBLAS=1"
119 "SCALAPACK=1"
120 (string-append "BLAS_BASE=" #$(this-package-input "openblas"))
121 (string-append "FFTW_BASE=" #$(this-package-input "fftw")))
122 #:phases
123 #~(modify-phases %standard-phases
124 (delete 'configure)
125 (add-after 'unpack 'patch-/bin/bash
126 (lambda _
127 (substitute* "tests/pics.mk"
128 (("/bin/bash") (which "bash"))))))))
129 (inputs
130 (list fftw
131 fftwf
132 libpng
133 openblas
134 python
135 scalapack))
136 (native-inputs
137 (list doxygen
138 util-linux)) ;for flock
139 (home-page "https://mrirecon.github.io/bart/")
140 (synopsis "Toolbox for computational magnetic resonance imaging")
141 (description "The Berkeley Advanced Reconstruction Toolbox (BART) is an
142 image-reconstruction framework for Computational Magnetic Resonance Imaging.
143 The tools in this software implement various reconstruction algorithms for
144 Magnetic Resonance Imaging.")
145 (license license:bsd-3)))
146
147 (define-public dcmtk
148 (package
149 (name "dcmtk")
150 (version "3.6.7")
151 (source
152 (origin
153 (method url-fetch)
154 (uri
155 (string-append "ftp://dicom.offis.de/pub/dicom/offis/software/dcmtk/"
156 "dcmtk" (string-join (string-split version #\.) "")
157 "/dcmtk-" version ".tar.gz"))
158 (sha256
159 (base32 "02kix73qhndgb56cmi5327666i6imp7hi17wwqp26q4d7s72jn3w"))))
160 (build-system cmake-build-system)
161 (arguments
162 ;; By default, only static archives are built.
163 (list #:configure-flags #~(list "-DBUILD_SHARED_LIBS=ON")))
164 (inputs
165 (list icu4c
166 libjpeg-turbo
167 libpng
168 libtiff
169 libxml2
170 openssl
171 zlib))
172 (native-inputs
173 (list doxygen)) ; for HTML documentation
174 (home-page "https://dcmtk.org")
175 (synopsis "Libraries and programs implementing parts of the DICOM standard")
176 (description "DCMTK is a collection of libraries and applications
177 implementing large parts the DICOM standard. It includes software for
178 examining, constructing and converting DICOM image files, handling offline
179 media, sending and receiving images over a network connection, as well as
180 demonstrative image storage and worklist servers.")
181 (license (license:fsf-free
182 "file://COPYRIGHT"
183 "A union of the Apache 2.0 licence and various non-copyleft
184 licences similar to the Modified BSD licence."))))
185
186 (define-public mia
187 (package
188 (name "mia")
189 (version "2.4.7")
190 (source (origin
191 (method url-fetch)
192 (uri (string-append "mirror://sourceforge/mia/mia/"
193 (version-major+minor version)
194 "/mia-" version ".tar.xz"))
195 (sha256
196 (base32
197 "0qpcd3n26q52dpyibm11f5l6cgscdr54p2jish39gc3p1f5h3ws1"))
198 (patches (search-patches "mia-fix-boost-headers.patch"
199 "mia-vtk9.patch"))))
200 (build-system cmake-build-system)
201 (arguments
202 `(#:configure-flags
203 (list "-DMIA_CREATE_NIPYPE_INTERFACES=OFF"
204 "-DCMAKE_CXX_FLAGS=-fpermissive")))
205 (inputs
206 (list boost
207 dcmtk
208 doxygen
209 eigen
210 fftw
211 fftwf
212 gsl
213 gts
214 hdf5
215 itpp
216 libjpeg-turbo
217 libpng
218 libtiff
219 libxml2
220 libxml++
221 maxflow
222 niftilib
223 nlopt
224 openexr-2
225 python-lxml
226 vtk))
227 (native-inputs
228 (list pkg-config
229 python-wrapper))
230 (home-page "http://mia.sourceforge.net")
231 (synopsis "Toolkit for gray scale medical image analysis")
232 (description "MIA provides a combination of command line tools, plug-ins,
233 and libraries that make it possible run image processing tasks interactively
234 in a command shell and to prototype using the shell's scripting language. It
235 is built around a plug-in structure that makes it easy to add functionality
236 without compromising the original code base and it makes use of a wide variety
237 of external libraries that provide additional functionality.")
238 (license license:gpl3+)))
239
240 (define-public opencolorio
241 (package
242 (name "opencolorio")
243 (version "1.1.1")
244 (source
245 (origin
246 (method git-fetch)
247 (uri (git-reference
248 (url "https://github.com/AcademySoftwareFoundation/OpenColorIO")
249 (commit (string-append "v" version))))
250 (sha256
251 (base32 "12srvxca51czpfjl0gabpidj9n84mw78ivxy5w75qhq2mmc798sb"))
252 (file-name (git-file-name name version))
253 (modules '((guix build utils)))
254 (snippet
255 `(begin
256 ;; Remove bundled tarballs, patches, and .jars(!). XXX: Upstream
257 ;; claims to have fixed USE_EXTERNAL_YAML, but it still fails with:
258 ;; https://github.com/AcademySoftwareFoundation/OpenColorIO/issues/517
259 ;; When removing it, also remove it from the licence field comment.
260 (for-each delete-file-recursively
261 (filter
262 (lambda (full-name)
263 (let ((file (basename full-name)))
264 (not (or (string-prefix? "yaml-cpp-0.3" file)
265 (string=? "unittest.h" file)))))
266 (find-files "ext" ".*")))
267
268 #t))))
269 (build-system cmake-build-system)
270 (arguments
271 `(#:configure-flags
272 (list (string-append "-DCMAKE_CXX_FLAGS="
273 "-Wno-error=deprecated-declarations "
274 "-Wno-error=unused-function")
275 "-DOCIO_BUILD_STATIC=OFF"
276 ;; "-DUSE_EXTERNAL_YAML=ON"
277 "-DUSE_EXTERNAL_TINYXML=ON"
278 "-DUSE_EXTERNAL_LCMS=ON")
279 #:phases
280 (modify-phases %standard-phases
281 (add-after 'unpack 'patch-test-suite
282 (lambda _
283 (substitute* "src/core_tests/CMakeLists.txt"
284 (("/bin/sh") (which "bash")))
285 #t)))))
286 (native-inputs
287 (list git pkg-config))
288 (inputs
289 ;; XXX Adding freeglut, glew, ilmbase, mesa, and openimageio for
290 ;; ocioconvert fails: error: conflicting declaration ?typedef void
291 ;; (* PFNGLGETFRAGMENTMATERIALFVSGIXPROC)(GLenum, GLenum, GLfloat*)
292 (list lcms openexr-2 tinyxml))
293 (home-page "https://opencolorio.org")
294 (synopsis "Color management for visual effects and animation")
295 (description
296 "OpenColorIO, or OCIO, is a complete color management solution geared
297 towards motion picture production, with an emphasis on visual effects and
298 computer animation. It provides a straightforward and consistent user
299 experience across all supporting applications while allowing for sophisticated
300 back-end configuration options suitable for high-end production usage.
301
302 OCIO is compatible with the @acronym{ACES, Academy Color Encoding
303 Specification} and is @acronym{LUT, look-up table}-format agnostic, supporting
304 many popular formats.")
305 (license (list license:expat ; docs/ociotheme/static, ext/yaml-cpp-*
306 license:zlib ; src/core/md5
307 license:bsd-3)))) ; the rest
308
309 (define-public vtk
310 (package
311 (name "vtk")
312 (version "9.0.1")
313 (source (origin
314 (method url-fetch)
315 (uri (string-append "https://vtk.org/files/release/"
316 (version-major+minor version)
317 "/VTK-" version ".tar.gz"))
318 (sha256
319 (base32
320 "1ir2lq9i45ls374lcmjzw0nrm5l5hnm1w47lg8g8d0n2j7hsaf8v"))
321 (patches
322 (search-patches "vtk-fix-freetypetools-build-failure.patch"))
323 (modules '((guix build utils)))
324 (snippet
325 '(begin
326 (for-each
327 (lambda (dir)
328 (delete-file-recursively
329 (string-append "ThirdParty/" dir "/vtk" dir)))
330 ;; pugixml depended upon unconditionally
331 '("doubleconversion" "eigen" "expat" "freetype" "gl2ps"
332 "glew" "hdf5" "jpeg" "jsoncpp" "libharu" "libproj"
333 "libxml2" "lz4" "netcdf" "ogg" "png" "sqlite" "theora"
334 "tiff" "zlib"))
335 (substitute* "IO/ExportPDF/vtkPDFContextDevice2D.cxx"
336 (("\\bHPDF_UINT16 (noPen|dash|dot|denseDot|dashDot|dashDotDot)\\b"
337 _ var)
338 (string-append "HPDF_REAL " var)))))))
339 (properties `((release-monitoring-url . "https://vtk.org/download/")))
340 (build-system cmake-build-system)
341 (arguments
342 '(#:build-type "Release" ;Build without '-g' to save space.
343 #:configure-flags '(;"-DBUILD_TESTING:BOOL=TRUE"
344 ; ; not honored
345 "-DVTK_USE_EXTERNAL=OFF" ;; default
346 "-DVTK_MODULE_USE_EXTERNAL_VTK_doubleconversion=ON"
347 "-DVTK_MODULE_USE_EXTERNAL_VTK_eigen=ON"
348 "-DVTK_MODULE_USE_EXTERNAL_VTK_expat=ON"
349 "-DVTK_MODULE_USE_EXTERNAL_VTK_freetype=ON"
350 "-DVTK_MODULE_USE_EXTERNAL_VTK_gl2ps=ON"
351 "-DVTK_MODULE_USE_EXTERNAL_VTK_glew=ON"
352 "-DVTK_MODULE_USE_EXTERNAL_VTK_hdf5=ON"
353 "-DVTK_MODULE_USE_EXTERNAL_VTK_jpeg=ON"
354 "-DVTK_MODULE_USE_EXTERNAL_VTK_jsoncpp=ON"
355 "-DVTK_MODULE_USE_EXTERNAL_VTK_libharu=ON"
356 "-DVTK_MODULE_USE_EXTERNAL_VTK_libproj=ON"
357 "-DVTK_MODULE_USE_EXTERNAL_VTK_libxml2=ON"
358 "-DVTK_MODULE_USE_EXTERNAL_VTK_lz4=ON"
359 "-DVTK_MODULE_USE_EXTERNAL_VTK_netcdf=ON"
360 "-DVTK_MODULE_USE_EXTERNAL_VTK_ogg=ON"
361 "-DVTK_MODULE_USE_EXTERNAL_VTK_png=ON"
362 ;"-DVTK_MODULE_USE_EXTERNAL_VTK_pugixml=ON" ; breaks IO/CityGML
363 "-DVTK_MODULE_USE_EXTERNAL_VTK_sqlite=ON"
364 "-DVTK_MODULE_USE_EXTERNAL_VTK_theora=ON"
365 "-DVTK_MODULE_USE_EXTERNAL_VTK_tiff=ON"
366 "-DVTK_MODULE_USE_EXTERNAL_VTK_zlib=ON"
367 "-DVTK_MODULE_ENABLE_VTK_RenderingExternal=YES" ; For F3D
368 "-DVTK_WRAP_PYTHON=ON"
369 "-DVTK_PYTHON_VERSION:STRING=3"
370 )
371 #:phases
372 (modify-phases %standard-phases
373 (add-after 'unpack 'patch-sources
374 (lambda _
375 (substitute* "Common/Core/vtkFloatingPointExceptions.cxx"
376 (("<fenv.h>") "<cfenv>"))
377 (substitute* "Common/Core/CMakeLists.txt"
378 (("fenv.h") "cfenv")))))
379 #:tests? #f)) ;XXX: test data not included
380 (inputs
381 (list double-conversion
382 eigen
383 expat
384 freetype
385 gl2ps
386 glew
387 glu
388 hdf5
389 libharu
390 libjpeg-turbo
391 jsoncpp
392 libtheora
393 libx11
394 libxml2
395 libxt
396 lz4
397 mesa
398 netcdf
399 libpng
400 proj-7
401 python
402 ;("pugixml" ,pugixml)
403 sqlite
404 libtiff
405 xorgproto
406 zlib))
407 (propagated-inputs
408 ;; VTK's 'VTK-vtk-module-find-packages.cmake' calls
409 ;; 'find_package(THEORA)', which in turns looks for libogg.
410 (list libogg))
411 (home-page "https://vtk.org/")
412 (synopsis "Libraries for 3D computer graphics")
413 (description
414 "The Visualization Toolkit (VTK) is a C++ library for 3D computer graphics,
415 image processing and visualization. It supports a wide variety of
416 visualization algorithms including: scalar, vector, tensor, texture, and
417 volumetric methods; and advanced modeling techniques such as: implicit
418 modeling, polygon reduction, mesh smoothing, cutting, contouring, and Delaunay
419 triangulation. VTK has an extensive information visualization framework, has
420 a suite of 3D interaction widgets, supports parallel processing, and
421 integrates with various databases on GUI toolkits such as Qt and Tk.")
422 (license license:bsd-3)))
423
424 (define-public vtk-7
425 (package
426 (inherit vtk)
427 (version "7.1.1")
428 (source (origin
429 (method url-fetch)
430 (uri (string-append "https://vtk.org/files/release/"
431 (version-major+minor version)
432 "/VTK-" version ".tar.gz"))
433 (sha256
434 (base32
435 "0nm7xwwj7rnsxjdv2ssviys8nhci4n9iiiqm2y14s520hl2dsp1d"))
436 (patches (search-patches "vtk-7-python-compat.patch"
437 "vtk-7-hdf5-compat.patch"
438 "vtk-7-gcc-10-compat.patch"))))
439 (arguments
440 (substitute-keyword-arguments (package-arguments vtk)
441 ((#:configure-flags flags)
442 ;; Otherwise, the build would fail with: "error: invalid conversion
443 ;; from ‘const char*’ to ‘char*’ [-fpermissive]".
444 `(cons "-DCMAKE_CXX_FLAGS=-fpermissive" ,flags))
445 ((#:phases phases)
446 #~(modify-phases #$phases
447 (add-after 'unpack 'remove-kernel-version
448 ;; Avoid embedding the kernel version for reproducible builds
449 (lambda _
450 (substitute*
451 "ThirdParty/hdf5/vtkhdf5/config/cmake/libhdf5.settings.cmake.in"
452 (("Host system: \\@CMAKE_HOST_SYSTEM\\@")
453 "Host system: @CMAKE_SYSTEM_NAME@"))))))))))
454
455 (define-public opencv
456 (package
457 (name "opencv")
458 (version "4.5.4")
459 (source (origin
460 (method git-fetch)
461 (uri (git-reference
462 (url "https://github.com/opencv/opencv")
463 (commit version)))
464 (file-name (git-file-name name version))
465 (sha256
466 (base32
467 "0gf2xs3r4s51m20mpf0wdidpk0xzp3m2w6jx72fwldhn0pshlmcj"))
468 (modules '((guix build utils)))
469 (snippet
470 '(begin
471 ;; Remove external libraries. We have almost all available
472 ;; in Guix:
473 (with-directory-excursion "3rdparty"
474 (for-each delete-file-recursively
475 '("carotene"
476 "cpufeatures"
477 "ffmpeg"
478 "include"
479 "ippicv"
480 "ittnotify"
481 "libjasper"
482 "libjpeg"
483 "libjpeg-turbo"
484 "libpng"
485 "libtengine"
486 "libtiff"
487 "libwebp"
488 "openexr"
489 "openjpeg"
490 "openvx"
491 "protobuf"
492 ;;"quirc"
493 "tbb"
494 "zlib")))
495
496 ;; Milky icon set is non-free:
497 (delete-file-recursively "modules/highgui/src/files_Qt/Milky")
498
499 ;; Some jars found:
500 (for-each delete-file
501 '("modules/java/test/pure_test/lib/junit-4.11.jar"
502 "samples/java/sbt/sbt/sbt-launch.jar"))))))
503 (build-system cmake-build-system)
504 (arguments
505 `(#:configure-flags
506 (list "-DWITH_ADE=OFF" ;we don't have a package for ade yet
507 "-DWITH_IPP=OFF"
508 "-DWITH_ITT=OFF"
509 "-DWITH_CAROTENE=OFF" ; only visible on arm/aarch64
510 "-DENABLE_PRECOMPILED_HEADERS=OFF"
511 "-DOPENCV_GENERATE_PKGCONFIG=ON"
512
513 ;; CPU-Features:
514 ;; See cmake/OpenCVCompilerOptimizations.cmake
515 ;; (CPU_ALL_OPTIMIZATIONS) for a list of all optimizations
516 ;; BASELINE is the minimum optimization all CPUs must support
517 ;;
518 ;; DISPATCH is the list of optional dispatches.
519 "-DCPU_BASELINE=SSE2"
520
521 ;; Build Python bindings.
522 "-DBUILD_opencv_python3=ON"
523
524 ,@(match (%current-system)
525 ("x86_64-linux"
526 '("-DCPU_DISPATCH=NEON;VFPV3;FP16;SSE;SSE2;SSE3;SSSE3;SSE4_1;SSE4_2;POPCNT;AVX;FP16;AVX2;FMA3;AVX_512F;AVX512_SKX"
527 "-DCPU_DISPATCH_REQUIRE=SSE3,SSSE3,SSE4_1,SSE4_2,AVX,AVX2"))
528 ("armhf-linux"
529 '("-DCPU_BASELINE_DISABLE=NEON")) ; causes build failures
530 ("aarch64-linux"
531 '("-DCPU_BASELINE=NEON"
532 "-DCPU_DISPATCH=NEON;VFPV3;FP16"))
533 (_ '()))
534
535 "-DBUILD_PERF_TESTS=OFF"
536 "-DBUILD_TESTS=ON"
537
538 (string-append "-DOPENCV_EXTRA_MODULES_PATH=" (getcwd)
539 "/opencv-contrib/modules")
540
541 ;;Define test data:
542 (string-append "-DOPENCV_TEST_DATA_PATH=" (getcwd)
543 "/opencv-extra/testdata")
544
545 ;; Is ON by default and would try to rebuild 3rd-party protobuf,
546 ;; which we had removed, which would lead to an error:
547 "-DBUILD_PROTOBUF=OFF"
548
549 ;; Rebuild protobuf files, because we have a slightly different
550 ;; version than the included one. If we would not update, we
551 ;; would get a compile error later:
552 "-DPROTOBUF_UPDATE_FILES=ON"
553
554 ;; xfeatures2d disabled, because it downloads extra binaries from
555 ;; https://github.com/opencv/opencv_3rdparty
556 ;; defined in xfeatures2d/cmake/download_{vgg|bootdesc}.cmake
557 ;; Cmp this bug entry:
558 ;; https://github.com/opencv/opencv_contrib/issues/1131
559 "-DBUILD_opencv_xfeatures2d=OFF")
560 #:phases
561 (modify-phases %standard-phases
562 (add-after 'unpack 'disable-broken-tests
563 (lambda _
564 ;; This test fails with "unknown file: Failure"
565 ;; But I couldn't figure out which file was missing:
566 (substitute* "../opencv-contrib/modules/face/test/test_face_align.cpp"
567 (("(TEST\\(CV_Face_FacemarkKazemi, )(can_detect_landmarks\\).*)"
568 all pre post)
569 (string-append pre "DISABLED_" post)))
570
571 ;; This test fails with a comparison between the expected 396 and
572 ;; the actual 440 in file size.
573 (substitute* "modules/imgcodecs/test/test_exr.impl.hpp"
574 (("(TEST\\(Imgcodecs_EXR, )(readWrite_32FC1\\).*)" all pre post)
575 (string-append pre "DISABLED_" post)))
576
577 ;; These fail with protobuf parse errors that come from
578 ;; opencv-extra/testdata.
579 (substitute* "modules/dnn/test/test_layers.cpp"
580 (("(TEST_P\\(Test_Caffe_layers, )\
581 (Accum\\).*|DataAugmentation\\).*|Resample\\).*|Correlation\\).*)" all pre post)
582 (string-append pre "DISABLED_" post)))))
583 (add-after 'unpack 'unpack-submodule-sources
584 (lambda* (#:key inputs #:allow-other-keys)
585 (mkdir "../opencv-extra")
586 (mkdir "../opencv-contrib")
587 (copy-recursively (assoc-ref inputs "opencv-extra")
588 "../opencv-extra")
589 (copy-recursively (assoc-ref inputs "opencv-contrib")
590 "../opencv-contrib")))
591 (add-after 'build 'do-not-install-3rdparty-file
592 (lambda _
593 (substitute* "cmake_install.cmake"
594 (("file\\(INSTALL .*source/3rdparty/include/opencl/LICENSE.txt.*") "\n"))))
595 (add-before 'check 'start-xserver
596 (lambda* (#:key inputs #:allow-other-keys)
597 (let ((xorg-server (assoc-ref inputs "xorg-server"))
598 (disp ":1"))
599 (setenv "HOME" (getcwd))
600 (setenv "DISPLAY" disp)
601 ;; There must be a running X server and make check doesn't start one.
602 ;; Therefore we must do it.
603 (zero? (system (format #f "~a/bin/Xvfb ~a &" xorg-server disp)))))))))
604 (native-inputs
605 `(("pkg-config" ,pkg-config)
606 ("xorg-server" ,xorg-server-for-tests) ; For running the tests
607 ("opencv-extra"
608 ,(origin
609 (method git-fetch)
610 (uri (git-reference
611 (url "https://github.com/opencv/opencv_extra")
612 (commit version)))
613 (file-name (git-file-name "opencv_extra" version))
614 (sha256
615 (base32 "1fg2hxdvphdvagc2fkmhqk7qql9mp7pj2bmp8kmd7vicpr72qk82"))))
616 ("opencv-contrib"
617 ,(origin
618 (method git-fetch)
619 (uri (git-reference
620 (url "https://github.com/opencv/opencv_contrib")
621 (commit version)))
622 (file-name (git-file-name "opencv_contrib" version))
623 (sha256
624 (base32 "0ga0l4ranp1834gxgp487ll1amvmssa02l2nk5ja5w0rx4d8hh26"))))))
625 (inputs
626 (list ffmpeg
627 gtk+
628 gtkglext
629 hdf5
630 ilmbase
631 imath ;should be propagated by openexr
632 jasper
633 libgphoto2
634 libjpeg-turbo
635 libpng
636 libtiff
637 libwebp
638 openblas
639 openexr
640 openjpeg
641 protobuf
642 python
643 python-numpy
644 vtk
645 zlib))
646 ;; These three CVEs are not a problem of OpenCV, see:
647 ;; https://github.com/opencv/opencv/issues/10998
648 (properties '((lint-hidden-cve . ("CVE-2018-7712"
649 "CVE-2018-7713"
650 "CVE-2018-7714"))))
651 (synopsis "Computer vision library")
652 (description "OpenCV is a library aimed at real-time computer vision,
653 including several hundred computer vision algorithms. It can be used to do
654 things like:
655
656 @itemize
657 @item image and video input and output
658 @item image and video processing
659 @item displaying
660 @item feature recognition
661 @item segmentation
662 @item facial recognition
663 @item stereo vision
664 @item structure from motion
665 @item augmented reality
666 @item machine learning
667 @end itemize\n")
668 (home-page "https://opencv.org/")
669 (license license:bsd-3)))
670
671 (define-public vips
672 (package
673 (name "vips")
674 (version "8.13.1")
675 (source
676 (origin
677 (method url-fetch)
678 (uri (string-append
679 "https://github.com/libvips/libvips/releases/download/v"
680 version "/vips-" version ".tar.gz"))
681 (sha256
682 (base32 "00kp3439jcqv9l2gcjg88xzvlq8clv54z1m3x66i3chvarz7ndxd"))))
683 (build-system gnu-build-system)
684 (native-inputs
685 (list gobject-introspection pkg-config))
686 (inputs
687 (list expat
688 fftw
689 giflib
690 glib
691 hdf5
692 imagemagick
693 lcms
694 libexif
695 libgsf
696 libjpeg-turbo
697 libpng
698 librsvg
699 libtiff
700 libxml2
701 libwebp
702 matio
703 niftilib
704 openexr-2
705 orc
706 pango
707 poppler))
708 (home-page "https://libvips.github.io/libvips/")
709 (synopsis "Multithreaded image processing system with low memory needs")
710 (description
711 "VIPS is a demand-driven, horizontally threaded image processing library.
712 It's particularly good at processing large images, working with colour,
713 scientific analysis, and general research & development.
714
715 Compared to most image processing libraries VIPS needs little RAM and runs
716 quickly, especially on machines with more than one CPU core. This is primarily
717 due to its architecture which automatically parallelises the image workflows.")
718 (license license:lgpl2.1+)))
719
720 (define-public gmic
721 (package
722 (name "gmic")
723 (version "3.0.0")
724 (source
725 (origin
726 (method url-fetch)
727 (uri (string-append "https://gmic.eu/files/source/gmic_"
728 version ".tar.gz"))
729 (sha256
730 (base32 "080inz0wisv3rhvbnzrgcs3j25wq86gybp68yi56gw6vwswnn19z"))))
731 (build-system cmake-build-system)
732 (arguments
733 `(#:tests? #f ;there are no tests
734 #:configure-flags '("-DBUILD_LIB_STATIC=OFF"
735 "-DENABLE_DYNAMIC_LINKING=ON"
736 "-DENABLE_LTO=ON")
737 #:phases
738 (modify-phases %standard-phases
739 (add-before 'configure 'set-LDFLAGS
740 (lambda* (#:key inputs outputs #:allow-other-keys)
741 (setenv "LDFLAGS"
742 (string-append
743 "-Wl,-rpath="
744 (assoc-ref outputs "out") "/lib")))))))
745 (native-inputs
746 (list pkg-config))
747 (inputs
748 (list curl
749 fftw
750 graphicsmagick
751 imath
752 libjpeg-turbo
753 libpng
754 libtiff
755 libx11
756 ;;opencv ;OpenCV is currently broken in the CI
757 openexr
758 zlib))
759 (home-page "https://gmic.eu/")
760 (synopsis "Full-featured framework for digital image processing")
761 (description "G'MIC is a full-featured framework for digital image
762 processing. It provides several user interfaces to convert / manipulate
763 / filter / visualize generic image datasets, ranging from 1D scalar
764 signals to 3D+t sequences of multi-spectral volumetric images, hence
765 including 2D color images.")
766 ;; Dual-licensed, either license applies.
767 (license (list license:cecill license:cecill-c))))
768
769 (define-public gmic-qt
770 (package
771 (inherit gmic)
772 (name "gmic-qt")
773 (arguments
774 (substitute-keyword-arguments (package-arguments gmic)
775 ((#:configure-flags _)
776 `(list "-DGMIC_QT_HOST=none" "-DENABLE_DYNAMIC_LINKING=ON"
777 (string-append "-DGMIC_LIB_PATH="
778 (assoc-ref %build-inputs "gmic") "/lib")))
779 ((#:phases phases)
780 `(modify-phases ,phases
781 (add-after 'unpack 'qt-chdir
782 (lambda _ (chdir "gmic-qt") #t))))))
783 (native-inputs
784 (list pkg-config qttools-5))
785 (inputs
786 (modify-inputs (package-inputs gmic)
787 (prepend gmic qtbase-5)))
788 (synopsis "Qt frontend for the G'MIC image processing framework")
789 (license license:gpl3+)))
790
791 (define-public gmic-qt-krita
792 (package
793 (inherit gmic-qt)
794 (name "gmic-qt-krita")
795 (arguments
796 (substitute-keyword-arguments (package-arguments gmic-qt)
797 ((#:configure-flags flags)
798 '(list "-DGMIC_QT_HOST=krita" "-DENABLE_DYNAMIC_LINKING=ON"
799 (string-append "-DGMIC_LIB_PATH="
800 (assoc-ref %build-inputs "gmic") "/lib")))))
801 (synopsis "Krita plugin for the G'MIC image processing framework")))
802
803 (define-public gmic-qt-gimp
804 (package
805 (inherit gmic-qt)
806 (name "gmic-qt-gimp")
807 (inputs
808 ;; GIMP and its dependencies.
809 (modify-inputs (package-inputs gmic-qt)
810 (prepend gimp gdk-pixbuf cairo gegl)))
811 (arguments
812 (substitute-keyword-arguments (package-arguments gmic-qt)
813 ((#:configure-flags flags)
814 '(list "-DGMIC_QT_HOST=gimp" "-DENABLE_DYNAMIC_LINKING=ON"
815 (string-append "-DGMIC_LIB_PATH="
816 (assoc-ref %build-inputs "gmic") "/lib")))))
817 (synopsis "GIMP plugin for the G'MIC image processing framework")))
818
819 (define-public nip2
820 (package
821 (name "nip2")
822 (version "8.7.1")
823 (source
824 (origin
825 (method url-fetch)
826 (uri (string-append "https://github.com/libvips/nip2/releases/download/v"
827 version "/nip2-" version ".tar.gz" ))
828 (sha256
829 (base32 "0l7n427njif53npqn02gfjjly8y3khbrkzqxp10j5vp9h97psgiw"))))
830 (build-system gnu-build-system)
831 (arguments
832 `(#:phases
833 (modify-phases %standard-phases
834 ;; test_conv.ws keep failing so disabling for now.
835 (add-after 'unpack 'disable-test-conv
836 (lambda _
837 (delete-file "test/workspaces/test_conv.ws")
838 #t))
839 (add-before 'check 'set-home
840 (lambda _
841 (setenv "HOME" "/tmp") #t)))))
842 (inputs
843 `(("vips" ,vips)
844 ("glib" ,glib)
845 ("libtiff" ,libtiff)
846 ("gtk+-2" ,gtk+-2)
847 ("libxml2" ,libxml2)
848 ("libexif" ,libexif)
849 ("libjpeg" ,libjpeg-turbo) ;required by vips.pc
850 ("librsvg" ,librsvg)
851 ("fftw" ,fftw)
852 ("libgsf" ,libgsf)
853 ("imagemagick" ,imagemagick)
854 ("orc" ,orc)
855 ("matio" ,matio)
856 ("lcms" ,lcms)
857 ("libwebp" ,libwebp)
858 ("openexr" ,openexr-2)
859 ("poppler" ,poppler)
860 ("gsl" ,gsl)))
861 (native-inputs
862 (list flex bison pkg-config))
863 (home-page "https://github.com/libvips/nip2")
864 (synopsis "Spreadsheet-like GUI for libvips")
865 (description "This package provide a graphical user interface (GUI) for
866 the VIPS image processing library. It's a little like a spreadsheet: you
867 create a set of formula connecting your objects together, and on a change nip2
868 recalculates.")
869 (license license:gpl2+)))
870
871 (define-public vxl
872 (package
873 (name "vxl")
874 (version "2.0.2")
875 (source
876 (origin
877 (method git-fetch)
878 (uri (git-reference
879 (url "https://github.com/vxl/vxl")
880 (commit (string-append "v" version))))
881 (file-name (git-file-name name version))
882 (sha256
883 (base32 "0949hw57szq8943f1whwqaz591xjmb19kj803hcv74hdai2b0ycg"))
884 (modules '((guix build utils)))
885 ;; TODO: vxl includes an old version of dcmtk. It won't build with
886 ;; version 3.6.x.
887 (snippet
888 '(begin
889 (for-each delete-file-recursively
890 '("v3p/bzlib/"
891 "v3p/geotiff/"
892 "v3p/jpeg/"
893 "v3p/png/"
894 "v3p/tiff/"
895 "v3p/zlib/"))
896 (substitute* "v3p/CMakeLists.txt"
897 (("add_subdirectory\\((tiff|png|jpeg|zlib|bzlib|geotiff)\\)")
898 ""))
899 #t))))
900 (build-system cmake-build-system)
901 (inputs
902 (list libgeotiff libtiff libjpeg-turbo libpng zlib))
903 (home-page "https://github.com/vxl/vxl/")
904 (synopsis "Collection of C++ libraries for computer vision")
905 (description "VXL (the Vision-something-Libraries) is a collection of C++
906 libraries designed for computer vision research and implementation.")
907 (license license:bsd-3)))
908
909 (define-public vxl-1
910 (package (inherit vxl)
911 (name "vxl")
912 (version "1.18.0")
913 (source
914 (origin
915 (method git-fetch)
916 (uri (git-reference
917 (url "https://github.com/vxl/vxl")
918 (commit (string-append "v" version))))
919 (file-name (git-file-name name version))
920 (sha256
921 (base32 "1g4mr2cc58jwm0vasscbd4y5380wj3ahkvq121z4gs83fhavvxgz"))
922 (modules '((guix build utils)))
923 (snippet
924 '(begin
925 (for-each delete-file-recursively
926 '("v3p/bzlib/"
927 "v3p/geotiff/"
928 "v3p/png/"
929 "v3p/tiff/"
930 "v3p/zlib/"))
931 (substitute* "v3p/CMakeLists.txt"
932 (("add_subdirectory\\((tiff|png|jpeg|zlib|bzlib|geotiff)\\)")
933 ""))
934 #t))))
935 (arguments
936 `(#:configure-flags
937 ;; Needed for itk-snap
938 (list "-DVNL_CONFIG_LEGACY_METHODS=ON")))))
939
940 (define-public insight-toolkit
941 (package
942 (name "insight-toolkit")
943 (version "5.0.0")
944 (source
945 (origin
946 (method url-fetch)
947 (uri (string-append "https://github.com/InsightSoftwareConsortium/ITK/"
948 "releases/download/v" version "/InsightToolkit-"
949 version ".tar.xz"))
950 (sha256
951 (base32 "0bs63mk4q8jmx38f031jy5w5n9yy5ng9x8ijwinvjyvas8cichqi"))))
952 (build-system cmake-build-system)
953 (arguments
954 `(#:tests? #f ; tests require network access and external data
955 #:configure-flags
956 '("-DITK_USE_GPU=ON"
957 "-DITK_USE_SYSTEM_LIBRARIES=ON"
958 "-DITK_USE_SYSTEM_GOOGLETEST=ON"
959 "-DITK_BUILD_SHARED=ON"
960 ;; This prevents "GTest::GTest" from being added to the ITK_LIBRARIES
961 ;; variable in the installed CMake files. This is necessary as other
962 ;; packages using insight-toolkit could not be configured otherwise.
963 "-DGTEST_ROOT=gtest")
964
965 #:phases
966 (modify-phases %standard-phases
967 (add-after 'unpack 'do-not-tune
968 (lambda _
969 (substitute* "CMake/ITKSetStandardCompilerFlags.cmake"
970 (("-mute=native") ""))
971 #t)))))
972 (inputs
973 `(("eigen" ,eigen)
974 ("expat" ,expat)
975 ("fftw" ,fftw)
976 ("fftwf" ,fftwf)
977 ("hdf5" ,hdf5)
978 ("libjpeg" ,libjpeg-turbo)
979 ("libpng" ,libpng)
980 ("libtiff" ,libtiff)
981 ("mesa" ,mesa-opencl)
982 ("perl" ,perl)
983 ("python" ,python)
984 ("tbb" ,tbb)
985 ("vxl" ,vxl-1)
986 ("zlib" ,zlib)))
987 (native-inputs
988 (list googletest pkg-config))
989 (home-page "https://github.com/InsightSoftwareConsortium/ITK/")
990 (synopsis "Scientific image processing, segmentation and registration")
991 (description "The Insight Toolkit (ITK) is a toolkit for N-dimensional
992 scientific image processing, segmentation, and registration. Segmentation is
993 the process of identifying and classifying data found in a digitally sampled
994 representation. Typically the sampled representation is an image acquired
995 from such medical instrumentation as CT or MRI scanners. Registration is the
996 task of aligning or developing correspondences between data. For example, in
997 the medical environment, a CT scan may be aligned with a MRI scan in order to
998 combine the information contained in both.")
999 (license license:asl2.0)))
1000
1001 (define-public insight-toolkit-4
1002 (package (inherit insight-toolkit)
1003 (version "4.13.2")
1004 (source
1005 (origin
1006 (method url-fetch)
1007 (uri (string-append "https://github.com/InsightSoftwareConsortium/ITK/"
1008 "releases/download/v" version "/InsightToolkit-"
1009 version ".tar.xz"))
1010 (sha256
1011 (base32 "19cgfpd63gqrvc3m27m394gy2d7w79g5y6lvznb5qqr49lihbgns"))))
1012 (arguments
1013 `(#:tests? #f ; tests require network access and external data
1014 #:configure-flags
1015 '("-DITKV3_COMPATIBILITY=ON" ; needed for itk-snap
1016 "-DITK_USE_GPU=ON"
1017 "-DITK_USE_SYSTEM_LIBRARIES=ON"
1018 "-DITK_USE_SYSTEM_GOOGLETEST=ON"
1019 "-DITK_USE_SYSTEM_VXL=ON")))))
1020
1021 (define-public insight-toolkit-4.12
1022 (package (inherit insight-toolkit-4)
1023 (version "4.12.2")
1024 (source
1025 (origin
1026 (method url-fetch)
1027 (uri (string-append "mirror://sourceforge/itk/itk/4.12/"
1028 "InsightToolkit-" version ".tar.xz"))
1029 (sha256
1030 (base32 "1qw9mxbh083siljygahl4gdfv91xvfd8hfl7ghwii19f60xrvn2w"))))))
1031
1032 (define-public itk-snap
1033 (package
1034 (name "itk-snap")
1035 (version "3.8.0")
1036 (source
1037 (origin
1038 (method git-fetch)
1039 (uri (git-reference
1040 (url "https://git.code.sf.net/p/itk-snap/src")
1041 (commit (string-append "v" version))))
1042 (file-name (git-file-name name version))
1043 (sha256
1044 (base32 "15i5ixpryfrbf3vrrb5rici8fb585f25k0v1ljds16bp1f1msr4q"))
1045 (patches (search-patches "itk-snap-alt-glibc-compat.patch"))))
1046 (build-system cmake-build-system)
1047 (arguments
1048 `(#:configure-flags
1049 (list "-DSNAP_VERSION_GIT_SHA1=release"
1050 "-DSNAP_VERSION_GIT_BRANCH=release"
1051 "-DSNAP_VERSION_GIT_TIMESTAMP=0"
1052 "-DSNAP_PACKAGE_QT_PLUGINS=OFF"
1053 "-DCMAKE_POSITION_INDEPENDENT_CODE=ON")
1054 #:phases
1055 (modify-phases %standard-phases
1056 ;; During the installation phase all libraries provided by all
1057 ;; dependencies will be copied to the lib directory. That's insane,
1058 ;; so we disable this.
1059 (add-after 'unpack 'do-not-copy-dependencies
1060 (lambda _
1061 (substitute* "CMakeLists.txt"
1062 (("install_qt5_executable\
1063 \\(\\$\\{SNAP_MAIN_INSTALL_DIR\\}/\\$\\{SNAP_EXE\\}\\)")
1064 ""))))
1065 (add-after 'unpack 'disable-gui-tests
1066 (lambda _
1067 ;; The GUI tests just time out.
1068 (substitute* "CMakeLists.txt"
1069 ((" (Workspace|DiffSpace|ProbeIntensity|RegionCompetition\
1070 |RandomForest|RandomForestBailOut)")
1071 ""))))
1072 (add-after 'unpack 'make-reproducible
1073 (lambda _
1074 (substitute* "CMakeLists.txt"
1075 (("TODAY\\(SNAP_VERSION_COMPILE_DATE\\)")
1076 "SET(SNAP_VERSION_COMPILE_DATE \"(removed for reproducibility)\")"))))
1077 (add-after 'unpack 'prepare-submodules
1078 (lambda* (#:key inputs #:allow-other-keys)
1079 (rmdir "Submodules/c3d")
1080 (copy-recursively (assoc-ref inputs "c3d-src")
1081 "Submodules/c3d")
1082 (substitute* '("Submodules/c3d/adapters/BiasFieldCorrectionN4.cxx"
1083 "Submodules/c3d/adapters/ApplyMetric.cxx")
1084 (("vcl_") "std::"))
1085 (rmdir "Submodules/greedy")
1086 (symlink (assoc-ref inputs "greedy-src")
1087 "Submodules/greedy")))
1088 (add-after 'unpack 'fix-includes
1089 (lambda _
1090 (substitute* "GUI/Model/RegistrationModel.cxx"
1091 (("<vnl_symmetric_eigensystem.h>")
1092 "<vnl/algo/vnl_symmetric_eigensystem.h>"))))
1093 (add-before 'check 'prepare-tests
1094 (lambda _
1095 ;; Needed by at least one test.
1096 (setenv "HOME" "/tmp")))
1097 (add-after 'install 'wrap-executable
1098 (lambda* (#:key inputs outputs #:allow-other-keys)
1099 (let ((out (assoc-ref outputs "out")))
1100 (wrap-program (string-append out "/bin/itksnap")
1101 `("QT_PLUGIN_PATH" ":" prefix
1102 ,(map (lambda (label)
1103 (string-append (assoc-ref inputs label)
1104 "/lib/qt5/plugins"))
1105 '("qtbase" "qtdeclarative-5"))))))))))
1106 (inputs
1107 (list curl
1108 fftw
1109 fftwf
1110 glu
1111 hdf5
1112 mesa-opencl
1113 ;; This package does not build with either insight-toolkit 5.0.0
1114 ;; and not with 4.13. It really needs to be 4.12.
1115 insight-toolkit-4.12
1116 vtk-7
1117 qtbase-5
1118 qtdeclarative-5
1119 vxl-1
1120 zlib))
1121 (native-inputs
1122 `(("googletest" ,googletest)
1123 ("qttools-5" ,qttools-5)
1124 ("pkg-config" ,pkg-config)
1125 ("c3d-src"
1126 ,(let* ((commit "f521358db26e00002c911cc47bf463b043942ad3")
1127 (revision "1")
1128 (version (git-version "0" revision commit)))
1129 (origin
1130 (method git-fetch)
1131 (uri (git-reference
1132 (url "https://github.com/pyushkevich/c3d")
1133 (commit commit)))
1134 (file-name (git-file-name "c3d" version))
1135 (sha256
1136 (base32
1137 "0kyv3rxrxwr8c3sa9zv01lsnhk95b27gx1s870k3yi8qp52h7bx3")))))
1138 ;; We are using an arbitrary commit from 2017 because the latest
1139 ;; version breaks the build...
1140 ("greedy-src"
1141 ,(let* ((commit "97e340f7e8e66597599144947775e6039e79a0d3")
1142 (revision "1")
1143 (version (git-version "0" revision commit)))
1144 (origin
1145 (method git-fetch)
1146 (uri (git-reference
1147 (url "https://github.com/pyushkevich/greedy")
1148 (commit commit)))
1149 (file-name (git-file-name "greedy" version))
1150 (sha256
1151 (base32
1152 "0k5bc9za4jrc8z9dj08z1rkcp5xf0gnd1d2jmi1w9ny4vxh2q2ab")))))))
1153 (home-page "https://sourceforge.net/p/itk-snap/")
1154 (synopsis "Medical image segmentation")
1155 (description "ITK-SNAP is a tool for segmenting anatomical structures in
1156 medical images. It provides an automatic active contour segmentation
1157 pipeline, along with supporting a manual segmentation toolbox. ITK-SNAP has a
1158 full-featured UI aimed at clinical researchers.")
1159 ;; This includes the submodules greedy and c3d.
1160 (license license:gpl3+)))
1161
1162 (define-public metapixel
1163 ;; Follow stable branch.
1164 (let ((commit "98ee9daa093b6c334941242e63f90b1c2876eb4f"))
1165 (package
1166 (name "metapixel")
1167 (version (git-version "1.0.2" "1" commit))
1168 (source
1169 (origin
1170 (method git-fetch)
1171 (uri (git-reference
1172 (url "https://github.com/schani/metapixel")
1173 (commit commit)
1174 ;; TODO: Package rwimg and lispreader?
1175 (recursive? #t)))
1176 (file-name (git-file-name name version))
1177 (sha256
1178 (base32 "0r7n3a6bvcxkbpda4mwmrpicii09iql5z69nkjqygkwxw7ny3309"))))
1179 (build-system gnu-build-system)
1180 (inputs
1181 `(("giflib" ,giflib)
1182 ("libjpeg" ,libjpeg-turbo)
1183 ("libpng" ,libpng)
1184 ("perl" ,perl)))
1185 (native-inputs
1186 `(("pkg-config" ,pkg-config)
1187 ("docbook-xml" ,docbook-xml)
1188 ("docbook-xsl" ,docbook-xsl)
1189 ("xsltproc" ,libxslt)))
1190 (arguments
1191 `(#:tests? #f ; No tests.
1192 #:make-flags (list
1193 (string-append "PREFIX=" (assoc-ref %outputs "out"))
1194 (string-append "MANPAGE_XSL="
1195 (assoc-ref %build-inputs "docbook-xsl")
1196 "/xml/xsl/docbook-xsl-*/manpages/docbook.xsl"))
1197 #:phases
1198 (modify-phases %standard-phases
1199 (delete 'configure)
1200 (add-before 'install 'make-local-docbook-xml
1201 (lambda* (#:key inputs #:allow-other-keys)
1202 (substitute* "metapixel.xml"
1203 (("http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd")
1204 (string-append (assoc-ref inputs "docbook-xml")
1205 "/xml/dtd/docbook/docbookx.dtd")))
1206 #t))
1207 (add-before 'install 'fix-directory-creation
1208 (lambda* (#:key outputs #:allow-other-keys)
1209 (mkdir-p (string-append (assoc-ref outputs "out") "/share/man/man1"))
1210 #t)))))
1211 (home-page "https://www.complang.tuwien.ac.at/schani/metapixel/")
1212 (synopsis "Photomosaics generator")
1213 (description "Metapixel is a program for generating photomosaics. It can
1214 generate classical photomosaics, in which the source image is viewed as a
1215 matrix of equally sized rectangles for each of which a matching image is
1216 substituted, as well as collage-style photomosaics, in which rectangular parts
1217 of the source image at arbitrary positions (i.e. not aligned to a matrix) are
1218 substituted by matching images.")
1219 (license license:gpl2))))
1220
1221 (define-public scantailor-advanced
1222 (let ((commit "3d1e74e6ace413733511086934a66f4e3f7a6027"))
1223 (package
1224 (name "scantailor-advanced")
1225 (version (string-append "1.0.16-" (string-take commit 7)))
1226 (source
1227 (origin
1228 (method git-fetch)
1229 (uri (git-reference
1230 (url "https://github.com/4lex4/scantailor-advanced")
1231 (commit commit)))
1232 (file-name (git-file-name name version))
1233 (sha256
1234 (base32
1235 "0kixwjb2x457dq7927hkh34c803p7yh1pmn6n61rk9shqrcg492h"))))
1236 (build-system qt-build-system)
1237 (native-inputs
1238 (list qttools-5))
1239 (inputs
1240 `(("boost" ,boost)
1241 ("libjpeg" ,libjpeg-turbo)
1242 ("libpng" ,libpng)
1243 ("libtiff" ,libtiff)
1244 ("qtbase" ,qtbase-5)
1245 ("qtsvg-5" ,qtsvg-5)
1246 ("zlib" ,zlib)))
1247 (arguments
1248 `(#:phases
1249 (modify-phases %standard-phases
1250 ;; Some tests require a display and fail with offscreen mode.
1251 (add-after 'unpack 'disable-failing-tests
1252 (lambda _
1253 (setenv "ARGS" "--exclude-regex \"imageproc_.*\"")
1254 #t)))))
1255 (home-page "https://github.com/4lex4/scantailor-advanced")
1256 (synopsis "Clean up scanned pages")
1257 (description "Scan Tailor is an interactive post-processing tool for
1258 scanned pages. It performs operations such as page splitting, deskewing,
1259 adding/removing borders, and others. You give it raw scans, and you get pages
1260 ready to be printed or assembled into a PDF or DJVU file. Scanning, optical
1261 character recognition, and assembling multi-page documents are out of scope of
1262 this project.
1263
1264 Scan Tailer Advanced is a fork of Scan Tailer that merges Scan Tailor Featured
1265 and Scan Tailor Enhanced versions as well as including many more bug fixes.")
1266 (license license:gpl3+))))
1267
1268 (define-public stiff
1269 (package
1270 (name "stiff")
1271 (version "2.4.0")
1272 (source
1273 (origin
1274 (method url-fetch)
1275 (uri (string-append "https://www.astromatic.net/download/stiff/stiff-"
1276 version ".tar.gz"))
1277 (sha256
1278 (base32 "14m92dskzw7bwsr64ha4p0mj3ndv13gwcbfic3qxrs3zq5353s7l"))))
1279 (build-system gnu-build-system)
1280 (inputs
1281 (list libtiff zlib libjpeg-turbo))
1282 (home-page "https://www.astromatic.net/software/stiff")
1283 (synopsis "Convert scientific FITS images to TIFF format")
1284 (description
1285 "STIFF is a program that converts scientific @acronym{FITS, Flexible Image
1286 Transport System} images to the more popular TIFF format for illustration
1287 purposes.")
1288 (license license:gpl3+)))
1289
1290 (define-public python-imgviz
1291 (package
1292 (name "python-imgviz")
1293 (version "1.2.6")
1294 (source
1295 (origin
1296 ;; PyPi tarball lacks tests.
1297 (method git-fetch)
1298 (uri (git-reference
1299 (url "https://github.com/wkentaro/imgviz.git")
1300 (commit (string-append "v" version))))
1301 (file-name (git-file-name name version))
1302 (sha256
1303 (base32 "1bm0wdv5p26i8nl4kx3145cz553v401sgbpgc96sddzjfmfiydcw"))))
1304 (build-system python-build-system)
1305 (arguments
1306 `(#:phases
1307 (modify-phases %standard-phases
1308 (replace 'check
1309 (lambda* (#:key inputs outputs tests? #:allow-other-keys)
1310 (when tests?
1311 (add-installed-pythonpath inputs outputs)
1312 (invoke "pytest" "-v" "tests"))
1313 #t)))))
1314 (propagated-inputs
1315 (list python-matplotlib python-numpy python-pillow python-pyyaml))
1316 (native-inputs (list python-pytest))
1317 (home-page "http://github.com/wkentaro/imgviz")
1318 (synopsis "Image Visualization Tools")
1319 (description "Python library for object detection, semantic and instance
1320 segmentation.")
1321 (license license:expat)))
1322
1323 (define-public labelme
1324 (package
1325 (name "labelme")
1326 (version "4.5.13")
1327 (source
1328 (origin
1329 ;; PyPi tarball lacks tests.
1330 (method git-fetch)
1331 (uri (git-reference
1332 (url "https://github.com/wkentaro/labelme.git")
1333 (commit (string-append "v" version))))
1334 (file-name (git-file-name name version))
1335 (sha256
1336 (base32 "0cmi2xb4dgh7738l259rgwhn9l134f0vnaaqc2gflc5yr3lqhrv2"))))
1337 (build-system python-build-system)
1338 (arguments
1339 `(#:phases
1340 (modify-phases %standard-phases
1341 (add-after 'unpack 'loosen-requirements
1342 (lambda _
1343 ;; Don't require an outdated version of matplotlib.
1344 (substitute* "setup.py"
1345 (("matplotlib<3\\.3")
1346 "matplotlib"))))
1347 (add-before 'check 'start-xserver
1348 (lambda* (#:key inputs #:allow-other-keys)
1349 (let ((xorg-server (assoc-ref inputs "xorg-server")))
1350 ;; Options taken from CI workflow.
1351 (system (string-append xorg-server "/bin/Xvfb :99 -screen 0 "
1352 "1920x1200x24 -ac +extension GLX +render "
1353 "-noreset &"))
1354 (setenv "DISPLAY" ":99.0"))))
1355 (replace 'check
1356 (lambda* (#:key inputs outputs tests? #:allow-other-keys)
1357 (when tests?
1358 (add-installed-pythonpath inputs outputs)
1359 ;; Fails when invoking help2man for unknown reason.
1360 (delete-file "tests/docs_tests/man_tests/test_labelme_1.py")
1361 ;; One test hangs.
1362 (delete-file "tests/labelme_tests/widgets_tests/test_label_dialog.py")
1363 ;; Calls incompatible function signatures.
1364 (delete-file "tests/labelme_tests/widgets_tests/test_label_list_widget.py")
1365 (setenv "MPLBACKEND" "agg")
1366 (invoke "pytest" "-v" "tests" "-m" "not gpu")))))))
1367 (propagated-inputs
1368 (list python-imgviz
1369 python-matplotlib
1370 python-numpy
1371 python-pillow
1372 python-pyyaml
1373 python-qtpy
1374 python-termcolor))
1375 (native-inputs
1376 (list python-pytest python-pytest-qt xorg-server-for-tests))
1377 (home-page "https://github.com/wkentaro/labelme")
1378 (synopsis
1379 "Image Polygonal Annotation")
1380 (description
1381 "Image and video labeling tool supporting different shapes like
1382 polygons, rectangles, circles, lines, points and VOC/COCO export.")
1383 (license license:gpl3+)))