ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
IoU.cpp
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - CloudViewer: www.cloudViewer.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2024 www.cloudViewer.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
8 #include "ml/contrib/IoU.h"
9 
10 #include <tbb/parallel_for.h>
11 
12 #include "ml/contrib/IoUImpl.h"
13 
14 namespace cloudViewer {
15 namespace ml {
16 namespace contrib {
17 
18 void IoUBevCPUKernel(const float *boxes_a,
19  const float *boxes_b,
20  float *iou,
21  int num_a,
22  int num_b) {
23  tbb::parallel_for(0, num_a, [&](int idx_a) {
24  tbb::parallel_for(0, num_b, [&](int idx_b) {
25  const float *box_a = boxes_a + idx_a * 5;
26  const float *box_b = boxes_b + idx_b * 5;
27  float *out = iou + idx_a * num_b + idx_b;
28  *out = IoUBev2DWithCenterAndSize(box_a, box_b);
29  });
30  });
31 }
32 
33 void IoU3dCPUKernel(const float *boxes_a,
34  const float *boxes_b,
35  float *iou,
36  int num_a,
37  int num_b) {
38  tbb::parallel_for(0, num_a, [&](int idx_a) {
39  tbb::parallel_for(0, num_b, [&](int idx_b) {
40  const float *box_a = boxes_a + idx_a * 7;
41  const float *box_b = boxes_b + idx_b * 7;
42  float *out = iou + idx_a * num_b + idx_b;
43  *out = IoU3DWithCenterAndSize(box_a, box_b);
44  });
45  });
46 }
47 
48 } // namespace contrib
49 } // namespace ml
50 } // namespace cloudViewer
void IoUBevCPUKernel(const float *boxes_a, const float *boxes_b, float *iou, int num_a, int num_b)
Definition: IoU.cpp:18
CLOUDVIEWER_HOST_DEVICE float IoUBev2DWithCenterAndSize(const float *box_a, const float *box_b, bool intersection_only=false)
(x_center, z_center, x_size, z_size, y_rotate)
Definition: IoUImpl.h:247
void IoU3dCPUKernel(const float *boxes_a, const float *boxes_b, float *iou, int num_a, int num_b)
Definition: IoU.cpp:33
CLOUDVIEWER_HOST_DEVICE float IoU3DWithCenterAndSize(const float *box_a, const float *box_b)
(x_center, y_max, z_center, x_size, y_size, z_size, y_rotate)
Definition: IoUImpl.h:268
Generic file read and write utility for python interface.