Home:ALL Converter>Compiling Opencv with Gstreamer, cmake not finding GStreamer

Compiling Opencv with Gstreamer, cmake not finding GStreamer

Ask Time:2016-06-07T19:37:10         Author:Asymptote

Json Formatter

I want to build opencv with GStreamer support.

I built the GStreamer from source (version 1.8.1) following this guide: http://kacianka.at/?p=145 I have 'gstreamer_build' folder at my home directory and it contains 'bin' folder with these:

gst-device-monitor-1.0 gst-discoverer-1.0 gst-inspect-1.0 gst-launch-1.0 gst-play-1.0 gst-stats-1.0 gst-typefind-1.0 orc-bugreport orcc

I have this path added to my environment variable PATH.

When I use cmake like:

cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib/modules -D BUILD_opencv_python3=ON -D WITH_GSTREAMER=ON -D WITH_FFMPEG=OFF ..

I get the following output clearly indicating that gstreamer is not found:

-- checking for module 'gstreamer-base-1.0'
--   package 'gstreamer-base-1.0' not found
-- checking for module 'gstreamer-video-1.0'
--   package 'gstreamer-video-1.0' not found
-- checking for module 'gstreamer-app-1.0'
--   package 'gstreamer-app-1.0' not found
-- checking for module 'gstreamer-riff-1.0'
--   package 'gstreamer-riff-1.0' not found
-- checking for module 'gstreamer-pbutils-1.0'
--   package 'gstreamer-pbutils-1.0' not found
-- checking for module 'gstreamer-base-0.10'
--   package 'gstreamer-base-0.10' not found
-- checking for module 'gstreamer-video-0.10'
--   package 'gstreamer-video-0.10' not found
-- checking for module 'gstreamer-app-0.10'
--   package 'gstreamer-app-0.10' not found
-- checking for module 'gstreamer-riff-0.10'
--   package 'gstreamer-riff-0.10' not found
-- checking for module 'gstreamer-pbutils-0.10'
--   package 'gstreamer-pbutils-0.10' not found

and this:

Video I/O:
--     DC1394 1.x:                  NO
--     DC1394 2.x:                  NO
--     FFMPEG:                      NO
--       codec:                     NO
--       format:                    NO
--       util:                      NO
--       swscale:                   NO
--       resample:                  NO
--       gentoo-style:              NO
--     GStreamer:                   NO
--     OpenNI:                      NO
--     OpenNI PrimeSensor Modules:  NO
--     OpenNI2:                     NO
--     PvAPI:                       NO
--     GigEVisionSDK:               NO
--     UniCap:                      NO
--     UniCap ucil:                 NO
--     V4L/V4L2:                    Using libv4l1 (ver 1.0.1) / libv4l2 (ver 1.0.1)
--     XIMEA:                       NO
--     Xine:                        NO
--     gPhoto2:                     NO

Can anyone help me with this?

Author:Asymptote,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/37678324/compiling-opencv-with-gstreamer-cmake-not-finding-gstreamer
Alex Punnen :

