-
Notifications
You must be signed in to change notification settings - Fork 21
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
Allows cameras to publish images in RGB24 format #3
base: hydro-devel
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -187,7 +187,18 @@ class ProsilicaNode | |
|
||
// Service call for setting calibration. | ||
set_camera_info_srv_ = nh_.advertiseService("set_camera_info", &ProsilicaNode::setCameraInfo, this); | ||
|
||
|
||
// Set the pixel format | ||
std::string pix_format = ""; | ||
if (local_nh.getParam("pixel_format", pix_format) && (pix_format == "Rgb24" || pix_format == "Bayer8")) | ||
{ | ||
if (cam_->hasAttribute("PixelFormat")) | ||
{ | ||
ROS_DEBUG_STREAM("Setting camera pixel format to " << pix_format); | ||
cam_->setAttribute("PixelFormat", pix_format); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The same block below has an else with a WARN should this not too? |
||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is unnecessary. Dynamic_reconfigure will automatically pull in parameters from the parameter server and call the configuration callback on initialization. |
||
// Start dynamic_reconfigure | ||
reconfigure_server_.setCallback(boost::bind(&ProsilicaNode::configure, this, _1, _2)); | ||
} | ||
|
@@ -331,6 +342,20 @@ class ProsilicaNode | |
if (!auto_adjust_stream_bytes_per_second_) | ||
cam_->setAttribute("StreamBytesPerSecond", (tPvUint32)config.stream_bytes_per_second); | ||
|
||
// Change the pixel format | ||
if (config.pixel_format == "Rgb24" || config.pixel_format == "Bayer8") | ||
{ | ||
if (cam_->hasAttribute("PixelFormat")) | ||
{ | ||
ROS_DEBUG_STREAM("Setting camera pixel format to " << config.pixel_format); | ||
cam_->setAttribute("PixelFormat", config.pixel_format); | ||
} | ||
else | ||
{ | ||
ROS_WARN("Changing pixel format is not supported by your camera"); | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should print a warning or an error if an invalid pixel format is specified. Take a look at how setting the streaming rate is handled. |
||
|
||
/// @todo If exception thrown due to bad settings, will fail to start camera | ||
if (level >= (uint32_t)driver_base::SensorLevels::RECONFIGURE_STOP) | ||
start(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably be an enumeration rather than a raw string. Take a look at how the enum for the streaming mode is implemented.