使用 Gstreamer 编译 Opencv,cmake 找不到 GStreamer
Compiling Opencv with Gstreamer, cmake not finding GStreamer
我想构建支持 GStreamer 的 opencv。
我按照本指南从源代码(版本 1.8.1)构建了 GStreamer:
http://kacianka.at/?p=145
我的主目录中有 'gstreamer_build' 个文件夹,它包含 'bin' 个文件夹,其中包含:
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
我已将此路径添加到我的环境变量 PATH 中。
当我像这样使用 cmake 时:
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
..
我得到以下输出,清楚地表明找不到 gstreamer:
-- 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
还有这个:
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
谁能帮我解决这个问题?
我遇到了同样的问题。
gstreamer-base对应libgstbase-1.0.so(或libgstbase-0.10.so),在包libgstreamer1.0-0[=24=中找到](或 libgstreamer0.10-0,视情况而定)。下面,我们安装“-dev”包。
我在包 libgstreamer-plugins-base1 中找到的其他库(libgst-video、libgst-app、libgst-riff、libgst-pbutils)。 0-dev(同样,替换您要使用的版本,v0.1 或 v1.0)。
因此,应使用以下命令来安装缺少的依赖项:
sudo apt install libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev
重复 cmake 命令,可能事先清除构建目录的内容。
如果你只开发一个 Gstreamer 应用程序,下面的方法对我有用
# 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} )
注意 - 如果您需要 GStreamer 的开发 docker,请参见下方;对于您的问题,它也包含使用 OpenCV 进行编译的部分;
更多详情请见 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
在 Windows 上没有 "sudo apt install..." 我也在我的 PATH 环境变量中设置了所有路径,但仍然有同样的问题。在设置以下 CMake 选项后,我已经开始工作了:
- 仅将 "WITH_GSTREAMER" 选项设置为 True,"WITH_GSTREAMER_0_10" 必须为 FALSE
- 添加新条目"GSTREAMER_DIR"=(gstreamer 的路径)
对我来说是 "C:/gstreamer/1.0/x86_64"
我找到了这个解决方案 here
我的OpenCV版本:3.4.3
添加新条目 "GSTREAMER_DIR"=(path to gstreamer)
对我有用 (WITH_GSTREAMER true
)。我的版本中没有 WITH_GSTREAMER_0_10
。
我想构建支持 GStreamer 的 opencv。
我按照本指南从源代码(版本 1.8.1)构建了 GStreamer: http://kacianka.at/?p=145 我的主目录中有 'gstreamer_build' 个文件夹,它包含 'bin' 个文件夹,其中包含:
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
我已将此路径添加到我的环境变量 PATH 中。
当我像这样使用 cmake 时:
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 ..
我得到以下输出,清楚地表明找不到 gstreamer:
-- 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
还有这个:
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
谁能帮我解决这个问题?
我遇到了同样的问题。
gstreamer-base对应libgstbase-1.0.so(或libgstbase-0.10.so),在包libgstreamer1.0-0[=24=中找到](或 libgstreamer0.10-0,视情况而定)。下面,我们安装“-dev”包。
我在包 libgstreamer-plugins-base1 中找到的其他库(libgst-video、libgst-app、libgst-riff、libgst-pbutils)。 0-dev(同样,替换您要使用的版本,v0.1 或 v1.0)。
因此,应使用以下命令来安装缺少的依赖项:
sudo apt install libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev
重复 cmake 命令,可能事先清除构建目录的内容。
如果你只开发一个 Gstreamer 应用程序,下面的方法对我有用
# 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} )
注意 - 如果您需要 GStreamer 的开发 docker,请参见下方;对于您的问题,它也包含使用 OpenCV 进行编译的部分; 更多详情请见 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
在 Windows 上没有 "sudo apt install..." 我也在我的 PATH 环境变量中设置了所有路径,但仍然有同样的问题。在设置以下 CMake 选项后,我已经开始工作了:
- 仅将 "WITH_GSTREAMER" 选项设置为 True,"WITH_GSTREAMER_0_10" 必须为 FALSE
- 添加新条目"GSTREAMER_DIR"=(gstreamer 的路径) 对我来说是 "C:/gstreamer/1.0/x86_64" 我找到了这个解决方案 here
我的OpenCV版本:3.4.3
添加新条目 "GSTREAMER_DIR"=(path to gstreamer)
对我有用 (WITH_GSTREAMER true
)。我的版本中没有 WITH_GSTREAMER_0_10
。