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  byte* aligned_data = reinterpret_cast<byte*>(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 
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  byte* aligned_data = reinterpret_cast<byte*>(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>();
48  auto other_profile = other.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 byte*>(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
int get_bytes_per_pixel() const
Definition: rs_frame.hpp:709
rs2_format format() const
Definition: rs_frame.hpp:44
GLint GLint GLsizei GLsizei GLsizei depth
unsigned short uint16_t
Definition: stdint.h:79
rs2_stream
Streams are different types of data provided by RealSense devices.
Definition: rs_sensor.h:42
unsigned char byte
Definition: src/types.h:40
const void * get_data() const
Definition: rs_frame.hpp:547
rs2_stream stream_type() const
Definition: rs_frame.hpp:39
rs2_intrinsics get_intrinsics() const
Definition: rs_frame.hpp:240
stream_profile get_profile() const
Definition: rs_frame.hpp:559


librealsense2
Author(s): LibRealSense ROS Team
autogenerated on Thu Dec 22 2022 03:43:16