I've struggled some time to make usb_cam to support mjpeg format usb camera, as libavcodec and libswscale that come with ROS somehow cannot work properly. it complains No accelerated colorspace conversion found from yuv422p to rgb24.
So I installed a new ffmpeg that enables libx264. After that, two versions of ffmpeg exist in my file system, the old one locates in /usr/lib/x86_64-linux-gnu, the new one in /usr/local/lib. In order to find the correct version, I changed two lines in the CMakeLists.txt :
pkg_check_modules(avcodec libavcodec>=56.12 REQUIRED)
pkg_check_modules(swscale libswscale>=3.1 REQUIRED)
If I run cmake inside the usb_cam directory, pkg_check_modules can find the correct header file and libraries, however if I run catkin_make, it returns the old ones. how could pkg_check_modules behave differently with/without ROS? Don't know what to do ...
Thanks to ahendrix! I added a few lines to print some pkgconfig-generated value
MESSAGE(STATUS "@@@@@@@@@@@@@@@@@ " ${avcodec_LIBRARIES})
MESSAGE(STATUS "@@@@@@@@@@@@@@@@@ " ${avcodec_LIBRARY_DIRS})
MESSAGE(STATUS "@@@@@@@@@@@@@@@@@ " ${avcodec_LDFLAGS})
MESSAGE(STATUS "@@@@@@@@@@@@@@@@@ " ${avcodec_INCLUDE_DIRS})
MESSAGE(STATUS "@@@@@@@@@@@@@@@@@ " ${avcodec_CFLAGS})
MESSAGE(STATUS "@@@@@@@@@@@@@@@@@ " ${avcodec_VERSION})
MESSAGE(STATUS "@@@@@@@@@@@@@@@@@ " ${avcodec_PREFIX})
MESSAGE(STATUS "@@@@@@@@@@@@@@@@@ " ${avcodec_INCLUDEDIR})
MESSAGE(STATUS "@@@@@@@@@@@@@@@@@ " ${avcodec_LIBDIR})
After I delete build/ and devel/ and run catkin_make as ahendrix suggestes, cmake output message shows it found the right version
-- checking for module 'libavcodec'
-- found libavcodec, version 56.13.100
-- checking for module 'libswscale'
-- found libswscale, version 3.1.101
-- @@@@@@@@@@@@@@@@@ avcodec
-- @@@@@@@@@@@@@@@@@ /usr/local/lib
-- @@@@@@@@@@@@@@@@@ -L/usr/local/lib-lavcodec
-- @@@@@@@@@@@@@@@@@ /usr/local/include
-- @@@@@@@@@@@@@@@@@ -I/usr/local/include
-- @@@@@@@@@@@@@@@@@ 56.13.100
-- @@@@@@@@@@@@@@@@@ /usr/local
-- @@@@@@@@@@@@@@@@@ /usr/local/include
-- @@@@@@@@@@@@@@@@@ /usr/local/lib
however, when ran this node "rosrun usb_cam usb_cam_node _pixel_format:=mjpeg", it just end with segment fault. But if write the CMakeLists.tst like
#find_package(PkgConfig REQUIRED)
#pkg_check_modules(avcodec libavcodec REQUIRED)
#pkg_check_modules(swscale libswscale REQUIRED)
set(avcodec_INCLUDE_DIRS /usr/local/include/libavcodec)
set(swscale_INCLUDE_DIRS /usr/local/include/libswscale)
set(avcodec_LIBRARIES /usr/local/lib/libavcodec.so.56)
set(swscale_LIBRARIES /usr/local/lib/libswscale.so.3)
usb_cam turns to work. So I wonder what happens to make such difference.
↧