Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Cross Compiling OpenCV with GStreamer

I'm trying to cross-compile OpenCV with GStreamer for the Raspberry Pi. I am using Debian on amd64, and have setup dpkg to install armhf packages. Here is my current build script.

PKG_CONFIG_LIBDIR="/usr/local/arm-linux-gnueabihf/lib/pkgconfig"
PKG_CONFIG_LIBDIR="$PKG_CONFIG_LIBDIR:/usr/local/lib/arm-linux-gnueabihf/pkgconfig"
PKG_CONFIG_LIBDIR="$PKG_CONFIG_LIBDIR:/usr/lib/arm-linux-gnueabihf/pkgconfig"
PKG_CONFIG_LIBDIR="$PKG_CONFIG_LIBDIR:/usr/arm-linux-gnueabihf/lib/pkgconfig"
export PKG_CONFIG_LIBDIR

cmake -D CMAKE_BUILD_TYPE=Debug \
    -D PYTHON3_INCLUDE_PATH=/usr/include/python3.7m \
    -D PYTHON3_LIBRARIES=/usr/lib/arm-linux-gnueabihf/libpython3.7m.so \
    -D PYTHON3_NUMPY_INCLUDE_DIRS=/usr/lib/python3/dist-packages/numpy/core/include \
    -D BUILD_opencv_python3=ON \
    -D PYTHON3_CVPY_SUFFIX='.cpython-37m-arm-linux-gnueabihf.so' \
    -D BUILD_DOCS=OFF \
    -D BUILD_EXAMPLES=OFF \
    -D BUILD_TESTS=OFF \
    -D BUILD_PERF_TESTS=OFF \
    -D WITH_GSTREAMER=ON \
    -D WITH_GSTREAMER_0_10=OFF \
    -D ENABLE_NEON=ON \
    -D ENABLE_VFPV3=ON \
    -D WITH_GTK=OFF \
    -D CPACK_BINARY_DEB=ON \
    -D CPACK_GENERATOR="DEB" \
    -D CPACK_DEBIAN_PACKAGE_MAINTAINER="Steven Spangler" \
    -D CPACK_DEBIAN_PACKAGE_NAME="OpenCV" \
    -D CPACK_DEBIAN_PACKAGE_VERSION="${OPENCV_VERSION}" \
    -D CPACK_DEBIAN_PACKAGE_ARCHITECTURE="armhf" \
    -D OPENCV_ENABLE_NONFREE=ON \
    -D CMAKE_TOOLCHAIN_FILE="../platforms/linux/arm-gnueabi.toolchain.cmake" \
    -B "${CV_DIR}/build/" \
    -S "${CV_DIR}"

For each GStreamer component, I get an error such as: -- Checking for module 'gstreamer-base-1.0' -- Found gstreamer-base-1.0, version 1.14.4 CMake Warning at cmake/OpenCVUtils.cmake:784 (message): ocv_check_modules(GSTREAMER_base): can't find library 'gstbase-1.0'. Specify 'pkgcfg_lib_GSTREAMER_base_gstbase-1.0' manualy Call Stack (most recent call first): modules/videoio/cmake/detect_gstreamer.cmake:85 (ocv_check_modules) modules/videoio/cmake/init.cmake:3 (include) modules/videoio/cmake/init.cmake:23 (add_backend) cmake/OpenCVModule.cmake:313 (include) cmake/OpenCVModule.cmake:376 (_add_modules_1) modules/CMakeLists.txt:7 (ocv_glob_modules)

Upon running pkg-config gstreamer-base-1.0 --libs --cflags, I get -pthread -I/usr/include/gstreamer-1.0 -I/usr/include/glib-2.0 -I/usr/lib/arm-linux-gnueabihf/glib-2.0/include -lgstbase-1.0 -lgstreamer-1.0 -lgobject-2.0 -lglib-2.0. If I then do pkg-config gstbase-1.0 --libs --cflags, it fails to find it.

Despite this, CMake still claims it was able to find GStreamer and it does compile successfully. However, when you try to use the GStreamer component of OpenCV on the target system, it simply hangs forever.

Here is the full build log. Thanks!