我从gstreamer
库中复制了三个文件,准备稍后修改。这些文件正在形成一个plugin
,并使用OpenCV
处理来自gstreamer
管道的帧。我稍后的目标是修改那个OpenCV
函数。问题是我无法编译包:
└── gstreamer-filter
├── build
├── CMakeLists.txt
├── gstcvequalizehist.cpp
├── include
│ ├── gstcvequalizehist.h
│ └── gstopencvvideofilter.h
└── main.cpp
字符串
你可以在gstreamer
github上找到这三个文件:
gstcvequalizehist.cppgstcvequalizehist.h的数据库
以下是我为它编写的CMakeLists
:
cmake_minimum_required(VERSION 3.10)
project(VideoFilter)
find_package(OpenCV REQUIRED)
find_package(PkgConfig REQUIRED)
pkg_check_modules(GSTREAMER REQUIRED gstreamer-1.0)
pkg_check_modules(GST_APP REQUIRED gstreamer-app-1.0)
include_directories(include)
include_directories(${OpenCV_INCLUDE_DIRS})
include_directories(${GSTREAMER_INCLUDE_DIRS})
include_directories(${GST_APP_INCLUDE_DIRS})
include_directories(${GST_OPENCV_INCLUDE_DIRS})
link_directories(${GST_OPENCV_LIBRARY_DIRS})
# Link directories
link_directories(${OpenCV_LIBRARY_DIRS})
link_directories(${GSTREAMER_LIBRARY_DIRS})
link_directories(${GST_APP_LIBRARY_DIRS})
add_executable(VideoFilter main.cpp gstcvequalizehist.cpp)
target_link_libraries(VideoFilter ${GSTREAMER_LIBRARIES} ${GST_APP_LIBRARIES} ${OpenCV_LIBRARIES} ${GST_OPENCV_LIBRARIES})
型
下面是cmake
命令的输出:
-- The C compiler identification is GNU 11.4.0
-- The CXX compiler identification is GNU 11.4.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Warning (dev) at /usr/local/lib/cmake/opencv4/OpenCVConfig.cmake:86 (find_package):
Policy CMP0146 is not set: The FindCUDA module is removed. Run "cmake
--help-policy CMP0146" for policy details. Use the cmake_policy command to
set the policy and suppress this warning.
Call Stack (most recent call first):
/usr/local/lib/cmake/opencv4/OpenCVConfig.cmake:108 (find_host_package)
CMakeLists.txt:7 (find_package)
This warning is for project developers. Use -Wno-dev to suppress it.
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
-- Found CUDA: /usr/local/cuda (found suitable exact version "12.1")
-- Found OpenCV: /usr/local (found version "4.7.0")
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.29.2")
-- Checking for module 'gstreamer-1.0'
-- Found gstreamer-1.0, version 1.20.3
-- Checking for module 'gstreamer-app-1.0'
-- Found gstreamer-app-1.0, version 1.20.1
-- Configuring done (1.0s)
-- Generating done (0.0s)
-- Build files have been written to: gstreamer-filter/build
[ 33%] Building CXX object CMakeFiles/VideoFilter.dir/main.cpp.o
[ 66%] Building CXX object CMakeFiles/VideoFilter.dir/gstcvequalizehist.cpp.o
[100%] Linking CXX executable VideoFilter
/usr/bin/ld: CMakeFiles/VideoFilter.dir/gstcvequalizehist.cpp.o: in function `gst_cv_equalize_hist_get_type_once()':
gstcvequalizehist.cpp:(.text+0x10a): undefined reference to `gst_opencv_video_filter_get_type'
/usr/bin/ld: CMakeFiles/VideoFilter.dir/gstcvequalizehist.cpp.o: in function `gst_cv_equalize_hist_init(_GstCvEqualizeHist*)':
gstcvequalizehist.cpp:(.text+0x26f): undefined reference to `gst_opencv_video_filter_set_in_place'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/VideoFilter.dir/build.make:182: VideoFilter] Error 1
make[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/VideoFilter.dir/all] Error 2
make: *** [Makefile:91: all] Error 2
型
它看起来像我没有链接某些文件或包,但我不能弄清楚他们是什么!
我用的是Ubuntu 22.04。
1条答案
按热度按时间rxztt3cl1#
我遇到了两个问题,第一个是关于设置
GST_PLUGIN_PATH
,第二个是target_link_libraries
我的可执行文件到正确的库gstopencv-1.0。对于任何感兴趣的人,我在github上分享了一个工作示例:LINK