Compiling Opencv with Gstreamer, cmake not finding GStreamer
The below worked for me if you are developing just a Gstreamer applicaiton
# GStreamer CMake building
cmake_minimum_required(VERSION 3.3)
project(GStreamerHello)
set(PKG_CONFIG_USE_CMAKE_PREFIX_PATH ON)
find_package(PkgConfig REQUIRED)
if ( NOT (PKGCONFIG_FOUND))
message(FATAL_ERROR "Please Install PPkgConfig: CMake will Exit")
endif()
pkg_check_modules(GST REQUIRED gstreamer-1.0>=1.8)
if ( NOT (GST_FOUND))
message(FATAL_ERROR "Please Install Gstreamer Dev: CMake will Exit")
endif()
set(ENV{PKG_CONFIG_PATH})
include_directories("${GST_INCLUDE_DIRS}")
link_libraries(${GST_LIBRARIES})
add_executable(gstreamerSrvc src/hello_gstreamer.cc)
add_dependencies(gstreamerSrvc vsphere_header )
target_link_libraries(gstreamerSrvc ${GST_LIBRARIES} )
Note - If you need a dev docker for GStreamer it is below; and for your question it has the parts of compiling with OpenCV as well; More details at https://medium.com/techlogs/compiling-opencv-for-cuda-for-yolo-and-other-cnn-libraries-9ce427c00ff8
FROM nvidia/cuda
# This is a dev image, needed to compile OpenCV with CUDA
# Install Gstreamer and OpenCV Pre-requisite libs
RUN apt-get update -y && apt-get install -y \
libgstreamer1.0-0 \
gstreamer1.0-plugins-base \
gstreamer1.0-plugins-good \
gstreamer1.0-plugins-bad \
gstreamer1.0-plugins-ugly \
gstreamer1.0-libav \
gstreamer1.0-doc \
gstreamer1.0-tools \
libgstreamer1.0-dev \
libgstreamer-plugins-base1.0-dev
RUN apt-get update -y && apt-get install -y pkg-config \
zlib1g-dev libwebp-dev \
libtbb2 libtbb-dev \
libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev \
cmake
RUN apt-get install -y \
autoconf \
autotools-dev \
build-essential \
gcc \
git
ENV OPENCV_RELEASE_TAG 3.4.5
RUN git clone https://github.com/opencv/opencv.git /var/local/git/opencv
RUN cd /var/local/git/opencv && \
git checkout tags/${OPENCV_RELEASE_TAG}
RUN mkdir -p /var/local/git/opencv/build && \
cd /var/local/git/opencv/build $$ && \
cmake -D CMAKE_BUILD_TYPE=Release -D BUILD_PNG=OFF -D \
BUILD_TIFF=OFF -D BUILD_TBB=OFF -D BUILD_JPEG=ON \
-D BUILD_JASPER=OFF -D BUILD_ZLIB=ON -D BUILD_EXAMPLES=OFF \
-D BUILD_opencv_java=OFF -D BUILD_opencv_python2=ON \
-D BUILD_opencv_python3=OFF -D ENABLE_NEON=OFF -D WITH_OPENCL=OFF \
-D WITH_OPENMP=OFF -D WITH_FFMPEG=OFF -D WITH_GSTREAMER=ON -D WITH_GSTREAMER_0_10=OFF \
-D WITH_CUDA=ON -D CUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda/ -D WITH_GTK=ON \
-D WITH_VTK=OFF -D WITH_TBB=ON -D WITH_1394=OFF -D WITH_OPENEXR=OFF \
-D CUDA_ARCH_BIN=6.0 6.1 7.0 -D CUDA_ARCH_PTX="" -D INSTALL_C_EXAMPLES=OFF -D INSTALL_TESTS=OFF ..
RUN cd /var/local/git/opencv/build && \
make install
# Install other tools you need for development
I had the same problem.
gstreamer-base corresponds to libgstbase-1.0.so (or libgstbase-0.10.so), found in package libgstreamer1.0-0 (or libgstreamer0.10-0, as the case may be). Below, we install the '-dev' package.
The other libraries (libgst-video, libgst-app, libgst-riff, libgst-pbutils) I found in package libgstreamer-plugins-base1.0-dev (again, substitute the version you wish to use, either v0.1, or v1.0).
Therefore, the following command should be used to install the missing dependencies:
sudo apt install libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev
Repeat the cmake command, possibly purging the contents of the build directory beforehand.
On Windows there is no "sudo apt install..." I also had all the paths set right in my PATH environment variable, and still had the same problem. I've got this working after setting following CMake Options:
- only set "WITH_GSTREAMER" option to True, "WITH_GSTREAMER_0_10" MUST BE FALSE
- add new entry "GSTREAMER_DIR"=(path to gstreamer) for me it was "C:/gstreamer/1.0/x86_64" I found this solution here
My OpenCV version: 3.4.3