Skip to the text
KDOS
Menu
kdos.dev KDOS from Scratch KDOS 0.2 · 4dd4a10 · 2026-11-30 Contents Index

278.1. opencv-4.14.0

Computer vision and machine-learning library, with the tracking, optical-flow and extended image-processing contrib modules and Python bindings

Version 4.14.0, release 2
Shelf ai — Machine learning inference, speech recognition, computer vision and neural translation
Phase 43_toolkits (Toolkits), 2 of 344 in build order
Licence Apache-2.0
Homepage https://opencv.org/
Build time 30.0 SBU
Installed size 66.8 MiB in 434 files
Recipe ports/core/ai/opencv/kpkgbuild

About

OpenCV is the computer-vision library: image processing, feature detection, camera calibration, object tracking, video input and output, and a neural-network inference module, with Python bindings (cv2). The port is the 4.x line, the API digikam, mlt (the motion tracker of Kdenlive and Shotcut), sdrangel and the other consumers are written against. Eight modules come from the separate opencv_contrib tarball.

Sources

Dependencies

Depends on: cmake, ninja, pkgconf, python3, numpy, zlib, libjpeg-turbo, libpng, libtiff, libwebp, openjpeg, openexr, libavif, libjxl, ffmpeg, gstreamer, gst-plugins-base, libva, onetbb, eigen, openblas, qt6-qtbase.

Required by (4): bcnc, digikam, mlt, sdrangel.

Optional, off in KDOS

These switches in build.sh turn off a feature whose library is a port here. The recipe may turn each off on purpose, or because the library was not yet a port when the recipe was written; this list cannot tell which.

Patches

build.sh applies these; kpkg applies nothing by itself.

Installation

From the repository root, inside the build container, this is the line kdosbuild runs for the port:

script/chroot/exec.sh bash -c 'source script/phases/43_toolkits/phase.env && kpkg install opencv'

What kpkg does

kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/ai/opencv.

1. Verify every declared source. Each file a sha256 = line names, found in the port directory or in /var/cache/kpkg/sources, must hash to its line; a mismatch stops the build before anything is unpacked.

cd /ports/core/ai/opencv
echo 'ee8fb9b30eb60850431b4656447080e3737b56e45719c92b67f245950609f86e  opencv-4.14.0.tar.gz' | sha256sum -c -
echo '4f17abd1bc7f88e19c3380c8de7cbf2d863aced5b5ee8d8934cc7902b67d42c9  opencv_contrib-4.14.0.tar.gz' | sha256sum -c -

2. Unpack. The work directory is emptied and the first source is unpacked into $SRC with its top directory stripped; any later tarball lands unstripped beside it in $SRC_ROOT, and a file that is not a tarball is copied into $SRC.

SRC_ROOT=/var/cache/kpkg/work/opencv
SRC=$SRC_ROOT/opencv-4.14.0
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf opencv-4.14.0.tar.gz -C "$SRC" --strip-components=1
tar --no-same-permissions --warning=no-unknown-keyword -xf opencv_contrib-4.14.0.tar.gz -C "$SRC_ROOT"

Every config.guess and config.sub older than automake’s is then replaced with automake’s, so a configure script recognises the musl target.

3. Build. build.sh is sourced in a subshell under set -e, from $SRC, with name, version, release and the five paths PKGNAME, PORT_SRC, SRC_ROOT, SRC and PKG set as shell variables. Its body, verbatim:

patch -p1 -i "$PORT_SRC/ffmpeg9.patch"

mkdir contrib
for m in aruco tracking optflow plot shape superres videostab ximgproc; do
	mv "$SRC_ROOT/opencv_contrib-$version/modules/$m" contrib/
done

case "$(uname -m)" in
	x86_64) _cpu="-DCPU_BASELINE=SSE2 -DCPU_BASELINE_DISABLE=SSE3" ;;
	*) _cpu= ;;
esac

_pydir=$(python3 -c 'import sysconfig; print(sysconfig.get_path("platlib", "posix_prefix"))')

