gnu: vips: Update to 8.7.4.
[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)
6c56e9c4 32 #:use-module (guix git-download)
cdb2a211 33 #:use-module (guix build-system cmake)
504c285d
JD
34 #:use-module (guix build-system gnu)
35 #:use-module (gnu packages)
cdb2a211 36 #:use-module (gnu packages algebra)
e506b5e9 37 #:use-module (gnu packages bison)
cdb2a211 38 #:use-module (gnu packages boost)
504c285d
JD
39 #:use-module (gnu packages compression)
40 #:use-module (gnu packages documentation)
e506b5e9 41 #:use-module (gnu packages flex)
fb226b43 42 #:use-module (gnu packages fontutils)
5bbd6931 43 #:use-module (gnu packages ghostscript)
fb226b43 44 #:use-module (gnu packages gl)
5bbd6931 45 #:use-module (gnu packages glib)
cdb2a211
JD
46 #:use-module (gnu packages gnome)
47 #:use-module (gnu packages graphics)
48 #:use-module (gnu packages graphviz)
5bbd6931 49 #:use-module (gnu packages gstreamer)
62834314 50 #:use-module (gnu packages gtk)
504c285d 51 #:use-module (gnu packages image)
5bbd6931 52 #:use-module (gnu packages imagemagick)
cdb2a211 53 #:use-module (gnu packages maths)
5bbd6931 54 #:use-module (gnu packages pdf)
cdb2a211 55 #:use-module (gnu packages perl)
62834314 56 #:use-module (gnu packages photo)
cdb2a211 57 #:use-module (gnu packages pkg-config)
62834314 58 #:use-module (gnu packages protobuf)
cdb2a211 59 #:use-module (gnu packages python)
44d10b1f 60 #:use-module (gnu packages python-xyz)
fb226b43 61 #:use-module (gnu packages serialization)
62834314 62 #:use-module (gnu packages video)
fb226b43 63 #:use-module (gnu packages xiph)
cdb2a211 64 #:use-module (gnu packages xml)
ebe0271a
EF
65 #:use-module (gnu packages xorg)
66 #:use-module (ice-9 match))
504c285d
JD
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
94implementing large parts the DICOM standard. It includes software for
95examining, constructing and converting DICOM image files, handling offline
96media, sending and receiving images over a network connection, as well as
97demonstrative 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
101licences similar to the Modified BSD licence."))))
cdb2a211
JD
102
103(define-public mia
104 (package
105 (name "mia")
11861d2b 106 (version "2.4.6")
cdb2a211
JD
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
11861d2b 114 "0j4nd5z7i3v199jh7hqqhwd4g7snchizkc7rhzanpvngqg91m1pb"))))
cdb2a211
JD
115 (build-system cmake-build-system)
116 (arguments
117 `(#:configure-flags
118 (list "-DMIA_CREATE_NIPYPE_INTERFACES=0"
cdb2a211
JD
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,
148and libraries that make it possible run image processing tasks interactively
149in a command shell and to prototype using the shell's scripting language. It
150is built around a plug-in structure that makes it easy to add functionality
151without compromising the original code base and it makes use of a wide variety
152of external libraries that provide additional functionality.")
153 (license license:gpl3+)))
fb226b43
JD
154
155(define-public vtk
156 (package
157 (name "vtk")
8f8bc406 158 (version "8.2.0")
fb226b43
JD
159 (source (origin
160 (method url-fetch)
f1d4f264 161 (uri (string-append "https://vtk.org/files/release/"
fb226b43
JD
162 (version-major+minor version)
163 "/VTK-" version ".tar.gz"))
164 (sha256
165 (base32
8f8bc406 166 "1fspgp8k0myr6p2a6wkc21ldcswb4bvmb484m12mxgk1a9vxrhrl"))))
fb226b43
JD
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)
6a6db57f 184 ("xorgproto" ,xorgproto)
fb226b43
JD
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)))
f1d4f264 199 (home-page "https://vtk.org/")
fb226b43
JD
200 (synopsis "Libraries for 3D computer graphics")
201 (description
202 "The Visualization Toolkit (VTK) is a C++ library for 3D computer graphics,
203image processing and visualization. It supports a wide variety of
204visualization algorithms including: scalar, vector, tensor, texture, and
205volumetric methods; and advanced modeling techniques such as: implicit
206modeling, polygon reduction, mesh smoothing, cutting, contouring, and Delaunay
207triangulation. VTK has an extensive information visualization framework, has
208a suite of 3D interaction widgets, supports parallel processing, and
209integrates with various databases on GUI toolkits such as Qt and Tk.")
210 (license license:bsd-3)))
62834314
BH
211
212(define-public opencv
213 (package
214 (name "opencv")
63856931 215 (version "3.4.3")
62834314 216 (source (origin
6c56e9c4
EF
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))
62834314
BH
222 (sha256
223 (base32
6c56e9c4 224 "06bc61r8myym4s8im10brdjfg4wxkrvsbhhl7vr1msdan2xddzi3"))
62834314
BH
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"
6c56e9c4
EF
237 "samples/java/sbt/sbt/sbt-launch.jar"))
238 #t))))
62834314
BH
239 (build-system cmake-build-system)
240 (arguments
241 `(#:configure-flags
242 (list "-DWITH_IPP=OFF"
243 "-DWITH_ITT=OFF"
6949f45c 244 "-DWITH_CAROTENE=OFF" ; only visible on arm/aarch64
fdeb2def 245 "-DENABLE_PRECOMPILED_HEADERS=OFF"
62834314
BH
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 ;;
ebe0271a
EF
252 ;; DISPATCH is the list of optional dispatches.
253 "-DCPU_BASELINE=SSE2"
62834314 254
ebe0271a
EF
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 (_ '()))
62834314
BH
265
266 "-DBUILD_PERF_TESTS=OFF"
6949f45c 267 "-DBUILD_TESTS=ON"
62834314 268
b5baf952 269 (string-append "-DOPENCV_EXTRA_MODULES_PATH=" (getcwd)
6c56e9c4 270 "/opencv-contrib/modules")
62834314
BH
271
272 ;;Define test data:
b5baf952 273 (string-append "-DOPENCV_TEST_DATA_PATH=" (getcwd)
6c56e9c4 274 "/opencv-extra/testdata")
62834314
BH
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:
6c56e9c4 307 (substitute* "../opencv-contrib/modules/face/test/test_face_align.cpp"
62834314
BH
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
6c56e9c4 314 (substitute* "../opencv-contrib/modules/rgbd/test/test_odometry.cpp"
62834314
BH
315 (("(TEST\\(RGBD_Odometry_Rgbd, )(algorithmic\\).*)" all pre post)
316 (string-append pre "DISABLED_" post)))
317 #t))
318
62834314
BH
319 (add-after 'unpack 'unpack-submodule-sources
320 (lambda* (#:key inputs #:allow-other-keys)
321 (mkdir "../opencv-extra")
322 (mkdir "../opencv-contrib")
6c56e9c4
EF
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")))
62834314
BH
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
6c56e9c4 350 `(("pkg-config" ,pkg-config)
62834314
BH
351 ("xorg-server" ,xorg-server) ; For running the tests
352 ("opencv-extra"
353 ,(origin
6c56e9c4
EF
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))
62834314 359 (sha256
6c56e9c4 360 (base32 "08p5xnq8n1jw8svvz0fnirfg7q8dm3p4a5dl7527s5xj0f9qn7lp"))))
62834314
BH
361 ("opencv-contrib"
362 ,(origin
6c56e9c4
EF
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))
8e21fa0b 368 (patches (search-patches "opencv-rgbd-aarch64-test-fix.patch"))
62834314 369 (sha256
6c56e9c4 370 (base32 "1f334glf39nk42mpqq6j732h3ql2mpz89jd4mcl678s8n73nfjh2"))))))
62834314
BH
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)))
5834e4b7
BH
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"))))
62834314
BH
394 (synopsis "Computer vision library")
395 (description "OpenCV is a library aimed at
396real-time computer vision, including several hundred computer
397vision 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)))
5bbd6931
L
413
414(define-public vips
415 (package
416 (name "vips")
7e52321f
TGR
417 (version "8.7.4")
418 (source
419 (origin
420 (method url-fetch)
421 (uri (string-append
422 "https://github.com/libvips/libvips/releases/download/v"
423 version "/vips-" version ".tar.gz"))
424 (sha256
425 (base32 "01gjhcrl6zj7mcj1al717v5jsniahplqhz1xkfh2j78vyfl1hxff"))))
5bbd6931
L
426 (build-system gnu-build-system)
427 (native-inputs
428 `(("pkg-config" ,pkg-config)
429 ("gobject-introspection" ,gobject-introspection)))
430 (inputs
431 `(("glib" ,glib)
432 ("libjpeg" ,libjpeg)
433 ("libpng" ,libpng)
434 ("librsvg" ,librsvg)
435 ("libtiff" ,libtiff)
436 ("libexif" ,libexif)
437 ("giflib" ,giflib)
438 ("libgsf" ,libgsf)
439 ("fftw" ,fftw)
440 ("poppler" ,poppler)
441 ("pango" ,pango)
442 ("lcms" ,lcms)
443 ("matio" ,matio)
444 ("libwebp" ,libwebp)
445 ("niftilib" ,niftilib)
446 ("openexr" ,openexr)
447 ("orc" ,orc)
448 ("imagemagick" ,imagemagick)
449 ("libxml2" ,libxml2)
450 ("expat" ,expat)
451 ("hdf5" ,hdf5)))
452 (home-page "https://libvips.github.io/libvips/")
37c1cf89
MB
453 (synopsis "Image processing system")
454 (description
455 "vips is a demand-driven, horizontally threaded image processing library.")
5bbd6931 456 (license license:lgpl2.1+)))
e506b5e9
L
457
458(define-public nip2
459 (package
460 (name "nip2")
f2d3d742 461 (version "8.7.1")
e506b5e9
L
462 (source
463 (origin
464 (method url-fetch)
465 (uri (string-append "https://github.com/libvips/nip2/releases/download/v"
466 version "/nip2-" version ".tar.gz" ))
467 (sha256
f2d3d742 468 (base32 "0l7n427njif53npqn02gfjjly8y3khbrkzqxp10j5vp9h97psgiw"))))
e506b5e9
L
469 (build-system gnu-build-system)
470 (arguments
471 `(#:phases
472 (modify-phases %standard-phases
f2d3d742 473 ;; test_conv.ws keep failing so disabling for now.
e506b5e9
L
474 (add-after 'unpack 'disable-test-conv
475 (lambda _
476 (delete-file "test/workspaces/test_conv.ws")
477 #t))
478 (add-before 'check 'set-home
479 (lambda _
480 (setenv "HOME" "/tmp") #t)))))
481 (inputs
482 `(("vips" ,vips)
483 ("glib" ,glib)
484 ("libtiff" ,libtiff)
485 ("gtk+-2" ,gtk+-2)
486 ("libxml2" ,libxml2)
487 ("libexif" ,libexif)
f2d3d742 488 ("libjpeg" ,libjpeg) ; required by vips.pc
e506b5e9
L
489 ("librsvg" ,librsvg)
490 ("fftw" ,fftw)
491 ("libgsf" ,libgsf)
492 ("imagemagick" ,imagemagick)
493 ("orc" ,orc)
494 ("matio" ,matio)
495 ("lcms" ,lcms)
496 ("libwebp" ,libwebp)
497 ("openexr" ,openexr)
498 ("poppler" ,poppler)
499 ("gsl" ,gsl)))
500 (native-inputs
501 `(("flex" ,flex)
502 ("bison" ,bison)
503 ("pkg-config" ,pkg-config)))
504 (home-page "https://github.com/libvips/nip2")
505 (synopsis "Spreadsheet-like GUI for libvips")
506 (description "This package provide a graphical user interface (GUI) for
507the VIPS image processing library. It's a little like a spreadsheet: you
508create a set of formula connecting your objects together, and on a change nip2
509recalculates.")
510 (license license:gpl2+)))