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