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 build-system cmake)
33 #:use-module (guix build-system gnu)
34 #:use-module (gnu packages)
35 #:use-module (gnu packages algebra)
36 #:use-module (gnu packages bison)
37 #:use-module (gnu packages boost)
38 #:use-module (gnu packages compression)
39 #:use-module (gnu packages documentation)
40 #:use-module (gnu packages flex)
41 #:use-module (gnu packages fontutils)
42 #:use-module (gnu packages ghostscript)
43 #:use-module (gnu packages gl)
44 #:use-module (gnu packages glib)
45 #:use-module (gnu packages gnome)
46 #:use-module (gnu packages graphics)
47 #:use-module (gnu packages graphviz)
48 #:use-module (gnu packages gstreamer)
49 #:use-module (gnu packages gtk)
50 #:use-module (gnu packages image)
51 #:use-module (gnu packages imagemagick)
52 #:use-module (gnu packages maths)
53 #:use-module (gnu packages pdf)
54 #:use-module (gnu packages perl)
55 #:use-module (gnu packages photo)
56 #:use-module (gnu packages pkg-config)
57 #:use-module (gnu packages protobuf)
58 #:use-module (gnu packages python)
59 #:use-module (gnu packages serialization)
60 #:use-module (gnu packages video)
61 #:use-module (gnu packages xiph)
62 #:use-module (gnu packages xml)
63 #:use-module (gnu packages xorg))
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
71 (version "3.6.1_20170228")
74 (uri (string-append "ftp://dicom.offis.de/pub/dicom/offis/"
75 "software/dcmtk/snapshot/dcmtk-"
79 "04cwfx8yrscqcd59mxk2fh6314ckayi9cp68iql5a57pf2pg5qld"))))
80 (build-system gnu-build-system)
82 `(("libtiff" ,libtiff)
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
91 implementing large parts the DICOM standard. It includes software for
92 examining, constructing and converting DICOM image files, handling offline
93 media, sending and receiving images over a network connection, as well as
94 demonstrative image storage and worklist servers.")
95 (license (license:fsf-free
97 "A union of the Apache 2.0 licence and various non-copyleft
98 licences similar to the Modified BSD licence."))))
106 (uri (string-append "mirror://sourceforge/mia/mia/"
107 (version-major+minor version)
108 "/mia-" version ".tar.xz"))
111 "0j4nd5z7i3v199jh7hqqhwd4g7snchizkc7rhzanpvngqg91m1pb"))))
112 (build-system cmake-build-system)
115 (list "-DMIA_CREATE_NIPYPE_INTERFACES=0"
116 "-DCMAKE_CXX_FLAGS=-fpermissive")))
132 ("libxml++" ,libxml++)
134 ("niftilib" ,niftilib)
137 ("python-lxml" ,python2-lxml)
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,
145 and libraries that make it possible run image processing tasks interactively
146 in a command shell and to prototype using the shell's scripting language. It
147 is built around a plug-in structure that makes it easy to add functionality
148 without compromising the original code base and it makes use of a wide variety
149 of external libraries that provide additional functionality.")
150 (license license:gpl3+)))
158 (uri (string-append "http://www.vtk.org/files/release/"
159 (version-major+minor version)
160 "/VTK-" version ".tar.gz"))
163 "0yj96z58haan77gzilnqp7xpf8hg5jk11a3jx55p2ksd400s0gjz"))))
164 (build-system cmake-build-system)
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
181 ("xorgproto" ,xorgproto)
187 ("freetype" ,freetype)
192 ("libtheora" ,libtheora)
196 (home-page "http://www.vtk.org/")
197 (synopsis "Libraries for 3D computer graphics")
199 "The Visualization Toolkit (VTK) is a C++ library for 3D computer graphics,
200 image processing and visualization. It supports a wide variety of
201 visualization algorithms including: scalar, vector, tensor, texture, and
202 volumetric methods; and advanced modeling techniques such as: implicit
203 modeling, polygon reduction, mesh smoothing, cutting, contouring, and Delaunay
204 triangulation. VTK has an extensive information visualization framework, has
205 a suite of 3D interaction widgets, supports parallel processing, and
206 integrates with various databases on GUI toolkits such as Qt and Tk.")
207 (license license:bsd-3)))
209 (define-public opencv
215 (uri (string-append "https://github.com/opencv/opencv/archive/"
217 (file-name (string-append name "-" version ".zip"))
220 "0pycx1pz8lj794q32mlalyc3ijqxwsyin65r26nh4yc0p71xiirp"))
221 (modules '((guix build utils)))
224 ;; Remove external libraries. We have all available in Guix:
225 (delete-file-recursively "3rdparty")
227 ;; Milky icon set is non-free:
228 (delete-file-recursively "modules/highgui/src/files_Qt/Milky")
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)
237 (list "-DWITH_IPP=OFF"
239 "-DWITH_CAROTENE=OFF" ; only visible on arm/aarch64
240 "-DENABLE_PRECOMPILED_HEADERS=OFF"
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
247 ;; DISPATCH is the list of optional dispatches. We add them all.
248 "-DCPU_BASELINE=SSE2, NEON"
250 "-DCPU_DISPATCH=NEON;VFPV3;FP16;SSE;SSE2;SSE3;SSSE3;SSE4_1;SSE4_2;POPCNT;AVX;FP16;AVX2;FMA3;AVX_512F;AVX512_SKX"
251 ,@(if (string-prefix? "x86_64" (or (%current-target-system)
253 '("-DCPU_DISPATCH_REQUIRE=SSE3,SSSE3,SSE4_1,SSE4_2,AVX,AVX2")
256 "-DBUILD_PERF_TESTS=OFF"
259 (string-append "-DOPENCV_EXTRA_MODULES_PATH=" (getcwd)
260 "/opencv-contrib/opencv_contrib-" ,version
264 (string-append "-DOPENCV_TEST_DATA_PATH=" (getcwd)
265 "/opencv-extra/opencv_extra-" ,version
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"
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"
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")
284 (modify-phases %standard-phases
285 (add-after 'unpack 'disable-broken-tests
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)))
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-"
302 "/modules/face/test/test_face_align.cpp"))
303 (("(TEST\\(CV_Face_FacemarkKazemi, )(can_detect_landmarks\\).*)"
305 (string-append pre "DISABLED_" post)))
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-"
312 "/modules/rgbd/test/test_odometry.cpp"))
313 (("(TEST\\(RGBD_Odometry_Rgbd, )(algorithmic\\).*)" all pre post)
314 (string-append pre "DISABLED_" post)))
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"
325 (list (assoc-ref inputs source)))))))
326 (unpack "opencv-extra" "../opencv-extra")
327 (unpack "opencv-contrib" "../opencv-contrib"))))
329 (add-after 'set-paths 'add-ilmbase-include-path
330 (lambda* (#:key inputs #:allow-other-keys)
331 ;; OpenEXR propagates ilmbase, but its include files do not appear
332 ;; in the CPATH, so we need to add "$ilmbase/include/OpenEXR/" to
333 ;; the CPATH to satisfy the dependency on "ImathVec.h".
335 (string-append (assoc-ref inputs "ilmbase")
337 ":" (or (getenv "CPATH") "")))
339 (add-before 'check 'start-xserver
340 (lambda* (#:key inputs #:allow-other-keys)
341 (let ((xorg-server (assoc-ref inputs "xorg-server"))
343 (setenv "HOME" (getcwd))
344 (setenv "DISPLAY" disp)
345 ;; There must be a running X server and make check doesn't start one.
346 ;; Therefore we must do it.
347 (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
355 (uri (string-append "https://codeload.github.com/"
356 "opencv/opencv_extra/zip/" version))
357 (file-name (string-append "opencv-extra-" version ".zip"))
359 (base32 "0yd1vidzbg6himxyh4yzivywijg8548kfmcn421khabnipm7l74y"))))
363 (uri (string-append "https://codeload.github.com/"
364 "opencv/opencv_contrib/zip/" version))
365 (file-name (string-append "opencv-contrib-" version ".zip"))
367 (base32 "0j0ci6ia1qwklp9hq07ypl0vkngj1wrgh6n98n657m5d0pyp4m0g"))))))
368 (inputs `(("libjpeg" ,libjpeg)
371 ;; ffmpeg 4.0 causes core dumps in tests.
372 ("ffmpeg" ,ffmpeg-3.4)
375 ("libgphoto2" ,libgphoto2)
378 ("gtkglext" ,gtkglext)
382 ("python-numpy" ,python-numpy)
383 ("protobuf" ,protobuf)
386 ;; These three CVEs are not a problem of OpenCV, see:
387 ;; https://github.com/opencv/opencv/issues/10998
388 (properties '((lint-hidden-cve . ("CVE-2018-7712"
391 (synopsis "Computer vision library")
392 (description "OpenCV is a library aimed at
393 real-time computer vision, including several hundred computer
394 vision algorithms. It can be used to do things like:
397 @item image and video input and output
398 @item image and video processing
400 @item feature recognition
402 @item facial recognition
404 @item structure from motion
405 @item augmented reality
406 @item machine learning
408 (home-page "https://opencv.org/")
409 (license license:bsd-3)))
418 "https://github.com/libvips/libvips/releases/download/v"
419 version "/vips-" version ".tar.gz"))
421 (base32 "1w3b90pdw7nj2p0gb4f96h6zhmga513f968ldfhz1rkhg7y81c0s"))))
422 (build-system gnu-build-system)
424 `(("pkg-config" ,pkg-config)
425 ("gobject-introspection" ,gobject-introspection)))
441 ("niftilib" ,niftilib)
444 ("imagemagick" ,imagemagick)
448 (home-page "https://libvips.github.io/libvips/")
449 (synopsis "Image processing system")
451 "vips is a demand-driven, horizontally threaded image processing library.")
452 (license license:lgpl2.1+)))
461 (uri (string-append "https://github.com/libvips/nip2/releases/download/v"
462 version "/nip2-" version ".tar.gz" ))
464 (base32 "08dxfds4n1vxdilxcw01741a2r6fxyhawi656b7f0hy6znnkbsbc"))))
465 (build-system gnu-build-system)
468 (modify-phases %standard-phases
469 ;; test_conv.ws keep failing so disabling for now
470 (add-after 'unpack 'disable-test-conv
472 (delete-file "test/workspaces/test_conv.ws")
474 (add-before 'check 'set-home
476 (setenv "HOME" "/tmp") #t)))))
484 ("libjpeg" ,libjpeg) ;required by vips.pc
488 ("imagemagick" ,imagemagick)
499 ("pkg-config" ,pkg-config)))
500 (home-page "https://github.com/libvips/nip2")
501 (synopsis "Spreadsheet-like GUI for libvips")
502 (description "This package provide a graphical user interface (GUI) for
503 the VIPS image processing library. It's a little like a spreadsheet: you
504 create a set of formula connecting your objects together, and on a change nip2
506 (license license:gpl2+)))