Skip to content

Commit c68f69e

Browse files
committed
Fix errors found by clang
Closes #349 Signed-off-by: Evan Flynn <[email protected]>
1 parent e09ea1d commit c68f69e

File tree

4 files changed

+63
-36
lines changed

4 files changed

+63
-36
lines changed

CMakeLists.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ rclcpp_components_register_node(${PROJECT_NAME}_node
6565
EXECUTABLE ${PROJECT_NAME}_node_exe
6666
)
6767

68+
# To fix `DSO missing from command line` error with clang
69+
target_link_libraries(${PROJECT_NAME}_node_exe stdc++)
70+
6871
if(SANITIZE)
6972
target_compile_options(${PROJECT_NAME} PUBLIC -fsanitize=address -fsanitize=leak)
7073
target_link_libraries(${PROJECT_NAME} -fsanitize=address -fsanitize=leak)
@@ -81,11 +84,11 @@ if(BUILD_TESTING)
8184
ament_add_gtest(test_usb_cam_utils
8285
test/test_usb_cam_utils.cpp)
8386
target_link_libraries(test_usb_cam_utils
84-
${PROJECT_NAME})
87+
${PROJECT_NAME} m stdc++)
8588
ament_add_gtest(test_pixel_formats
8689
test/test_pixel_formats.cpp)
8790
target_link_libraries(test_pixel_formats
88-
${PROJECT_NAME})
91+
${PROJECT_NAME} m stdc++)
8992
if(INTEGRATION_TESTS)
9093
ament_add_gtest(test_usb_cam_lib
9194
test/test_usb_cam_lib.cpp)

include/usb_cam/formats/mjpeg.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,8 +243,6 @@ class MJPEG2RGB : public pixel_format_base
243243
size_t m_avframe_rgb_size;
244244
char * m_averror_str;
245245
int m_result = 0;
246-
int m_counter = 0;
247-
const int * m_linesize;
248246

249247
const int m_align = 32;
250248
};

include/usb_cam/formats/pixel_format_base.hpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,11 @@ namespace formats
5050
/// arguments for future pixel format(s) that are added.
5151
typedef struct
5252
{
53-
std::string name = "";
54-
int width = 640;
55-
int height = 480;
56-
size_t pixels = 640 * 480;
57-
std::string av_device_format_str = "AV_PIX_FMT_YUV422P";
53+
std::string name;
54+
int width;
55+
int height;
56+
size_t pixels;
57+
std::string av_device_format_str;
5858
} format_arguments_t;
5959

6060

@@ -74,6 +74,8 @@ class pixel_format_base
7474
m_requires_conversion(requires_conversion)
7575
{}
7676

77+
virtual ~pixel_format_base() {}
78+
7779
/// @brief Name of pixel format. Used in the parameters file to select this format
7880
/// @return
7981
inline std::string name() {return m_name;}

include/usb_cam/usb_cam.hpp

Lines changed: 51 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -96,38 +96,65 @@ std::vector<std::shared_ptr<pixel_format_base>> driver_supported_formats(
9696
return fmts;
9797
}
9898

99-
typedef struct
99+
typedef struct capture_format_t
100100
{
101101
struct v4l2_fmtdesc format;
102102
struct v4l2_frmivalenum v4l2_fmt;
103103
} capture_format_t;
104104

105-
typedef struct
105+
typedef struct parameters_t
106106
{
107-
std::string camera_name = "usb_cam"; // can be anything
108-
std::string device_name = "/dev/video0"; // usually /dev/video0 or something similiar
109-
std::string frame_id = "camera";
110-
std::string io_method_name = "mmap";
111-
std::string camera_info_url = "package://usb_cam/config/camera_info.yaml";
112-
std::string pixel_format_name = "yuyv2rgb";
113-
std::string av_device_format = "YUV422P";
114-
int image_width = 600;
115-
int image_height = 400;
116-
int framerate = 30.0;
117-
int brightness = -1;
118-
int contrast = -1;
119-
int saturation = -1;
120-
int sharpness = -1;
121-
int gain = -1;
122-
int white_balance = -1;
123-
int exposure = -1;
124-
int focus = -1;
125-
bool auto_white_balance = true;
126-
bool autoexposure = true;
127-
bool autofocus = false;
107+
std::string camera_name;
108+
std::string device_name;
109+
std::string frame_id;
110+
std::string io_method_name;
111+
std::string camera_info_url;
112+
std::string pixel_format_name;
113+
std::string av_device_format;
114+
int image_width;
115+
int image_height;
116+
int framerate;
117+
int brightness;
118+
int contrast;
119+
int saturation;
120+
int sharpness;
121+
int gain;
122+
int white_balance;
123+
int exposure;
124+
int focus;
125+
bool auto_white_balance;
126+
bool autoexposure;
127+
bool autofocus;
128+
129+
parameters_t()
130+
// *INDENT-OFF*
131+
: camera_name("usb_cam"),
132+
device_name("/dev/video0"),
133+
frame_id("camera"),
134+
io_method_name("mmap"),
135+
camera_info_url("package://usb_cam/config/camera_info.yaml"),
136+
pixel_format_name("yuyv2rgb"),
137+
av_device_format("YUV422P"),
138+
image_width(600),
139+
image_height(480),
140+
framerate(30.0),
141+
brightness(-1),
142+
contrast(-1),
143+
saturation(-1),
144+
sharpness(-1),
145+
gain(-1),
146+
white_balance(-1),
147+
exposure(-1),
148+
focus(-1),
149+
auto_white_balance(true),
150+
autoexposure(true),
151+
autofocus(false)
152+
{
153+
}
154+
// *INDENT-ON*
128155
} parameters_t;
129156

130-
typedef struct
157+
typedef struct image_t
131158
{
132159
char * data;
133160
size_t width;
@@ -396,13 +423,10 @@ class UsbCam
396423
image_t m_image;
397424

398425
AVFrame * m_avframe;
399-
int m_avframe_size;
400426
AVCodec * m_avcodec;
401-
AVCodecID m_codec_id;
402427
AVDictionary * m_avoptions;
403428
AVCodecContext * m_avcodec_context;
404429

405-
int64_t m_buffer_time_us;
406430
bool m_is_capturing;
407431
int m_framerate;
408432
const time_t m_epoch_time_shift_us;

0 commit comments

Comments
 (0)