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

Added support for YUV422 and RGB8 #141

Open
wants to merge 7 commits into
base: master
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
Next Next commit
added support for PIXEL_FORMAT_RGB8 and PIXEL_FORMAT_422YUV8
Jit Ray Chowdhury committed Aug 16, 2017

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit eaf6a9bb8a0edbe33e52b101c34541485d5c71a5
4 changes: 3 additions & 1 deletion pointgrey_camera_driver/cfg/PointGrey.cfg
Original file line number Diff line number Diff line change
@@ -129,7 +129,9 @@ gen.add("format7_y_offset", int_t, SensorLevels.RECONFIGURE_STOP, "Vert
codings = gen.enum([gen.const("Mono8", str_t, "mono8", ""),
gen.const("Mono16", str_t, "mono16", ""),
gen.const("Raw8", str_t, "raw8", ""),
gen.const("Raw16", str_t, "raw16", "")],
gen.const("Raw16", str_t, "raw16", ""),
gen.const("Rgb8", str_t, "rgb8", ""),
gen.const("yuv422", str_t, "yuv422", "")],
"Format7 color coding methods")

gen.add("format7_color_coding", str_t, SensorLevels.RECONFIGURE_STOP, "Color coding (only for Format7 modes)", "raw8", edit_method = codings)
52 changes: 43 additions & 9 deletions pointgrey_camera_driver/src/PointGreyCamera.cpp
Original file line number Diff line number Diff line change
@@ -75,19 +75,33 @@ bool PointGreyCamera::setNewConfiguration(pointgrey_camera_driver::PointGreyConf
{
PixelFormat fmt7PixFmt;
PointGreyCamera::getFormat7PixelFormatFromString(config.format7_color_coding, fmt7PixFmt);
switch(fmt7PixFmt)
{
case PIXEL_FORMAT_RAW8: ROS_INFO_STREAM("Setting PIXEL_FORMAT_RAW8");break;
case PIXEL_FORMAT_RAW16: ROS_INFO_STREAM("Setting PIXEL_FORMAT_RAW16");break;
case PIXEL_FORMAT_MONO8: ROS_INFO_STREAM("Setting PIXEL_FORMAT_MONO8");break;
case PIXEL_FORMAT_MONO16: ROS_INFO_STREAM("Setting PIXEL_FORMAT_MONO16");break;
case PIXEL_FORMAT_422YUV8: ROS_INFO_STREAM("Setting PIXEL_FORMAT_422YUV8");break;
case PIXEL_FORMAT_RGB8: ROS_INFO_STREAM("Setting PIXEL_FORMAT_RGB8");break;
case PIXEL_FORMAT_BGR: ROS_INFO_STREAM("Setting PIXEL_FORMAT_BGR");break;
default: ROS_INFO_STREAM("GetDefaultOutputFormat "<<std::hex<<fmt7PixFmt);
}
// Oh no, these all need to be converted into uints, so my pass by reference trick doesn't work
uint16_t uwidth = (uint16_t)config.format7_roi_width;
uint16_t uheight = (uint16_t)config.format7_roi_height;
uint16_t uoffsetx = (uint16_t)config.format7_x_offset;
uint16_t uoffsety = (uint16_t)config.format7_y_offset;
retVal &= PointGreyCamera::setFormat7(fmt7Mode, fmt7PixFmt, uwidth, uheight, uoffsetx, uoffsety);
ROS_INFO_STREAM("Setting VIDEOMODE_FORMAT7 MODE "<<fmt7Mode);

config.format7_roi_width = uwidth;
config.format7_roi_height = uheight;
config.format7_x_offset = uoffsetx;
config.format7_y_offset = uoffsety;
}
else
{
ROS_INFO_STREAM("Setting VIDEOMODE "<<vMode);
// Need to set just videoMode
PointGreyCamera::setVideoMode(vMode);
}
@@ -430,6 +444,14 @@ bool PointGreyCamera::getFormat7PixelFormatFromString(std::string &sformat, FlyC
{
fmt7PixFmt = PIXEL_FORMAT_MONO16;
}
else if(sformat.compare("rgb8") == 0)
{
fmt7PixFmt = PIXEL_FORMAT_RGB8;
}
else if(sformat.compare("yuv422") == 0)
{
fmt7PixFmt = PIXEL_FORMAT_422YUV8;
}
else
{
sformat = "raw8";
@@ -987,9 +1009,14 @@ void PointGreyCamera::grabImage(sensor_msgs::Image &image, const std::string &fr
// Check the bits per pixel.
uint8_t bitsPerPixel = rawImage.GetBitsPerPixel();

// Set the image encoding
// Set the default image encoding
std::string imageEncoding = sensor_msgs::image_encodings::MONO8;

//Get image encoding details
BayerTileFormat bayer_format = rawImage.GetBayerTileFormat();
PixelFormat p_fmt=rawImage.GetPixelFormat();
ROS_DEBUG_STREAM("bayer_format "<<bayer_format<<" bitsPerPixel "<<(unsigned)bitsPerPixel<< " PixelFormat "<<std::hex<<p_fmt);

if(isColor_ && bayer_format != NONE)
{
if(bitsPerPixel == 16)
@@ -1029,16 +1056,23 @@ void PointGreyCamera::grabImage(sensor_msgs::Image &image, const std::string &fr
}
}
}
else // Mono camera or in pixel binned mode.
else
{
if(bitsPerPixel == 16)
{
imageEncoding = sensor_msgs::image_encodings::MONO16;
}
else
switch(p_fmt)
{
imageEncoding = sensor_msgs::image_encodings::MONO8;
}

case PIXEL_FORMAT_422YUV8:
imageEncoding = sensor_msgs::image_encodings::YUV422;break;
case PIXEL_FORMAT_RGB8:
imageEncoding = sensor_msgs::image_encodings::RGB8;break;
case PIXEL_FORMAT_MONO8:
imageEncoding = sensor_msgs::image_encodings::MONO8;break;
case PIXEL_FORMAT_MONO16:
imageEncoding = sensor_msgs::image_encodings::MONO16;break;
default:
ROS_WARN_STREAM(" imageEncoding not supported (defaults to MONO8)");
imageEncoding = sensor_msgs::image_encodings::MONO8;
}
}

fillImage(image, imageEncoding, rawImage.GetRows(), rawImage.GetCols(), rawImage.GetStride(), rawImage.GetData());