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

[ADD] flag for jpeg compression of bayer format #98

Open
wants to merge 3 commits into
base: rolling
Choose a base branch
from
Open
Changes from 1 commit
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
18 changes: 17 additions & 1 deletion compressed_image_transport/src/compressed_publisher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ enum compressedParameters
FORMAT = 0,
PNG_LEVEL,
JPEG_QUALITY,
JPEG_COMPRESS_BAYER,
TIFF_RESOLUTION_UNIT,
TIFF_XDPI,
TIFF_YDPI
Expand Down Expand Up @@ -102,6 +103,14 @@ const struct ParameterDefinition kParameters[] =
.set__to_value(100)
.set__step(1)})
},
{ //JPEG_COMPRESS_BAYER - allow compression of bayer encoded images.
ParameterValue((bool)false),
ParameterDescriptor()
.set__name("jpeg_compress_bayer")
.set__type(rcl_interfaces::msg::ParameterType::PARAMETER_BOOL)
.set__description("Allow JPEG compression for bayer format")
.set__read_only(false)
},
{ //TIFF_RESOLUTION_UNIT - TIFF resolution unit, can be one of "none", "inch", "centimeter".
ParameterValue("inch"),
ParameterDescriptor()
Expand Down Expand Up @@ -162,6 +171,7 @@ void CompressedPublisher::publish(
std::string cfg_format = node_->get_parameter(parameters_[FORMAT]).get_value<std::string>();
int cfg_png_level = node_->get_parameter(parameters_[PNG_LEVEL]).get_value<int64_t>();
int cfg_jpeg_quality = node_->get_parameter(parameters_[JPEG_QUALITY]).get_value<int64_t>();;
bool cfg_jpeg_compress_bayer = node_->get_parameter(parameters_[JPEG_COMPRESS_BAYER]).get_value<bool>();;
std::string cfg_tiff_res_unit = node_->get_parameter(parameters_[TIFF_RESOLUTION_UNIT]).get_value<std::string>();
int cfg_tiff_xdpi = node_->get_parameter(parameters_[TIFF_XDPI]).get_value<int64_t>();
int cfg_tiff_ydpi = node_->get_parameter(parameters_[TIFF_YDPI]).get_value<int64_t>();
Expand Down Expand Up @@ -209,7 +219,13 @@ void CompressedPublisher::publish(
// convert color images to BGR8 format
targetFormat = "bgr8";
compressed.format += targetFormat;
} else {
}
else if (enc::isBayer(message.encoding) and cfg_jpeg_compress_bayer)
{
targetFormat = message.encoding;
compressed.format += targetFormat;
}
else {
// convert gray images to mono8 format
targetFormat = "mono8";
compressed.format += targetFormat;
Expand Down