adi_3dtof_adtf31xx_output_thread.cpp
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 #include "module_profile.h"
9 #include "adi_3dtof_adtf31xx.h"
10 #include <compressed_depth_image_transport/rvl_codec.h>
11 #include <sensor_msgs/Image.h>
12 #include <boost/chrono.hpp>
13 #include <boost/thread/thread.hpp>
14 
16 
23 {
25 }
26 
35 {
36  output_thread_mtx_.lock();
37  int queue_size = output_node_queue_.size();
38  output_thread_mtx_.unlock();
39 
40  if (queue_size <= (max_debug_queue_length_ - 1))
41  {
42  // Push this one
43  output_thread_mtx_.lock();
44  output_node_queue_.push(new_output_node);
45  output_thread_mtx_.unlock();
46  }
47  else
48  {
49  [[maybe_unused]] ADI3DToFADTF31xxOutputInfo* last_node = nullptr;
50  // Replace the last item with the current one.
51  output_thread_mtx_.lock();
53  output_thread_mtx_.unlock();
54 
55  // Copy the contents of new node into the old one and then delete the new node.
56  last_node = new_output_node;
57 
58  // Delete this one
59  delete new_output_node;
60  }
61 }
62 
70 {
71  int debug_queue_size = output_node_queue_.size();
72 
73  while ((!process_output_thread_abort_) || (debug_queue_size > 0))
74  {
75  // std::cout << "Inside processOutput" << std::endl;
76  output_thread_mtx_.lock();
77  debug_queue_size = output_node_queue_.size();
78  output_thread_mtx_.unlock();
79  if (debug_queue_size > 0)
80  {
81  PROFILE_FUNCTION_START(processOutput_Thread)
82  output_thread_mtx_.lock();
84  output_node_queue_.pop();
85  output_thread_mtx_.unlock();
86 
88  {
89  // Compress ab frame
90  PROFILE_FUNCTION_START(adtf31xx_abFrameCompression)
92  new_frame->compressed_ab_frame_size_ = rvl.CompressRVL(
93  &new_frame->ab_frame_[0], &new_frame->compressed_ab_frame_[0], image_width_ * image_height_);
94  PROFILE_FUNCTION_END(adtf31xx_abFrameCompression)
95  }
96  // Publish the output
97  publishImageAndCameraInfo(new_frame);
98  delete new_frame;
99  PROFILE_FUNCTION_END(processOutput_Thread)
100  }
101 
102  // Sleep
103  boost::this_thread::sleep_for(boost::chrono::milliseconds(2));
104  }
105 }
ADI3DToFADTF31xxOutputInfo
This is the class for adtf31xx sensor node output information.
Definition: adi_3dtof_adtf31xx_output_info.h:14
sensor_msgs::image_encodings
ADI3DToFADTF31xxOutputInfo::compressed_ab_frame_size_
int compressed_ab_frame_size_
Definition: adi_3dtof_adtf31xx_output_info.h:120
ADI3DToFADTF31xx::enable_depth_ab_compression_
bool enable_depth_ab_compression_
Definition: adi_3dtof_adtf31xx.h:245
ADI3DToFADTF31xxOutputInfo::compressed_ab_frame_
unsigned char * compressed_ab_frame_
Definition: adi_3dtof_adtf31xx_output_info.h:117
module_profile.h
compressed_depth_image_transport::RvlCodec::CompressRVL
int CompressRVL(const unsigned short *input, unsigned char *output, int numPixels)
Definition: rvl_codec.cpp:51
ADI3DToFADTF31xx::processOutput
void processOutput()
The output process function, this is running a loop which reads the frame from the putput queue,...
Definition: adi_3dtof_adtf31xx_output_thread.cpp:69
ADI3DToFADTF31xx::output_thread_mtx_
boost::mutex output_thread_mtx_
Definition: adi_3dtof_adtf31xx.h:274
ADI3DToFADTF31xx::image_width_
int image_width_
Definition: adi_3dtof_adtf31xx.h:242
PROFILE_FUNCTION_END
#define PROFILE_FUNCTION_END(ID)
Definition: module_profile.h:25
ADI3DToFADTF31xx::process_output_thread_abort_
bool process_output_thread_abort_
Definition: adi_3dtof_adtf31xx.h:271
ADI3DToFADTF31xx::adtf31xxSensorPushOutputNode
void adtf31xxSensorPushOutputNode(ADI3DToFADTF31xxOutputInfo *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_adtf31xx_output_thread.cpp:34
compressed_depth_image_transport::RvlCodec
Definition: rvl_codec.h:6
adi_3dtof_adtf31xx_frame_info.h
ADI3DToFADTF31xx::processOutputAbort
void processOutputAbort()
This function sets the abort flag for the output thread, the function is normally called by the main ...
Definition: adi_3dtof_adtf31xx_output_thread.cpp:22
ADI3DToFADTF31xxOutputInfo::ab_frame_
unsigned short * ab_frame_
Definition: adi_3dtof_adtf31xx_output_info.h:114
PROFILE_FUNCTION_START
#define PROFILE_FUNCTION_START(ID)
Definition: module_profile.h:24
ADI3DToFADTF31xx::max_debug_queue_length_
int max_debug_queue_length_
Definition: adi_3dtof_adtf31xx.h:282
ADI3DToFADTF31xx::image_height_
int image_height_
Definition: adi_3dtof_adtf31xx.h:243
adi_3dtof_adtf31xx_output_info.h
adi_3dtof_adtf31xx.h
ADI3DToFADTF31xx::publishImageAndCameraInfo
void publishImageAndCameraInfo(ADI3DToFADTF31xxOutputInfo *out_frame)
Publishes the image and camera information. This function publishes the camera information and depth,...
Definition: adi_3dtof_adtf31xx.h:433
ADI3DToFADTF31xx::output_node_queue_
std::queue< ADI3DToFADTF31xxOutputInfo * > output_node_queue_
Definition: adi_3dtof_adtf31xx.h:283


adi_3dtof_adtf31xx
Author(s):
autogenerated on Sat May 17 2025 02:12:30