cmake -B build -G Ninja \
	-DCMAKE_POLICY_VERSION_MINIMUM=3.5 \
	-DCMAKE_BUILD_TYPE=Release \
	-DCMAKE_INSTALL_PREFIX=/usr \
	-DCMAKE_INSTALL_LIBDIR=lib \
	-DCMAKE_SKIP_INSTALL_RPATH=ON \
	-DOPENCV_EXTRA_MODULES_PATH="$SRC/contrib" \
	-DOPENCV_GENERATE_PKGCONFIG=ON \
	-DOPENCV_GENERATE_SETUPVARS=OFF \
	-DOPENCV_ENABLE_NONFREE=OFF \
	$_cpu \
	-DBUILD_TESTS=OFF \
	-DBUILD_PERF_TESTS=OFF \
	-DBUILD_EXAMPLES=OFF \
	-DBUILD_DOCS=OFF \
	-DBUILD_PACKAGE=OFF \
	-DBUILD_opencv_apps=ON \
	-DBUILD_opencv_gapi=OFF \
	-DBUILD_opencv_python3=ON \
	-DBUILD_opencv_python2=OFF \
	-DBUILD_JAVA=OFF \
	-DBUILD_opencv_js=OFF \
	-DINSTALL_C_EXAMPLES=OFF \
	-DINSTALL_PYTHON_EXAMPLES=OFF \
	-DINSTALL_TESTS=OFF \
	-DPYTHON3_EXECUTABLE=/usr/bin/python3 \
	-DOPENCV_SKIP_PYTHON_LOADER=ON \
	-DOPENCV_PYTHON3_INSTALL_PATH="$_pydir" \
	-DBUILD_ZLIB=OFF \
	-DBUILD_JPEG=OFF \
	-DBUILD_PNG=OFF \
	-DBUILD_TIFF=OFF \
	-DBUILD_WEBP=OFF \
	-DBUILD_OPENJPEG=OFF \
	-DBUILD_OPENEXR=OFF \
	-DBUILD_JASPER=OFF \
	-DBUILD_TBB=OFF \
	-DBUILD_IPP_IW=OFF \
	-DBUILD_ITT=OFF \
	-DBUILD_PROTOBUF=ON \
	-DPROTOBUF_UPDATE_FILES=OFF \
	-DWITH_PROTOBUF=ON \
	-DWITH_FLATBUFFERS=ON \
	-DWITH_JPEG=ON \
	-DWITH_PNG=ON \
	-DWITH_SPNG=OFF \
	-DWITH_TIFF=ON \
	-DWITH_WEBP=ON \
	-DWITH_OPENJPEG=ON \
	-DWITH_JASPER=OFF \
	-DWITH_OPENEXR=ON \
	-DWITH_AVIF=ON \
	-DWITH_JPEGXL=ON \
	-DWITH_GDAL=OFF \
	-DWITH_GDCM=OFF \
	-DWITH_QUIRC=ON \
	-DWITH_FFMPEG=ON \
	-DWITH_GSTREAMER=ON \
	-DWITH_V4L=ON \
	-DWITH_VA=ON \
	-DWITH_VA_INTEL=OFF \
	-DWITH_1394=OFF \
	-DWITH_GPHOTO2=OFF \
	-DWITH_OPENNI2=OFF \
	-DWITH_OBSENSOR=OFF \
	-DWITH_PVAPI=OFF \
	-DWITH_ARAVIS=OFF \
	-DWITH_XIMEA=OFF \
	-DWITH_UEYE=OFF \
	-DWITH_QT=ON \
	-DWITH_GTK=OFF \
	-DWITH_WAYLAND=OFF \
	-DWITH_FRAMEBUFFER=OFF \
	-DWITH_OPENGL=OFF \
	-DWITH_VTK=OFF \
	-DWITH_VULKAN=OFF \
	-DWITH_OPENCL=ON \
	-DWITH_OPENCL_SVM=OFF \
	-DWITH_OPENCLAMDFFT=OFF \
	-DWITH_OPENCLAMDBLAS=OFF \
	-DWITH_CUDA=OFF \
	-DWITH_TBB=ON \
	-DWITH_OPENMP=OFF \
	-DWITH_PTHREADS_PF=ON \
	-DWITH_EIGEN=ON \
	-DWITH_LAPACK=ON \
	-DWITH_IPP=OFF \
	-DWITH_ITT=OFF \
	-DWITH_ADE=OFF \
	-DWITH_KLEIDICV=OFF \
	-DWITH_FASTCV=OFF \
	-DWITH_HALIDE=OFF \
	-DWITH_OPENVINO=OFF \
	-DWITH_ONNX=OFF \
	-DWITH_TIMVX=OFF \
	-DWITH_CANN=OFF
ninja -C build
DESTDIR=$PKG ninja -C build install

test -f "$PKG/usr/lib/libopencv_core.so"
test -f "$PKG/usr/lib/libopencv_tracking.so"
test -f "$PKG/usr/lib/pkgconfig/opencv4.pc"
test -f "$PKG/usr/include/opencv4/opencv2/core.hpp"
test -n "$(find "$PKG$_pydir" -name 'cv2*.so' | head -1)"

The switches, and why each is set:

The common switches of each build system are explained in the Flag glossary.

4. Package. kpkg removes libtool archives, the info directory index, mimeinfo.cache and every fonts.dir from $PKG, copies the source’s licence files into /usr/share/licenses/opencv, prunes what the image does not ship, lints the tree and rolls it reproducibly:

tar --sort=name --format=gnu --numeric-owner --owner=0 --group=0 \
    --mtime=@$SOURCE_DATE_EPOCH \
    --use-compress-program='xz -9 -T0 --block-size=32MiB --no-adjust' \
    -cf opencv-4.14.0-2.tar.xz -C "$PKG" .

5. Adopt. kpkgadd installs the package’s files over the root, refusing a path another package owns, records the file list in /var/lib/kpkg/db/opencv, and runs the triggers its paths call for.

Contents

Installed programs: opencv_annotation, opencv_interactive-calibration, opencv_model_diagnostics, opencv_version, opencv_visualisation.

Installed libraries: libopencv_aruco.so, libopencv_calib3d.so, libopencv_core.so, libopencv_dnn.so, libopencv_features2d.so, libopencv_flann.so, libopencv_highgui.so, libopencv_imgcodecs.so, libopencv_imgproc.so, libopencv_ml.so, libopencv_objdetect.so, libopencv_optflow.so, libopencv_photo.so, libopencv_plot.so, libopencv_shape.so, libopencv_stitching.so, libopencv_superres.so, libopencv_tracking.so, libopencv_video.so, libopencv_videoio.so, libopencv_videostab.so, libopencv_ximgproc.so.

Installed directories: /usr/include/opencv4, /usr/lib/cmake/opencv4, /usr/share/licenses/opencv, /usr/share/licenses/opencv4, /usr/share/opencv4.

Short descriptions

opencv4.pc Open Source Computer Vision Library

Notes

The two tarballs unpack side by side under $SRC_ROOT; build.sh runs in the OpenCV tree and moves the eight contrib modules out of opencv_contrib-<version>/modules/ into contrib/. Both tarballs carry the same version, and a bump must move both sha256 lines together, or the contrib modules are built against a core they were not released with.

The test lines after the install stop the build unless the core and tracking libraries, opencv4.pc, the headers and the cv2 extension are all in the package, so a contrib module or the Python binding that CMake quietly dropped cannot ship.