all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Björn Höfling" <bjoern.hoefling@bjoernhoefling.de>
To: 30801@debbugs.gnu.org
Subject: [bug#30801] [PATCH 1/1] gnu: Add opencv.
Date: Tue, 13 Mar 2018 18:07:56 +0100	[thread overview]
Message-ID: <20180313180756.6834a23f@alma-ubu> (raw)
In-Reply-To: <20180313175809.7d782c1a@alma-ubu>

[-- Attachment #1: Type: text/plain, Size: 10183 bytes --]


* gnu/packages/image-processing.scm (opencv): New variable.
---
 gnu/packages/image-processing.scm | 186 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 186 insertions(+)

diff --git a/gnu/packages/image-processing.scm b/gnu/packages/image-processing.scm
index 6705a726c..c33075abc 100644
--- a/gnu/packages/image-processing.scm
+++ b/gnu/packages/image-processing.scm
@@ -5,6 +5,7 @@
 ;;; Copyright © 2014 Mark H Weaver <mhw@netris.org>
 ;;; Copyright © 2016 Eric Bavier <bavier@member.fsf.org>
 ;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
+;;; Copyright © 2018 Björn Höfling <bjoern.hoefling@bjoernhoefling.de>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -38,12 +39,16 @@
   #:use-module (gnu packages gnome)
   #:use-module (gnu packages graphics)
   #:use-module (gnu packages graphviz)
+  #:use-module (gnu packages gtk)
   #:use-module (gnu packages image)
   #:use-module (gnu packages maths)
   #:use-module (gnu packages perl)
+  #:use-module (gnu packages photo)
   #:use-module (gnu packages pkg-config)
+  #:use-module (gnu packages protobuf)
   #:use-module (gnu packages python)
   #:use-module (gnu packages serialization)
+  #:use-module (gnu packages video)
   #:use-module (gnu packages xiph)
   #:use-module (gnu packages xml)
   #:use-module (gnu packages xorg))
@@ -191,3 +196,184 @@ triangulation.  VTK has an extensive information visualization framework, has
 a suite of 3D interaction widgets, supports parallel processing, and
 integrates with various databases on GUI toolkits such as Qt and Tk.")
     (license license:bsd-3)))
