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, 2019 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))
76 (string-append "ftp://dicom.offis.de/pub/dicom/offis/software/dcmtk/"
77 "dcmtk" (string-join (string-split version #\.) "")
78 "/dcmtk-" version ".tar.gz"))
80 (base32 "1h22z8g0kmvhg8lgkbikyzyphhvxvq6018a00yd6i4g0z9ag6gx9"))))
81 (build-system cmake-build-system)
83 `(("libjpeg" ,libjpeg)
88 `(("doxygen" ,doxygen))) ; for HTML documentation
89 (home-page "https://dcmtk.org")
90 (synopsis "Libraries and programs implementing parts of the DICOM standard")
91 (description "DCMTK is a collection of libraries and applications
92 implementing large parts the DICOM standard. It includes software for
93 examining, constructing and converting DICOM image files, handling offline
94 media, sending and receiving images over a network connection, as well as
95 demonstrative image storage and worklist servers.")
96 (license (license:fsf-free
98 "A union of the Apache 2.0 licence and various non-copyleft
99 licences similar to the Modified BSD licence."))))
107 (uri (string-append "mirror://sourceforge/mia/mia/"
108 (version-major+minor version)
109 "/mia-" version ".tar.xz"))
112 "0j4nd5z7i3v199jh7hqqhwd4g7snchizkc7rhzanpvngqg91m1pb"))))
113 (build-system cmake-build-system)
116 (list "-DMIA_CREATE_NIPYPE_INTERFACES=0"
117 "-DCMAKE_CXX_FLAGS=-fpermissive")))
133 ("libxml++" ,libxml++)
135 ("niftilib" ,niftilib)
138 ("python-lxml" ,python2-lxml)
141 `(("pkg-config" ,pkg-config)
142 ("python" ,python-2)))
143 (home-page "http://mia.sourceforge.net")
144 (synopsis "Toolkit for gray scale medical image analysis")
145 (description "MIA provides a combination of command line tools, plug-ins,
146 and libraries that make it possible run image processing tasks interactively
147 in a command shell and to prototype using the shell's scripting language. It
148 is built around a plug-in structure that makes it easy to add functionality
149 without compromising the original code base and it makes use of a wide variety
150 of external libraries that provide additional functionality.")
151 (license license:gpl3+)))
159 (uri (string-append "https://vtk.org/files/release/"
160 (version-major+minor version)
161 "/VTK-" version ".tar.gz"))
164 "1fspgp8k0myr6p2a6wkc21ldcswb4bvmb484m12mxgk1a9vxrhrl"))))
165 (build-system cmake-build-system)
167 '(#:build-type "Release" ;Build without '-g' to save space.
168 ;; -DVTK_USE_SYSTEM_NETCDF:BOOL=TRUE requires netcdf_cxx
169 #:configure-flags '("-DVTK_USE_SYSTEM_EXPAT:BOOL=TRUE"
170 "-DVTK_USE_SYSTEM_FREETYPE:BOOL=TRUE"
171 "-DVTK_USE_SYSTEM_HDF5:BOOL=TRUE"
172 "-DVTK_USE_SYSTEM_JPEG:BOOL=TRUE"
173 "-DVTK_USE_SYSTEM_JSONCPP:BOOL=TRUE"
174 "-DVTK_USE_SYSTEM_LIBXML2:BOOL=TRUE"
175 "-DVTK_USE_SYSTEM_OGGTHEORA:BOOL=TRUE"
176 "-DVTK_USE_SYSTEM_PNG:BOOL=TRUE"
177 "-DVTK_USE_SYSTEM_TIFF:BOOL=TRUE"
178 "-DVTK_USE_SYSTEM_ZLIB:BOOL=TRUE")
179 #:tests? #f)) ;XXX: no "test" target
182 ("xorgproto" ,xorgproto)
188 ("freetype" ,freetype)
193 ("libtheora" ,libtheora)
197 (home-page "https://vtk.org/")
198 (synopsis "Libraries for 3D computer graphics")
200 "The Visualization Toolkit (VTK) is a C++ library for 3D computer graphics,
201 image processing and visualization. It supports a wide variety of
202 visualization algorithms including: scalar, vector, tensor, texture, and
203 volumetric methods; and advanced modeling techniques such as: implicit
204 modeling, polygon reduction, mesh smoothing, cutting, contouring, and Delaunay
205 triangulation. VTK has an extensive information visualization framework, has
206 a suite of 3D interaction widgets, supports parallel processing, and
207 integrates with various databases on GUI toolkits such as Qt and Tk.")
208 (license license:bsd-3)))
210 (define-public opencv
217 (url "https://github.com/opencv/opencv")
219 (file-name (git-file-name name version))
222 "06bc61r8myym4s8im10brdjfg4wxkrvsbhhl7vr1msdan2xddzi3"))
223 (modules '((guix build utils)))
226 ;; Remove external libraries. We have all available in Guix:
227 (delete-file-recursively "3rdparty")
229 ;; Milky icon set is non-free:
230 (delete-file-recursively "modules/highgui/src/files_Qt/Milky")
233 (for-each delete-file
234 '("modules/java/test/pure_test/lib/junit-4.11.jar"
235 "samples/java/sbt/sbt/sbt-launch.jar"))
237 (build-system cmake-build-system)
240 (list "-DWITH_IPP=OFF"
242 "-DWITH_CAROTENE=OFF" ; only visible on arm/aarch64
243 "-DENABLE_PRECOMPILED_HEADERS=OFF"
246 ;; See cmake/OpenCVCompilerOptimizations.cmake
247 ;; (CPU_ALL_OPTIMIZATIONS) for a list of all optimizations
248 ;; BASELINE is the minimum optimization all CPUs must support
250 ;; DISPATCH is the list of optional dispatches.
251 "-DCPU_BASELINE=SSE2"
253 ,@(match (%current-system)
255 '("-DCPU_DISPATCH=NEON;VFPV3;FP16;SSE;SSE2;SSE3;SSSE3;SSE4_1;SSE4_2;POPCNT;AVX;FP16;AVX2;FMA3;AVX_512F;AVX512_SKX"
256 "-DCPU_DISPATCH_REQUIRE=SSE3,SSSE3,SSE4_1,SSE4_2,AVX,AVX2"))
258 '("-DCPU_BASELINE_DISABLE=NEON")) ; causes build failures
260 '("-DCPU_BASELINE=NEON"
261 "-DCPU_DISPATCH=NEON;VFPV3;FP16"))
264 "-DBUILD_PERF_TESTS=OFF"
267 (string-append "-DOPENCV_EXTRA_MODULES_PATH=" (getcwd)
268 "/opencv-contrib/modules")
271 (string-append "-DOPENCV_TEST_DATA_PATH=" (getcwd)
272 "/opencv-extra/testdata")
274 ;; Is ON by default and would try to rebuild 3rd-party protobuf,
275 ;; which we had removed, which would lead to an error:
276 "-DBUILD_PROTOBUF=OFF"
278 ;; Rebuild protobuf files, because we have a slightly different
279 ;; version than the included one. If we would not update, we
280 ;; would get a compile error later:
281 "-DPROTOBUF_UPDATE_FILES=ON"
283 ;; xfeatures2d disabled, because it downloads extra binaries from
284 ;; https://github.com/opencv/opencv_3rdparty
285 ;; defined in xfeatures2d/cmake/download_{vgg|bootdesc}.cmake
286 ;; Cmp this bug entry:
287 ;; https://github.com/opencv/opencv_contrib/issues/1131
288 "-DBUILD_opencv_xfeatures2d=OFF")
290 (modify-phases %standard-phases
291 (add-after 'unpack 'disable-broken-tests
293 ;; These tests fails with:
294 ;; vtkXOpenGLRenderWindow (0x723990): Could not find a decent config
295 ;; I think we have no OpenGL support with the Xvfb.
296 (substitute* '("modules/viz/test/test_tutorial3.cpp"
297 "modules/viz/test/test_main.cpp"
298 "modules/viz/test/tests_simple.cpp"
299 "modules/viz/test/test_viz3d.cpp")
300 (("(TEST\\(Viz, )([a-z].*\\).*)" all pre post)
301 (string-append pre "DISABLED_" post)))
303 ;; This one fails with "unknown file: Failure"
304 ;; But I couldn't figure out which file was missing:
305 (substitute* "../opencv-contrib/modules/face/test/test_face_align.cpp"
306 (("(TEST\\(CV_Face_FacemarkKazemi, )(can_detect_landmarks\\).*)"
308 (string-append pre "DISABLED_" post)))
310 ;; Failure reason: Bad accuracy
311 ;; Incorrect count of accurate poses [2nd case]: 90.000000 / 94.000000
312 (substitute* "../opencv-contrib/modules/rgbd/test/test_odometry.cpp"
313 (("(TEST\\(RGBD_Odometry_Rgbd, )(algorithmic\\).*)" all pre post)
314 (string-append pre "DISABLED_" post)))
317 (add-after 'unpack 'unpack-submodule-sources
318 (lambda* (#:key inputs #:allow-other-keys)
319 (mkdir "../opencv-extra")
320 (mkdir "../opencv-contrib")
321 (copy-recursively (assoc-ref inputs "opencv-extra")
324 (assoc-ref inputs "opencv-contrib")
325 "--strip-components=1"
326 "-C" "../opencv-contrib")))
328 (add-after 'set-paths 'add-ilmbase-include-path
329 (lambda* (#:key inputs #:allow-other-keys)
330 ;; OpenEXR propagates ilmbase, but its include files do not appear
331 ;; in the CPATH, so we need to add "$ilmbase/include/OpenEXR/" to
332 ;; the CPATH to satisfy the dependency on "ImathVec.h".
334 (string-append (assoc-ref inputs "ilmbase")
336 ":" (or (getenv "CPATH") "")))
338 (add-before 'check 'start-xserver
339 (lambda* (#:key inputs #:allow-other-keys)
340 (let ((xorg-server (assoc-ref inputs "xorg-server"))
342 (setenv "HOME" (getcwd))
343 (setenv "DISPLAY" disp)
344 ;; There must be a running X server and make check doesn't start one.
345 ;; Therefore we must do it.
346 (zero? (system (format #f "~a/bin/Xvfb ~a &" xorg-server disp)))))))))
348 `(("pkg-config" ,pkg-config)
349 ("xorg-server" ,xorg-server) ; For running the tests
354 (url "https://github.com/opencv/opencv_extra")
356 (file-name (git-file-name "opencv_extra" version))
358 (base32 "08p5xnq8n1jw8svvz0fnirfg7q8dm3p4a5dl7527s5xj0f9qn7lp"))))
363 (url "https://github.com/opencv/opencv_contrib")
365 (file-name (git-file-name "opencv_contrib" version))
366 (patches (search-patches "opencv-rgbd-aarch64-test-fix.patch"))
368 (base32 "1f334glf39nk42mpqq6j732h3ql2mpz89jd4mcl678s8n73nfjh2"))))))
369 (inputs `(("libjpeg" ,libjpeg)
372 ;; ffmpeg 4.0 causes core dumps in tests.
373 ("ffmpeg" ,ffmpeg-3.4)
376 ("libgphoto2" ,libgphoto2)
379 ("gtkglext" ,gtkglext)
383 ("python-numpy" ,python-numpy)
384 ("protobuf" ,protobuf)
387 ;; These three CVEs are not a problem of OpenCV, see:
388 ;; https://github.com/opencv/opencv/issues/10998
389 (properties '((lint-hidden-cve . ("CVE-2018-7712"
392 (synopsis "Computer vision library")
393 (description "OpenCV is a library aimed at
394 real-time computer vision, including several hundred computer
395 vision algorithms. It can be used to do things like:
398 @item image and video input and output
399 @item image and video processing
401 @item feature recognition
403 @item facial recognition
405 @item structure from motion
406 @item augmented reality
407 @item machine learning
409 (home-page "https://opencv.org/")
410 (license license:bsd-3)))
420 "https://github.com/libvips/libvips/releases/download/v"
421 version "/vips-" version ".tar.gz"))
423 (base32 "01gjhcrl6zj7mcj1al717v5jsniahplqhz1xkfh2j78vyfl1hxff"))))
424 (build-system gnu-build-system)
426 `(("pkg-config" ,pkg-config)
427 ("gobject-introspection" ,gobject-introspection)))
443 ("niftilib" ,niftilib)
446 ("imagemagick" ,imagemagick)
450 (home-page "https://libvips.github.io/libvips/")
451 (synopsis "Multithreaded image processing system with low memory needs")
453 "VIPS is a demand-driven, horizontally threaded image processing library.
454 It's particularly good at processing large images, working with colour,
455 scientific analysis, and general research & development.
457 Compared to most image processing libraries VIPS needs little RAM and runs
458 quickly, especially on machines with more than one CPU core. This is primarily
459 due to its architecture which automatically parallelises the image workflows.")
460 (license license:lgpl2.1+)))
469 (uri (string-append "https://github.com/libvips/nip2/releases/download/v"
470 version "/nip2-" version ".tar.gz" ))
472 (base32 "0l7n427njif53npqn02gfjjly8y3khbrkzqxp10j5vp9h97psgiw"))))
473 (build-system gnu-build-system)
476 (modify-phases %standard-phases
477 ;; test_conv.ws keep failing so disabling for now.
478 (add-after 'unpack 'disable-test-conv
480 (delete-file "test/workspaces/test_conv.ws")
482 (add-before 'check 'set-home
484 (setenv "HOME" "/tmp") #t)))))
492 ("libjpeg" ,libjpeg) ; required by vips.pc
496 ("imagemagick" ,imagemagick)
507 ("pkg-config" ,pkg-config)))
508 (home-page "https://github.com/libvips/nip2")
509 (synopsis "Spreadsheet-like GUI for libvips")
510 (description "This package provide a graphical user interface (GUI) for
511 the VIPS image processing library. It's a little like a spreadsheet: you
512 create a set of formula connecting your objects together, and on a change nip2
514 (license license:gpl2+)))