# Contributor: Marian Buschsieweke # Maintainer: Bart Ribbers pkgname=opencv pkgver=4.8.0 pkgrel=4 pkgdesc="Open source computer vision and machine learning library" url="https://opencv.org/" # s390x blocked by vtk -> netcdf arch="all !s390x" license="BSD-3-Clause" depends_dev=" blas-dev eigen-dev ffmpeg-dev freetype-dev glew-dev gst-plugins-base-dev gstreamer-dev harfbuzz-dev hdf5-dev libdc1394-dev libgphoto2-dev libva-glx-dev mesa-dev onetbb-dev openblas-dev openexr-dev openjpeg-dev openjpeg-tools py3-setuptools qt6-qtbase-dev vtk-dev " makedepends=" $depends_dev clang cmake lld samurai python3-dev py3-gpep517 py3-numpy-dev py3-setuptools py3-wheel " subpackages=" $pkgname-dbg $pkgname-dev $pkgname-doc py3-$pkgname-pyc py3-$pkgname:_py3 libopencv_aruco:_lib libopencv_calib3d:_lib libopencv_core:_lib libopencv_dnn:_lib libopencv_face:_lib libopencv_features2d:_lib libopencv_flann:_lib libopencv_highgui:_lib libopencv_imgcodecs:_lib libopencv_imgproc:_lib libopencv_ml:_lib libopencv_objdetect:_lib libopencv_optflow:_lib libopencv_photo:_lib libopencv_plot:_lib libopencv_shape:_lib libopencv_stitching:_lib libopencv_superres:_lib libopencv_tracking:_lib libopencv_video:_lib libopencv_videoio:_lib libopencv_videostab:_lib libopencv_ximgproc:_lib " source="https://github.com/opencv/opencv/archive/$pkgver/opencv-$pkgver.tar.gz https://github.com/opencv/opencv_contrib/archive/$pkgver/opencv_contrib-$pkgver.tar.gz " # Tests require human interaction # net required to download a data file (face_landmark_model.dat) options="net !check" prepare() { default_prepare cd "$srcdir/opencv_contrib-$pkgver"/modules # Only use modules that we care about mv \ aruco \ face \ tracking \ optflow \ plot \ shape \ superres \ videostab \ ximgproc \ "$builddir"/modules/ } build() { case "$CARCH" in x86_64) local extra_cmake_flags="-DCPU_BASELINE_DISABLE=SSE3 -DCPU_BASELINE_REQUIRE=SSE2" ;; esac case "$CARCH" in riscv64) local lto=OFF ;; *) local lto=ON ;; esac # reduce size of debug syms CFLAGS="$CFLAGS -g1" CXXFLAGS="$CXXFLAGS -g1" \ LDFLAGS="$LDFLAGS -fuse-ld=lld" \ CC=clang CXX=clang++ \ cmake -B build -G Ninja \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_INSTALL_PREFIX=/usr \ -DCMAKE_INSTALL_LIBDIR=lib \ -DENABLE_BUILD_HARDENING=ON \ -DENABLE_THIN_LTO=$lto \ -DWITH_OPENCL=ON \ -DWITH_OPENGL=ON \ -DWITH_TBB=ON \ -DWITH_VULKAN=ON \ -DWITH_QT=ON \ -DWITH_ADE=OFF \ -DWITH_opencv_gapi=OFF \ -DWITH_IPP=OFF \ -DBUILD_WITH_DEBUG_INFO=ON \ -DBUILD_TESTS=OFF \ -DBUILD_PERF_TESTS=OFF \ -DBUILD_EXAMPLES=OFF \ -DINSTALL_C_EXAMPLES=OFF \ -DINSTALL_PYTHON_EXAMPLES=OFF \ -DOPENCV_SKIP_PYTHON_LOADER=OFF \ -DOPENCV_GENERATE_PKGCONFIG=ON \ -DOPENCV_ENABLE_NONFREE=OFF \ -DOPENCV_GENERATE_SETUPVARS=OFF \ -DEIGEN_INCLUDE_PATH=/usr/include/eigen3 \ -DCMAKE_SKIP_INSTALL_RPATH=ON \ -DPYTHON_EXECUTABLE=/usr/bin/python3 \ $extra_cmake_flags cmake --build build cd modules/python/package gpep517 build-wheel \ --wheel-dir "$builddir"/.dist \ --output-fd 3 3>&1 >&2 } check() { cd build CTEST_OUTPUT_ON_FAILURE=TRUE ctest } package() { python3 -m installer -d "$pkgdir" \ .dist/*.whl DESTDIR="$pkgdir" cmake --install build python3 -m compileall -fq "$pkgdir"/usr/lib/python* # opencv's python metainfo names it "opencv", as expected. # however, people usually don't use this, they use # https://github.com/opencv/opencv-python # which is installed with "pip install opencv-python", is # exactly the same thing, and is named differently. # so, to be satisfied with a system dependency, it has to follow # that same name. # we can trick pip into thinking both are installed by just copying the # dist-info and changing the name. cd "$pkgdir"/usr/lib/python*/site-packages cp -r opencv-*.dist-info opencv-python-$pkgver.dist-info sed -i \ -e "s|Name: opencv|Name: opencv-python|" \ opencv-python-$pkgver.dist-info/METADATA } samples() { pkgdesc="OpenCV Samples" depends="$pkgname=$pkgver-r$pkgrel" amove usr/share/opencv4/samples } _py3() { pkgdesc="$pkgdesc (python modules)" depends="py3-numpy" amove usr/lib/python3.* } _lib() { pkgdesc="$pkgdesc ($subpkgname library)" amove usr/lib/$subpkgname.so.* } sha512sums=" 48738c3e7460a361274357aef1dd427082ccd59f749d6317d92a414b3741ce6116ea15ed4fedd2d47a25e456c705f3ba114357558646097bfc0e6dba9b3b865c opencv-4.8.0.tar.gz 81cc41cfe1ea03e60b0657edeaa76a90926e5e79a9f93a482e17bc9edbf1b5ce36b13d108fd8fb097f2fb3d6381fbeb102811f44bfc761c2de7f69bf3c5298a1 opencv_contrib-4.8.0.tar.gz "