Skip to content

Commit 904a088

Browse files
committed
add utils file, fix lint errors
1 parent c4bb6e0 commit 904a088

File tree

6 files changed

+433
-361
lines changed

6 files changed

+433
-361
lines changed

LICENSE

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
Software License Agreement (BSD License)
2-
3-
Copyright (c) 2014, Robert Bosch LLC.
41
All rights reserved.
52

3+
Software License Agreement (BSD License 2.0)
4+
65
Redistribution and use in source and binary forms, with or without
76
modification, are permitted provided that the following conditions
87
are met:
@@ -13,7 +12,7 @@ are met:
1312
copyright notice, this list of conditions and the following
1413
disclaimer in the documentation and/or other materials provided
1514
with the distribution.
16-
* Neither the name of the Robert Bosch LLC. nor the names of its
15+
* Neither the name of the copyright holder nor the names of its
1716
contributors may be used to endorse or promote products derived
1817
from this software without specific prior written permission.
1918

include/usb_cam/usb_cam.h include/usb_cam/usb_cam.hpp

+24-22
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@
2727
// POSSIBILITY OF SUCH DAMAGE.
2828

2929

30-
#ifndef USB_CAM__USB_CAM_H_
31-
#define USB_CAM__USB_CAM_H_
30+
#ifndef USB_CAM__USB_CAM_HPP_
31+
#define USB_CAM__USB_CAM_HPP_
32+
#include "usb_cam/usb_cam_utils.hpp"
3233

3334
#include <asm/types.h> /* for videodev2.h */
3435

@@ -58,7 +59,8 @@ namespace usb_cam
5859
{
5960

6061

61-
class UsbCam {
62+
class UsbCam
63+
{
6264
public:
6365
typedef enum
6466
{
@@ -84,28 +86,28 @@ class UsbCam {
8486

8587
// start camera
8688
bool start(
87-
const std::string& dev, io_method io, pixel_format pf,
89+
const std::string & dev, io_method io, pixel_format pf,
8890
int image_width, int image_height, int framerate);
8991
// shutdown camera
9092
bool shutdown(void);
9193

9294
// grabs a new image from the camera
9395
// bool get_image(sensor_msgs::msg::Image:::SharedPtr image);
94-
bool get_image(builtin_interfaces::msg::Time& stamp,
95-
std::string& encoding, uint32_t& height, uint32_t& width,
96-
uint32_t& step, std::vector<uint8_t>& data);
96+
bool get_image(
97+
builtin_interfaces::msg::Time & stamp, std::string & encoding,
98+
uint32_t & height, uint32_t & width, uint32_t & step, std::vector<uint8_t> & data);
9799

98100
void get_formats(); // std::vector<usb_cam::msg::Format>& formats);
99101

100102
// enables/disable auto focus
101103
bool set_auto_focus(int value);
102104

103105
// Set video device parameters
104-
bool set_v4l_parameter(const std::string& param, int value);
105-
bool set_v4l_parameter(const std::string& param, const std::string& value);
106+
bool set_v4l_parameter(const std::string & param, int value);
107+
bool set_v4l_parameter(const std::string & param, const std::string & value);
106108

107-
static io_method io_method_from_string(const std::string& str);
108-
static pixel_format pixel_format_from_string(const std::string& str);
109+
static io_method io_method_from_string(const std::string & str);
110+
static pixel_format pixel_format_from_string(const std::string & str);
109111

110112
bool stop_capturing(void);
111113
bool start_capturing(void);
@@ -120,7 +122,7 @@ class UsbCam {
120122
int bytes_per_pixel;
121123
int image_size;
122124
builtin_interfaces::msg::Time stamp;
123-
char *image;
125+
char * image;
124126
int is_new;
125127
} camera_image_t;
126128

@@ -132,8 +134,8 @@ class UsbCam {
132134

133135

134136
int init_mjpeg_decoder(int image_width, int image_height);
135-
bool mjpeg2rgb(char *MJPEG, int len, char *RGB, int NumPixels);
136-
bool process_image(const void * src, int len, camera_image_t *dest);
137+
bool mjpeg2rgb(char * MJPEG, int len, char * RGB, int NumPixels);
138+
bool process_image(const void * src, int len, camera_image_t * dest);
137139
bool read_frame();
138140
bool uninit_device(void);
139141
bool init_read(unsigned int buffer_size);
@@ -154,17 +156,17 @@ class UsbCam {
154156
int fd_;
155157
buffer * buffers_;
156158
unsigned int n_buffers_;
157-
AVFrame *avframe_camera_;
158-
AVFrame *avframe_rgb_;
159-
AVCodec *avcodec_;
160-
AVDictionary *avoptions_;
161-
AVCodecContext *avcodec_context_;
159+
AVFrame * avframe_camera_;
160+
AVFrame * avframe_rgb_;
161+
AVCodec * avcodec_;
162+
AVDictionary * avoptions_;
163+
AVCodecContext * avcodec_context_;
162164
int avframe_camera_size_;
163165
int avframe_rgb_size_;
164-
struct SwsContext *video_sws_;
165-
camera_image_t *image_;
166+
struct SwsContext * video_sws_;
167+
camera_image_t * image_;
166168
};
167169

168170
} // namespace usb_cam
169171

170-
#endif // USB_CAM__USB_CAM_H_
172+
#endif // USB_CAM__USB_CAM_HPP_

include/usb_cam/usb_cam_node.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
#ifndef USB_CAM__USB_CAM_NODE_HPP_
3131
#define USB_CAM__USB_CAM_NODE_HPP_
32-
#include "usb_cam/usb_cam.h"
32+
#include "usb_cam/usb_cam.hpp"
3333

3434

3535
#include <rclcpp/rclcpp.hpp>

0 commit comments

Comments
 (0)