[Documentation] [TitleIndex] [WordIndex

API review

Reviewer:

Question / concerns / comments

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.

Conclusion



2019-12-14 12:40