Skip to content
Open
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
6 changes: 3 additions & 3 deletions cv_bridge/include/cv_bridge/cv_bridge.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ class CV_BRIDGE_EXPORT CvImage
* \brief Constructor.
*/
CvImage(
const std_msgs::msg::Header & header, const std::string & encoding,
const cv::Mat & image = cv::Mat())
: header(header), encoding(encoding), image(image)
const std_msgs::msg::Header & header_, const std::string & encoding_,
const cv::Mat & image_ = cv::Mat())
: header(header_), encoding(encoding_), image(image_)
{
}

Expand Down
8 changes: 4 additions & 4 deletions cv_bridge/src/cv_bridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -514,10 +514,10 @@ void CvImage::toCompressedImageMsg(
const Format dst_format) const
{
ros_image.header = header;
cv::Mat image;
cv::Mat image_to_encode;
if (encoding == enc::BGR8 || encoding == enc::BGRA8 || encoding == enc::MONO8 || encoding == enc::MONO16)
{
image = this->image;
image_to_encode = this->image;
} else {
CvImagePtr tempThis = std::make_shared<CvImage>(*this);
CvImagePtr temp;
Expand All @@ -526,12 +526,12 @@ void CvImage::toCompressedImageMsg(
} else {
temp = cvtColor(tempThis, enc::BGR8);
}
image = temp->image;
image_to_encode = temp->image;
}

std::string format = getFormat(dst_format);
ros_image.format = format;
cv::imencode("." + format, image, ros_image.data);
cv::imencode("." + format, image_to_encode, ros_image.data);
}

// Deep copy data, returnee is mutable
Expand Down