docs/html/cudaPointCloud_8h_source.html
| | Jetson Inference
DNN Vision Library |
cudaPointCloud.h
Go to the documentation of this file.
1 /*
2 * Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 * DEALINGS IN THE SOFTWARE.
21 */
22
23 #ifndef __CUDA_POINT_CLOUD_H__
24 #define __CUDA_POINT_CLOUD_H__
25
26
27 #include "cudaUtility.h"
28
29
30 // forward declarations
31 class glBuffer;
32 class glCamera;
33
34
39 class cudaPointCloud
40 {
41 public:
46 {
51
57
63
64 } __attribute__((packed));
65
69static cudaPointCloud* Create();
70
74~cudaPointCloud();
75
83bool Reserve( uint32_t maxPoints );
84
88void Free();
89
93void Clear();
94
98bool Extract( float* depth, float4* rgba, uint32_t width, uint32_t height );
99
103bool Extract( float* depth, uint32_t depth_width, uint32_t depth_height,
104 float4* rgba, uint32_t color_width, uint32_t color_height );
105
109inline uint32_t GetNumPoints() const { return mNumPoints; }
110
114inline uint32_t GetMaxPoints() const { return mMaxPoints; }
115
119inline size_t GetSize() const { return mNumPoints * sizeof(Vertex); }
120
124inline size_t GetMaxSize() const { return mMaxPoints * sizeof(Vertex); }
125
129inline Vertex* GetData() const { return mPointsCPU; }
130
134inline Vertex* GetData( size_t index ) const { return mPointsCPU + index; }
135
139inline bool HasRGB() const { return mHasRGB; }
140
144bool Render();
145
149bool Save( const char* filename );
150
154bool SetCalibration( const char* filename );
155
159void SetCalibration( const float K[3][3] );
160
164void SetCalibration( const float2& focalLength, const float2& principalPoint );
165
166 protected:
167cudaPointCloud();
168
169bool allocBufferGL();
170bool allocDepthResize( size_t size );
171
174
177
178 uint32_t mNumPoints;
179 uint32_t mMaxPoints;
180
181 float2 mFocalLength;
182 float2 mPrincipalPoint;
183
184float* mDepthResize;
185size_t mDepthSize;
186
188bool mHasNewPoints;
189bool mHasCalibration;
190 };
191
192 #endif
193
bool mHasNewPoints
Definition: cudaPointCloud.h:188
Point vertex.
Definition: cudaPointCloud.h:45
size_t GetMaxSize() const
Retrieve the maximum size in bytes of the point cloud.
Definition: cudaPointCloud.h:124
uchar3 color
The RGB color of the point.
Definition: cudaPointCloud.h:56
Vertex * mPointsGPU
Definition: cudaPointCloud.h:173
uint32_t GetNumPoints() const
Retrieve the number of points being used.
Definition: cudaPointCloud.h:109
uint32_t mNumPoints
Definition: cudaPointCloud.h:178
uint32_t mMaxPoints
Definition: cudaPointCloud.h:179
CUDA-accelerated point cloud processing.
Definition: cudaPointCloud.h:39
uint32_t GetMaxPoints() const
Retrieve the max number of points in memory.
Definition: cudaPointCloud.h:114
cudaPointCloud::allocDepthResize
bool allocDepthResize(size_t size)
cudaPointCloud::Vertex::classID
uint8_t classID
The class ID of the point.
Definition: cudaPointCloud.h:62
cudaPointCloud::SetCalibration
bool SetCalibration(const char *filename)
Set the intrinsic camera calibration.
bool Save(const char *filename)
Save point cloud to PCD file.
static cudaPointCloud * Create()
Create.
bool Render()
Render the point cloud with OpenGL.
Vertex * mPointsCPU
Definition: cudaPointCloud.h:172
void Clear()
Clear the points, but keep the memory allocated.
cudaPointCloud::~cudaPointCloud
~cudaPointCloud()
Destructor.
float * mDepthResize
Definition: cudaPointCloud.h:184
bool mHasRGB
Definition: cudaPointCloud.h:187
Vertex * GetData() const
Retrieve memory pointer to point cloud data.
Definition: cudaPointCloud.h:129
Vertex * GetData(size_t index) const
Retrieve memory pointer to a specific point.
Definition: cudaPointCloud.h:134
OpenGL perspective camera supporting Look-At, Yaw/Pitch/Roll, and Ortho modes.
Definition: glCamera.h:35
void Free()
Free the memory being used to store the point cloud.
cudaPointCloud::mPrincipalPoint
float2 mPrincipalPoint
Definition: cudaPointCloud.h:182
cudaPointCloud::cudaPointCloud
cudaPointCloud()
float2 mFocalLength
Definition: cudaPointCloud.h:181
glCamera * mCameraGL
Definition: cudaPointCloud.h:176
glBuffer * mBufferGL
Definition: cudaPointCloud.h:175
OpenGL buffer with CUDA interoperability.
Definition: glBuffer.h:114
float3 pos
The XYZ position of the point.
Definition: cudaPointCloud.h:50
size_t mDepthSize
Definition: cudaPointCloud.h:185
struct cudaPointCloud::Vertex __attribute__((packed))
bool Reserve(uint32_t maxPoints)
Allocate and reserve memory for the max number of points.
bool allocBufferGL()
bool HasRGB() const
Does the point cloud have RGB data?
Definition: cudaPointCloud.h:139
bool Extract(float *depth, float4 *rgba, uint32_t width, uint32_t height)
Extract point cloud from depth map and optional RGBA image.
size_t GetSize() const
Retrieve the size in bytes currently being used.
Definition: cudaPointCloud.h:119
cudaPointCloud::mHasCalibration
bool mHasCalibration
Definition: cudaPointCloud.h:189