openkinect.scm 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2020 Ekaitz Zarraga <ekaitz@elenq.tech>
  3. ;;; Copyright © 2021 Tobias Geerinckx-Rice <me@tobias.gr>
  4. ;;;
  5. ;;; This file is part of GNU Guix.
  6. ;;;
  7. ;;; GNU Guix is free software; you can redistribute it and/or modify it
  8. ;;; under the terms of the GNU General Public License as published by
  9. ;;; the Free Software Foundation; either version 3 of the License, or (at
  10. ;;; your option) any later version.
  11. ;;;
  12. ;;; GNU Guix is distributed in the hope that it will be useful, but
  13. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  14. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. ;;; GNU General Public License for more details.
  16. ;;;
  17. ;;; You should have received a copy of the GNU General Public License
  18. ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
  19. (define-module (gnu packages openkinect)
  20. #:use-module (guix packages)
  21. #:use-module (guix git-download)
  22. #:use-module (guix build-system cmake)
  23. #:use-module ((guix licenses) #:prefix license:)
  24. #:use-module (gnu packages pkg-config)
  25. #:use-module (gnu packages libusb)
  26. #:use-module (gnu packages python)
  27. #:use-module (gnu packages python-xyz)
  28. #:use-module (gnu packages gl)
  29. #:use-module (gnu packages pkg-config)
  30. #:use-module (gnu packages image-processing))
  31. (define-public libfreenect
  32. (let ((version "0.6.2"))
  33. (package
  34. (name "libfreenect")
  35. (version version)
  36. (source (origin
  37. (method git-fetch)
  38. (uri (git-reference
  39. (url "https://github.com/OpenKinect/libfreenect")
  40. (commit (string-append "v" version))))
  41. (file-name (git-file-name name version))
  42. (sha256
  43. (base32
  44. "02pb8mcl62kzdcgbnv3rw4nl0f08iw8pjiqqhfy3ycpkvyppw97w"))))
  45. (build-system cmake-build-system)
  46. (arguments
  47. '(#:tests? #f ; package has no tests
  48. #:configure-flags
  49. '("-DBUILD_FAKENECT=ON"
  50. "-DBUILD_CPP=ON"
  51. "-DBUILD_EXAMPLES=OFF" ; available in libfreenect-examples
  52. "-DBUILD_CV=OFF" ; available in libfreenect-cv
  53. "-DBUILD_PYTHON=OFF" ; available in python-libfreenect
  54. "-DBUILD_C_SYNC=ON")
  55. #:phases
  56. (modify-phases %standard-phases
  57. (add-after 'install 'install-udev-rules
  58. (lambda* (#:key outputs #:allow-other-keys)
  59. (let* ((out (assoc-ref outputs "out"))
  60. (rules-out (string-append out "/lib/udev/rules.d")))
  61. (install-file "../source/platform/linux/udev/51-kinect.rules"
  62. (string-append rules-out "51-kinect.rules"))
  63. #t))))))
  64. (native-inputs
  65. `(("pkg-config" ,pkg-config)))
  66. (inputs
  67. `(("libusb" ,libusb)))
  68. (synopsis "Drivers and libraries for the Xbox Kinect device")
  69. (description "libfreenect is a userspace driver for the Microsoft Kinect.
  70. It supports: RGB and Depth Images, Motors, Accelerometer, LED and Audio.")
  71. (home-page "https://openkinect.org/")
  72. (license license:gpl2+))))
  73. ;; Library are already compiled in libfreenect, avoid build it again.
  74. (define libfreenect-derived-phases
  75. '(modify-phases %standard-phases
  76. (add-after 'unpack 'patch-CMakeLists.txt
  77. (lambda* (#:key outputs #:allow-other-keys)
  78. (substitute* "CMakeLists.txt"
  79. ((".*libusb.*") "")
  80. (("add_subdirectory \\(src\\)") "")
  81. ((".*libfreenectConfig.cmake.*") ""))
  82. #t))))
  83. (define-public libfreenect-examples
  84. (package
  85. (inherit libfreenect)
  86. (name "libfreenect-examples")
  87. (inputs
  88. `(("libfreenect" ,libfreenect)
  89. ("glut" ,freeglut)))
  90. (arguments
  91. `(#:tests? #f ; package has no tests
  92. #:configure-flags '("-DBUILD_EXAMPLES=ON"
  93. "-DBUILD_FAKENECT=OFF"
  94. "-DBUILD_CPP=OFF"
  95. "-DBUILD_C_SYNC=OFF"
  96. "-DBUILD_CV=OFF")
  97. #:phases ,libfreenect-derived-phases))
  98. (synopsis "Examples for libfreenect, the Xbox Kinect device library")))
  99. (define-public libfreenect-opencv
  100. (package
  101. (inherit libfreenect)
  102. (name "libfreenect-opencv")
  103. (inputs
  104. `(("libfreenect" ,libfreenect)
  105. ("opencv" ,opencv)))
  106. (arguments
  107. `(#:tests? #f ; package has no tests
  108. #:configure-flags '("-DBUILD_EXAMPLES=OFF"
  109. "-DBUILD_FAKENECT=OFF"
  110. "-DBUILD_CPP=OFF"
  111. "-DBUILD_C_SYNC=OFF"
  112. "-DBUILD_CV=ON")
  113. #:phases ,libfreenect-derived-phases))
  114. (synopsis "OpenCV wrapper for libfreenect, the Xbox Kinect device
  115. library")))
  116. (define-public python-libfreenect
  117. (package
  118. (inherit libfreenect)
  119. (name "python-libfreenect")
  120. (native-inputs
  121. `(("python-cython" ,python-cython)))
  122. (inputs
  123. `(("libfreenect" ,libfreenect)))
  124. (propagated-inputs
  125. `(("python" ,python)
  126. ("python-numpy" ,python-numpy)))
  127. (arguments
  128. `(#:tests? #f ; package has no tests
  129. #:configure-flags '("-DBUILD_EXAMPLES=OFF"
  130. "-DBUILD_FAKENECT=OFF"
  131. "-DBUILD_CPP=OFF"
  132. "-DBUILD_C_SYNC=OFF"
  133. "-DBUILD_CV=OFF"
  134. "-DBUILD_PYTHON3=ON")
  135. #:phases ,libfreenect-derived-phases))
  136. (synopsis "Python wrapper for libfreenect, the Xbox Kinect device
  137. library")))