NVIDIA DeepStream SDK API Reference

9.2 Release
sources/libs/ds3d/dataloader/realsense/realsense_external_frame.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: Copyright (c) 2021-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3  * SPDX-License-Identifier: Apache-2.0
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #ifndef _DS3D_DATALOADER_RS_EXTERNAL_FRAME__H
19 #define _DS3D_DATALOADER_RS_EXTERNAL_FRAME__H
20 
21 #pragma GCC diagnostic push
22 #pragma GCC diagnostic ignored "-Wsign-compare"
23 #pragma GCC diagnostic ignored "-Wpessimizing-move"
24 #include <librealsense2/rs.hpp>
25 #pragma GCC diagnostic pop
26 
27 #include "ds3d/common/hpp/frame.hpp"
28 #include "ds3d/common/impl/impl_frames.h"
29 
30 
31 namespace ds3d { namespace impl { namespace realsense {
32 
34 {
35  Frame2DPlane p{
36  (uint32_t)f.get_width(), (uint32_t)f.get_height(), (uint32_t)f.get_stride_in_bytes(),
37  (uint32_t)f.get_bytes_per_pixel(), 0};
38  return p;
39 }
40 
41 template <typename DataTypeTP, FrameType ft>
42 class RsFrameWrapper : public Frame2DBaseImpl<DataTypeTP, ft> {
43 public:
44  template <class rsFrame>
45  RsFrameWrapper(/*rs2::video_frame*/ rsFrame f)
46  : Frame2DBaseImpl<DataTypeTP, ft>(
47  const_cast<void*>(f.get_data()), (size_t)f.get_data_size(), {0, {0}}, MemType::kCpu,
48  0, nullptr)
49  {
50  DS_ASSERT((size_t)f.get_bytes_per_pixel() >= sizeof(DataTypeTP));
51  std::vector<Frame2DPlane> planes{rsFrame2Plane(f)};
52  DS_ASSERT(bytesPerPixel<DataTypeTP>(ft) == planes[0].bytesPerPixel);
53  this->setPlanes(planes);
54  this->setDeleter([f = std::move(f)](void*) mutable { rs2::frame().swap(f); });
55  }
56 };
57 
60 
61 }}} // namespace ds3d::impl::realsense
62 
63 #endif // _DS3D_DATALOADER_RS_EXTERNAL_FRAME__H
ds3d::impl::Frame2DBaseImpl
Definition: includes/ds3d/common/impl/impl_frames.h:109
rs2::video_frame::get_stride_in_bytes
int get_stride_in_bytes() const
retrieve frame stride, meaning the actual line width in memory in bytes (not the logical image width)
Definition: sources/libs/ds3d/3rdparty/realsense2/include/librealsense2/hpp/rs_frame.hpp:683
ds3d::impl::realsense::RsFrameWrapper::RsFrameWrapper
RsFrameWrapper(rsFrame f)
Definition: sources/libs/ds3d/dataloader/realsense/realsense_external_frame.h:45
rs2::frame
Definition: sources/libs/ds3d/3rdparty/realsense2/include/librealsense2/hpp/rs_frame.hpp:343
ds3d::MemType::kCpu
@ kCpu
rs2::frame::swap
void swap(frame &other)
Swap the internal frame handle with the one in parameter.
Definition: sources/libs/ds3d/3rdparty/realsense2/include/librealsense2/hpp/rs_frame.hpp:413
ds3d::Frame2DPlane
Definition: includes/ds3d/common/abi_frame.h:47
ds3d::impl::realsense::RsFrameWrapper
Definition: sources/libs/ds3d/dataloader/realsense/realsense_external_frame.h:42
ds3d::bytesPerPixel
uint32_t bytesPerPixel(FrameType f)
Definition: includes/ds3d/common/func_utils.h:122
ds3d::impl::Frame2DBaseImpl::planes
uint32_t planes() const final
Definition: includes/ds3d/common/impl/impl_frames.h:120
absl::move
constexpr absl::OTABSL_OPTION_NAMESPACE_NAME::remove_reference_t< T > && move(T &&t) noexcept
Definition: includes/opentelemetry/nostd/internal/absl/utility/utility.h:199
rs2::video_frame::get_width
int get_width() const
returns image width in pixels
Definition: sources/libs/ds3d/3rdparty/realsense2/include/librealsense2/hpp/rs_frame.hpp:659
ds3d::impl::realsense::rsFrame2Plane
Frame2DPlane rsFrame2Plane(rs2::video_frame &f)
Definition: sources/libs/ds3d/dataloader/realsense/realsense_external_frame.h:33
ds3d::impl::Frame2DBaseImpl::setPlanes
void setPlanes(const std::vector< Frame2DPlane > &p)
Definition: includes/ds3d/common/impl/impl_frames.h:129
ds3d::impl::BaseFrame< DataTypeTP, ft, abi2DFrame >::setDeleter
void setDeleter(F &&f)
Definition: includes/ds3d/common/impl/impl_frames.h:86
rs2::video_frame
Definition: sources/libs/ds3d/3rdparty/realsense2/include/librealsense2/hpp/rs_frame.hpp:636
rs2::video_frame::get_bytes_per_pixel
int get_bytes_per_pixel() const
retrieve bytes per pixel
Definition: sources/libs/ds3d/3rdparty/realsense2/include/librealsense2/hpp/rs_frame.hpp:707
ds3d
Definition: includes/ds3d/common/abi_dataprocess.h:25
DS_ASSERT
#define DS_ASSERT(...)
Definition: includes/ds3d/common/defines.h:36
rs2::video_frame::get_height
int get_height() const
returns image height in pixels
Definition: sources/libs/ds3d/3rdparty/realsense2/include/librealsense2/hpp/rs_frame.hpp:671