+
+(define-public opencv
+  (package
+    (name "opencv")
+    (version "3.4.1")
+    (source (origin
+              (method url-fetch)
+              (uri (string-append "https://github.com/opencv/opencv/archive/"
+                                  version ".zip"))
+              (file-name (string-append name "-" version ".zip"))
+              (sha256
+               (base32
+                "1g8pvnlkzzp50amd89149hqsbvsc2hq3vk1d6a9fksdcx8ra9g94"))
+              (modules '((guix build utils)))
+              (snippet
+               '(begin
+                  ;; Remove external libraries. We have all available in Guix:
+                  (delete-file-recursively "3rdparty")
+
+                  ;; Milky icon set is non-free:
+                  (delete-file-recursively "modules/highgui/src/files_Qt/Milky")
+
+                  ;; Some jars found:
+                  (for-each delete-file
+                            '("modules/java/test/pure_test/lib/junit-4.11.jar"
+                              "samples/java/sbt/sbt/sbt-launch.jar"))))))
+    (build-system cmake-build-system)
+    (arguments
+     `(#:configure-flags
+       (list "-DWITH_IPP=OFF"
+             "-DWITH_ITT=OFF"
+
+             ;; CPU-Features:
+             ;; See cmake/OpenCVCompilerOptimizations.cmake
+             ;; (CPU_ALL_OPTIMIZATIONS) for a list of all optimizations
+             ;; BASELINE is the minimum optimization all CPUs must support
+             ;;
+             ;; DISPATCH is the list of optional dispatches
+             "-DCPU_BASELINE=SSE2, NEON"
+
+             "-DCPU_DISPATCH=SSE3,SSSE3,SSE4_1,SSE4_2,AVX,AVX2"
+             "-DCPU_DISPATCH_REQUIRE=SSE3,SSSE3,SSE4_1,SSE4_2,AVX,AVX2"
+
+             "-DBUILD_PERF_TESTS=OFF"
+             "-D BUILD_TESTS=ON"
+
+             (string-append "-DOPENCV_EXTRA_MODULES_PATH="
+                            "/tmp/guix-build-opencv-" ,version ".drv-0"
+                            "/opencv-contrib/opencv_contrib-" ,version
+                            "/modules")
+
+             ;;Define test data:
+             (string-append "-DOPENCV_TEST_DATA_PATH="
+                            "/tmp/guix-build-opencv-" ,version ".drv-0"
+                            ;;"/opencv-3.4.0"
+                            "/opencv-extra/opencv_extra-" ,version
+                            "/testdata")
+
+             ;; Is ON by default and would try to rebuild 3rd-party protobuf,
+             ;; which we had removed, which would lead to an error:
+             "-DBUILD_PROTOBUF=OFF"
+
+             ;; Rebuild protobuf files, because we have a slightly different
+             ;; version than the included one. If we would not update, we
+             ;; would get a compile error later:
+             "-DPROTOBUF_UPDATE_FILES=ON"
+
+             ;; xfeatures2d disabled, because it downloads extra binaries from
+             ;; https://github.com/opencv/opencv_3rdparty
+             ;; defined in xfeatures2d/cmake/download_{vgg|bootdesc}.cmake
+             ;; Cmp this bug entry:
+             ;; https://github.com/opencv/opencv_contrib/issues/1131
+             "-DBUILD_opencv_xfeatures2d=OFF")
+       #:phases
+       (modify-phases %standard-phases
+         (add-after 'unpack 'disable-broken-tests
+           (lambda _
+             ;; These tests fails with:
+             ;; vtkXOpenGLRenderWindow (0x723990): Could not find a decent config
+             ;; I think we have no OpenGL support with the Xvfb.
+             (substitute* '("modules/viz/test/test_tutorial3.cpp"
+                            "modules/viz/test/test_main.cpp"
+                            "modules/viz/test/tests_simple.cpp"
+                            "modules/viz/test/test_viz3d.cpp")
+               (("(TEST\\(Viz, )([a-z].*\\).*)" all pre post)
+                (string-append pre "DISABLED_" post)))
+
+             ;; This one fails with "unknown file: Failure"
+             ;; But I couldn't figure out which file was missing:
+             (substitute* (list (string-append
+                                 "../opencv-contrib/opencv_contrib-"
+                                 ,version
+                                 "/modules/face/test/test_face_align.cpp"))
+               (("(TEST\\(CV_Face_FacemarkKazemi, )(can_detect_landmarks\\).*)"
+                 all pre post)
+                (string-append pre "DISABLED_" post)))
+
+             ;; Failure reason: Bad accuracy
+             ;; Incorrect count of accurate poses [2nd case]: 90.000000 / 94.000000
+             (substitute* (list (string-append
+                                 "../opencv-contrib/opencv_contrib-"
+                                 ,version
+                                 "/modules/rgbd/test/test_odometry.cpp"))
+               (("(TEST\\(RGBD_Odometry_Rgbd, )(algorithmic\\).*)" all pre post)
+                (string-append pre "DISABLED_" post)))
+             #t))
+
+         ;; Idea copied from ldc.scm (ldc-bootstrap):
+         (add-after 'unpack 'unpack-submodule-sources
+           (lambda* (#:key inputs #:allow-other-keys)
+             (mkdir "../opencv-extra")
+             (mkdir "../opencv-contrib")
+             (let ((unpack (lambda (source target)
+                             (with-directory-excursion target
+                               (apply invoke "unzip"
+                                      (list (assoc-ref inputs source)))))))
+               (unpack "opencv-extra" "../opencv-extra")
+               (unpack "opencv-contrib" "../opencv-contrib"))))
+
+         (add-after 'set-paths 'add-ilmbase-include-path
+           (lambda* (#:key inputs #:allow-other-keys)
+           ;; OpenEXR propagates ilmbase, but its include files do not appear
+           ;; in the CPATH, so we need to add "$ilmbase/include/OpenEXR/" to
+           ;; the CPATH to satisfy the dependency on "ImathVec.h".
+           (setenv "CPATH"
+                   (string-append (assoc-ref inputs "ilmbase")
+                                  "/include/OpenEXR"
+                                  ":" (or (getenv "CPATH") "")))
+           #t))
+       (add-before 'check 'start-xserver
+         (lambda* (#:key inputs #:allow-other-keys)
+           (let ((xorg-server (assoc-ref inputs "xorg-server"))
+                 (disp ":1"))
+             (setenv "HOME" (getcwd))
+             (setenv "DISPLAY" disp)
+             ;; There must be a running X server and make check doesn't start one.
+             ;; Therefore we must do it.
+             (zero? (system (format #f "~a/bin/Xvfb ~a &" xorg-server disp)))))))))
+    (native-inputs
+     `(("unzip" ,unzip)
+       ("pkg-config" ,pkg-config)
+       ("xorg-server" ,xorg-server) ; For running the tests
+       ("opencv-extra"
+        ,(origin
+           (method url-fetch)
+           (uri (string-append "https://codeload.github.com/"
+                               "opencv/opencv_extra/zip/" version))
+           (file-name (string-append "opencv-extra-" version ".zip"))
+           (sha256
+            (base32 "0wfh3pvfxqydf7hsccp50npcsg37sf6fqi6cd3zkc4qil9zhpbps"))))
+       ("opencv-contrib"
+        ,(origin
+           (method url-fetch)
+           (uri (string-append "https://codeload.github.com/"
+                               "opencv/opencv_contrib/zip/" version))
+           (file-name (string-append "opencv-contrib-" version ".zip"))
+           (sha256
+           (base32 "18zm0qmjcdvg90c33gzv0ws0xdaid1xpqzz2xa9l2x12qkr6zj3p"))))))
+    (inputs `(("ffmpeg" ,ffmpeg)
+              ("libjpeg" ,libjpeg)
+              ("libpng" ,libpng)
+              ("jasper" ,jasper)
+              ("libtiff" ,libtiff)
+              ("hdf5" ,hdf5)
+              ("libgphoto2" ,libgphoto2)
+              ("libwebp" ,libwebp)
+              ("zlib" ,zlib)
+              ("gtkglext" ,gtkglext)
+              ("openexr" ,openexr)
+              ("ilmbase" ,ilmbase)
+              ("gtk+" ,gtk+-2)
+              ("python-numpy" ,python-numpy)
+              ("protobuf" ,protobuf)
+              ("vtk" ,vtk)
+              ("python" ,python)))
+    (synopsis "Computer Vision Library")
+    (description "OpenCV (Open Source Computer Vision) is a library aimed at
+real-time computer vision, including several hundred computer
+vision algorithms.")
+    (home-page "https://opencv.org/")
+    (license license:bsd-3)))
-- 
2.16.2


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

  reply	other threads:[~2018-03-13 17:09 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-13 16:58 [bug#30801] [PATCH 0/1] Add opencv Björn Höfling
2018-03-13 17:07 ` Björn Höfling [this message]
2018-03-15 21:04 ` Ludovic Courtès
2018-03-31 22:26   ` Björn Höfling
2018-04-01 12:21     ` Ludovic Courtès
2018-05-07 18:35       ` [bug#30801] " Björn Höfling
2018-05-09 22:01         ` bug#30801: " Ludovic Courtès
2018-05-11  9:51           ` [bug#30801] " Björn Höfling
2018-05-11 12:00             ` Ludovic Courtès
2018-05-12 23:42               ` Björn Höfling

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180313180756.6834a23f@alma-ubu \
    --to=bjoern.hoefling@bjoernhoefling.de \
    --cc=30801@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.