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>
12 ;;; This file is part of GNU Guix.
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.
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.
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/>.
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))
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
74 (version "3.6.1_20170228")
77 (uri (string-append "ftp://dicom.offis.de/pub/dicom/offis/"
78 "software/dcmtk/snapshot/dcmtk-"
82 "04cwfx8yrscqcd59mxk2fh6314ckayi9cp68iql5a57pf2pg5qld"))))
83 (build-system gnu-build-system)
85 `(("libtiff" ,libtiff)
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
100 "A union of the Apache 2.0 licence and various non-copyleft
101 licences similar to the Modified BSD licence."))))
109 (uri (string-append "mirror://sourceforge/mia/mia/"
110 (version-major+minor version)
111 "/mia-" version ".tar.xz"))
114 "0j4nd5z7i3v199jh7hqqhwd4g7snchizkc7rhzanpvngqg91m1pb"))))
115 (build-system cmake-build-system)
118 (list "-DMIA_CREATE_NIPYPE_INTERFACES=0"
119 "-DCMAKE_CXX_FLAGS=-fpermissive")))
135 ("libxml++" ,libxml++)
137 ("niftilib" ,niftilib)
140 ("python-lxml" ,python2-lxml)
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+)))
161 (uri (string-append "https://vtk.org/files/release/"
162 (version-major+minor version)
163 "/VTK-" version ".tar.gz"))
166 "1fspgp8k0myr6p2a6wkc21ldcswb4bvmb484m12mxgk1a9vxrhrl"))))
167 (build-system cmake-build-system)
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
184 ("xorgproto" ,xorgproto)
190 ("freetype" ,freetype)
195 ("libtheora" ,libtheora)
199 (home-page "https://vtk.org/")
200 (synopsis "Libraries for 3D computer graphics")
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)))
212 (define-public opencv
219 (url "https://github.com/opencv/opencv")
221 (file-name (git-file-name name version))
224 "06bc61r8myym4s8im10brdjfg4wxkrvsbhhl7vr1msdan2xddzi3"))
225 (modules '((guix build utils)))
228 ;; Remove external libraries. We have all available in Guix:
229 (delete-file-recursively "3rdparty")
231 ;; Milky icon set is non-free:
232 (delete-file-recursively "modules/highgui/src/files_Qt/Milky")
235 (for-each delete-file
236 '("modules/java/test/pure_test/lib/junit-4.11.jar"
237 "samples/java/sbt/sbt/sbt-launch.jar"))
239 (build-system cmake-build-system)
242 (list "-DWITH_IPP=OFF"
244 "-DWITH_CAROTENE=OFF" ; only visible on arm/aarch64
245 "-DENABLE_PRECOMPILED_HEADERS=OFF"
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
252 ;; DISPATCH is the list of optional dispatches.
253 "-DCPU_BASELINE=SSE2"
255 ,@(match (%current-system)
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"))
260 '("-DCPU_BASELINE_DISABLE=NEON")) ; causes build failures
262 '("-DCPU_BASELINE=NEON"
263 "-DCPU_DISPATCH=NEON;VFPV3;FP16"))
266 "-DBUILD_PERF_TESTS=OFF"
269 (string-append "-DOPENCV_EXTRA_MODULES_PATH=" (getcwd)
270 "/opencv-contrib/modules")
273 (string-append "-DOPENCV_TEST_DATA_PATH=" (getcwd)
274 "/opencv-extra/testdata")
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"
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"
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")
292 (modify-phases %standard-phases
293 (add-after 'unpack 'disable-broken-tests
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)))
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\\).*)"
310 (string-append pre "DISABLED_" post)))
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)))
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")
326 (assoc-ref inputs "opencv-contrib")
327 "--strip-components=1"
328 "-C" "../opencv-contrib")))
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".
336 (string-append (assoc-ref inputs "ilmbase")
338 ":" (or (getenv "CPATH") "")))
340 (add-before 'check 'start-xserver
341 (lambda* (#:key inputs #:allow-other-keys)
342 (let ((xorg-server (assoc-ref inputs "xorg-server"))
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)))))))))
350 `(("pkg-config" ,pkg-config)
351 ("xorg-server" ,xorg-server) ; For running the tests
356 (url "https://github.com/opencv/opencv_extra")
358 (file-name (git-file-name "opencv_extra" version))
360 (base32 "08p5xnq8n1jw8svvz0fnirfg7q8dm3p4a5dl7527s5xj0f9qn7lp"))))
365 (url "https://github.com/opencv/opencv_contrib")
367 (file-name (git-file-name "opencv_contrib" version))
368 (patches (search-patches "opencv-rgbd-aarch64-test-fix.patch"))
370 (base32 "1f334glf39nk42mpqq6j732h3ql2mpz89jd4mcl678s8n73nfjh2"))))))
371 (inputs `(("libjpeg" ,libjpeg)
374 ;; ffmpeg 4.0 causes core dumps in tests.
375 ("ffmpeg" ,ffmpeg-3.4)
378 ("libgphoto2" ,libgphoto2)
381 ("gtkglext" ,gtkglext)
385 ("python-numpy" ,python-numpy)
386 ("protobuf" ,protobuf)
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"
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:
400 @item image and video input and output
401 @item image and video processing
403 @item feature recognition
405 @item facial recognition
407 @item structure from motion
408 @item augmented reality
409 @item machine learning
411 (home-page "https://opencv.org/")
412 (license license:bsd-3)))
422 "https://github.com/libvips/libvips/releases/download/v"
423 version "/vips-" version ".tar.gz"))
425 (base32 "01gjhcrl6zj7mcj1al717v5jsniahplqhz1xkfh2j78vyfl1hxff"))))
426 (build-system gnu-build-system)
428 `(("pkg-config" ,pkg-config)
429 ("gobject-introspection" ,gobject-introspection)))
445 ("niftilib" ,niftilib)
448 ("imagemagick" ,imagemagick)
452 (home-page "https://libvips.github.io/libvips/")
453 (synopsis "Image processing system")
455 "vips is a demand-driven, horizontally threaded image processing library.")
456 (license license:lgpl2.1+)))
465 (uri (string-append "https://github.com/libvips/nip2/releases/download/v"
466 version "/nip2-" version ".tar.gz" ))
468 (base32 "0l7n427njif53npqn02gfjjly8y3khbrkzqxp10j5vp9h97psgiw"))))
469 (build-system gnu-build-system)
472 (modify-phases %standard-phases
473 ;; test_conv.ws keep failing so disabling for now.
474 (add-after 'unpack 'disable-test-conv
476 (delete-file "test/workspaces/test_conv.ws")
478 (add-before 'check 'set-home
480 (setenv "HOME" "/tmp") #t)))))
488 ("libjpeg" ,libjpeg) ; required by vips.pc
492 ("imagemagick" ,imagemagick)
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
507 the VIPS image processing library. It's a little like a spreadsheet: you
508 create a set of formula connecting your objects together, and on a change nip2
510 (license license:gpl2+)))