API review
Reviewer:
- Ethan
Question / concerns / comments
- What happens with on demand processing if a color image is requested when the camera is mono? Can we avoid publishing the color topic at all (or unadvertise it? Is it even possible to unadvertise a topic?)
- There are a number of cases where it is useful to be able to perform rectification or debayering on an image within a single node rather than requiring a separate node. Can we add a static function which looks something like this (an appropriate header file will need to be added):
static void processImage(const sensor_msgs::ImageConstPtr& raw_image, const sensor_msgs::CameraInfoConstPtr& cam_info, bool doColorize, bool doRectify, sensor_msgs::ImagePtr &output_image) { if(!doRectify && !doColorize) { ROS_WARN("Neither doRectify nor doColorize is true, processImage aborting"); return; } cam::ImageData img_data; cam_bridge::RawToCamData(*raw_image, *cam_info, cam::IMAGE_RAW, &img_data); if (doColorize) img_data.doBayerColorRGB(); if (doRectify) img_data.doRectify(); // Fill output image output_img.header.stamp = raw_image->header.stamp; output_img.header.frame_id = raw_image->header.frame_id; if(doColorize && doRectify) { uint32_t step = img_data.imRectColorSize / img_data.imHeight; fillImage(output_image, cam_bridge::ColorCodingToImageEncoding(img_data_.imRectColorType), img_data.imHeight, img_data.imWidth, step, img_data.imRectColor); return; } else if(doColorize) { uint32_t step = img_data.imColorSize / img_data.imHeight; fillImage(output_image, cam_bridge::ColorCodingToImageEncoding(img_data_.imColorType), img_data.imHeight, img_data.imWidth, step, img_data.imColor); return; } else // doRectify { uint32_t step = img_data.imRectSize / img_data.imHeight; fillImage(output_image, cam_bridge::ColorCodingToImageEncoding(img_data_.imRectType), img_data.imHeight, img_data.imWidth, step, img_data.imRect); return; } }
NOTE I have not tried to compile this code so it is probably broken, but it should get the idea across and be close to functional.
- There should probably be either an INFO or DEBUG level logging event for subscribing and unsubscribing to the camera.
- local_nh_ no longer appears to be used, and should probably be removed unless parameters are added
- Do we want to expose any options with respect to the debayering / rectification? What about interpolation method options for the rectification?
Conclusion
Add static processImage method.
Should we expose any options for debayering / rectification, and if so how (probably just a few parameters)?