diff --git a/CMakeLists.txt b/CMakeLists.txt index 9088a143..1a83c1ef 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -65,6 +65,9 @@ rclcpp_components_register_node(${PROJECT_NAME}_node EXECUTABLE ${PROJECT_NAME}_node_exe ) +# To fix `DSO missing from command line` error with clang +target_link_libraries(${PROJECT_NAME}_node_exe stdc++) + if(SANITIZE) target_compile_options(${PROJECT_NAME} PUBLIC -fsanitize=address -fsanitize=leak) target_link_libraries(${PROJECT_NAME} -fsanitize=address -fsanitize=leak) @@ -81,11 +84,11 @@ if(BUILD_TESTING) ament_add_gtest(test_usb_cam_utils test/test_usb_cam_utils.cpp) target_link_libraries(test_usb_cam_utils - ${PROJECT_NAME}) + ${PROJECT_NAME} m stdc++) ament_add_gtest(test_pixel_formats test/test_pixel_formats.cpp) target_link_libraries(test_pixel_formats - ${PROJECT_NAME}) + ${PROJECT_NAME} m stdc++) if(INTEGRATION_TESTS) ament_add_gtest(test_usb_cam_lib test/test_usb_cam_lib.cpp) diff --git a/include/usb_cam/formats/mjpeg.hpp b/include/usb_cam/formats/mjpeg.hpp index b8d87f77..25f8b2f1 100644 --- a/include/usb_cam/formats/mjpeg.hpp +++ b/include/usb_cam/formats/mjpeg.hpp @@ -243,8 +243,6 @@ class MJPEG2RGB : public pixel_format_base size_t m_avframe_rgb_size; char * m_averror_str; int m_result = 0; - int m_counter = 0; - const int * m_linesize; const int m_align = 32; }; diff --git a/include/usb_cam/formats/pixel_format_base.hpp b/include/usb_cam/formats/pixel_format_base.hpp index 81eedc85..e575e9b8 100644 --- a/include/usb_cam/formats/pixel_format_base.hpp +++ b/include/usb_cam/formats/pixel_format_base.hpp @@ -50,11 +50,11 @@ namespace formats /// arguments for future pixel format(s) that are added. typedef struct { - std::string name = ""; - int width = 640; - int height = 480; - size_t pixels = 640 * 480; - std::string av_device_format_str = "AV_PIX_FMT_YUV422P"; + std::string name; + int width; + int height; + size_t pixels; + std::string av_device_format_str; } format_arguments_t; @@ -74,6 +74,8 @@ class pixel_format_base m_requires_conversion(requires_conversion) {} + virtual ~pixel_format_base() {} + /// @brief Name of pixel format. Used in the parameters file to select this format /// @return inline std::string name() {return m_name;} diff --git a/include/usb_cam/usb_cam.hpp b/include/usb_cam/usb_cam.hpp index 6138cee0..e453d5f9 100644 --- a/include/usb_cam/usb_cam.hpp +++ b/include/usb_cam/usb_cam.hpp @@ -96,38 +96,65 @@ std::vector> driver_supported_formats( return fmts; } -typedef struct +typedef struct capture_format_t { struct v4l2_fmtdesc format; struct v4l2_frmivalenum v4l2_fmt; } capture_format_t; -typedef struct +typedef struct parameters_t { - std::string camera_name = "usb_cam"; // can be anything - std::string device_name = "/dev/video0"; // usually /dev/video0 or something similiar - std::string frame_id = "camera"; - std::string io_method_name = "mmap"; - std::string camera_info_url = "package://usb_cam/config/camera_info.yaml"; - std::string pixel_format_name = "yuyv2rgb"; - std::string av_device_format = "YUV422P"; - int image_width = 600; - int image_height = 400; - int framerate = 30.0; - int brightness = -1; - int contrast = -1; - int saturation = -1; - int sharpness = -1; - int gain = -1; - int white_balance = -1; - int exposure = -1; - int focus = -1; - bool auto_white_balance = true; - bool autoexposure = true; - bool autofocus = false; + std::string camera_name; + std::string device_name; + std::string frame_id; + std::string io_method_name; + std::string camera_info_url; + std::string pixel_format_name; + std::string av_device_format; + int image_width; + int image_height; + int framerate; + int brightness; + int contrast; + int saturation; + int sharpness; + int gain; + int white_balance; + int exposure; + int focus; + bool auto_white_balance; + bool autoexposure; + bool autofocus; + + parameters_t() +// *INDENT-OFF* + : camera_name("usb_cam"), + device_name("/dev/video0"), + frame_id("camera"), + io_method_name("mmap"), + camera_info_url("package://usb_cam/config/camera_info.yaml"), + pixel_format_name("yuyv2rgb"), + av_device_format("YUV422P"), + image_width(600), + image_height(480), + framerate(30.0), + brightness(-1), + contrast(-1), + saturation(-1), + sharpness(-1), + gain(-1), + white_balance(-1), + exposure(-1), + focus(-1), + auto_white_balance(true), + autoexposure(true), + autofocus(false) + { + } +// *INDENT-ON* } parameters_t; -typedef struct +typedef struct image_t { char * data; size_t width; @@ -396,13 +423,10 @@ class UsbCam image_t m_image; AVFrame * m_avframe; - int m_avframe_size; AVCodec * m_avcodec; - AVCodecID m_codec_id; AVDictionary * m_avoptions; AVCodecContext * m_avcodec_context; - int64_t m_buffer_time_us; bool m_is_capturing; int m_framerate; const time_t m_epoch_time_shift_us;