Skip to content

beam_containers

Evan McLaughlin edited this page Jul 10, 2019 · 23 revisions

beam_containers

This module contains containers to store data for efficient use with other Beam code. Each application of Beam's robots will required a pair of containers: a custom PCL Point Type for storing cloud information and an image container for containing images and corresponding masks for labeling that custom point cloud. E.g., ImageBridge and PointBridge are the image container and point type used for bridge inspection, respectively.

Currently Supported Containers

Bridge Inspection Containers

Bridge inspection containers contain information to facilitate visual inspection of reinforced concrete defects. These defects include: cracks, spallshttps://wiki.ubuntu.com/, delaminations, and corrosion stains.

PointBridge.h

Fields: {x,y,z,intensity,rgb,r,g,b,alpha,thermal,crack,spall,corrosion,delam}

Type: {f,f,f,f,f,uint8,uint8,uint8,uint8,uint8,f,f,f,f}

This container is similar to a typical PointXYZRGB point type. The key additions are the fields for crack, spall, delamination, and corrosion for each point. Each of these fields stores a float that should be between 0.0 and 1.0. This value represents the likelihood that this point represents a defect of its corresponding type.

ImageBridge.h

Member variables:

  • bgr_image_ (cv::Mat), bgr_mask_ (cv::Mat), bgr_mask_method_ (string), bgr_frame_id_ (string), bgr_is_distorted_ (bool), is_bgr_image_set_ (bool), is_bgr_mask_set_ (bool)
  • ir_image_ (cv::Mat), ir_mask_ (cv::Mat), ir_mask_method_ (string), ir_frame_id_ (string), ir_is_distorted_ (bool), is_ir_image_set_ (bool), is_ir_mask_set_ (bool)
  • bag_name_ (string)
  • time_stamp_ (beam::TimePoint)
  • image_seq_ (int)

Example Use of Beam Point Container

Example code to load a PointBridge container from a .pcd file. Note that

#include <beam_containers/PointBridge.h>

#include <pcl/io/pcd_io.h>

#include <boost/smart_ptr.hpp>
int main() {
  // Read data from a PCD into a PointBridge container
  pcl::PCDReader reader;
  auto cloud = boost::make_shared<pcl::PointCloud<beam_containers::PointBridge>>();
  reader.read("test_data/20180622-flir_delam_ptCloud.pcd", *cloud);

  // Example on how to assign custom points to a PointBridge container
  auto cloud2 = boost::make_share<pcl::PointCloud<beam_containers::PointBridge>>();
  cloud2->width = 3;
  cloud2->height = 1;
  cloud2->points.resize(cloud2->width * cloud2->height);

  // Add example values for point bridge
  // x,y,z,intensity,rgb,r,g,b,a,thermal,crack,spall,corrosion,delam
  float RGB = 0, I = 0, C = 0, S = 0.7, CS = 0.2, D = 0.9;
  uint8_t T = 100, R = 0, G = 0, B = 0, A = 0;
 
  // Assign custom point
  cloud2->points[0] = beam_containers::PointBridge{
    0, 0, 0, I, RGB, R, G, B, A, T, C, S, CS, D};
  
  // This can be wordy, so use alias
  using PB = beam_containers::PointBridge;
  cloud2->points[1] = PB{0.1, 0.1, 0.1, I, RGB, R, G, B, A, T, C, S, CS, D};
  cloud2->points[2] = PB{0.2, 0.3, 0.4, I, RGB, R, G, B, A, T, C, S, CS, D};

  // Show some output
  std::cout << cloud2->points[1].spall << std::endl; // outputs 0.7
  std::cout << cloud2->points[2].thermal << std::endl; //outputs 100
  std::cout << cloud2->points[0].delam << std::endl; // outputs 0.9
  
  return 0;
}

For more information on custom PCL point type containers, see PCL's point type documentation.

Example Use of Beam Image Container

#include "beam_containers/ImageBridge.h"
#include "beam_utils/time.hpp"

beam_containers::ImageBridge img_container;
std::string file_location = "/path/to/json";
img_container.LoadFromJSON(file_location);
std::string bag_name = img_container.GetBagName();
int img_seq = img_container.GetImageSeq();
std::string BGR_image_frame = img_container.GetBGRFrameId();
bool is_ir_distorted = img_container.GetIRIsDistorted();
bool is_bgr_image_set = img_container.IsBGRImageSet();
bool is_ir_mask_set = img_container.IsIRMaskSet();
beam::TimePoint time_point = img_container.GetTimePoint();
Clone this wiki locally