gnu: python-django-filter: Use 'invoke'.
[jackhill/guix/guix.git] / gnu / packages / image-processing.scm
CommitLineData
504c285d
JD
1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2017 John Darrington <jmd@gnu.org>
3;;; Copyright © 2017 Ricardo Wurmus <rekado@elephly.net>
fb226b43
JD
4;;; Copyright © 2014 Ludovic Courtès <ludo@gnu.org>
5;;; Copyright © 2014 Mark H Weaver <mhw@netris.org>
6;;; Copyright © 2016 Eric Bavier <bavier@member.fsf.org>
11861d2b 7;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
62834314 8;;; Copyright © 2018 Björn Höfling <bjoern.hoefling@bjoernhoefling.de>
e506b5e9 9;;; Copyright © 2018 Lprndn <guix@lprndn.info>
6949f45c 10;;; Copyright © 2019 Efraim Flashner <efraim@flashner.co.il>
504c285d
JD
11;;;
12;;; This file is part of GNU Guix.
13;;;
14;;; GNU Guix is free software; you can redistribute it and/or modify it
15;;; under the terms of the GNU General Public License as published by
16;;; the Free Software Foundation; either version 3 of the License, or (at
17;;; your option) any later version.
18;;;
19;;; GNU Guix is distributed in the hope that it will be useful, but
20;;; WITHOUT ANY WARRANTY; without even the implied warranty of
21;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22;;; GNU General Public License for more details.
23;;;
24;;; You should have received a copy of the GNU General Public License
25;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
26
27(define-module (gnu packages image-processing)
28 #:use-module ((guix licenses) #:prefix license:)
29 #:use-module (guix packages)
30 #:use-module (guix utils)
31 #:use-module (guix download)
cdb2a211 32 #:use-module (guix build-system cmake)
504c285d
JD
33 #:use-module (guix build-system gnu)
34 #:use-module (gnu packages)
cdb2a211 35 #:use-module (gnu packages algebra)
e506b5e9 36 #:use-module (gnu packages bison)
cdb2a211 37 #:use-module (gnu packages boost)
504c285d
JD
38 #:use-module (gnu packages compression)
39 #:use-module (gnu packages documentation)
e506b5e9 40 #:use-module (gnu packages flex)
fb226b43 41 #:use-module (gnu packages fontutils)
5bbd6931 42 #:use-module (gnu packages ghostscript)
fb226b43 43 #:use-module (gnu packages gl)
5bbd6931 44 #:use-module (gnu packages glib)
cdb2a211
JD
45 #:use-module (gnu packages gnome)
46 #:use-module (gnu packages graphics)
47 #:use-module (gnu packages graphviz)
5bbd6931 48 #:use-module (gnu packages gstreamer)
62834314 49 #:use-module (gnu packages gtk)
504c285d 50 #:use-module (gnu packages image)
5bbd6931 51 #:use-module (gnu packages imagemagick)
cdb2a211 52 #:use-module (gnu packages maths)
5bbd6931 53 #:use-module (gnu packages pdf)
cdb2a211 54 #:use-module (gnu packages perl)
62834314 55 #:use-module (gnu packages photo)
cdb2a211 56 #:use-module (gnu packages pkg-config)
62834314 57 #:use-module (gnu packages protobuf)
cdb2a211 58 #:use-module (gnu packages python)
fb226b43 59 #:use-module (gnu packages serialization)
62834314 60 #:use-module (gnu packages video)
fb226b43 61 #:use-module (gnu packages xiph)
cdb2a211 62 #:use-module (gnu packages xml)
98d6cdda 63 #:use-module (gnu packages xorg))
504c285d
JD
64
65;; We use the latest snapshot of this package because the latest release is
66;; from 2011 and has known vulnerabilities that cannot easily be fixed by
67;; applying patches.
68(define-public dcmtk
69 (package
70 (name "dcmtk")
71 (version "3.6.1_20170228")
72 (source (origin
73 (method url-fetch)
74 (uri (string-append "ftp://dicom.offis.de/pub/dicom/offis/"
75 "software/dcmtk/snapshot/dcmtk-"
76 version ".tar.gz"))
77 (sha256
78 (base32
79 "04cwfx8yrscqcd59mxk2fh6314ckayi9cp68iql5a57pf2pg5qld"))))
80 (build-system gnu-build-system)
81 (inputs
82 `(("libtiff" ,libtiff)
83 ("libpng" ,libpng)
84 ("doxygen" ,doxygen)
85 ("zlib" ,zlib)))
86 (native-inputs
87 `(("perl" ,perl)))
88 (home-page "http://dcmtk.org")
89 (synopsis "Libraries and programs implementing parts of the DICOM standard")
90 (description "DCMTK is a collection of libraries and applications
91implementing large parts the DICOM standard. It includes software for
92examining, constructing and converting DICOM image files, handling offline
93media, sending and receiving images over a network connection, as well as
94demonstrative image storage and worklist servers.")
95 (license (license:fsf-free
96 "file://COPYRIGHT"
97 "A union of the Apache 2.0 licence and various non-copyleft
98licences similar to the Modified BSD licence."))))
cdb2a211
JD
99
100(define-public mia
101 (package
102 (name "mia")
11861d2b 103 (version "2.4.6")
cdb2a211
JD
104 (source (origin
105 (method url-fetch)
106 (uri (string-append "mirror://sourceforge/mia/mia/"
107 (version-major+minor version)
108 "/mia-" version ".tar.xz"))
109 (sha256
110 (base32
11861d2b 111 "0j4nd5z7i3v199jh7hqqhwd4g7snchizkc7rhzanpvngqg91m1pb"))))
cdb2a211
JD
112 (build-system cmake-build-system)
113 (arguments
114 `(#:configure-flags
115 (list "-DMIA_CREATE_NIPYPE_INTERFACES=0"
cdb2a211
JD
116 "-DCMAKE_CXX_FLAGS=-fpermissive")))
117 (inputs
118 `(("boost" ,boost)
119 ("dcmtk" ,dcmtk)
120 ("doxygen" ,doxygen)
121 ("eigen" ,eigen)
122 ("fftw" ,fftw)
123 ("fftwf" ,fftwf)
124 ("gsl" ,gsl)
125 ("gts" ,gts)
126 ("hdf5" ,hdf5)
127 ("itpp" ,itpp)
128 ("libjpeg" ,libjpeg)
129 ("libpng" ,libpng)
130 ("libtiff" ,libtiff)
131 ("libxml" ,libxml2)
132 ("libxml++" ,libxml++)
133 ("maxflow" ,maxflow)
134 ("niftilib" ,niftilib)
135 ("nlopt" ,nlopt)
136 ("openexr" ,openexr)
137 ("python-lxml" ,python2-lxml)
138 ("vtk" ,vtk)))
139 (native-inputs
140 `(("pkg-config" ,pkg-config)
141 ("python" ,python-2)))
142 (home-page "http://mia.sourceforge.net")
143 (synopsis "Toolkit for gray scale medical image analysis")
144 (description "MIA provides a combination of command line tools, plug-ins,
145and libraries that make it possible run image processing tasks interactively
146in a command shell and to prototype using the shell's scripting language. It
147is built around a plug-in structure that makes it easy to add functionality
148without compromising the original code base and it makes use of a wide variety
149of external libraries that provide additional functionality.")
150 (license license:gpl3+)))
fb226b43
JD
151
152(define-public vtk
153 (package
154 (name "vtk")
155 (version "7.1.0")
156 (source (origin
157 (method url-fetch)
158 (uri (string-append "http://www.vtk.org/files/release/"
159 (version-major+minor version)
160 "/VTK-" version ".tar.gz"))
161 (sha256
162 (base32
163 "0yj96z58haan77gzilnqp7xpf8hg5jk11a3jx55p2ksd400s0gjz"))))
164 (build-system cmake-build-system)
165 (arguments
166 '(#:build-type "Release" ;Build without '-g' to save space.
167 ;; -DVTK_USE_SYSTEM_NETCDF:BOOL=TRUE requires netcdf_cxx
168 #:configure-flags '("-DVTK_USE_SYSTEM_EXPAT:BOOL=TRUE"
169 "-DVTK_USE_SYSTEM_FREETYPE:BOOL=TRUE"
170 "-DVTK_USE_SYSTEM_HDF5:BOOL=TRUE"
171 "-DVTK_USE_SYSTEM_JPEG:BOOL=TRUE"
172 "-DVTK_USE_SYSTEM_JSONCPP:BOOL=TRUE"
173 "-DVTK_USE_SYSTEM_LIBXML2:BOOL=TRUE"
174 "-DVTK_USE_SYSTEM_OGGTHEORA:BOOL=TRUE"
175 "-DVTK_USE_SYSTEM_PNG:BOOL=TRUE"
176 "-DVTK_USE_SYSTEM_TIFF:BOOL=TRUE"
177 "-DVTK_USE_SYSTEM_ZLIB:BOOL=TRUE")
178 #:tests? #f)) ;XXX: no "test" target
179 (inputs
180 `(("libXt" ,libxt)
6a6db57f 181 ("xorgproto" ,xorgproto)
fb226b43
JD
182 ("libX11" ,libx11)
183 ("libxml2" ,libxml2)
184 ("mesa" ,mesa)
185 ("glu" ,glu)
186 ("expat" ,expat)
187 ("freetype" ,freetype)
188 ("hdf5" ,hdf5)
189 ("jpeg" ,libjpeg)
190 ("jsoncpp" ,jsoncpp)
191 ("libogg" ,libogg)
192 ("libtheora" ,libtheora)
193 ("png" ,libpng)
194 ("tiff" ,libtiff)
195 ("zlib" ,zlib)))
196 (home-page "http://www.vtk.org/")
197 (synopsis "Libraries for 3D computer graphics")
198 (description
199 "The Visualization Toolkit (VTK) is a C++ library for 3D computer graphics,
200image processing and visualization. It supports a wide variety of
201visualization algorithms including: scalar, vector, tensor, texture, and
202volumetric methods; and advanced modeling techniques such as: implicit
203modeling, polygon reduction, mesh smoothing, cutting, contouring, and Delaunay
204triangulation. VTK has an extensive information visualization framework, has
205a suite of 3D interaction widgets, supports parallel processing, and
206integrates with various databases on GUI toolkits such as Qt and Tk.")
207 (license license:bsd-3)))
62834314
BH
208
209(define-public opencv
210 (package
211 (name "opencv")
63856931 212 (version "3.4.3")
62834314
BH
213 (source (origin
214 (method url-fetch)
215 (uri (string-append "https://github.com/opencv/opencv/archive/"
216 version ".zip"))
217 (file-name (string-append name "-" version ".zip"))
218 (sha256
219 (base32
63856931 220 "0pycx1pz8lj794q32mlalyc3ijqxwsyin65r26nh4yc0p71xiirp"))
62834314
BH
221 (modules '((guix build utils)))
222 (snippet
223 '(begin
224 ;; Remove external libraries. We have all available in Guix:
225 (delete-file-recursively "3rdparty")
226
227 ;; Milky icon set is non-free:
228 (delete-file-recursively "modules/highgui/src/files_Qt/Milky")
229
230 ;; Some jars found:
231 (for-each delete-file
232 '("modules/java/test/pure_test/lib/junit-4.11.jar"
233 "samples/java/sbt/sbt/sbt-launch.jar"))))))
234 (build-system cmake-build-system)
235 (arguments
236 `(#:configure-flags
237 (list "-DWITH_IPP=OFF"
238 "-DWITH_ITT=OFF"
6949f45c 239 "-DWITH_CAROTENE=OFF" ; only visible on arm/aarch64
fdeb2def 240 "-DENABLE_PRECOMPILED_HEADERS=OFF"
62834314
BH
241
242 ;; CPU-Features:
243 ;; See cmake/OpenCVCompilerOptimizations.cmake
244 ;; (CPU_ALL_OPTIMIZATIONS) for a list of all optimizations
245 ;; BASELINE is the minimum optimization all CPUs must support
246 ;;
fdeb2def 247 ;; DISPATCH is the list of optional dispatches. We add them all.
62834314
BH
248 "-DCPU_BASELINE=SSE2, NEON"
249
fdeb2def 250 "-DCPU_DISPATCH=NEON;VFPV3;FP16;SSE;SSE2;SSE3;SSSE3;SSE4_1;SSE4_2;POPCNT;AVX;FP16;AVX2;FMA3;AVX_512F;AVX512_SKX"
6949f45c
EF
251 ,@(if (string-prefix? "x86_64" (or (%current-target-system)
252 (%current-system)))
253 '("-DCPU_DISPATCH_REQUIRE=SSE3,SSSE3,SSE4_1,SSE4_2,AVX,AVX2")
254 '())
62834314
BH
255
256 "-DBUILD_PERF_TESTS=OFF"
6949f45c 257 "-DBUILD_TESTS=ON"
62834314 258
b5baf952 259 (string-append "-DOPENCV_EXTRA_MODULES_PATH=" (getcwd)
62834314
BH
260 "/opencv-contrib/opencv_contrib-" ,version
261 "/modules")
262
263 ;;Define test data:
b5baf952 264 (string-append "-DOPENCV_TEST_DATA_PATH=" (getcwd)
62834314
BH
265 "/opencv-extra/opencv_extra-" ,version
266 "/testdata")
267
268 ;; Is ON by default and would try to rebuild 3rd-party protobuf,
269 ;; which we had removed, which would lead to an error:
270 "-DBUILD_PROTOBUF=OFF"
271
272 ;; Rebuild protobuf files, because we have a slightly different
273 ;; version than the included one. If we would not update, we
274 ;; would get a compile error later:
275 "-DPROTOBUF_UPDATE_FILES=ON"
276
277 ;; xfeatures2d disabled, because it downloads extra binaries from
278 ;; https://github.com/opencv/opencv_3rdparty
279 ;; defined in xfeatures2d/cmake/download_{vgg|bootdesc}.cmake
280 ;; Cmp this bug entry:
281 ;; https://github.com/opencv/opencv_contrib/issues/1131
282 "-DBUILD_opencv_xfeatures2d=OFF")
283 #:phases
284 (modify-phases %standard-phases
285 (add-after 'unpack 'disable-broken-tests
286 (lambda _
287 ;; These tests fails with:
288 ;; vtkXOpenGLRenderWindow (0x723990): Could not find a decent config
289 ;; I think we have no OpenGL support with the Xvfb.
290 (substitute* '("modules/viz/test/test_tutorial3.cpp"
291 "modules/viz/test/test_main.cpp"
292 "modules/viz/test/tests_simple.cpp"
293 "modules/viz/test/test_viz3d.cpp")
294 (("(TEST\\(Viz, )([a-z].*\\).*)" all pre post)
295 (string-append pre "DISABLED_" post)))
296
297 ;; This one fails with "unknown file: Failure"
298 ;; But I couldn't figure out which file was missing:
299 (substitute* (list (string-append
300 "../opencv-contrib/opencv_contrib-"
301 ,version
302 "/modules/face/test/test_face_align.cpp"))
303 (("(TEST\\(CV_Face_FacemarkKazemi, )(can_detect_landmarks\\).*)"
304 all pre post)
305 (string-append pre "DISABLED_" post)))
306
307 ;; Failure reason: Bad accuracy
308 ;; Incorrect count of accurate poses [2nd case]: 90.000000 / 94.000000
309 (substitute* (list (string-append
310 "../opencv-contrib/opencv_contrib-"
311 ,version
312 "/modules/rgbd/test/test_odometry.cpp"))
313 (("(TEST\\(RGBD_Odometry_Rgbd, )(algorithmic\\).*)" all pre post)
314 (string-append pre "DISABLED_" post)))
315 #t))
316
317 ;; Idea copied from ldc.scm (ldc-bootstrap):
318 (add-after 'unpack 'unpack-submodule-sources
319 (lambda* (#:key inputs #:allow-other-keys)
320 (mkdir "../opencv-extra")
321 (mkdir "../opencv-contrib")
322 (let ((unpack (lambda (source target)
323 (with-directory-excursion target
324 (apply invoke "unzip"
8e21fa0b
EF
325 (list (assoc-ref inputs source))))))
326 (untar (lambda (source target)
327 (with-directory-excursion target
328 (apply invoke "tar" "xvf"
329 (list (assoc-ref inputs source)))))))
62834314 330 (unpack "opencv-extra" "../opencv-extra")
8e21fa0b 331 (untar "opencv-contrib" "../opencv-contrib"))))
62834314
BH
332
333 (add-after 'set-paths 'add-ilmbase-include-path
334 (lambda* (#:key inputs #:allow-other-keys)
335 ;; OpenEXR propagates ilmbase, but its include files do not appear
336 ;; in the CPATH, so we need to add "$ilmbase/include/OpenEXR/" to
337 ;; the CPATH to satisfy the dependency on "ImathVec.h".
338 (setenv "CPATH"
339 (string-append (assoc-ref inputs "ilmbase")
340 "/include/OpenEXR"
341 ":" (or (getenv "CPATH") "")))
342 #t))
343 (add-before 'check 'start-xserver
344 (lambda* (#:key inputs #:allow-other-keys)
345 (let ((xorg-server (assoc-ref inputs "xorg-server"))
346 (disp ":1"))
347 (setenv "HOME" (getcwd))
348 (setenv "DISPLAY" disp)
349 ;; There must be a running X server and make check doesn't start one.
350 ;; Therefore we must do it.
351 (zero? (system (format #f "~a/bin/Xvfb ~a &" xorg-server disp)))))))))
352 (native-inputs
353 `(("unzip" ,unzip)
354 ("pkg-config" ,pkg-config)
355 ("xorg-server" ,xorg-server) ; For running the tests
356 ("opencv-extra"
357 ,(origin
358 (method url-fetch)
359 (uri (string-append "https://codeload.github.com/"
360 "opencv/opencv_extra/zip/" version))
361 (file-name (string-append "opencv-extra-" version ".zip"))
362 (sha256
63856931 363 (base32 "0yd1vidzbg6himxyh4yzivywijg8548kfmcn421khabnipm7l74y"))))
62834314
BH
364 ("opencv-contrib"
365 ,(origin
366 (method url-fetch)
367 (uri (string-append "https://codeload.github.com/"
368 "opencv/opencv_contrib/zip/" version))
369 (file-name (string-append "opencv-contrib-" version ".zip"))
8e21fa0b 370 (patches (search-patches "opencv-rgbd-aarch64-test-fix.patch"))
62834314 371 (sha256
63856931 372 (base32 "0j0ci6ia1qwklp9hq07ypl0vkngj1wrgh6n98n657m5d0pyp4m0g"))))))
62834314
BH
373 (inputs `(("libjpeg" ,libjpeg)
374 ("libpng" ,libpng)
375 ("jasper" ,jasper)
376 ;; ffmpeg 4.0 causes core dumps in tests.
377 ("ffmpeg" ,ffmpeg-3.4)
378 ("libtiff" ,libtiff)
379 ("hdf5" ,hdf5)
380 ("libgphoto2" ,libgphoto2)
381 ("libwebp" ,libwebp)
382 ("zlib" ,zlib)
383 ("gtkglext" ,gtkglext)
384 ("openexr" ,openexr)
385 ("ilmbase" ,ilmbase)
386 ("gtk+" ,gtk+-2)
387 ("python-numpy" ,python-numpy)
388 ("protobuf" ,protobuf)
389 ("vtk" ,vtk)
390 ("python" ,python)))
5834e4b7
BH
391 ;; These three CVEs are not a problem of OpenCV, see:
392 ;; https://github.com/opencv/opencv/issues/10998
393 (properties '((lint-hidden-cve . ("CVE-2018-7712"
394 "CVE-2018-7713"
395 "CVE-2018-7714"))))
62834314
BH
396 (synopsis "Computer vision library")
397 (description "OpenCV is a library aimed at
398real-time computer vision, including several hundred computer
399vision algorithms. It can be used to do things like:
400
401@itemize
402@item image and video input and output
403@item image and video processing
404@item displaying
405@item feature recognition
406@item segmentation
407@item facial recognition
408@item stereo vision
409@item structure from motion
410@item augmented reality
411@item machine learning
412@end itemize\n")
413 (home-page "https://opencv.org/")
414 (license license:bsd-3)))
5bbd6931
L
415
416(define-public vips
417 (package
418 (name "vips")
419 (version "8.7.1")
420 (source (origin
421 (method url-fetch)
422 (uri (string-append
423 "https://github.com/libvips/libvips/releases/download/v"
424 version "/vips-" version ".tar.gz"))
425 (sha256
426 (base32 "1w3b90pdw7nj2p0gb4f96h6zhmga513f968ldfhz1rkhg7y81c0s"))))
427 (build-system gnu-build-system)
428 (native-inputs
429 `(("pkg-config" ,pkg-config)
430 ("gobject-introspection" ,gobject-introspection)))
431 (inputs
432 `(("glib" ,glib)
433 ("libjpeg" ,libjpeg)
434 ("libpng" ,libpng)
435 ("librsvg" ,librsvg)
436 ("libtiff" ,libtiff)
437 ("libexif" ,libexif)
438 ("giflib" ,giflib)
439 ("libgsf" ,libgsf)
440 ("fftw" ,fftw)
441 ("poppler" ,poppler)
442 ("pango" ,pango)
443 ("lcms" ,lcms)
444 ("matio" ,matio)
445 ("libwebp" ,libwebp)
446 ("niftilib" ,niftilib)
447 ("openexr" ,openexr)
448 ("orc" ,orc)
449 ("imagemagick" ,imagemagick)
450 ("libxml2" ,libxml2)
451 ("expat" ,expat)
452 ("hdf5" ,hdf5)))
453 (home-page "https://libvips.github.io/libvips/")
37c1cf89
MB
454 (synopsis "Image processing system")
455 (description
456 "vips is a demand-driven, horizontally threaded image processing library.")
5bbd6931 457 (license license:lgpl2.1+)))
e506b5e9
L
458
459(define-public nip2
460 (package
461 (name "nip2")
462 (version "8.7.0")
463 (source
464 (origin
465 (method url-fetch)
466 (uri (string-append "https://github.com/libvips/nip2/releases/download/v"
467 version "/nip2-" version ".tar.gz" ))
468 (sha256
469 (base32 "08dxfds4n1vxdilxcw01741a2r6fxyhawi656b7f0hy6znnkbsbc"))))
470 (build-system gnu-build-system)
471 (arguments
472 `(#:phases
473 (modify-phases %standard-phases
474 ;; test_conv.ws keep failing so disabling for now
475 (add-after 'unpack 'disable-test-conv
476 (lambda _
477 (delete-file "test/workspaces/test_conv.ws")
478 #t))
479 (add-before 'check 'set-home
480 (lambda _
481 (setenv "HOME" "/tmp") #t)))))
482 (inputs
483 `(("vips" ,vips)
484 ("glib" ,glib)
485 ("libtiff" ,libtiff)
486 ("gtk+-2" ,gtk+-2)
487 ("libxml2" ,libxml2)
488 ("libexif" ,libexif)
489 ("libjpeg" ,libjpeg) ;required by vips.pc
490 ("librsvg" ,librsvg)
491 ("fftw" ,fftw)
492 ("libgsf" ,libgsf)
493 ("imagemagick" ,imagemagick)
494 ("orc" ,orc)
495 ("matio" ,matio)
496 ("lcms" ,lcms)
497 ("libwebp" ,libwebp)
498 ("openexr" ,openexr)
499 ("poppler" ,poppler)
500 ("gsl" ,gsl)))
501 (native-inputs
502 `(("flex" ,flex)
503 ("bison" ,bison)
504 ("pkg-config" ,pkg-config)))
505 (home-page "https://github.com/libvips/nip2")
506 (synopsis "Spreadsheet-like GUI for libvips")
507 (description "This package provide a graphical user interface (GUI) for
508the VIPS image processing library. It's a little like a spreadsheet: you
509create a set of formula connecting your objects together, and on a change nip2
510recalculates.")
511 (license license:gpl2+)))