doc: Update documentation of guix lint
[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>
504c285d
JD
9;;;
10;;; This file is part of GNU Guix.
11;;;
12;;; GNU Guix is free software; you can redistribute it and/or modify it
13;;; under the terms of the GNU General Public License as published by
14;;; the Free Software Foundation; either version 3 of the License, or (at
15;;; your option) any later version.
16;;;
17;;; GNU Guix is distributed in the hope that it will be useful, but
18;;; WITHOUT ANY WARRANTY; without even the implied warranty of
19;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20;;; GNU General Public License for more details.
21;;;
22;;; You should have received a copy of the GNU General Public License
23;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
24
25(define-module (gnu packages image-processing)
26 #:use-module ((guix licenses) #:prefix license:)
27 #:use-module (guix packages)
28 #:use-module (guix utils)
29 #:use-module (guix download)
cdb2a211 30 #:use-module (guix build-system cmake)
504c285d
JD
31 #:use-module (guix build-system gnu)
32 #:use-module (gnu packages)
cdb2a211
JD
33 #:use-module (gnu packages algebra)
34 #:use-module (gnu packages boost)
504c285d
JD
35 #:use-module (gnu packages compression)
36 #:use-module (gnu packages documentation)
fb226b43
JD
37 #:use-module (gnu packages fontutils)
38 #:use-module (gnu packages gl)
cdb2a211
JD
39 #:use-module (gnu packages gnome)
40 #:use-module (gnu packages graphics)
41 #:use-module (gnu packages graphviz)
62834314 42 #:use-module (gnu packages gtk)
504c285d 43 #:use-module (gnu packages image)
cdb2a211
JD
44 #:use-module (gnu packages maths)
45 #:use-module (gnu packages perl)
62834314 46 #:use-module (gnu packages photo)
cdb2a211 47 #:use-module (gnu packages pkg-config)
62834314 48 #:use-module (gnu packages protobuf)
cdb2a211 49 #:use-module (gnu packages python)
fb226b43 50 #:use-module (gnu packages serialization)
62834314 51 #:use-module (gnu packages video)
fb226b43 52 #:use-module (gnu packages xiph)
cdb2a211 53 #:use-module (gnu packages xml)
98d6cdda 54 #:use-module (gnu packages xorg))
504c285d
JD
55
56;; We use the latest snapshot of this package because the latest release is
57;; from 2011 and has known vulnerabilities that cannot easily be fixed by
58;; applying patches.
59(define-public dcmtk
60 (package
61 (name "dcmtk")
62 (version "3.6.1_20170228")
63 (source (origin
64 (method url-fetch)
65 (uri (string-append "ftp://dicom.offis.de/pub/dicom/offis/"
66 "software/dcmtk/snapshot/dcmtk-"
67 version ".tar.gz"))
68 (sha256
69 (base32
70 "04cwfx8yrscqcd59mxk2fh6314ckayi9cp68iql5a57pf2pg5qld"))))
71 (build-system gnu-build-system)
72 (inputs
73 `(("libtiff" ,libtiff)
74 ("libpng" ,libpng)
75 ("doxygen" ,doxygen)
76 ("zlib" ,zlib)))
77 (native-inputs
78 `(("perl" ,perl)))
79 (home-page "http://dcmtk.org")
80 (synopsis "Libraries and programs implementing parts of the DICOM standard")
81 (description "DCMTK is a collection of libraries and applications
82implementing large parts the DICOM standard. It includes software for
83examining, constructing and converting DICOM image files, handling offline
84media, sending and receiving images over a network connection, as well as
85demonstrative image storage and worklist servers.")
86 (license (license:fsf-free
87 "file://COPYRIGHT"
88 "A union of the Apache 2.0 licence and various non-copyleft
89licences similar to the Modified BSD licence."))))
cdb2a211
JD
90
91(define-public mia
92 (package
93 (name "mia")
11861d2b 94 (version "2.4.6")
cdb2a211
JD
95 (source (origin
96 (method url-fetch)
97 (uri (string-append "mirror://sourceforge/mia/mia/"
98 (version-major+minor version)
99 "/mia-" version ".tar.xz"))
100 (sha256
101 (base32
11861d2b 102 "0j4nd5z7i3v199jh7hqqhwd4g7snchizkc7rhzanpvngqg91m1pb"))))
cdb2a211
JD
103 (build-system cmake-build-system)
104 (arguments
105 `(#:configure-flags
106 (list "-DMIA_CREATE_NIPYPE_INTERFACES=0"
cdb2a211
JD
107 "-DCMAKE_CXX_FLAGS=-fpermissive")))
108 (inputs
109 `(("boost" ,boost)
110 ("dcmtk" ,dcmtk)
111 ("doxygen" ,doxygen)
112 ("eigen" ,eigen)
113 ("fftw" ,fftw)
114 ("fftwf" ,fftwf)
115 ("gsl" ,gsl)
116 ("gts" ,gts)
117 ("hdf5" ,hdf5)
118 ("itpp" ,itpp)
119 ("libjpeg" ,libjpeg)
120 ("libpng" ,libpng)
121 ("libtiff" ,libtiff)
122 ("libxml" ,libxml2)
123 ("libxml++" ,libxml++)
124 ("maxflow" ,maxflow)
125 ("niftilib" ,niftilib)
126 ("nlopt" ,nlopt)
127 ("openexr" ,openexr)
128 ("python-lxml" ,python2-lxml)
129 ("vtk" ,vtk)))
130 (native-inputs
131 `(("pkg-config" ,pkg-config)
132 ("python" ,python-2)))
133 (home-page "http://mia.sourceforge.net")
134 (synopsis "Toolkit for gray scale medical image analysis")
135 (description "MIA provides a combination of command line tools, plug-ins,
136and libraries that make it possible run image processing tasks interactively
137in a command shell and to prototype using the shell's scripting language. It
138is built around a plug-in structure that makes it easy to add functionality
139without compromising the original code base and it makes use of a wide variety
140of external libraries that provide additional functionality.")
141 (license license:gpl3+)))
fb226b43
JD
142
143(define-public vtk
144 (package
145 (name "vtk")
146 (version "7.1.0")
147 (source (origin
148 (method url-fetch)
149 (uri (string-append "http://www.vtk.org/files/release/"
150 (version-major+minor version)
151 "/VTK-" version ".tar.gz"))
152 (sha256
153 (base32
154 "0yj96z58haan77gzilnqp7xpf8hg5jk11a3jx55p2ksd400s0gjz"))))
155 (build-system cmake-build-system)
156 (arguments
157 '(#:build-type "Release" ;Build without '-g' to save space.
158 ;; -DVTK_USE_SYSTEM_NETCDF:BOOL=TRUE requires netcdf_cxx
159 #:configure-flags '("-DVTK_USE_SYSTEM_EXPAT:BOOL=TRUE"
160 "-DVTK_USE_SYSTEM_FREETYPE:BOOL=TRUE"
161 "-DVTK_USE_SYSTEM_HDF5:BOOL=TRUE"
162 "-DVTK_USE_SYSTEM_JPEG:BOOL=TRUE"
163 "-DVTK_USE_SYSTEM_JSONCPP:BOOL=TRUE"
164 "-DVTK_USE_SYSTEM_LIBXML2:BOOL=TRUE"
165 "-DVTK_USE_SYSTEM_OGGTHEORA:BOOL=TRUE"
166 "-DVTK_USE_SYSTEM_PNG:BOOL=TRUE"
167 "-DVTK_USE_SYSTEM_TIFF:BOOL=TRUE"
168 "-DVTK_USE_SYSTEM_ZLIB:BOOL=TRUE")
169 #:tests? #f)) ;XXX: no "test" target
170 (inputs
171 `(("libXt" ,libxt)
172 ("xproto" ,xproto)
173 ("libX11" ,libx11)
174 ("libxml2" ,libxml2)
175 ("mesa" ,mesa)
176 ("glu" ,glu)
177 ("expat" ,expat)
178 ("freetype" ,freetype)
179 ("hdf5" ,hdf5)
180 ("jpeg" ,libjpeg)
181 ("jsoncpp" ,jsoncpp)
182 ("libogg" ,libogg)
183 ("libtheora" ,libtheora)
184 ("png" ,libpng)
185 ("tiff" ,libtiff)
186 ("zlib" ,zlib)))
187 (home-page "http://www.vtk.org/")
188 (synopsis "Libraries for 3D computer graphics")
189 (description
190 "The Visualization Toolkit (VTK) is a C++ library for 3D computer graphics,
191image processing and visualization. It supports a wide variety of
192visualization algorithms including: scalar, vector, tensor, texture, and
193volumetric methods; and advanced modeling techniques such as: implicit
194modeling, polygon reduction, mesh smoothing, cutting, contouring, and Delaunay
195triangulation. VTK has an extensive information visualization framework, has
196a suite of 3D interaction widgets, supports parallel processing, and
197integrates with various databases on GUI toolkits such as Qt and Tk.")
198 (license license:bsd-3)))
62834314
BH
199
200(define-public opencv
201 (package
202 (name "opencv")
203 (version "3.4.1")
204 (source (origin
205 (method url-fetch)
206 (uri (string-append "https://github.com/opencv/opencv/archive/"
207 version ".zip"))
208 (file-name (string-append name "-" version ".zip"))
209 (sha256
210 (base32
211 "1g8pvnlkzzp50amd89149hqsbvsc2hq3vk1d6a9fksdcx8ra9g94"))
212 (modules '((guix build utils)))
213 (snippet
214 '(begin
215 ;; Remove external libraries. We have all available in Guix:
216 (delete-file-recursively "3rdparty")
217
218 ;; Milky icon set is non-free:
219 (delete-file-recursively "modules/highgui/src/files_Qt/Milky")
220
221 ;; Some jars found:
222 (for-each delete-file
223 '("modules/java/test/pure_test/lib/junit-4.11.jar"
224 "samples/java/sbt/sbt/sbt-launch.jar"))))))
225 (build-system cmake-build-system)
226 (arguments
227 `(#:configure-flags
228 (list "-DWITH_IPP=OFF"
229 "-DWITH_ITT=OFF"
230
231 ;; CPU-Features:
232 ;; See cmake/OpenCVCompilerOptimizations.cmake
233 ;; (CPU_ALL_OPTIMIZATIONS) for a list of all optimizations
234 ;; BASELINE is the minimum optimization all CPUs must support
235 ;;
236 ;; DISPATCH is the list of optional dispatches
237 "-DCPU_BASELINE=SSE2, NEON"
238
239 "-DCPU_DISPATCH=SSE3,SSSE3,SSE4_1,SSE4_2,AVX,AVX2"
240 "-DCPU_DISPATCH_REQUIRE=SSE3,SSSE3,SSE4_1,SSE4_2,AVX,AVX2"
241
242 "-DBUILD_PERF_TESTS=OFF"
243 "-D BUILD_TESTS=ON"
244
245 (string-append "-DOPENCV_EXTRA_MODULES_PATH="
246 "/tmp/guix-build-opencv-" ,version ".drv-0"
247 "/opencv-contrib/opencv_contrib-" ,version
248 "/modules")
249
250 ;;Define test data:
251 (string-append "-DOPENCV_TEST_DATA_PATH="
252 "/tmp/guix-build-opencv-" ,version ".drv-0"
253 ;;"/opencv-3.4.0"
254 "/opencv-extra/opencv_extra-" ,version
255 "/testdata")
256
257 ;; Is ON by default and would try to rebuild 3rd-party protobuf,
258 ;; which we had removed, which would lead to an error:
259 "-DBUILD_PROTOBUF=OFF"
260
261 ;; Rebuild protobuf files, because we have a slightly different
262 ;; version than the included one. If we would not update, we
263 ;; would get a compile error later:
264 "-DPROTOBUF_UPDATE_FILES=ON"
265
266 ;; xfeatures2d disabled, because it downloads extra binaries from
267 ;; https://github.com/opencv/opencv_3rdparty
268 ;; defined in xfeatures2d/cmake/download_{vgg|bootdesc}.cmake
269 ;; Cmp this bug entry:
270 ;; https://github.com/opencv/opencv_contrib/issues/1131
271 "-DBUILD_opencv_xfeatures2d=OFF")
272 #:phases
273 (modify-phases %standard-phases
274 (add-after 'unpack 'disable-broken-tests
275 (lambda _
276 ;; These tests fails with:
277 ;; vtkXOpenGLRenderWindow (0x723990): Could not find a decent config
278 ;; I think we have no OpenGL support with the Xvfb.
279 (substitute* '("modules/viz/test/test_tutorial3.cpp"
280 "modules/viz/test/test_main.cpp"
281 "modules/viz/test/tests_simple.cpp"
282 "modules/viz/test/test_viz3d.cpp")
283 (("(TEST\\(Viz, )([a-z].*\\).*)" all pre post)
284 (string-append pre "DISABLED_" post)))
285
286 ;; This one fails with "unknown file: Failure"
287 ;; But I couldn't figure out which file was missing:
288 (substitute* (list (string-append
289 "../opencv-contrib/opencv_contrib-"
290 ,version
291 "/modules/face/test/test_face_align.cpp"))
292 (("(TEST\\(CV_Face_FacemarkKazemi, )(can_detect_landmarks\\).*)"
293 all pre post)
294 (string-append pre "DISABLED_" post)))
295
296 ;; Failure reason: Bad accuracy
297 ;; Incorrect count of accurate poses [2nd case]: 90.000000 / 94.000000
298 (substitute* (list (string-append
299 "../opencv-contrib/opencv_contrib-"
300 ,version
301 "/modules/rgbd/test/test_odometry.cpp"))
302 (("(TEST\\(RGBD_Odometry_Rgbd, )(algorithmic\\).*)" all pre post)
303 (string-append pre "DISABLED_" post)))
304 #t))
305
306 ;; Idea copied from ldc.scm (ldc-bootstrap):
307 (add-after 'unpack 'unpack-submodule-sources
308 (lambda* (#:key inputs #:allow-other-keys)
309 (mkdir "../opencv-extra")
310 (mkdir "../opencv-contrib")
311 (let ((unpack (lambda (source target)
312 (with-directory-excursion target
313 (apply invoke "unzip"
314 (list (assoc-ref inputs source)))))))
315 (unpack "opencv-extra" "../opencv-extra")
316 (unpack "opencv-contrib" "../opencv-contrib"))))
317
318 (add-after 'set-paths 'add-ilmbase-include-path
319 (lambda* (#:key inputs #:allow-other-keys)
320 ;; OpenEXR propagates ilmbase, but its include files do not appear
321 ;; in the CPATH, so we need to add "$ilmbase/include/OpenEXR/" to
322 ;; the CPATH to satisfy the dependency on "ImathVec.h".
323 (setenv "CPATH"
324 (string-append (assoc-ref inputs "ilmbase")
325 "/include/OpenEXR"
326 ":" (or (getenv "CPATH") "")))
327 #t))
328 (add-before 'check 'start-xserver
329 (lambda* (#:key inputs #:allow-other-keys)
330 (let ((xorg-server (assoc-ref inputs "xorg-server"))
331 (disp ":1"))
332 (setenv "HOME" (getcwd))
333 (setenv "DISPLAY" disp)
334 ;; There must be a running X server and make check doesn't start one.
335 ;; Therefore we must do it.
336 (zero? (system (format #f "~a/bin/Xvfb ~a &" xorg-server disp)))))))))
337 (native-inputs
338 `(("unzip" ,unzip)
339 ("pkg-config" ,pkg-config)
340 ("xorg-server" ,xorg-server) ; For running the tests
341 ("opencv-extra"
342 ,(origin
343 (method url-fetch)
344 (uri (string-append "https://codeload.github.com/"
345 "opencv/opencv_extra/zip/" version))
346 (file-name (string-append "opencv-extra-" version ".zip"))
347 (sha256
348 (base32 "0wfh3pvfxqydf7hsccp50npcsg37sf6fqi6cd3zkc4qil9zhpbps"))))
349 ("opencv-contrib"
350 ,(origin
351 (method url-fetch)
352 (uri (string-append "https://codeload.github.com/"
353 "opencv/opencv_contrib/zip/" version))
354 (file-name (string-append "opencv-contrib-" version ".zip"))
355 (sha256
356 (base32 "18zm0qmjcdvg90c33gzv0ws0xdaid1xpqzz2xa9l2x12qkr6zj3p"))))))
357 (inputs `(("libjpeg" ,libjpeg)
358 ("libpng" ,libpng)
359 ("jasper" ,jasper)
360 ;; ffmpeg 4.0 causes core dumps in tests.
361 ("ffmpeg" ,ffmpeg-3.4)
362 ("libtiff" ,libtiff)
363 ("hdf5" ,hdf5)
364 ("libgphoto2" ,libgphoto2)
365 ("libwebp" ,libwebp)
366 ("zlib" ,zlib)
367 ("gtkglext" ,gtkglext)
368 ("openexr" ,openexr)
369 ("ilmbase" ,ilmbase)
370 ("gtk+" ,gtk+-2)
371 ("python-numpy" ,python-numpy)
372 ("protobuf" ,protobuf)
373 ("vtk" ,vtk)
374 ("python" ,python)))
375 (synopsis "Computer vision library")
376 (description "OpenCV is a library aimed at
377real-time computer vision, including several hundred computer
378vision algorithms. It can be used to do things like:
379
380@itemize
381@item image and video input and output
382@item image and video processing
383@item displaying
384@item feature recognition
385@item segmentation
386@item facial recognition
387@item stereo vision
388@item structure from motion
389@item augmented reality
390@item machine learning
391@end itemize\n")
392 (home-page "https://opencv.org/")
393 (license license:bsd-3)))