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