Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix small warnings #170

Merged
merged 7 commits into from
Sep 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions include/usb_cam/usb_cam.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,6 @@ class UsbCam
bool close_device(void);
bool open_device(void);
bool grab_image();
bool is_capturing_;


rclcpp::Clock::SharedPtr clock_;
std::string camera_dev_;
Expand All @@ -165,6 +163,7 @@ class UsbCam
int avframe_rgb_size_;
struct SwsContext * video_sws_;
camera_image_t * image_;
bool is_capturing_;
};

} // namespace usb_cam
Expand Down
10 changes: 5 additions & 5 deletions include/usb_cam/usb_cam_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ void monotonicToRealTime(const timespec & monotonic_time, timespec & real_time)
}
}

static int xioctl(int fd, int request, void * arg)
inline int xioctl(int fd, int request, void * arg)
{
int r;

Expand Down Expand Up @@ -245,7 +245,7 @@ const int clipping_table_offset = 128;
/** Clip a value to the range 0<val<255. For speed this is done using an
* array, so can only cope with numbers in the range -128<val<383.
*/
static unsigned char CLIPVALUE(int val)
inline unsigned char CLIPVALUE(int val)
{
// Old method (if)
/* val = val < 0 ? 0 : val; */
Expand Down Expand Up @@ -276,7 +276,7 @@ static unsigned char CLIPVALUE(int val)
* [ B ] [ 1.0 2.041 0.002 ] [ V ]
*
*/
static bool YUV2RGB(
inline bool YUV2RGB(
const unsigned char y, const unsigned char u, const unsigned char v,
unsigned char * r, unsigned char * g, unsigned char * b)
{
Expand Down Expand Up @@ -326,7 +326,7 @@ bool uyvy2rgb(char * YUV, char * RGB, int NumPixels)
return true;
}

static bool mono102mono8(char * RAW, char * MONO, int NumPixels)
inline bool mono102mono8(char * RAW, char * MONO, int NumPixels)
{
int i, j;
for (i = 0, j = 0; i < (NumPixels << 1); i += 2, j += 1) {
Expand All @@ -336,7 +336,7 @@ static bool mono102mono8(char * RAW, char * MONO, int NumPixels)
return true;
}

static bool yuyv2rgb(char * YUV, char * RGB, int NumPixels)
inline bool yuyv2rgb(char * YUV, char * RGB, int NumPixels)
{
int i, j;
unsigned char y0, y1, u, v;
Expand Down
9 changes: 5 additions & 4 deletions src/usb_cam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,11 @@ int UsbCam::init_mjpeg_decoder(int image_width, int image_height)
return 1;
}

bool UsbCam::mjpeg2rgb(char * MJPEG, int len, char * RGB, int NumPixels)
bool UsbCam::mjpeg2rgb(char * MJPEG, int len, char * RGB, int /* NumPixels */)
{
// RCLCPP_INFO_STREAM(
// rclcpp::get_logger("usb_cam"),
// "mjpeg2rgb " << len << ", image 0x" << std::hex << (unsigned long int)RGB \
// "mjpeg2rgb " << len << ", image 0x" << std::hex << (unsigned long int)RGB
// << std::dec << " " << NumPixels << ", avframe_rgb_size_ " << avframe_rgb_size_);
int got_picture;

Expand Down Expand Up @@ -169,7 +169,7 @@ bool UsbCam::mjpeg2rgb(char * MJPEG, int len, char * RGB, int NumPixels)

// TODO(lucasw) why does the image need to be scaled? Does it also convert formats?
// RCLCPP_INFO_STREAM(
// rclcpp::get_logger("usb_cam"), "sw scaler " << xsize << " " << ysize << " " \
// rclcpp::get_logger("usb_cam"), "sw scaler " << xsize << " " << ysize << " "
// << avcodec_context_->pix_fmt << ", linesize " << avframe_rgb_->linesize);
#if 1
avcodec_context_->pix_fmt = pix_fmt_backup;
Expand Down Expand Up @@ -735,7 +735,7 @@ bool UsbCam::init_device(int image_width, int image_height, int framerate)
RCLCPP_INFO_STREAM(
rclcpp::get_logger("usb_cam"),
"Capability flag: 0x" << std::hex << stream_params.parm.capture.capability << std::dec);
if (!stream_params.parm.capture.capability & V4L2_CAP_TIMEPERFRAME) {
if (!(stream_params.parm.capture.capability & V4L2_CAP_TIMEPERFRAME)) {
RCLCPP_ERROR(rclcpp::get_logger("usb_cam"), "V4L2_CAP_TIMEPERFRAME not supported");
}

Expand Down Expand Up @@ -1080,6 +1080,7 @@ bool UsbCam::set_v4l_parameter(const std::string & param, const std::string & va
} else {
RCLCPP_WARN(rclcpp::get_logger("usb_cam"), "usb_cam_node could not run '%s'", cmd.c_str());
}
return true;
}

UsbCam::io_method UsbCam::io_method_from_string(const std::string & str)
Expand Down
2 changes: 1 addition & 1 deletion src/usb_cam_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ void UsbCamNode::get_params()
} else if (parameter.get_name() == "video_device") {
video_device_name_ = parameter.value_to_string();
} else {
RCLCPP_WARN(this->get_logger(), "Invalid parameter name: %s", parameter.get_name());
RCLCPP_WARN(this->get_logger(), "Invalid parameter name: %s", parameter.get_name().c_str());
}
}
}
Expand Down