usb_cam
usb_cam copied to clipboard
stderr: usb_cam while installing from source in docker image
I am facing an error while building docker image and installing the usb_cam ros2 package from source. Following is my Dockerfile
FROM osrf/ros:foxy-desktop ARG ROS_DISTRO=foxy
ENV ROS_DISTRO $ROS_DISTRO RUN rm /bin/sh && ln -s /bin/bash /bin/sh
RUN apt-get update &&
apt-get -y install ros-$ROS_DISTRO-librealsense2
#create workspace
RUN source /opt/ros/$ROS_DISTRO/setup.bash &&
apt -y install libusb-1.0-0-dev build-essential python3-colcon-common-extensions python3-rosdep git libpython3-dev python3-pip &&
pip3 install -U argcomplete &&
mkdir -p /root/dev_ws/src &&
cd /root/dev_ws &&
rosdep update &&
colcon build
#build usb_cam from source
RUN cd /root/dev_ws/src &&
source /root/dev_ws/install/setup.bash &&
git clone https://github.com/ros-drivers/usb_cam.git --branch ros2 &&
cd .. &&
apt update &&
rosdep install --from-paths src --ignore-src -r -y &&
colcon build
Getting following errors:
--- stderr: usb_cam /root/dev_ws/src/usb_cam/src/usb_cam.cpp: In member function ‘int usb_cam::UsbCam::init_mjpeg_decoder(int, int)’: /root/dev_ws/src/usb_cam/src/usb_cam.cpp:75:24: warning: ‘void avcodec_register_all()’ is deprecated [-Wdeprecated-declarations] 75 | avcodec_register_all(); | ^ In file included from /root/dev_ws/src/usb_cam/include/usb_cam/usb_cam.hpp:39, from /root/dev_ws/src/usb_cam/src/usb_cam.cpp:31: /usr/include/x86_64-linux-gnu/libavcodec/avcodec.h:4159:6: note: declared here 4159 | void avcodec_register_all(void); | ^~~~~~~~~~~~~~~~~~~~ /root/dev_ws/src/usb_cam/src/usb_cam.cpp:75:24: warning: ‘void avcodec_register_all()’ is deprecated [-Wdeprecated-declarations] 75 | avcodec_register_all(); | ^ In file included from /root/dev_ws/src/usb_cam/include/usb_cam/usb_cam.hpp:39, from /root/dev_ws/src/usb_cam/src/usb_cam.cpp:31: /usr/include/x86_64-linux-gnu/libavcodec/avcodec.h:4159:6: note: declared here 4159 | void avcodec_register_all(void); | ^~~~~~~~~~~~~~~~~~~~ /root/dev_ws/src/usb_cam/src/usb_cam.cpp:93:93: warning: ‘int avpicture_alloc(AVPicture*, AVPixelFormat, int, int)’ is deprecated [-Wdeprecated-declarations] 93 | reinterpret_cast<AVPicture >(avframe_rgb_), AV_PIX_FMT_RGB24, image_width, image_height); | ^ In file included from /root/dev_ws/src/usb_cam/include/usb_cam/usb_cam.hpp:39, from /root/dev_ws/src/usb_cam/src/usb_cam.cpp:31: /usr/include/x86_64-linux-gnu/libavcodec/avcodec.h:5483:5: note: declared here 5483 | int avpicture_alloc(AVPicture picture, enum AVPixelFormat pix_fmt, int width, int height); | ^~~~~~~~~~~~~~~ /root/dev_ws/src/usb_cam/src/usb_cam.cpp:93:93: warning: ‘int avpicture_alloc(AVPicture, AVPixelFormat, int, int)’ is deprecated [-Wdeprecated-declarations] 93 | reinterpret_cast<AVPicture >(avframe_rgb_), AV_PIX_FMT_RGB24, image_width, image_height); | ^ In file included from /root/dev_ws/src/usb_cam/include/usb_cam/usb_cam.hpp:39, from /root/dev_ws/src/usb_cam/src/usb_cam.cpp:31: /usr/include/x86_64-linux-gnu/libavcodec/avcodec.h:5483:5: note: declared here 5483 | int avpicture_alloc(AVPicture picture, enum AVPixelFormat pix_fmt, int width, int height); | ^~~~~~~~~~~~~~~ /root/dev_ws/src/usb_cam/src/usb_cam.cpp:108:90: warning: ‘int avpicture_get_size(AVPixelFormat, int, int)’ is deprecated [-Wdeprecated-declarations] 108 | avframe_camera_size_ = avpicture_get_size(AV_PIX_FMT_YUV422P, image_width, image_height); | ^ In file included from /root/dev_ws/src/usb_cam/include/usb_cam/usb_cam.hpp:39, from /root/dev_ws/src/usb_cam/src/usb_cam.cpp:31: /usr/include/x86_64-linux-gnu/libavcodec/avcodec.h:5510:5: note: declared here 5510 | int avpicture_get_size(enum AVPixelFormat pix_fmt, int width, int height); | ^~~~~~~~~~~~~~~~~~ /root/dev_ws/src/usb_cam/src/usb_cam.cpp:108:90: warning: ‘int avpicture_get_size(AVPixelFormat, int, int)’ is deprecated [-Wdeprecated-declarations] 108 | avframe_camera_size_ = avpicture_get_size(AV_PIX_FMT_YUV422P, image_width, image_height); | ^ In file included from /root/dev_ws/src/usb_cam/include/usb_cam/usb_cam.hpp:39, from /root/dev_ws/src/usb_cam/src/usb_cam.cpp:31: /usr/include/x86_64-linux-gnu/libavcodec/avcodec.h:5510:5: note: declared here 5510 | int avpicture_get_size(enum AVPixelFormat pix_fmt, int width, int height); | ^~~~~~~~~~~~~~~~~~ /root/dev_ws/src/usb_cam/src/usb_cam.cpp:109:85: warning: ‘int avpicture_get_size(AVPixelFormat, int, int)’ is deprecated [-Wdeprecated-declarations] 109 | avframe_rgb_size_ = avpicture_get_size(AV_PIX_FMT_RGB24, image_width, image_height); | ^ In file included from /root/dev_ws/src/usb_cam/include/usb_cam/usb_cam.hpp:39, from /root/dev_ws/src/usb_cam/src/usb_cam.cpp:31: /usr/include/x86_64-linux-gnu/libavcodec/avcodec.h:5510:5: note: declared here 5510 | int avpicture_get_size(enum AVPixelFormat pix_fmt, int width, int height); | ^~~~~~~~~~~~~~~~~~ /root/dev_ws/src/usb_cam/src/usb_cam.cpp:109:85: warning: ‘int avpicture_get_size(AVPixelFormat, int, int)’ is deprecated [-Wdeprecated-declarations] 109 | avframe_rgb_size_ = avpicture_get_size(AV_PIX_FMT_RGB24, image_width, image_height); | ^ In file included from /root/dev_ws/src/usb_cam/include/usb_cam/usb_cam.hpp:39, from /root/dev_ws/src/usb_cam/src/usb_cam.cpp:31: /usr/include/x86_64-linux-gnu/libavcodec/avcodec.h:5510:5: note: declared here 5510 | int avpicture_get_size(enum AVPixelFormat pix_fmt, int width, int height); | ^~~~~~~~~~~~~~~~~~ /root/dev_ws/src/usb_cam/src/usb_cam.cpp: In member function ‘bool usb_cam::UsbCam::mjpeg2rgb(char, int, char, int)’: /root/dev_ws/src/usb_cam/src/usb_cam.cpp:142:94: warning: ‘int avcodec_decode_video2(AVCodecContext, AVFrame*, int*, const AVPacket*)’ is deprecated [-Wdeprecated-declarations] 142 | decoded_len = avcodec_decode_video2(avcodec_context_, avframe_camera_, &got_picture, &avpkt); | ^ In file included from /root/dev_ws/src/usb_cam/include/usb_cam/usb_cam.hpp:39, from /root/dev_ws/src/usb_cam/src/usb_cam.cpp:31: /usr/include/x86_64-linux-gnu/libavcodec/avcodec.h:4828:5: note: declared here 4828 | int avcodec_decode_video2(AVCodecContext avctx, AVFrame picture, | ^~~~~~~~~~~~~~~~~~~~~ /root/dev_ws/src/usb_cam/src/usb_cam.cpp:142:94: warning: ‘int avcodec_decode_video2(AVCodecContext, AVFrame, int*, const AVPacket*)’ is deprecated [-Wdeprecated-declarations] 142 | decoded_len = avcodec_decode_video2(avcodec_context_, avframe_camera_, &got_picture, &avpkt); | ^ In file included from /root/dev_ws/src/usb_cam/include/usb_cam/usb_cam.hpp:39, from /root/dev_ws/src/usb_cam/src/usb_cam.cpp:31: /usr/include/x86_64-linux-gnu/libavcodec/avcodec.h:4828:5: note: declared here 4828 | int avcodec_decode_video2(AVCodecContext avctx, AVFrame picture, | ^~~~~~~~~~~~~~~~~~~~~ /root/dev_ws/src/usb_cam/src/usb_cam.cpp:161:76: warning: ‘int avpicture_get_size(AVPixelFormat, int, int)’ is deprecated [-Wdeprecated-declarations] 161 | int pic_size = avpicture_get_size(avcodec_context_->pix_fmt, xsize, ysize); | ^ In file included from /root/dev_ws/src/usb_cam/include/usb_cam/usb_cam.hpp:39, from /root/dev_ws/src/usb_cam/src/usb_cam.cpp:31: /usr/include/x86_64-linux-gnu/libavcodec/avcodec.h:5510:5: note: declared here 5510 | int avpicture_get_size(enum AVPixelFormat pix_fmt, int width, int height); | ^~~~~~~~~~~~~~~~~~ /root/dev_ws/src/usb_cam/src/usb_cam.cpp:161:76: warning: ‘int avpicture_get_size(AVPixelFormat, int, int)’ is deprecated [-Wdeprecated-declarations] 161 | int pic_size = avpicture_get_size(avcodec_context_->pix_fmt, xsize, ysize); | ^ In file included from /root/dev_ws/src/usb_cam/include/usb_cam/usb_cam.hpp:39, from /root/dev_ws/src/usb_cam/src/usb_cam.cpp:31: /usr/include/x86_64-linux-gnu/libavcodec/avcodec.h:5510:5: note: declared here 5510 | int avpicture_get_size(enum AVPixelFormat pix_fmt, int width, int height); | ^~~~~~~~~~~~~~~~~~ /root/dev_ws/src/usb_cam/src/usb_cam.cpp:189:70: warning: ‘int avpicture_layout(const AVPicture, AVPixelFormat, int, int, unsigned char, int)’ is deprecated [-Wdeprecated-declarations] 189 | xsize, ysize, reinterpret_cast<uint8_t >(RGB), avframe_rgb_size_); | ^ In file included from /root/dev_ws/src/usb_cam/include/usb_cam/usb_cam.hpp:39, from /root/dev_ws/src/usb_cam/src/usb_cam.cpp:31: /usr/include/x86_64-linux-gnu/libavcodec/avcodec.h:5502:5: note: declared here 5502 | int avpicture_layout(const AVPicture src, enum AVPixelFormat pix_fmt, | ^~~~~~~~~~~~~~~~ /root/dev_ws/src/usb_cam/src/usb_cam.cpp:189:70: warning: ‘int avpicture_layout(const AVPicture, AVPixelFormat, int, int, unsigned char, int)’ is deprecated [-Wdeprecated-declarations] 189 | xsize, ysize, reinterpret_cast<uint8_t *>(RGB), avframe_rgb_size_); | ^ In file included from /root/dev_ws/src/usb_cam/include/usb_cam/usb_cam.hpp:39, from /root/dev_ws/src/usb_cam/src/usb_cam.cpp:31: /usr/include/x86_64-linux-gnu/libavcodec/avcodec.h:5502:5: note: declared here 5502 | int avpicture_layout(const AVPicture *src, enum AVPixelFormat pix_fmt, | ^~~~~~~~~~~~~~~~ /root/dev_ws/src/usb_cam/src/usb_cam.cpp: In member function ‘bool usb_cam::UsbCam::read_frame()’: /root/dev_ws/src/usb_cam/src/usb_cam.cpp:274:29: warning: overflow in conversion from ‘long unsigned int’ to ‘int’ changes value from ‘3227014673’ to ‘-1067952623’ [-Woverflow] 274 | if (-1 == xioctl(fd_, VIDIOC_DQBUF, &buf)) { | ^~~~~~~~~~~~ /root/dev_ws/src/usb_cam/src/usb_cam.cpp:302:29: warning: overflow in conversion from ‘long unsigned int’ to ‘int’ changes value from ‘3227014671’ to ‘-1067952625’ [-Woverflow] 302 | if (-1 == xioctl(fd_, VIDIOC_QBUF, &buf)) { | ^~~~~~~~~~~ /root/dev_ws/src/usb_cam/src/usb_cam.cpp:317:29: warning: overflow in conversion from ‘long unsigned int’ to ‘int’ changes value from ‘3227014673’ to ‘-1067952623’ [-Woverflow] 317 | if (-1 == xioctl(fd_, VIDIOC_DQBUF, &buf)) { | ^~~~~~~~~~~~ /root/dev_ws/src/usb_cam/src/usb_cam.cpp:352:29: warning: overflow in conversion from ‘long unsigned int’ to ‘int’ changes value from ‘3227014671’ to ‘-1067952625’ [-Woverflow] 352 | if (-1 == xioctl(fd_, VIDIOC_QBUF, &buf)) { | ^~~~~~~~~~~ /root/dev_ws/src/usb_cam/src/usb_cam.cpp:242:10: warning: enumeration value ‘IO_METHOD_UNKNOWN’ not handled in switch [-Wswitch] 242 | switch (io_) { | ^ /root/dev_ws/src/usb_cam/src/usb_cam.cpp: In member function ‘bool usb_cam::UsbCam::stop_capturing()’: /root/dev_ws/src/usb_cam/src/usb_cam.cpp:376:10: warning: enumeration value ‘IO_METHOD_UNKNOWN’ not handled in switch [-Wswitch] 376 | switch (io_) { | ^ /root/dev_ws/src/usb_cam/src/usb_cam.cpp: In member function ‘bool usb_cam::UsbCam::start_capturing()’: /root/dev_ws/src/usb_cam/src/usb_cam.cpp:417:31: warning: overflow in conversion from ‘long unsigned int’ to ‘int’ changes value from ‘3227014671’ to ‘-1067952625’ [-Woverflow] 417 | if (-1 == xioctl(fd_, VIDIOC_QBUF, &buf)) { | ^~~~~~~~~~~ /root/dev_ws/src/usb_cam/src/usb_cam.cpp:443:31: warning: overflow in conversion from ‘long unsigned int’ to ‘int’ changes value from ‘3227014671’ to ‘-1067952625’ [-Woverflow] 443 | if (-1 == xioctl(fd_, VIDIOC_QBUF, &buf)) { | ^~~~~~~~~~~ /root/dev_ws/src/usb_cam/src/usb_cam.cpp:402:10: warning: enumeration value ‘IO_METHOD_UNKNOWN’ not handled in switch [-Wswitch] 402 | switch (io_) { | ^ /root/dev_ws/src/usb_cam/src/usb_cam.cpp: In member function ‘bool usb_cam::UsbCam::uninit_device()’: /root/dev_ws/src/usb_cam/src/usb_cam.cpp:466:10: warning: enumeration value ‘IO_METHOD_UNKNOWN’ not handled in switch [-Wswitch] 466 | switch (io_) { | ^ /root/dev_ws/src/usb_cam/src/usb_cam.cpp: In member function ‘bool usb_cam::UsbCam::init_mmap()’: /root/dev_ws/src/usb_cam/src/usb_cam.cpp:520:25: warning: overflow in conversion from ‘long unsigned int’ to ‘int’ changes value from ‘3222558216’ to ‘-1072409080’ [-Woverflow] 520 | if (-1 == xioctl(fd_, VIDIOC_REQBUFS, &req)) { | ^~~~~~~~~~~~~~ /root/dev_ws/src/usb_cam/src/usb_cam.cpp:555:27: warning: overflow in conversion from ‘long unsigned int’ to ‘int’ changes value from ‘3227014665’ to ‘-1067952631’ [-Woverflow] 555 | if (-1 == xioctl(fd_, VIDIOC_QUERYBUF, &buf)) { | ^~~~~~~~~~~~~~~ /root/dev_ws/src/usb_cam/src/usb_cam.cpp: In member function ‘bool usb_cam::UsbCam::init_userp(unsigned int)’: /root/dev_ws/src/usb_cam/src/usb_cam.cpp:588:25: warning: overflow in conversion from ‘long unsigned int’ to ‘int’ changes value from ‘3222558216’ to ‘-1072409080’ [-Woverflow] 588 | if (-1 == xioctl(fd_, VIDIOC_REQBUFS, &req)) { | ^~~~~~~~~~~~~~ /root/dev_ws/src/usb_cam/src/usb_cam.cpp: In member function ‘bool usb_cam::UsbCam::init_device(int, int, int)’: /root/dev_ws/src/usb_cam/src/usb_cam.cpp:627:25: warning: overflow in conversion from ‘long unsigned int’ to ‘int’ changes value from ‘2154321408’ to ‘-2140645888’ [-Woverflow] 627 | if (-1 == xioctl(fd_, VIDIOC_QUERYCAP, &cap)) { | ^~~~~~~~~~~~~~~ /root/dev_ws/src/usb_cam/src/usb_cam.cpp:646:10: warning: enumeration value ‘IO_METHOD_UNKNOWN’ not handled in switch [-Wswitch] 646 | switch (io_) { | ^ /root/dev_ws/src/usb_cam/src/usb_cam.cpp:675:24: warning: overflow in conversion from ‘long unsigned int’ to ‘int’ changes value from ‘3224131130’ to ‘-1070836166’ [-Woverflow] 675 | if (0 == xioctl(fd_, VIDIOC_CROPCAP, &cropcap)) { | ^~~~~~~~~~~~~~ /root/dev_ws/src/usb_cam/src/usb_cam.cpp:701:25: warning: overflow in conversion from ‘long unsigned int’ to ‘int’ changes value from ‘3234878981’ to ‘-1060088315’ [-Woverflow] 701 | if (-1 == xioctl(fd_, VIDIOC_S_FMT, &fmt)) { | ^~~~~~~~~~~~ /root/dev_ws/src/usb_cam/src/usb_cam.cpp:707:21: warning: overflow in conversion from ‘long unsigned int’ to ‘int’ changes value from ‘3234878980’ to ‘-1060088316’ [-Woverflow] 707 | if (xioctl(fd_, VIDIOC_G_FMT, &fmt) >= 0) { | ^~~~~~~~~~~~ /root/dev_ws/src/usb_cam/src/usb_cam.cpp:717:27: warning: comparison of integer expressions of different signedness: ‘u32’ {aka ‘unsigned int’} and ‘int’ [-Wsign-compare] 717 | fmt.fmt.pix.width == image_width && | ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~ /root/dev_ws/src/usb_cam/src/usb_cam.cpp:718:28: warning: comparison of integer expressions of different signedness: ‘u32’ {aka ‘unsigned int’} and ‘int’ [-Wsign-compare] 718 | fmt.fmt.pix.height == image_height) { | ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~ /root/dev_ws/src/usb_cam/src/usb_cam.cpp:751:19: warning: overflow in conversion from ‘long unsigned int’ to ‘int’ changes value from ‘3234616853’ to ‘-1060350443’ [-Woverflow] 751 | if (xioctl(fd, VIDIOC_G_PARM, &stream_params) < 0) { | ^~~~~~~~~~~~~ /root/dev_ws/src/usb_cam/src/usb_cam.cpp:766:19: warning: overflow in conversion from ‘long unsigned int’ to ‘int’ changes value from ‘3234616854’ to ‘-1060350442’ [-Woverflow] 766 | if (xioctl(fd, VIDIOC_S_PARM, &stream_params) < 0) { | ^~~~~~~~~~~~~ /root/dev_ws/src/usb_cam/src/usb_cam.cpp:772:10: warning: enumeration value ‘IO_METHOD_UNKNOWN’ not handled in switch [-Wswitch] 772 | switch (io) { | ^ /root/dev_ws/src/usb_cam/src/usb_cam.cpp: In member function ‘void usb_cam::UsbCam::get_formats()’: /root/dev_ws/src/usb_cam/src/usb_cam.cpp:949:35: warning: overflow in conversion from ‘long unsigned int’ to ‘int’ changes value from ‘3225441794’ to ‘-1069525502’ [-Woverflow] 949 | for (fmt.index = 0; xioctl(fd, VIDIOC_ENUM_FMT, &fmt) == 0; ++fmt.index) { | ^~~~~~~~~~~~~~~ /root/dev_ws/src/usb_cam/src/usb_cam.cpp:959:38: warning: overflow in conversion from ‘long unsigned int’ to ‘int’ changes value from ‘3224131146’ to ‘-1070836150’ [-Woverflow] 959 | for (size.index = 0; xioctl(fd_, VIDIOC_ENUM_FRAMESIZES, &size) == 0; ++size.index) { | ^~~~~~~~~~~~~~~~~~~~~~ /root/dev_ws/src/usb_cam/src/usb_cam.cpp:968:44: warning: overflow in conversion from ‘long unsigned int’ to ‘int’ changes value from ‘3224655435’ to ‘-1070311861’ [-Woverflow] 968 | for (interval.index = 0; xioctl(fd_, VIDIOC_ENUM_FRAMEINTERVALS, &interval) == 0; | ^~~~~~~~~~~~~~~~~~~~~~~~~~ /root/dev_ws/src/usb_cam/src/usb_cam.cpp: In member function ‘bool usb_cam::UsbCam::set_auto_focus(int)’: /root/dev_ws/src/usb_cam/src/usb_cam.cpp:1034:25: warning: overflow in conversion from ‘long unsigned int’ to ‘int’ changes value from ‘3225703972’ to ‘-1069263324’ [-Woverflow] 1034 | if (-1 == xioctl(fd_, VIDIOC_QUERYCTRL, &queryctrl)) { | ^~~~~~~~~~~~~~~~ /root/dev_ws/src/usb_cam/src/usb_cam.cpp:1050:27: warning: overflow in conversion from ‘long unsigned int’ to ‘int’ changes value from ‘3221771804’ to ‘-1073195492’ [-Woverflow] 1050 | if (-1 == xioctl(fd_, VIDIOC_S_CTRL, &control)) { | ^~~~~~~~~~~~~
Can anyone please help how can I solve this error? Thank you
Make sure you call rosdep install before trying to build. It looks like you are building, then using rosdep install after
Closing as issue is stale and unclear what the actual issue is