Open3D (C++ API)  0.20.0
Loading...
Searching...
No Matches
RoiPoolKernel.h
Go to the documentation of this file.
1// ----------------------------------------------------------------------------
2// - Open3D: www.open3d.org -
3// ----------------------------------------------------------------------------
4// Copyright (c) 2018-2026 www.open3d.org
5// SPDX-License-Identifier: MIT
6// ----------------------------------------------------------------------------
7//***************************************************************************************/
8//
9// Based on PointRCNN Library (MIT License):
10// https://github.com/sshaoshuai/PointRCNN
11//
12// Copyright (c) 2019 Shaoshuai Shi
13//
14// Permission is hereby granted, free of charge, to any person obtaining a
15// copy of this software and associated documentation files (the "Software"),
16// to deal in the Software without restriction, including without limitation
17// the rights to use, copy, modify, merge, publish, distribute, sublicense,
18// and/or sell copies of the Software, and to permit persons to whom the
19// Software is furnished to do so, subject to the following conditions:
20//
21// The above copyright notice and this permission notice shall be included in
22// all copies or substantial portions of the Software.
23//
24// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
27// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
29// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
30// DEALINGS IN THE SOFTWARE.
31//
32//***************************************************************************************/
33
34#pragma once
35
36#include <math.h>
37
38#include "open3d/Macro.h"
40
41#ifdef BUILD_SYCL_MODULE
42// roipool3dLauncherSYCL takes a real sycl::queue&, so any TU that sees this
43// declaration needs the full SYCL runtime type (not -fsycl compilation --
44// RoiPoolOps.cpp already gets this transitively via
45// <c10/xpu/XPUDeviceProp.h>, but this header may be included first, so it
46// must include the SYCL header directly to avoid an incomplete-type error).
47// RoiPoolKernelSYCL.cpp (built with -fsycl) is where the actual device
48// kernels are compiled.
49#include <sycl/sycl.hpp>
50#endif
51
52namespace open3d {
53namespace ml {
54namespace contrib {
55
63 float y,
64 float z,
65 float cx,
66 float bottom_y,
67 float cz,
68 float h,
69 float w,
70 float l,
71 float angle,
72 float max_dis) {
73 float x_rot, z_rot, cosa, sina, cy;
74 cy = bottom_y - h / 2.0;
75 if ((fabsf(x - cx) > max_dis) || (fabsf(y - cy) > h / 2.0) ||
76 (fabsf(z - cz) > max_dis)) {
77 return false;
78 }
79 cosa = cos(angle);
80 sina = sin(angle);
81 x_rot = (x - cx) * cosa + (z - cz) * (-sina);
82 z_rot = (x - cx) * sina + (z - cz) * cosa;
83
84 return (x_rot >= -l / 2.0) & (x_rot <= l / 2.0) & (z_rot >= -w / 2.0) &
85 (z_rot <= w / 2.0);
86}
87
88#ifdef BUILD_CUDA_MODULE
89
90void roipool3dLauncher(int batch_size,
91 int pts_num,
92 int boxes_num,
93 int feature_in_len,
94 int sampled_pts_num,
95 const float *xyz,
96 const float *boxes3d,
97 const float *pts_feature,
98 float *pooled_features,
99 int *pooled_empty_flag);
100#endif
101
102#ifdef BUILD_SYCL_MODULE
103
104void roipool3dLauncherSYCL(sycl::queue &queue,
105 int batch_size,
106 int pts_num,
107 int boxes_num,
108 int feature_in_len,
109 int sampled_pts_num,
110 const float *xyz,
111 const float *boxes3d,
112 const float *pts_feature,
113 float *pooled_features,
114 int *pooled_empty_flag);
115#endif
116
117void roipool3dLauncherCPU(int batch_size,
118 int pts_num,
119 int boxes_num,
120 int feature_in_len,
121 int sampled_pts_num,
122 const float *xyz,
123 const float *boxes3d,
124 const float *pts_feature,
125 float *pooled_features,
126 int *pooled_empty_flag);
127
128} // namespace contrib
129} // namespace ml
130} // namespace open3d
Common CUDA utilities.
#define OPEN3D_HOST_DEVICE
Definition CUDAUtils.h:43
std::int64_t y
Definition NormalDistributionsTransform.cpp:43
std::int64_t x
Definition NormalDistributionsTransform.cpp:42
std::int64_t z
Definition NormalDistributionsTransform.cpp:44
sycl::queue queue
Definition SYCLContext.cpp:88
void roipool3dLauncherCPU(int batch_size, int pts_num, int boxes_num, int feature_in_len, int sampled_pts_num, const float *xyz, const float *boxes3d, const float *pts_feature, float *pooled_features, int *pooled_empty_flag)
Definition RoiPool.cpp:23
OPEN3D_HOST_DEVICE bool pt_in_box3d(float x, float y, float z, float cx, float bottom_y, float cz, float h, float w, float l, float angle, float max_dis)
Definition RoiPoolKernel.h:62
void roipool3dLauncherSYCL(sycl::queue &queue, int batch_size, int pts_num, int boxes_num, int feature_in_len, int sampled_pts_num, const float *xyz, const float *boxes3d, const float *pts_feature, float *pooled_features, int *pooled_empty_flag)
Definition RoiPoolKernelSYCL.cpp:35
Definition PinholeCameraIntrinsic.cpp:16