NVIDIA DeepStream SDK API Reference

9.2 Release
sources/libs/ds3d/glprocess/gl_depth_render_ctx.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_GLPROCESS_GL_DEPTH_RENDER_CTX_H
19 #define DS3D_GLPROCESS_GL_DEPTH_RENDER_CTX_H
20 
21 #include "ds3d/common/hpp/frame.hpp"
22 
23 #include "gl_render_ctx.h"
24 #include "glfw_init.h"
25 #include "gl_program.h"
26 #include "gl_buf.h"
27 
28 namespace ds3d { namespace gl {
29 
31 public:
32  DepthRenderCtxImpl(bool enableVideo, bool enableDepth)
33  {
34  _imageProgInfo.enabled = enableVideo;
35  _depthProgInfo.enabled = enableDepth;
36  }
37  void setDepthRange(float min, float max) override
38  {
39  _minDepth = min;
40  _maxDepth = max;
41  }
42 
43  void setDepthColor(const vec3b& minDepthColor, const vec3b& maxDepthColor) override
44  {
45  _minDepthColor = minDepthColor;
46  _maxDepthColor = maxDepthColor;
47  }
48 
49  ~DepthRenderCtxImpl() = default;
50 
51  struct ProgramInfo {
52  bool enabled = true;
53  std::unique_ptr<Program> program;
54  std::unique_ptr<VertexArray> vao;
55  int inVertAttrib = -1;
56  int inTexCoordAttrib = -1;
57  uint32_t x = 0, y = 0, width = 0, height = 0;
58  float texAspectRatio = 1.0f;
59  };
60 
61  ErrCode initResource() override;
62  ErrCode uploadData(GuardDataMap datamap) override;
63  ErrCode draw(GuardDataMap datamap) override;
64  ErrCode deinitResource() override;
65 
66 private:
67  Program* imageProgram() const { return _imageProgInfo.program.get(); }
68  Program* depthProgram() const { return _depthProgInfo.program.get(); }
69  WindowInfo _initWindowInfo{1280, 720, ""};
70 
71  ErrCode initVertexBuffer();
72  ErrCode initVAO();
73  ErrCode initTextures();
74 
75  ErrCode uploadImage(Frame2DGuard& image);
76  ErrCode uploadDepth(Frame2DGuard& depth);
77 
78  ErrCode updateLayout();
79 
80  std::unique_ptr<VertexBuf> _vertexBuf;
81  std::unique_ptr<VertexBuf> _coordBuf;
82 
83  ProgramInfo _imageProgInfo;
84  ProgramInfo _depthProgInfo;
85 
86  std::unique_ptr<Texture> _image;
87  std::unique_ptr<Texture> _depth;
88  std::unique_ptr<Texture> _depthColor;
89  float _depthScale = 1.0f;
90  float _minDepth = 0.3f; // meters
91  float _maxDepth = 5.0f; // meters
92  vec3b _minDepthColor = {{200, 200, 0}};
93  vec3b _maxDepthColor = {{50, 50, 50}};
94 };
95 
96 }} // namespace ds3d::gl
97 
98 #endif
ds3d::gl::Program
Definition: sources/libs/ds3d/glprocess/gl_program.h:49
ds3d::vec3b
vec3< uint8_t > vec3b
Definition: includes/ds3d/common/idatatype.h:77
ds3d::__xyz
Definition: includes/ds3d/common/idatatype.h:39
ds3d::gl::DepthRenderCtxImpl::ProgramInfo::program
std::unique_ptr< Program > program
Definition: sources/libs/ds3d/glprocess/gl_depth_render_ctx.h:53
ds3d::gl::DepthRenderCtxImpl::uploadData
ErrCode uploadData(GuardDataMap datamap) override
ds3d::gl::DepthRenderCtxImpl::ProgramInfo
Definition: sources/libs/ds3d/glprocess/gl_depth_render_ctx.h:51
ds3d::gl::DepthRenderCtxImpl::ProgramInfo::height
uint32_t height
Definition: sources/libs/ds3d/glprocess/gl_depth_render_ctx.h:57
gl_render_ctx.h
ds3d::gl::DepthRenderCtxImpl
Definition: sources/libs/ds3d/glprocess/gl_depth_render_ctx.h:30
ds3d::gl::DepthRenderCtxImpl::ProgramInfo::y
uint32_t y
Definition: sources/libs/ds3d/glprocess/gl_depth_render_ctx.h:57
gl_program.h
ds3d::gl::DepthRenderCtxImpl::~DepthRenderCtxImpl
~DepthRenderCtxImpl()=default
ds3d::gl::DepthRenderCtxImpl::ProgramInfo::inVertAttrib
int inVertAttrib
Definition: sources/libs/ds3d/glprocess/gl_depth_render_ctx.h:55
ds3d::ErrCode
ErrCode
Definition: includes/ds3d/common/common.h:47
ds3d::gl::DepthRenderCtxImpl::ProgramInfo::enabled
bool enabled
Definition: sources/libs/ds3d/glprocess/gl_depth_render_ctx.h:52
max
int max(int a, int b)
Compute the component-wise maximum.
Definition: sources/libs/nvmultiobjecttracker/include/modules/cuDCFv2/helper_math.h:60
ds3d::gl::DepthRenderCtxImpl::draw
ErrCode draw(GuardDataMap datamap) override
ds3d::gl::DepthRenderCtxImpl::initResource
ErrCode initResource() override
ds3d::gl::DepthRender
Definition: sources/libs/ds3d/glprocess/gl_render_ctx.h:64
ds3d::gl::DepthRenderCtxImpl::ProgramInfo::vao
std::unique_ptr< VertexArray > vao
Definition: sources/libs/ds3d/glprocess/gl_depth_render_ctx.h:54
ds3d::Frame2DGuard
GuardDataT< abi2DFrame > Frame2DGuard
Definition: includes/ds3d/common/hpp/frame.hpp:57
min
int min(int a, int b)
Compute the component-wise minimum.
Definition: sources/libs/nvmultiobjecttracker/include/modules/cuDCFv2/helper_math.h:70
ds3d::gl::DepthRenderCtxImpl::ProgramInfo::x
uint32_t x
Definition: sources/libs/ds3d/glprocess/gl_depth_render_ctx.h:57
ds3d::gl::DepthRenderCtxImpl::ProgramInfo::inTexCoordAttrib
int inTexCoordAttrib
Definition: sources/libs/ds3d/glprocess/gl_depth_render_ctx.h:56
ds3d::gl::DepthRenderCtxImpl::DepthRenderCtxImpl
DepthRenderCtxImpl(bool enableVideo, bool enableDepth)
Definition: sources/libs/ds3d/glprocess/gl_depth_render_ctx.h:32
ds3d::gl::DepthRenderCtxImpl::setDepthColor
void setDepthColor(const vec3b &minDepthColor, const vec3b &maxDepthColor) override
Definition: sources/libs/ds3d/glprocess/gl_depth_render_ctx.h:43
ds3d::GuardDataMap
Definition: includes/ds3d/common/hpp/datamap.hpp:27
glfw_init.h
ds3d::gl::DepthRenderCtxImpl::ProgramInfo::width
uint32_t width
Definition: sources/libs/ds3d/glprocess/gl_depth_render_ctx.h:57
ds3d::gl::DepthRenderCtxImpl::deinitResource
ErrCode deinitResource() override
ds3d::gl::DepthRenderCtxImpl::ProgramInfo::texAspectRatio
float texAspectRatio
Definition: sources/libs/ds3d/glprocess/gl_depth_render_ctx.h:58
ds3d
Definition: includes/ds3d/common/abi_dataprocess.h:25
gl_buf.h
ds3d::gl::DepthRenderCtxImpl::setDepthRange
void setDepthRange(float min, float max) override
Definition: sources/libs/ds3d/glprocess/gl_depth_render_ctx.h:37