The below worked for me if you are developing just a Gstreamer applicaiton\n\n# GStreamer CMake building\ncmake_minimum_required(VERSION 3.3)\nproject(GStreamerHello)\n\nset(PKG_CONFIG_USE_CMAKE_PREFIX_PATH ON)\nfind_package(PkgConfig REQUIRED)\nif ( NOT (PKGCONFIG_FOUND))\n message(FATAL_ERROR \"Please Install PPkgConfig: CMake will Exit\")\nendif()\npkg_check_modules(GST REQUIRED gstreamer-1.0>=1.8)\nif ( NOT (GST_FOUND))\n message(FATAL_ERROR \"Please Install Gstreamer Dev: CMake will Exit\")\nendif()\nset(ENV{PKG_CONFIG_PATH})\n\ninclude_directories(\"${GST_INCLUDE_DIRS}\")\n\nlink_libraries(${GST_LIBRARIES})\n\nadd_executable(gstreamerSrvc src/hello_gstreamer.cc)\nadd_dependencies(gstreamerSrvc vsphere_header )\ntarget_link_libraries(gstreamerSrvc ${GST_LIBRARIES} )\n\n\nNote - 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;\nMore details at https://medium.com/techlogs/compiling-opencv-for-cuda-for-yolo-and-other-cnn-libraries-9ce427c00ff8\n\nFROM nvidia/cuda\n# This is a dev image, needed to compile OpenCV with CUDA\n# Install Gstreamer and OpenCV Pre-requisite libs\nRUN apt-get update -y && apt-get install -y \\\n libgstreamer1.0-0 \\\n gstreamer1.0-plugins-base \\\n gstreamer1.0-plugins-good \\\n gstreamer1.0-plugins-bad \\\n gstreamer1.0-plugins-ugly \\\n gstreamer1.0-libav \\\n gstreamer1.0-doc \\\n gstreamer1.0-tools \\\n libgstreamer1.0-dev \\\n libgstreamer-plugins-base1.0-dev\nRUN apt-get update -y && apt-get install -y pkg-config \\\n zlib1g-dev libwebp-dev \\\n libtbb2 libtbb-dev \\\n libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev \\\n cmake\nRUN apt-get install -y \\\n autoconf \\\n autotools-dev \\\n build-essential \\\n gcc \\\n git\nENV OPENCV_RELEASE_TAG 3.4.5\nRUN git clone https://github.com/opencv/opencv.git /var/local/git/opencv\nRUN cd /var/local/git/opencv && \\\n git checkout tags/${OPENCV_RELEASE_TAG} \nRUN mkdir -p /var/local/git/opencv/build && \\\n cd /var/local/git/opencv/build $$ && \\\n cmake -D CMAKE_BUILD_TYPE=Release -D BUILD_PNG=OFF -D \\\n BUILD_TIFF=OFF -D BUILD_TBB=OFF -D BUILD_JPEG=ON \\\n -D BUILD_JASPER=OFF -D BUILD_ZLIB=ON -D BUILD_EXAMPLES=OFF \\\n -D BUILD_opencv_java=OFF -D BUILD_opencv_python2=ON \\\n -D BUILD_opencv_python3=OFF -D ENABLE_NEON=OFF -D WITH_OPENCL=OFF \\\n -D WITH_OPENMP=OFF -D WITH_FFMPEG=OFF -D WITH_GSTREAMER=ON -D WITH_GSTREAMER_0_10=OFF \\\n -D WITH_CUDA=ON -D CUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda/ -D WITH_GTK=ON \\\n -D WITH_VTK=OFF -D WITH_TBB=ON -D WITH_1394=OFF -D WITH_OPENEXR=OFF \\\n -D CUDA_ARCH_BIN=6.0 6.1 7.0 -D CUDA_ARCH_PTX=\"\" -D INSTALL_C_EXAMPLES=OFF -D INSTALL_TESTS=OFF ..\nRUN cd /var/local/git/opencv/build && \\ \n make install\n# Install other tools you need for development\n",
2019-01-11T08:07:00
Butterfly :

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:\n\n\nonly set \"WITH_GSTREAMER\" option to True, \"WITH_GSTREAMER_0_10\" MUST BE FALSE\nadd new entry \"GSTREAMER_DIR\"=(path to gstreamer)\n for me it was \"C:/gstreamer/1.0/x86_64\"\nI found this solution here\n\n\nMy OpenCV version: 3.4.3",
2019-02-22T17:56:41
Dan0 :

I had the same problem.\n\ngstreamer-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.\n\nThe 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).\n\nTherefore, the following command should be used to install the missing dependencies:\n\nsudo apt install libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev\n\n\nRepeat the cmake command, possibly purging the contents of the build directory beforehand.",
2017-01-15T21:38:39
yy