cuda-align.h
Go to the documentation of this file.
1 /* License: Apache 2.0. See LICENSE file in root directory. */
2 /* Copyright(c) 2019 Intel Corporation. All Rights Reserved. */
3 #pragma once
4 #ifdef RS2_USE_CUDA
5 
6 #include "proc/align.h"
7 #include "cuda-align.cuh"
8 #include <memory>
9 #include <stdint.h>
10 
11 namespace librealsense
12 {
13  class align_cuda : public align
14  {
15  public:
16  align_cuda(rs2_stream align_to) : align(align_to, "Align (CUDA)") {}
17 
18  protected:
19  void reset_cache(rs2_stream from, rs2_stream to) override
20  {
21  aligners[std::tuple<rs2_stream, rs2_stream>(from, to)] = align_cuda_helper();
22  }
23 
24  void align_z_to_other(rs2::video_frame& aligned, const rs2::video_frame& depth, const rs2::video_stream_profile& other_profile, float z_scale) override
25  {
26  uint8_t * aligned_data = reinterpret_cast<uint8_t *>(const_cast<void*>(aligned.get_data()));
27  auto aligned_profile = aligned.get_profile().as<rs2::video_stream_profile>();
28  memset(aligned_data, 0, aligned_profile.height() * aligned_profile.width() * aligned.get_bytes_per_pixel());
29 
30  auto depth_profile = depth.get_profile().as<rs2::video_stream_profile>();
31 
32  auto z_intrin = depth_profile.get_intrinsics();
33  auto other_intrin = other_profile.get_intrinsics();
34  auto z_to_other = depth_profile.get_extrinsics_to(other_profile);
35 
36  auto z_pixels = reinterpret_cast<const uint16_t*>(depth.get_data());
37  auto& aligner = aligners[std::tuple<rs2_stream, rs2_stream>(RS2_STREAM_DEPTH, other_profile.stream_type())];
38  aligner.align_depth_to_other(aligned_data, z_pixels, z_scale, z_intrin, z_to_other, other_intrin);
39  }
40 
41  void align_other_to_z(rs2::video_frame& aligned, const rs2::video_frame& depth, const rs2::video_frame& other, float z_scale) override
42  {
43  uint8_t * aligned_data = reinterpret_cast<uint8_t *>(const_cast<void*>(aligned.get_data()));
44  auto aligned_profile = aligned.get_profile().as<rs2::video_stream_profile>();
45  memset(aligned_data, 0, aligned_profile.height() * aligned_profile.width() * aligned.get_bytes_per_pixel());
46 
47  auto depth_profile = depth.get_profile().as<rs2::video_stream_profile>();
49 
50  auto z_intrin = depth_profile.get_intrinsics();
51  auto other_intrin = other_profile.get_intrinsics();
52  auto z_to_other = depth_profile.get_extrinsics_to(other_profile);
53 
54  auto z_pixels = reinterpret_cast<const uint16_t*>(depth.get_data());
55  auto other_pixels = reinterpret_cast<const uint8_t *>(other.get_data());
56 
57  auto& aligner = aligners[std::tuple<rs2_stream, rs2_stream>(other_profile.stream_type(), RS2_STREAM_DEPTH)];
58  aligner.align_other_to_depth(
59  aligned_data, z_pixels, z_scale, z_intrin, z_to_other, other_intrin, other_pixels, other_profile.format(), other.get_bytes_per_pixel());
60  }
61 
62  private:
63  std::map<std::tuple<rs2_stream, rs2_stream>, align_cuda_helper> aligners;
64  };
65 }
66 #endif // RS2_USE_CUDA
librealsense
Definition: algo.h:18
uint8_t
unsigned char uint8_t
Definition: stdint.h:78
align.h
rs2::stream_profile::as
T as() const
Definition: rs_frame.hpp:103
uint16_t
unsigned short uint16_t
Definition: stdint.h:79
rs2::frame::get_data
const void * get_data() const
Definition: rs_frame.hpp:547
rs2::video_stream_profile
Definition: rs_frame.hpp:201
RS2_STREAM_DEPTH
@ RS2_STREAM_DEPTH
Definition: rs_sensor.h:46
test-post-processing-from-bag.align
align
Definition: test-post-processing-from-bag.py:108
stdint.h
pyglet_pointcloud_viewer.other_profile
other_profile
Definition: pyglet_pointcloud_viewer.py:156
rs2::frame::get_profile
stream_profile get_profile() const
Definition: rs_frame.hpp:559
rs2::video_frame
Definition: rs_frame.hpp:638
rs2::video_frame::get_bytes_per_pixel
int get_bytes_per_pixel() const
Definition: rs_frame.hpp:709
test-projection-from-recording.depth_profile
depth_profile
Definition: test-projection-from-recording.py:27
align-depth2color.align_to
align_to
Definition: align-depth2color.py:56
rs2_stream
rs2_stream
Streams are different types of data provided by RealSense devices.
Definition: rs_sensor.h:43
depth
GLint GLint GLsizei GLsizei GLsizei depth
Definition: glad/glad/glad.h:2398


librealsense2
Author(s): LibRealSense ROS Team
autogenerated on Fri Aug 2 2024 08:30:01