PKGBUILD 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. # Maintainer (arch): Ray Rashif <schiv@archlinux.org>
  2. # Contributor (arch): Tobias Powalowski <tpowa@archlinux.org>
  3. # Contributor: André Silva <emulatorman@hyperbola.info>
  4. # Contributor: Márcio Silva <coadde@hyperbola.info>
  5. # Maintainer: Omar Vega Ramos <ovruni@gnu.org.pe>
  6. # Contributor: grizzlyuser <grizzlyuser@protonmail.com>
  7. # parabola changes and rationale:
  8. # - remove non-free/patent-encumbered algorithms and graphics
  9. pkgbase=opencv
  10. pkgname=(opencv opencv-samples)
  11. pkgver=4.5.1
  12. pkgrel=1
  13. pkgrel+=.parabola1
  14. pkgdesc="Free Computer Vision Library, without non-free SIFT and SURF algorithms, Milky icons, and lena images"
  15. arch=(x86_64)
  16. arch+=(armv7h i686)
  17. license=(BSD3)
  18. url="https://opencv.org/"
  19. depends=(tbb openexr gst-plugins-base libdc1394 cblas lapack libgphoto2 openjpeg2 ffmpeg)
  20. depends+=(hicolor-icon-theme)
  21. makedepends=(cmake python-numpy python-setuptools mesa eigen hdf5 lapacke qt5-base vtk glew ant java-environment)
  22. optdepends=('opencv-samples: samples'
  23. 'vtk: for the viz module'
  24. 'qt5-base: for the HighGUI module and the Python bindings'
  25. 'hdf5: for the HDF5 module and the Python bindings'
  26. 'opencl-icd-loader: For coding with OpenCL'
  27. 'python-numpy: Python bindings'
  28. 'java-runtime: Java interface')
  29. mksource=("$pkgbase-$pkgver.tar.gz::https://github.com/opencv/opencv/archive/$pkgver.zip"
  30. "opencv_contrib-$pkgver.tar.gz::https://github.com/opencv/opencv_contrib/archive/$pkgver.tar.gz"
  31. libre.patch)
  32. source=("https://repo.parabola.nu/other/$pkgname-libre/$pkgname-libre-$pkgver.tar.gz")
  33. mksha256sums=('5fbc26ee09e148a4d494b225d04217f7c913ca1a4d46115b70cca3565d7bbe05'
  34. '12c3b1ddd0b8c1a7da5b743590a288df0934e5cef243e036ca290c2e45e425f5'
  35. '15139ab05b9713be6a7ee35b610f42668ea331a67c914b84a5696abd50076c54')
  36. sha256sums=('ceaf168d694e8044e2c705c47537410d8c9871b5665edd82d9792b1233e575a1')
  37. mksource() {
  38. cd "$srcdir/opencv_contrib-$pkgver"
  39. # remove SIFT and SURF algorithms
  40. rm -rv modules/xfeatures2d
  41. cd "$srcdir/$pkgname-$pkgver"
  42. # remove nonfree Milky icons
  43. rm -rv modules/highgui/src/files_Qt/Milky
  44. patch -p1 -i ../libre.patch
  45. # remove nonfree lena.png and lena.jpg images
  46. rm -v $(find . -iname '*lena*')
  47. }
  48. build() {
  49. # SSE only available from Pentium 3 onwards (i686 is way older)
  50. # SSE only available x86 hardware and ARM uses NEON
  51. local _per_arch_options
  52. case "$CARCH" in
  53. i686) _per_arch_options='-DCPU_BASELINE_DISABLE=SSE,SSE2' ;;
  54. x86_64) _per_arch_options='-DCPU_BASELINE_DISABLE=SSE3 -DCPU_BASELINE_REQUIRE=SSE2' ;;
  55. *) _per_arch_options='' ;;
  56. esac
  57. export JAVA_HOME="/usr/lib/jvm/default"
  58. # cmake's FindLAPACK doesn't add cblas to LAPACK_LIBRARIES, so we need to specify them manually
  59. _pythonpath=`python -c "from sysconfig import get_path; print(get_path('platlib'))"`
  60. cmake -B build -S $pkgname-$pkgver \
  61. -DWITH_OPENCL=ON \
  62. -DWITH_OPENGL=ON \
  63. -DWITH_TBB=ON \
  64. -DWITH_VULKAN=ON \
  65. -DWITH_QT=ON \
  66. -DBUILD_WITH_DEBUG_INFO=OFF \
  67. -DBUILD_TESTS=OFF \
  68. -DBUILD_PERF_TESTS=OFF \
  69. -DBUILD_EXAMPLES=ON \
  70. -DINSTALL_C_EXAMPLES=ON \
  71. -DINSTALL_PYTHON_EXAMPLES=ON \
  72. -DCMAKE_INSTALL_PREFIX=/usr \
  73. ${_per_arch_options} \
  74. -DOPENCV_EXTRA_MODULES_PATH="$srcdir/opencv_contrib-$pkgver/modules" \
  75. -DOPENCV_SKIP_PYTHON_LOADER=ON \
  76. -DOPENCV_PYTHON3_INSTALL_PATH=$_pythonpath \
  77. -DLAPACK_LIBRARIES="/usr/lib/liblapack.so;/usr/lib/libblas.so;/usr/lib/libcblas.so" \
  78. -DLAPACK_CBLAS_H="/usr/include/cblas.h" \
  79. -DLAPACK_LAPACKE_H="/usr/include/lapacke.h" \
  80. -DOPENCV_GENERATE_PKGCONFIG=ON \
  81. -DOPENCV_ENABLE_NONFREE=OFF \
  82. -DOPENCV_JNI_INSTALL_PATH=lib \
  83. -DOPENCV_GENERATE_SETUPVARS=OFF \
  84. -DEIGEN_INCLUDE_PATH=/usr/include/eigen3
  85. cmake --build build
  86. }
  87. package_opencv() {
  88. DESTDIR="$pkgdir" cmake --install build
  89. # install license file
  90. install -Dm644 $pkgname-$pkgver/LICENSE -t "$pkgdir"/usr/share/licenses/$pkgname
  91. # separate samples package
  92. mv "$pkgdir"/usr/share/opencv4/samples "$srcdir"
  93. # Add java symlinks expected by some binary blobs
  94. ln -sr "$pkgdir"/usr/share/java/{opencv4/opencv-${pkgver//./},opencv}.jar
  95. ln -sr "$pkgdir"/usr/lib/{libopencv_java${pkgver//./},libopencv_java}.so
  96. }
  97. package_opencv-samples() {
  98. pkgdesc+=" (samples)"
  99. depends=("opencv=$pkgver")
  100. unset optdepends
  101. mkdir -p "$pkgdir"/usr/share/opencv4
  102. mv samples "$pkgdir"/usr/share/opencv4
  103. # install license file
  104. install -Dm644 opencv-$pkgver/LICENSE -t "$pkgdir"/usr/share/licenses/$pkgname
  105. }