adi_3dtof_image_stitching.h
Go to the documentation of this file.
1 /******************************************************************************
2 Copyright (c), 2023 - Analog Devices Inc. All Rights Reserved.
3 This software is PROPRIETARY & CONFIDENTIAL to Analog Devices, Inc.
4 and its licensors.
5 ******************************************************************************/
6 #ifndef ADI_3DTOF_IMAGE_STITCH_H
7 #define ADI_3DTOF_IMAGE_STITCH_H
8 
11 #include "adi_camera.h"
12 #include "image_proc_utils.h"
13 #include "module_profile.h"
14 #include "output_sensor.h"
15 #include "output_sensor_factory.h"
16 #ifdef ENABLE_GPU_OPTIMIZATION
17 #include "stitch_frames_core_gpu.cuh"
18 #else
19 #include "stitch_frames_core_cpu.h"
20 #endif
21 #include <boost/make_shared.hpp>
22 #include <cv_bridge/cv_bridge.h>
30 #include <pcl/features/normal_3d.h>
31 #include <pcl/filters/filter.h>
32 #include <pcl/filters/voxel_grid.h>
33 #include <pcl/point_cloud.h>
34 #include <pcl/point_representation.h>
35 #include <pcl/point_types.h>
36 #include <pcl/registration/icp.h>
37 #include <pcl/registration/icp_nl.h>
38 #include <pcl/registration/transforms.h>
40 #include <pcl_ros/transforms.h>
41 #include <ros/ros.h>
42 #include <sensor_msgs/CameraInfo.h>
43 #include <sensor_msgs/Image.h>
44 #include <sensor_msgs/PointCloud2.h>
47 #include <std_msgs/Bool.h>
50 #include <utility>
51 
52 #include <opencv2/core.hpp>
53 #include <opencv2/highgui.hpp>
54 #include <opencv2/imgcodecs.hpp>
55 
56 #include <boost/chrono.hpp>
57 #include <boost/thread/thread.hpp>
58 #include <queue>
59 
60 #define MAX_QUEUE_SIZE_FOR_TIME_SYNC 10
61 #define SENSOR_OVERLAP_PERCENT 10.0f
62 
64 
65 // Declaring synchronization policies
68 typedef message_filters::sync_policies::ApproximateTime<sensor_msgs::CameraInfo, sensor_msgs::CameraInfo,
69  sensor_msgs::CameraInfo>
71 typedef message_filters::sync_policies::ApproximateTime<sensor_msgs::CameraInfo, sensor_msgs::CameraInfo,
72  sensor_msgs::CameraInfo, sensor_msgs::CameraInfo>
74 typedef message_filters::sync_policies::ApproximateTime<sensor_msgs::Image, sensor_msgs::Image, sensor_msgs::Image,
75  sensor_msgs::Image>
77 typedef message_filters::sync_policies::ApproximateTime<sensor_msgs::Image, sensor_msgs::Image, sensor_msgs::Image,
78  sensor_msgs::Image, sensor_msgs::Image, sensor_msgs::Image>
80 typedef message_filters::sync_policies::ApproximateTime<sensor_msgs::Image, sensor_msgs::Image, sensor_msgs::Image,
81  sensor_msgs::Image, sensor_msgs::Image, sensor_msgs::Image,
82  sensor_msgs::Image, sensor_msgs::Image>
84 
85 // Defining Synchronizers
92 
98 {
99  typedef void (ADI3DToFImageStitching::*ImageCallbackFuncPointer)(const sensor_msgs::ImageConstPtr&);
100  typedef void (ADI3DToFImageStitching::*ObjectDetectCallbackFuncPointer)(const std_msgs::BoolConstPtr&);
101  typedef void (ADI3DToFImageStitching::*PointCloudCallbackFuncPointer)(const sensor_msgs::PointCloud2ConstPtr&);
102 
103 public:
104  static const int MAX_NUM_DEVICES = 4;
108  int out_image_height_ = 512;
110 
116  {
117  ROS_INFO("adi_3dtof_image_stitching::Inside ADI3DToFImageStitching()");
118  ros::NodeHandle nh("~");
119  //Initializing image transport
121 
122  // Get Parameters
123  nh.param<int>("param_enable_pointcloud_generation", enable_pointcloud_generation_, 2);
124  nh.param<int>("param_output_mode", output_sensor_mode_, 0);
125  nh.param<std::string>("param_camera_link", camera_link_, "adi_camera_link");
126  nh.param<std::string>("param_out_file_name", output_file_name_, "stitched_output.avi");
127 
128  // Getting Camera prefixes
129  std::vector<std::string> cam_prefix;
130  XmlRpc::XmlRpcValue cam_prefix_arr;
131  nh.param("param_camera_prefixes", cam_prefix_arr, cam_prefix_arr);
132  std::vector<std::string> cam_prefix_1;
133  for (int i = 0; i < cam_prefix_arr.size(); i++)
134  {
135  cam_prefix.push_back(cam_prefix_arr[i]);
136  std::cerr << "camera_prefixes: " << cam_prefix[i] << std::endl;
137  }
138  // Getting projection parameters
139  nh.param<float>("param_sensor_vertical_fov_in_degrees", vertical_fov_sensor_in_degrees_, 75.0);
140  nh.param<float>("param_sensor_horizontal_fov_in_degrees", horizontal_fov_sensor_in_degrees_, 75.0);
141  nh.param<int>("param_sensor_image_height", sensor_image_height_, 512);
142  nh.param<int>("param_sensor_image_width", sensor_image_width_, 512);
143  nh.param<bool>("param_enable_autoscaling", enable_autoscaling_, true);
144 
145  // init
146  frame_counter_ = 0;
147  //flag to indicate autoscaling is not applied yet
148  autoscaling_flag_ = false;
149 
150  // Do not allow more than the max cameras supported.
151  int max_devices_allowed = static_cast<int>(sizeof(depth_image_subscriber_) / sizeof(depth_image_subscriber_[0]));
152  num_sensors_ = std::min(max_devices_allowed, static_cast<int>(cam_prefix.size()));
153  input_read_abort_ = false;
154 
155  //Setting output width and height for max horizontal sensor combination
156  out_image_width_ = sensor_image_width_ * max_devices_allowed;
158 
159 
160  for (int i = 0; i < num_sensors_; i++)
161  {
162 
163  // Synchronized subscribers
164  camera_info_subscriber_[i].subscribe(nh, "/" + cam_prefix[i] + "/camera_info", 5);
165  ir_image_subscriber_[i].subscribe(*it_, "/" + cam_prefix[i] + "/ir_image", 5);
166  depth_image_subscriber_[i].subscribe(*it_, "/" + cam_prefix[i] + "/depth_image", 5);
167 
168  // Create TF listerner instance
170 
173 
174  // Different flags
175  ir_image_recvd_[i] = false;
176  depth_image_recvd_[i] = false;
177  tf_recvd_[i] = false;
178  }
179 
180  // Get output sensor module
186  if (output_sensor_ != nullptr)
187  {
188  // TODO: check how to better pass the output image width and height, currently
189  // the output size values an be changed from main function after initialization.
192  }
193 
194  if (num_sensors_ == 2)
195  {
196  try {
199  sync_CamInfo_2cam_->registerCallback(boost::bind(&ADI3DToFImageStitching::sync2CamerasCamInfoCallback, this, _1, _2));
200 
202  {
206  sync_depth_ir_2cam_->registerCallback(
207  boost::bind(&ADI3DToFImageStitching::sync2CamerasDepthIRImageCallback, this, _1, _2, _3, _4));
208  }
209  }
210  catch (...) {
211  printf("\n ERROR: Exception while registering Synchronizers \n");
212  }
213  }
214  else if (num_sensors_ == 3)
215  {
216  try {
220  sync_CamInfo_3cam_->registerCallback(boost::bind(&ADI3DToFImageStitching::sync3CamerasCamInfoCallback, this, _1, _2, _3));
221 
223  {
228  sync_depth_ir_3cam_->registerCallback(
229  boost::bind(&ADI3DToFImageStitching::sync3CamerasDepthIRImageCallback, this, _1, _2, _3, _4, _5, _6));
230  }
231  }
232  catch (...) {
233  printf("\n ERROR: Exception while registering Synchronizers \n");
234  }
235  }
236  else if (num_sensors_ == 4)
237  {
238  try {
242  sync_CamInfo_4cam_->registerCallback(
243  boost::bind(&ADI3DToFImageStitching::sync4CamerasCamInfoCallback, this, _1, _2, _3, _4));
244  // We need depth image for point-cloud generation
245 
247  {
252  sync_depth_ir_4cam_->registerCallback(
253  boost::bind(&ADI3DToFImageStitching::sync4CamerasDepthIRImageCallback, this, _1, _2, _3, _4, _5, _6, _7, _8));
254  }
255  }
256  catch (...) {
257  printf("\n ERROR: Exception while registering Synchronizers \n");
258  }
259  }
260 
261  // Create publishers.
262  combo_out_point_cloud_publisher_ = this->advertise<sensor_msgs::PointCloud2>("point_cloud", 10);
263  stitched_depth_image_publisher_ = this->advertise<sensor_msgs::Image>("depth_image", 10);
264  stitched_ir_image_publisher_ = this->advertise<sensor_msgs::Image>("ir_image", 10);
265  stitched_camera_info_publisher_ = this->advertise<sensor_msgs::CameraInfo>("camera_info", 10);
266 
267  // Initialize stitched point cloud buffer
268  stitched_pc_pcl_ = pcl::PointCloud<pcl::PointXYZ>::Ptr(new pcl::PointCloud<pcl::PointXYZ>);
270 
271  float max_stitched_horizontal_FOV = ((horizontal_fov_sensor_in_degrees_*((100-SENSOR_OVERLAP_PERCENT)/100))*(max_devices_allowed-1))+horizontal_fov_sensor_in_degrees_;
272 
273 #ifdef ENABLE_GPU_OPTIMIZATION
274  // GPU class init
275  stitch_frames_core_GPU_ = new StitchFramesCoreGPU(sensor_image_width_, sensor_image_height_, out_image_width_,
276  out_image_height_, num_sensors_, vertical_fov_sensor_in_degrees_, max_stitched_horizontal_FOV);
277 #else
279  out_image_height_, num_sensors_, vertical_fov_sensor_in_degrees_, max_stitched_horizontal_FOV);
280 #endif
281 
284  }
285 
291  {
292  int status = system("rosnode kill -a");
293  if (status < 0)
294  {
295  ROS_INFO_STREAM("Error in \"rosnode kill -a\": " << status);
296  }
297  ros::shutdown();
298  }
299 
305  {
306  for (int i = 0; i < num_sensors_; i++)
307  {
308  delete tf_listener_[i];
309  delete image_proc_utils_[i];
310  }
311 
312  // Close outputs
313  if (output_sensor_ != nullptr)
314  {
316  }
317  }
327  sensor_msgs::PointCloud2::Ptr convert2ROSPointCloudMsg(short* xyz_frame, std_msgs::Header sensor_header,
328  int img_width, int img_height)
329  {
330  sensor_msgs::PointCloud2::Ptr pointcloud_msg(new sensor_msgs::PointCloud2);
331 
332  pointcloud_msg->header.seq = frame_counter_;
333  pointcloud_msg->header.stamp = sensor_header.stamp;
334  pointcloud_msg->header.frame_id = sensor_header.frame_id;
335  pointcloud_msg->width = img_width;
336  pointcloud_msg->height = img_height;
337  pointcloud_msg->is_dense = false;
338  pointcloud_msg->is_bigendian = false;
339 
340  // XYZ data from sensor.
341  // This data is in 16 bpp format.
342  short* xyz_sensor_buf;
343  xyz_sensor_buf = xyz_frame;
344  sensor_msgs::PointCloud2Modifier pcd_modifier(*pointcloud_msg);
345  pcd_modifier.setPointCloud2FieldsByString(1, "xyz");
346 
347  sensor_msgs::PointCloud2Iterator<float> iter_x(*pointcloud_msg, "x");
348  sensor_msgs::PointCloud2Iterator<float> iter_y(*pointcloud_msg, "y");
349  sensor_msgs::PointCloud2Iterator<float> iter_z(*pointcloud_msg, "z");
350  // TODO:Parallelize this below loop with openmp
351  for (int i = 0; i < img_height; i++)
352  {
353  for (int j = 0; j < img_width; j++)
354  {
355  *iter_x = (float)(*xyz_sensor_buf++) / 1000.0f;
356  *iter_y = (float)(*xyz_sensor_buf++) / 1000.0f;
357  *iter_z = (float)(*xyz_sensor_buf++) / 1000.0f;
358  ++iter_x;
359  ++iter_y;
360  ++iter_z;
361  }
362  }
363 
364  return pointcloud_msg;
365  }
366 
367  void sync2CamerasDepthIRImageCallback(const sensor_msgs::ImageConstPtr& depth_image_cam1,
368  const sensor_msgs::ImageConstPtr& ir_image_cam1,
369  const sensor_msgs::ImageConstPtr& depth_image_cam2,
370  const sensor_msgs::ImageConstPtr& ir_image_cam2);
371 
372  void sync3CamerasDepthIRImageCallback(const sensor_msgs::ImageConstPtr& depth_image_cam1,
373  const sensor_msgs::ImageConstPtr& ir_image_cam1,
374  const sensor_msgs::ImageConstPtr& depth_image_cam2,
375  const sensor_msgs::ImageConstPtr& ir_image_cam2,
376  const sensor_msgs::ImageConstPtr& depth_image_cam3,
377  const sensor_msgs::ImageConstPtr& ir_image_cam3);
378 
380  const sensor_msgs::ImageConstPtr& depth_image_cam1, const sensor_msgs::ImageConstPtr& ir_image_cam1,
381  const sensor_msgs::ImageConstPtr& depth_image_cam2, const sensor_msgs::ImageConstPtr& ir_image_cam2,
382  const sensor_msgs::ImageConstPtr& depth_image_cam3, const sensor_msgs::ImageConstPtr& ir_image_cam3,
383  const sensor_msgs::ImageConstPtr& depth_image_cam4, const sensor_msgs::ImageConstPtr& ir_image_cam4);
384 
385  void sync2CamerasCamInfoCallback(const sensor_msgs::CameraInfoConstPtr& CameraInfo_cam1,
386  const sensor_msgs::CameraInfoConstPtr& CameraInfo_cam2);
387 
388  void sync3CamerasCamInfoCallback(const sensor_msgs::CameraInfoConstPtr& CameraInfo_cam1,
389  const sensor_msgs::CameraInfoConstPtr& CameraInfo_cam2,
390  const sensor_msgs::CameraInfoConstPtr& CameraInfo_cam3);
391 
392  void sync4CamerasCamInfoCallback(const sensor_msgs::CameraInfoConstPtr& CameraInfo_cam1,
393  const sensor_msgs::CameraInfoConstPtr& CameraInfo_cam2,
394  const sensor_msgs::CameraInfoConstPtr& CameraInfo_cam3,
395  const sensor_msgs::CameraInfoConstPtr& CameraInfo_cam4);
396 
397  void camInfoCallback(const sensor_msgs::CameraInfoConstPtr& cam_info, int cam_id);
398 
399  void depthImageCallback(const sensor_msgs::ImageConstPtr& depth_image, int cam_id,
400  ADI3DToFImageStitchingInputInfo* image_stitch_input_info);
401 
402  void irImageCallback(const sensor_msgs::ImageConstPtr& ir_image, int cam_id,
403  ADI3DToFImageStitchingInputInfo* image_stitch_input_info);
404 
405  void AutoscaleStitching(ADI3DToFImageStitchingInputInfo* image_stitch_input_info);
406 
407  bool stitchFrames();
408 
409  void generatePointCloud(float* xyz_frame, int* lut_3d_to_2d_mapping, const pcl::PointCloud<pcl::PointXYZ>::Ptr& out_pointcloud);
410 
411  void processOutputAbort();
412 
413  void pushOutputNode(ADI3DToFImageStitchingOutputInfo* new_output_node);
414 
415  void processOutput();
416 
418  {
419  input_read_abort_ = true;
420  }
421 
423 
424  template <typename T>
425  void addInputNodeToQueue(T* image_stitch_input_info);
426 
427 private:
432  std::string camera_link_;
433  sensor_msgs::CameraInfo cam_info_msg_;
438  std::string output_file_name_;
441 
451  float transform_matrix_[MAX_NUM_DEVICES][16]; // a 4x4 matrix for all the sensors
453  geometry_msgs::TransformStamped camera_map_transform_[MAX_NUM_DEVICES];
457 
458  // Defining synchronizers
465 
470 
471  sensor_msgs::PointCloud2 stitched_pc_;
472  pcl::PointCloud<pcl::PointXYZ>::Ptr stitched_pc_pcl_;
473 
475 
477 
480 
482 
483  boost::mutex output_thread_mtx_;
484  boost::mutex input_thread_mtx_;
485 
487 
488  std::queue<ADI3DToFImageStitchingInputInfo*> input_node_queue_;
489  std::queue<ADI3DToFImageStitchingOutputInfo*> output_node_queue_;
490 #ifdef ENABLE_GPU_OPTIMIZATION
491  StitchFramesCoreGPU* stitch_frames_core_GPU_;
492 #else
494 #endif
495 
503  void publishImageAsRosMsg(cv::Mat img, const std::string& encoding_type, std::string frame_id,
504  const ros::Publisher& publisher)
505  {
507 
508  cv_ptr->encoding = encoding_type;
509  cv_ptr->header.seq = frame_counter_;
510  cv_ptr->header.stamp = curr_frame_timestamp_;
511  cv_ptr->header.frame_id = std::move(frame_id);
512  cv_ptr->image = std::move(img);
513 
514  publisher.publish(cv_ptr->toImageMsg());
515  }
516 
523  void fillAndPublishCameraInfo(std::string frame_id, const ros::Publisher& publisher)
524  {
525  cam_info_msg_.header.seq = frame_counter_;
526  cam_info_msg_.header.stamp = curr_frame_timestamp_;
527  cam_info_msg_.header.frame_id = std::move(frame_id);
528 
531 
533 
534  cam_info_msg_.K.fill(0.0f);
535  cam_info_msg_.K[0] = 781.291565f / 2; // fx
536  cam_info_msg_.K[2] = cam_info_msg_.width / 2; // cx
537  cam_info_msg_.K[4] = 781.87738f / 2; // fy
538  cam_info_msg_.K[5] = cam_info_msg_.height / 2; // cy
539  cam_info_msg_.K[8] = 1.0f;
540 
541  cam_info_msg_.P.fill(0.0);
542  cam_info_msg_.D.resize(8);
543  cam_info_msg_.R.fill(0.0f);
544  cam_info_msg_.binning_x = 0;
545  cam_info_msg_.binning_y = 0;
546  cam_info_msg_.roi.do_rectify = false;
547  cam_info_msg_.roi.height = 0;
548  cam_info_msg_.roi.width = 0;
549  cam_info_msg_.roi.x_offset = 0;
550  cam_info_msg_.roi.y_offset = 0;
551 
552  publisher.publish(cam_info_msg_);
553  }
554 
561  {
562  camera_intrinsics.camera_matrix[0] = 781.291565f;
563  camera_intrinsics.camera_matrix[1] = 0.0f;
564  camera_intrinsics.camera_matrix[2] = 520.714905f;
565  camera_intrinsics.camera_matrix[3] = 0.0f;
566  camera_intrinsics.camera_matrix[4] = 781.87738f;
567  camera_intrinsics.camera_matrix[5] = 513.001709f;
568  camera_intrinsics.camera_matrix[6] = 0.0f;
569  camera_intrinsics.camera_matrix[7] = 0.0f;
570  camera_intrinsics.camera_matrix[8] = 1.0f;
571 
572  camera_intrinsics.distortion_coeffs[0] = -0.0693829656f;
573  camera_intrinsics.distortion_coeffs[1] = 0.115561306f;
574  camera_intrinsics.distortion_coeffs[2] = 0.000196631983f;
575  camera_intrinsics.distortion_coeffs[3] = -0.00011414945f;
576  camera_intrinsics.distortion_coeffs[4] = 0.0944529548f;
577  camera_intrinsics.distortion_coeffs[5] = 0.269195855f;
578  camera_intrinsics.distortion_coeffs[6] = -0.00811018609f;
579  camera_intrinsics.distortion_coeffs[7] = 0.190516844f;
580 
581  // Scale
582  camera_intrinsics.camera_matrix[0] /= 2;
583  camera_intrinsics.camera_matrix[2] /= 2;
584  camera_intrinsics.camera_matrix[4] /= 2;
585  camera_intrinsics.camera_matrix[5] /= 2;
586  }
587 };
588 
589 #endif
XmlRpc::XmlRpcValue::size
int size() const
ADI3DToFImageStitching::input_node_queue_
std::queue< ADI3DToFImageStitchingInputInfo * > input_node_queue_
Definition: adi_3dtof_image_stitching.h:488
ADI3DToFImageStitching::tf_recvd_
bool tf_recvd_[MAX_NUM_DEVICES]
Definition: adi_3dtof_image_stitching.h:450
adi_3dtof_image_stitching_input_info.h
image_transport::SubscriberFilter
ADI3DToFImageStitching::fillAndPublishCameraInfo
void fillAndPublishCameraInfo(std::string frame_id, const ros::Publisher &publisher)
This image fills and publishes the camera information.
Definition: adi_3dtof_image_stitching.h:523
sensor_msgs::image_encodings
ADI3DToFImageStitching::sync4CamerasCamInfoCallback
void sync4CamerasCamInfoCallback(const sensor_msgs::CameraInfoConstPtr &CameraInfo_cam1, const sensor_msgs::CameraInfoConstPtr &CameraInfo_cam2, const sensor_msgs::CameraInfoConstPtr &CameraInfo_cam3, const sensor_msgs::CameraInfoConstPtr &CameraInfo_cam4)
Call back for synchronised topics(CameraInfo) for 4 camera configuration.
Definition: callback_impl.cpp:300
ADI3DToFImageStitchingOutputInfo
ENABLE_GPU_OPTIMIZATION.
Definition: adi_3dtof_image_stitching_output_info.h:19
point_cloud2_iterator.h
OutputSensorFactory::getOutputSensor
static IOutputSensor * getOutputSensor(int output_sensor_type)
Get the Output Sensor object.
Definition: output_sensor_factory.h:29
ADI3DToFImageStitching::AutoscaleStitching
void AutoscaleStitching(ADI3DToFImageStitchingInputInfo *image_stitch_input_info)
Calculates Yaw correction and updates output size.
Definition: callback_impl.cpp:24
ADI3DToFImageStitching::~ADI3DToFImageStitching
~ADI3DToFImageStitching()
Destroy the ADI3DToFImageStitching object.
Definition: adi_3dtof_image_stitching.h:304
ADI3DToFImageStitching::enable_pointcloud_generation_
int enable_pointcloud_generation_
Definition: adi_3dtof_image_stitching.h:436
ros::Publisher
ADI3DToFImageStitching::tf_listener_
tf2_ros::TransformListener * tf_listener_[MAX_NUM_DEVICES]
Definition: adi_3dtof_image_stitching.h:447
ADI3DToFImageStitching::sync_CamInfo_2cam_
boost::shared_ptr< sync_CamInfo_2cam > sync_CamInfo_2cam_
Definition: adi_3dtof_image_stitching.h:459
ADI3DToFImageStitching::depthImageCallback
void depthImageCallback(const sensor_msgs::ImageConstPtr &depth_image, int cam_id, ADI3DToFImageStitchingInputInfo *image_stitch_input_info)
Low-level callback for depth image.
Definition: callback_impl.cpp:369
ADI3DToFImageStitching::out_image_height_
int out_image_height_
Definition: adi_3dtof_image_stitching.h:108
ADI3DToFImageStitching::output_thread_mtx_
boost::mutex output_thread_mtx_
Definition: adi_3dtof_image_stitching.h:483
image_transport::ImageTransport
ADI3DToFImageStitching::combo_out_point_cloud_publisher_
ros::Publisher combo_out_point_cloud_publisher_
Definition: adi_3dtof_image_stitching.h:468
message_filters::Synchronizer
boost::shared_ptr
distortion_models.h
ADI3DToFImageStitching::ObjectDetectCallbackFuncPointer
void(ADI3DToFImageStitching::* ObjectDetectCallbackFuncPointer)(const std_msgs::BoolConstPtr &)
Definition: adi_3dtof_image_stitching.h:100
ADI3DToFImageStitching::input_queue_length_
int input_queue_length_
Definition: adi_3dtof_image_stitching.h:478
pinhole_camera_model.h
ADI3DToFImageStitching::depth_image_subscriber_
image_transport::SubscriberFilter depth_image_subscriber_[MAX_NUM_DEVICES]
Definition: adi_3dtof_image_stitching.h:444
ADI3DToFImageStitching::sensor_image_width_
int sensor_image_width_
Definition: adi_3dtof_image_stitching.h:429
module_profile.h
ADI3DToFImageStitching::stitched_ir_image_publisher_
ros::Publisher stitched_ir_image_publisher_
Definition: adi_3dtof_image_stitching.h:467
output_sensor.h
ADI3DToFImageStitching::horizontal_fov_sensor_in_degrees_
float horizontal_fov_sensor_in_degrees_
Definition: adi_3dtof_image_stitching.h:107
ros.h
sync_CamInfo_3cam
message_filters::Synchronizer< Sync_CameraInfo_3sensors > sync_CamInfo_3cam
Definition: adi_3dtof_image_stitching.h:87
ADI3DToFImageStitching::inputReadAbort
void inputReadAbort()
Definition: adi_3dtof_image_stitching.h:417
ADI3DToFImageStitching::input_read_abort_
bool input_read_abort_
Definition: adi_3dtof_image_stitching.h:486
Sync_CameraInfo_4sensors
message_filters::sync_policies::ApproximateTime< sensor_msgs::CameraInfo, sensor_msgs::CameraInfo, sensor_msgs::CameraInfo, sensor_msgs::CameraInfo > Sync_CameraInfo_4sensors
Definition: adi_3dtof_image_stitching.h:73
ADI3DToFImageStitching::output_queue_length_
int output_queue_length_
Definition: adi_3dtof_image_stitching.h:479
sync_depth_ir_3
message_filters::sync_policies::ApproximateTime< sensor_msgs::Image, sensor_msgs::Image, sensor_msgs::Image, sensor_msgs::Image, sensor_msgs::Image, sensor_msgs::Image > sync_depth_ir_3
Definition: adi_3dtof_image_stitching.h:79
ADI3DToFImageStitching::generatePointCloud
void generatePointCloud(float *xyz_frame, int *lut_3d_to_2d_mapping, const pcl::PointCloud< pcl::PointXYZ >::Ptr &out_pointcloud)
Function to convert 3D XYZ frame to PCL point cloud format.
Definition: stitch_frames.cpp:108
ADI3DToFImageStitching::sensor_image_height_
int sensor_image_height_
Definition: adi_3dtof_image_stitching.h:430
ADI3DToFImageStitching::camera_info_subscriber_
message_filters::Subscriber< sensor_msgs::CameraInfo > camera_info_subscriber_[MAX_NUM_DEVICES]
Definition: adi_3dtof_image_stitching.h:443
ros::shutdown
ROSCPP_DECL void shutdown()
image_transport::SubscriberFilter::subscribe
void subscribe(ImageTransport &it, const std::string &base_topic, uint32_t queue_size, const TransportHints &transport_hints=TransportHints())
ADI3DToFImageStitching
This is main class for this package.
Definition: adi_3dtof_image_stitching.h:97
MAX_QUEUE_SIZE_FOR_TIME_SYNC
#define MAX_QUEUE_SIZE_FOR_TIME_SYNC
Definition: adi_3dtof_image_stitching.h:60
ADI3DToFImageStitching::camera_map_transform_
geometry_msgs::TransformStamped camera_map_transform_[MAX_NUM_DEVICES]
Definition: adi_3dtof_image_stitching.h:453
CameraIntrinsics::camera_matrix
float camera_matrix[9]
Camera matrix = [fx, 0, cx, 0, fy, cy, 0, 0, 1] fx, fy : Camera focal lengths (pixels) cx,...
Definition: adi_camera.h:27
ADI3DToFImageStitching::stitched_pc_
sensor_msgs::PointCloud2 stitched_pc_
Definition: adi_3dtof_image_stitching.h:471
ros::Publisher::publish
void publish(const boost::shared_ptr< M > &message) const
ADI3DToFImageStitching::output_sensor_
IOutputSensor * output_sensor_
Definition: adi_3dtof_image_stitching.h:428
transforms.h
f
f
ADI3DToFImageStitching::output_file_name_
std::string output_file_name_
Definition: adi_3dtof_image_stitching.h:438
message_filters::Subscriber< sensor_msgs::CameraInfo >
ImageProcUtils
This class has image processing utilities.
Definition: image_proc_utils.h:19
tf2_ros::TransformListener
sync_depth_ir_4
message_filters::sync_policies::ApproximateTime< sensor_msgs::Image, sensor_msgs::Image, sensor_msgs::Image, sensor_msgs::Image, sensor_msgs::Image, sensor_msgs::Image, sensor_msgs::Image, sensor_msgs::Image > sync_depth_ir_4
Definition: adi_3dtof_image_stitching.h:83
ADI3DToFImageStitching::sync2CamerasCamInfoCallback
void sync2CamerasCamInfoCallback(const sensor_msgs::CameraInfoConstPtr &CameraInfo_cam1, const sensor_msgs::CameraInfoConstPtr &CameraInfo_cam2)
Call back for synchronised topics(CameraInfo) for 2 camera configuration.
Definition: callback_impl.cpp:266
ADI3DToFImageStitching::output_node_queue_
std::queue< ADI3DToFImageStitchingOutputInfo * > output_node_queue_
Definition: adi_3dtof_image_stitching.h:489
sync_depth_ir_2cam
message_filters::Synchronizer< sync_depth_ir_2 > sync_depth_ir_2cam
Definition: adi_3dtof_image_stitching.h:89
ADI3DToFImageStitching::sync2CamerasDepthIRImageCallback
void sync2CamerasDepthIRImageCallback(const sensor_msgs::ImageConstPtr &depth_image_cam1, const sensor_msgs::ImageConstPtr &ir_image_cam1, const sensor_msgs::ImageConstPtr &depth_image_cam2, const sensor_msgs::ImageConstPtr &ir_image_cam2)
Call back for synchronised topics(depth and IR image pair) for 2 camera configuration.
Definition: callback_impl.cpp:64
message_filters::sync_policies::ApproximateTime
ADI3DToFImageStitching::camInfoCallback
void camInfoCallback(const sensor_msgs::CameraInfoConstPtr &cam_info, int cam_id)
Low-level callback for Com-Info the ID would indicate the source camera.
Definition: callback_impl.cpp:319
ADI3DToFImageStitching::sync3CamerasCamInfoCallback
void sync3CamerasCamInfoCallback(const sensor_msgs::CameraInfoConstPtr &CameraInfo_cam1, const sensor_msgs::CameraInfoConstPtr &CameraInfo_cam2, const sensor_msgs::CameraInfoConstPtr &CameraInfo_cam3)
Call back for synchronised topics(CameraInfo) for 3 camera configuration.
Definition: callback_impl.cpp:281
ADI3DToFImageStitching::sync_depth_ir_2cam_
boost::shared_ptr< sync_depth_ir_2cam > sync_depth_ir_2cam_
Definition: adi_3dtof_image_stitching.h:462
adi_3dtof_image_stitching_output_info.h
sensor_msgs::PointCloud2Iterator
ADI3DToFImageStitching::processOutput
void processOutput()
The output process function, this is running a loop which reads the frame from the putput queue,...
Definition: adi_3dtof_image_stitching_output_thread.cpp:65
ADI3DToFImageStitching::image_proc_utils_
ImageProcUtils * image_proc_utils_[MAX_NUM_DEVICES]
Definition: adi_3dtof_image_stitching.h:435
ADI3DToFImageStitching::camera_yaw_min_
float camera_yaw_min_
Definition: adi_3dtof_image_stitching.h:454
subscriber_filter.h
ADI3DToFImageStitching::output_sensor_mode_
int output_sensor_mode_
Definition: adi_3dtof_image_stitching.h:437
ADI3DToFImageStitching::processOutputAbort
void processOutputAbort()
This function sets the abort flag for the output thread, the function is normally called by the main ...
Definition: adi_3dtof_image_stitching_output_thread.cpp:18
subscriber.h
sync_depth_ir_2
message_filters::sync_policies::ApproximateTime< sensor_msgs::Image, sensor_msgs::Image, sensor_msgs::Image, sensor_msgs::Image > sync_depth_ir_2
Definition: adi_3dtof_image_stitching.h:76
Quaternion.h
ADI3DToFImageStitching::stitched_depth_image_publisher_
ros::Publisher stitched_depth_image_publisher_
Definition: adi_3dtof_image_stitching.h:466
ADI3DToFImageStitching::tf_buffer_
tf2_ros::Buffer tf_buffer_[MAX_NUM_DEVICES]
Definition: adi_3dtof_image_stitching.h:446
ADI3DToFImageStitching::PointCloudCallbackFuncPointer
void(ADI3DToFImageStitching::* PointCloudCallbackFuncPointer)(const sensor_msgs::PointCloud2ConstPtr &)
Definition: adi_3dtof_image_stitching.h:101
eigen_msg.h
IOutputSensor::close
virtual void close()=0
stitch_frames_core_cpu.h
ADI3DToFImageStitching::camera_link_
std::string camera_link_
Definition: adi_3dtof_image_stitching.h:432
ADI3DToFImageStitching::it_
image_transport::ImageTransport * it_
Definition: adi_3dtof_image_stitching.h:442
ADI3DToFImageStitching::sync_CamInfo_4cam_
boost::shared_ptr< sync_CamInfo_4cam > sync_CamInfo_4cam_
Definition: adi_3dtof_image_stitching.h:461
tf2_ros::Buffer
ADI3DToFImageStitching::process_output_thread_abort_
bool process_output_thread_abort_
Definition: adi_3dtof_image_stitching.h:481
ADI3DToFImageStitching::depth_image_recvd_
bool depth_image_recvd_[MAX_NUM_DEVICES]
Definition: adi_3dtof_image_stitching.h:449
image_proc_utils.h
ROS_INFO_STREAM
#define ROS_INFO_STREAM(args)
adi_camera.h
ADI3DToFImageStitching::publishImageAsRosMsg
void publishImageAsRosMsg(cv::Mat img, const std::string &encoding_type, std::string frame_id, const ros::Publisher &publisher)
This function publishes images as Ros messages.
Definition: adi_3dtof_image_stitching.h:503
IOutputSensor::open
virtual void open(std::string input_file_name, int image_width, int image_height)=0
sync_depth_ir_3cam
message_filters::Synchronizer< sync_depth_ir_3 > sync_depth_ir_3cam
Definition: adi_3dtof_image_stitching.h:90
ADI3DToFImageStitching::out_image_width_
int out_image_width_
Definition: adi_3dtof_image_stitching.h:109
ADI3DToFImageStitchingInputInfo
ENABLE_GPU_OPTIMIZATION.
Definition: adi_3dtof_image_stitching_input_info.h:20
image_transport.h
ADI3DToFImageStitching::sync4CamerasDepthIRImageCallback
void sync4CamerasDepthIRImageCallback(const sensor_msgs::ImageConstPtr &depth_image_cam1, const sensor_msgs::ImageConstPtr &ir_image_cam1, const sensor_msgs::ImageConstPtr &depth_image_cam2, const sensor_msgs::ImageConstPtr &ir_image_cam2, const sensor_msgs::ImageConstPtr &depth_image_cam3, const sensor_msgs::ImageConstPtr &ir_image_cam3, const sensor_msgs::ImageConstPtr &depth_image_cam4, const sensor_msgs::ImageConstPtr &ir_image_cam4)
Call back for synchronised topics(depth and IR image pair) for 4 camera configuration.
Definition: callback_impl.cpp:187
ADI3DToFImageStitching::shutDownAllNodes
void shutDownAllNodes()
This function shuts down all the nodes running in a roscore.
Definition: adi_3dtof_image_stitching.h:290
message_filters::Subscriber::subscribe
void subscribe()
output_sensor_factory.h
ADI3DToFImageStitching::stitch_frames_core_CPU_
StitchFramesCoreCPU * stitch_frames_core_CPU_
Definition: adi_3dtof_image_stitching.h:493
ADI3DToFImageStitching::camera_yaw_max_
float camera_yaw_max_
Definition: adi_3dtof_image_stitching.h:455
ADI3DToFImageStitching::ImageCallbackFuncPointer
void(ADI3DToFImageStitching::* ImageCallbackFuncPointer)(const sensor_msgs::ImageConstPtr &)
Definition: adi_3dtof_image_stitching.h:99
ADI3DToFImageStitching::enable_autoscaling_
bool enable_autoscaling_
Definition: adi_3dtof_image_stitching.h:439
ADI3DToFImageStitching::MAX_NUM_DEVICES
static const int MAX_NUM_DEVICES
Definition: adi_3dtof_image_stitching.h:104
ros::Time
Sync_CameraInfo_3sensors
message_filters::sync_policies::ApproximateTime< sensor_msgs::CameraInfo, sensor_msgs::CameraInfo, sensor_msgs::CameraInfo > Sync_CameraInfo_3sensors
Definition: adi_3dtof_image_stitching.h:70
ADI3DToFImageStitching::convert2ROSPointCloudMsg
sensor_msgs::PointCloud2::Ptr convert2ROSPointCloudMsg(short *xyz_frame, std_msgs::Header sensor_header, int img_width, int img_height)
COnvery XYZ 3D fram to ROS point cloud message format.
Definition: adi_3dtof_image_stitching.h:327
ADI3DToFImageStitching::stitchFrames
bool stitchFrames()
Stitch function.
Definition: stitch_frames.cpp:30
ADI3DToFImageStitching::frame_counter_
int frame_counter_
Definition: adi_3dtof_image_stitching.h:431
SENSOR_OVERLAP_PERCENT
#define SENSOR_OVERLAP_PERCENT
Definition: adi_3dtof_image_stitching.h:61
sync_depth_ir_4cam
message_filters::Synchronizer< sync_depth_ir_4 > sync_depth_ir_4cam
Definition: adi_3dtof_image_stitching.h:91
sensor_msgs::PointCloud2Modifier
ADI3DToFImageStitching::ADI3DToFImageStitching
ADI3DToFImageStitching()
Construct a new ADI3DToFImageStitching object.
Definition: adi_3dtof_image_stitching.h:115
IOutputSensor
This is base class for output.
Definition: output_sensor.h:22
ADI3DToFImageStitching::input_thread_mtx_
boost::mutex input_thread_mtx_
Definition: adi_3dtof_image_stitching.h:484
ADI3DToFImageStitching::camera_parameters_updated_
bool camera_parameters_updated_[MAX_NUM_DEVICES]
Definition: adi_3dtof_image_stitching.h:105
ADI3DToFImageStitching::sync_CamInfo_3cam_
boost::shared_ptr< sync_CamInfo_3cam > sync_CamInfo_3cam_
Definition: adi_3dtof_image_stitching.h:460
StitchFramesCoreCPU
Class for Stitch frame core CPU implementation.
Definition: stitch_frames_core_cpu.h:14
cv_bridge.h
ADI3DToFImageStitching::camera_yaw_correction_
float camera_yaw_correction_
Definition: adi_3dtof_image_stitching.h:456
ADI3DToFImageStitching::addInputNodeToQueue
void addInputNodeToQueue(T *image_stitch_input_info)
Definition: callback_impl.cpp:496
CameraIntrinsics
Intrinsic parameters of the camera.
Definition: adi_camera.h:15
ADI3DToFImageStitching::sync3CamerasDepthIRImageCallback
void sync3CamerasDepthIRImageCallback(const sensor_msgs::ImageConstPtr &depth_image_cam1, const sensor_msgs::ImageConstPtr &ir_image_cam1, const sensor_msgs::ImageConstPtr &depth_image_cam2, const sensor_msgs::ImageConstPtr &ir_image_cam2, const sensor_msgs::ImageConstPtr &depth_image_cam3, const sensor_msgs::ImageConstPtr &ir_image_cam3)
Call back for synchronised topics(depth and IR image pair) for 3 camera configuration.
Definition: callback_impl.cpp:110
cv_bridge::CvImage
ADI3DToFImageStitching::transform_matrix_
float transform_matrix_[MAX_NUM_DEVICES][16]
Definition: adi_3dtof_image_stitching.h:451
ADI3DToFImageStitching::sync_depth_ir_4cam_
boost::shared_ptr< sync_depth_ir_4cam > sync_depth_ir_4cam_
Definition: adi_3dtof_image_stitching.h:464
ADI3DToFImageStitching::ir_image_recvd_
bool ir_image_recvd_[MAX_NUM_DEVICES]
Definition: adi_3dtof_image_stitching.h:448
ADI3DToFImageStitching::camera_yaw_
float camera_yaw_[MAX_NUM_DEVICES]
Definition: adi_3dtof_image_stitching.h:452
ros::NodeHandle::param
T param(const std::string &param_name, const T &default_val) const
ADI3DToFImageStitching::sync_depth_ir_3cam_
boost::shared_ptr< sync_depth_ir_3cam > sync_depth_ir_3cam_
Definition: adi_3dtof_image_stitching.h:463
sync_CamInfo_4cam
message_filters::Synchronizer< Sync_CameraInfo_4sensors > sync_CamInfo_4cam
Definition: adi_3dtof_image_stitching.h:88
synchronizer.h
tf2_geometry_msgs.h
approximate_time.h
ADI3DToFImageStitching::stitched_pc_pcl_
pcl::PointCloud< pcl::PointXYZ >::Ptr stitched_pc_pcl_
Definition: adi_3dtof_image_stitching.h:472
ADI3DToFImageStitching::curr_frame_timestamp_
ros::Time curr_frame_timestamp_
Definition: adi_3dtof_image_stitching.h:474
ADI3DToFImageStitching::depth_intrinsics_
CameraIntrinsics depth_intrinsics_
Definition: adi_3dtof_image_stitching.h:434
ADI3DToFImageStitching::pushOutputNode
void pushOutputNode(ADI3DToFImageStitchingOutputInfo *new_output_node)
This function pushes the debug node to the output queue. If the queue is full, then the last item in ...
Definition: adi_3dtof_image_stitching_output_thread.cpp:30
ADI3DToFImageStitching::num_sensors_
int num_sensors_
Definition: adi_3dtof_image_stitching.h:476
sensor_msgs::distortion_models::PLUMB_BOB
const std::string PLUMB_BOB
ROS_INFO
#define ROS_INFO(...)
Sync_CameraInfo_2sensors
message_filters::sync_policies::ApproximateTime< sensor_msgs::CameraInfo, sensor_msgs::CameraInfo > Sync_CameraInfo_2sensors
Definition: adi_3dtof_image_stitching.h:67
ADI3DToFImageStitching::irImageCallback
void irImageCallback(const sensor_msgs::ImageConstPtr &ir_image, int cam_id, ADI3DToFImageStitchingInputInfo *image_stitch_input_info)
Low-level callback for IR image.
Definition: callback_impl.cpp:464
CameraIntrinsics::distortion_coeffs
float distortion_coeffs[8]
Distortion vector = [k1, k2, p1, p2, k3, k4, k5, k6] k1, k2, k3, k4, k5, k6 : Camera radial distortio...
Definition: adi_camera.h:35
ADI3DToFImageStitching::stitched_camera_info_publisher_
ros::Publisher stitched_camera_info_publisher_
Definition: adi_3dtof_image_stitching.h:469
sync_CamInfo_2cam
message_filters::Synchronizer< Sync_CameraInfo_2sensors > sync_CamInfo_2cam
Definition: adi_3dtof_image_stitching.h:86
ADI3DToFImageStitching::populateCameraInstrinsics
void populateCameraInstrinsics(CameraIntrinsics &camera_intrinsics)
Populate camera Intrinsic data.
Definition: adi_3dtof_image_stitching.h:560
ADI3DToFImageStitching::autoscaling_flag_
bool autoscaling_flag_
Definition: adi_3dtof_image_stitching.h:440
ADI3DToFImageStitching::ir_image_subscriber_
image_transport::SubscriberFilter ir_image_subscriber_[MAX_NUM_DEVICES]
Definition: adi_3dtof_image_stitching.h:445
ADI3DToFImageStitching::vertical_fov_sensor_in_degrees_
float vertical_fov_sensor_in_degrees_
Definition: adi_3dtof_image_stitching.h:106
sensor_msgs::PointCloud2Modifier::setPointCloud2FieldsByString
void setPointCloud2FieldsByString(int n_fields,...)
XmlRpc::XmlRpcValue
ros::NodeHandle
ADI3DToFImageStitching::cam_info_msg_
sensor_msgs::CameraInfo cam_info_msg_
Definition: adi_3dtof_image_stitching.h:433
ADI3DToFImageStitching::getInputNode
ADI3DToFImageStitchingInputInfo * getInputNode()
Function to read the next node from the input Queue.
Definition: stitch_frames.cpp:136
ros::Time::now
static Time now()
pcl_conversions.h


adi_3dtof_image_stitching
Author(s):
autogenerated on Fri Mar 21 2025 02:27:20