Skip to content

Commit

Permalink
Merge pull request #292 from ros-drivers/288-fix-uyvy2rgb-size
Browse files Browse the repository at this point in the history
288 fix uyvy2rgb size
  • Loading branch information
flynneva authored Nov 13, 2023
2 parents aa11493 + 140b6d6 commit c052be0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
3 changes: 3 additions & 0 deletions include/usb_cam/formats/pixel_format_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ class pixel_format_base
/// @return
inline uint8_t bit_depth() {return m_bit_depth;}

/// @brief Number of bytes per channel
inline uint8_t byte_depth() {return m_bit_depth / 8;}

/// @brief True if the current pixel format requires a call to the `convert` method
/// Used in the usb_cam library logic to determine if a plain `memcopy` call can be
/// used instead of a call to the `convert` method of this class.
Expand Down
2 changes: 1 addition & 1 deletion include/usb_cam/formats/uyvy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class UYVY2RGB : public pixel_format_base
"uyvy2rgb",
V4L2_PIX_FMT_UYVY,
usb_cam::constants::RGB8,
2,
3,
8,
true),
m_number_of_pixels(number_of_pixels)
Expand Down
4 changes: 2 additions & 2 deletions include/usb_cam/usb_cam.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,12 @@ typedef struct
}
size_t set_bytes_per_line()
{
bytes_per_line = width * pixel_format->channels();
bytes_per_line = width * pixel_format->byte_depth() * pixel_format->channels();
return bytes_per_line;
}
size_t set_size_in_bytes()
{
size_in_bytes = width * height * pixel_format->channels();
size_in_bytes = height * bytes_per_line;
return size_in_bytes;
}

Expand Down

0 comments on commit c052be0

Please sign in to comment.