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 tls)
63 #:use-module (gnu packages video)
64 #:use-module (gnu packages xiph)
65 #:use-module (gnu packages xml)
66 #:use-module (gnu packages xorg)
67 #:use-module (ice-9 match))
77 (string-append "ftp://dicom.offis.de/pub/dicom/offis/software/dcmtk/"
78 "dcmtk" (string-join (string-split version #\.) "")
79 "/dcmtk-" version ".tar.gz"))
81 (base32 "1h22z8g0kmvhg8lgkbikyzyphhvxvq6018a00yd6i4g0z9ag6gx9"))))
82 (build-system cmake-build-system)
84 `(;; Our ICU is too recent: “error: ‘UChar’ does not name a type“.
93 `(("doxygen" ,doxygen))) ; for HTML documentation
94 (home-page "https://dcmtk.org")
95 (synopsis "Libraries and programs implementing parts of the DICOM standard")
96 (description "DCMTK is a collection of libraries and applications
97 implementing large parts the DICOM standard. It includes software for
98 examining, constructing and converting DICOM image files, handling offline
99 media, sending and receiving images over a network connection, as well as
100 demonstrative image storage and worklist servers.")
101 (license (license:fsf-free
103 "A union of the Apache 2.0 licence and various non-copyleft
104 licences similar to the Modified BSD licence."))))
112 (uri (string-append "mirror://sourceforge/mia/mia/"
113 (version-major+minor version)
114 "/mia-" version ".tar.xz"))
117 "0j4nd5z7i3v199jh7hqqhwd4g7snchizkc7rhzanpvngqg91m1pb"))))
118 (build-system cmake-build-system)
121 (list "-DMIA_CREATE_NIPYPE_INTERFACES=0"
122 "-DCMAKE_CXX_FLAGS=-fpermissive")))
138 ("libxml++" ,libxml++)
140 ("niftilib" ,niftilib)
143 ("python-lxml" ,python2-lxml)
146 `(("pkg-config" ,pkg-config)
147 ("python" ,python-2)))
148 (home-page "http://mia.sourceforge.net")
149 (synopsis "Toolkit for gray scale medical image analysis")
150 (description "MIA provides a combination of command line tools, plug-ins,
151 and libraries that make it possible run image processing tasks interactively
152 in a command shell and to prototype using the shell's scripting language. It
153 is built around a plug-in structure that makes it easy to add functionality
154 without compromising the original code base and it makes use of a wide variety
155 of external libraries that provide additional functionality.")
156 (license license:gpl3+)))
164 (uri (string-append "https://vtk.org/files/release/"
165 (version-major+minor version)
166 "/VTK-" version ".tar.gz"))
169 "1fspgp8k0myr6p2a6wkc21ldcswb4bvmb484m12mxgk1a9vxrhrl"))))
170 (build-system cmake-build-system)
172 '(#:build-type "Release" ;Build without '-g' to save space.
173 ;; -DVTK_USE_SYSTEM_NETCDF:BOOL=TRUE requires netcdf_cxx
174 #:configure-flags '("-DVTK_USE_SYSTEM_EXPAT:BOOL=TRUE"
175 "-DVTK_USE_SYSTEM_FREETYPE:BOOL=TRUE"
176 "-DVTK_USE_SYSTEM_HDF5:BOOL=TRUE"
177 "-DVTK_USE_SYSTEM_JPEG:BOOL=TRUE"
178 "-DVTK_USE_SYSTEM_JSONCPP:BOOL=TRUE"
179 "-DVTK_USE_SYSTEM_LIBXML2:BOOL=TRUE"
180 "-DVTK_USE_SYSTEM_OGGTHEORA:BOOL=TRUE"
181 "-DVTK_USE_SYSTEM_PNG:BOOL=TRUE"
182 "-DVTK_USE_SYSTEM_TIFF:BOOL=TRUE"
183 "-DVTK_USE_SYSTEM_ZLIB:BOOL=TRUE")
184 #:tests? #f)) ;XXX: no "test" target
187 ("xorgproto" ,xorgproto)
193 ("freetype" ,freetype)
198 ("libtheora" ,libtheora)
202 (home-page "https://vtk.org/")
203 (synopsis "Libraries for 3D computer graphics")
205 "The Visualization Toolkit (VTK) is a C++ library for 3D computer graphics,
206 image processing and visualization. It supports a wide variety of
207 visualization algorithms including: scalar, vector, tensor, texture, and
208 volumetric methods; and advanced modeling techniques such as: implicit
209 modeling, polygon reduction, mesh smoothing, cutting, contouring, and Delaunay
210 triangulation. VTK has an extensive information visualization framework, has
211 a suite of 3D interaction widgets, supports parallel processing, and
212 integrates with various databases on GUI toolkits such as Qt and Tk.")
213 (license license:bsd-3)))
215 (define-public opencv
222 (url "https://github.com/opencv/opencv")
224 (file-name (git-file-name name version))
227 "06bc61r8myym4s8im10brdjfg4wxkrvsbhhl7vr1msdan2xddzi3"))
228 (modules '((guix build utils)))
231 ;; Remove external libraries. We have all available in Guix:
232 (delete-file-recursively "3rdparty")
234 ;; Milky icon set is non-free:
235 (delete-file-recursively "modules/highgui/src/files_Qt/Milky")
238 (for-each delete-file
239 '("modules/java/test/pure_test/lib/junit-4.11.jar"
240 "samples/java/sbt/sbt/sbt-launch.jar"))
242 (build-system cmake-build-system)
245 (list "-DWITH_IPP=OFF"
247 "-DWITH_CAROTENE=OFF" ; only visible on arm/aarch64
248 "-DENABLE_PRECOMPILED_HEADERS=OFF"
251 ;; See cmake/OpenCVCompilerOptimizations.cmake
252 ;; (CPU_ALL_OPTIMIZATIONS) for a list of all optimizations
253 ;; BASELINE is the minimum optimization all CPUs must support
255 ;; DISPATCH is the list of optional dispatches.
256 "-DCPU_BASELINE=SSE2"
258 ,@(match (%current-system)
260 '("-DCPU_DISPATCH=NEON;VFPV3;FP16;SSE;SSE2;SSE3;SSSE3;SSE4_1;SSE4_2;POPCNT;AVX;FP16;AVX2;FMA3;AVX_512F;AVX512_SKX"
261 "-DCPU_DISPATCH_REQUIRE=SSE3,SSSE3,SSE4_1,SSE4_2,AVX,AVX2"))
263 '("-DCPU_BASELINE_DISABLE=NEON")) ; causes build failures
265 '("-DCPU_BASELINE=NEON"
266 "-DCPU_DISPATCH=NEON;VFPV3;FP16"))
269 "-DBUILD_PERF_TESTS=OFF"
272 (string-append "-DOPENCV_EXTRA_MODULES_PATH=" (getcwd)
273 "/opencv-contrib/modules")
276 (string-append "-DOPENCV_TEST_DATA_PATH=" (getcwd)
277 "/opencv-extra/testdata")
279 ;; Is ON by default and would try to rebuild 3rd-party protobuf,
280 ;; which we had removed, which would lead to an error:
281 "-DBUILD_PROTOBUF=OFF"
283 ;; Rebuild protobuf files, because we have a slightly different
284 ;; version than the included one. If we would not update, we
285 ;; would get a compile error later:
286 "-DPROTOBUF_UPDATE_FILES=ON"
288 ;; xfeatures2d disabled, because it downloads extra binaries from
289 ;; https://github.com/opencv/opencv_3rdparty
290 ;; defined in xfeatures2d/cmake/download_{vgg|bootdesc}.cmake
291 ;; Cmp this bug entry:
292 ;; https://github.com/opencv/opencv_contrib/issues/1131
293 "-DBUILD_opencv_xfeatures2d=OFF")
295 (modify-phases %standard-phases
296 (add-after 'unpack 'disable-broken-tests
298 ;; These tests fails with:
299 ;; vtkXOpenGLRenderWindow (0x723990): Could not find a decent config
300 ;; I think we have no OpenGL support with the Xvfb.
301 (substitute* '("modules/viz/test/test_tutorial3.cpp"
302 "modules/viz/test/test_main.cpp"
303 "modules/viz/test/tests_simple.cpp"
304 "modules/viz/test/test_viz3d.cpp")
305 (("(TEST\\(Viz, )([a-z].*\\).*)" all pre post)
306 (string-append pre "DISABLED_" post)))
308 ;; This one fails with "unknown file: Failure"
309 ;; But I couldn't figure out which file was missing:
310 (substitute* "../opencv-contrib/modules/face/test/test_face_align.cpp"
311 (("(TEST\\(CV_Face_FacemarkKazemi, )(can_detect_landmarks\\).*)"
313 (string-append pre "DISABLED_" post)))
315 ;; Failure reason: Bad accuracy
316 ;; Incorrect count of accurate poses [2nd case]: 90.000000 / 94.000000
317 (substitute* "../opencv-contrib/modules/rgbd/test/test_odometry.cpp"
318 (("(TEST\\(RGBD_Odometry_Rgbd, )(algorithmic\\).*)" all pre post)
319 (string-append pre "DISABLED_" post)))
322 (add-after 'unpack 'unpack-submodule-sources
323 (lambda* (#:key inputs #:allow-other-keys)
324 (mkdir "../opencv-extra")
325 (mkdir "../opencv-contrib")
326 (copy-recursively (assoc-ref inputs "opencv-extra")
329 (assoc-ref inputs "opencv-contrib")
330 "--strip-components=1"
331 "-C" "../opencv-contrib")))
333 (add-after 'set-paths 'add-ilmbase-include-path
334 (lambda* (#:key inputs #:allow-other-keys)
335 ;; OpenEXR propagates ilmbase, but its include files do not appear
336 ;; in the CPATH, so we need to add "$ilmbase/include/OpenEXR/" to
337 ;; the CPATH to satisfy the dependency on "ImathVec.h".
339 (string-append (assoc-ref inputs "ilmbase")
341 ":" (or (getenv "CPATH") "")))
343 (add-before 'check 'start-xserver
344 (lambda* (#:key inputs #:allow-other-keys)
345 (let ((xorg-server (assoc-ref inputs "xorg-server"))
347 (setenv "HOME" (getcwd))
348 (setenv "DISPLAY" disp)
349 ;; There must be a running X server and make check doesn't start one.
350 ;; Therefore we must do it.
351 (zero? (system (format #f "~a/bin/Xvfb ~a &" xorg-server disp)))))))))
353 `(("pkg-config" ,pkg-config)
354 ("xorg-server" ,xorg-server) ; For running the tests
359 (url "https://github.com/opencv/opencv_extra")
361 (file-name (git-file-name "opencv_extra" version))
363 (base32 "08p5xnq8n1jw8svvz0fnirfg7q8dm3p4a5dl7527s5xj0f9qn7lp"))))
368 (url "https://github.com/opencv/opencv_contrib")
370 (file-name (git-file-name "opencv_contrib" version))
371 (patches (search-patches "opencv-rgbd-aarch64-test-fix.patch"))
373 (base32 "1f334glf39nk42mpqq6j732h3ql2mpz89jd4mcl678s8n73nfjh2"))))))
374 (inputs `(("libjpeg" ,libjpeg)
377 ;; ffmpeg 4.0 causes core dumps in tests.
378 ("ffmpeg" ,ffmpeg-3.4)
381 ("libgphoto2" ,libgphoto2)
384 ("gtkglext" ,gtkglext)
388 ("python-numpy" ,python-numpy)
389 ("protobuf" ,protobuf)
392 ;; These three CVEs are not a problem of OpenCV, see:
393 ;; https://github.com/opencv/opencv/issues/10998
394 (properties '((lint-hidden-cve . ("CVE-2018-7712"
397 (synopsis "Computer vision library")
398 (description "OpenCV is a library aimed at
399 real-time computer vision, including several hundred computer
400 vision algorithms. It can be used to do things like:
403 @item image and video input and output
404 @item image and video processing
406 @item feature recognition
408 @item facial recognition
410 @item structure from motion
411 @item augmented reality
412 @item machine learning
414 (home-page "https://opencv.org/")
415 (license license:bsd-3)))
425 "https://github.com/libvips/libvips/releases/download/v"
426 version "/vips-" version ".tar.gz"))
428 (base32 "01gjhcrl6zj7mcj1al717v5jsniahplqhz1xkfh2j78vyfl1hxff"))))
429 (build-system gnu-build-system)
431 `(("pkg-config" ,pkg-config)
432 ("gobject-introspection" ,gobject-introspection)))
448 ("niftilib" ,niftilib)
451 ("imagemagick" ,imagemagick)
455 (home-page "https://libvips.github.io/libvips/")
456 (synopsis "Multithreaded image processing system with low memory needs")
458 "VIPS is a demand-driven, horizontally threaded image processing library.
459 It's particularly good at processing large images, working with colour,
460 scientific analysis, and general research & development.
462 Compared to most image processing libraries VIPS needs little RAM and runs
463 quickly, especially on machines with more than one CPU core. This is primarily
464 due to its architecture which automatically parallelises the image workflows.")
465 (license license:lgpl2.1+)))
474 (uri (string-append "https://github.com/libvips/nip2/releases/download/v"
475 version "/nip2-" version ".tar.gz" ))
477 (base32 "0l7n427njif53npqn02gfjjly8y3khbrkzqxp10j5vp9h97psgiw"))))
478 (build-system gnu-build-system)
481 (modify-phases %standard-phases
482 ;; test_conv.ws keep failing so disabling for now.
483 (add-after 'unpack 'disable-test-conv
485 (delete-file "test/workspaces/test_conv.ws")
487 (add-before 'check 'set-home
489 (setenv "HOME" "/tmp") #t)))))
497 ("libjpeg" ,libjpeg) ; required by vips.pc
501 ("imagemagick" ,imagemagick)
512 ("pkg-config" ,pkg-config)))
513 (home-page "https://github.com/libvips/nip2")
514 (synopsis "Spreadsheet-like GUI for libvips")
515 (description "This package provide a graphical user interface (GUI) for
516 the VIPS image processing library. It's a little like a spreadsheet: you
517 create a set of formula connecting your objects together, and on a change nip2
519 (license license:gpl2+)))