Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
one
spconv
Commits
9cf5d747
Commit
9cf5d747
authored
Apr 07, 2019
by
traveller59
Browse files
add rbbox intersection cpu for kitti evaluation
parent
cbb29a47
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
65 additions
and
1 deletion
+65
-1
include/spconv/box_iou.h
include/spconv/box_iou.h
+56
-0
spconv/utils/__init__.py
spconv/utils/__init__.py
+1
-1
src/utils/all.cc
src/utils/all.cc
+8
-0
No files found.
include/spconv/box_iou.h
View file @
9cf5d747
...
@@ -97,5 +97,61 @@ rbbox_iou(py::array_t<DType> box_corners, py::array_t<DType> qbox_corners,
...
@@ -97,5 +97,61 @@ rbbox_iou(py::array_t<DType> box_corners, py::array_t<DType> qbox_corners,
}
}
return
overlaps
;
return
overlaps
;
}
}
template
<
typename
DType
>
py
::
array_t
<
DType
>
rbbox_intersection
(
py
::
array_t
<
DType
>
box_corners
,
py
::
array_t
<
DType
>
qbox_corners
,
py
::
array_t
<
DType
>
standup_iou
,
DType
standup_thresh
)
{
namespace
bg
=
boost
::
geometry
;
typedef
bg
::
model
::
point
<
DType
,
2
,
bg
::
cs
::
cartesian
>
point_t
;
typedef
bg
::
model
::
polygon
<
point_t
>
polygon_t
;
polygon_t
poly
,
qpoly
;
std
::
vector
<
polygon_t
>
poly_inter
,
poly_union
;
DType
inter_area
,
union_area
;
auto
box_corners_r
=
box_corners
.
template
unchecked
<
3
>();
auto
qbox_corners_r
=
qbox_corners
.
template
unchecked
<
3
>();
auto
standup_iou_r
=
standup_iou
.
template
unchecked
<
2
>();
auto
N
=
box_corners_r
.
shape
(
0
);
auto
K
=
qbox_corners_r
.
shape
(
0
);
py
::
array_t
<
DType
>
overlaps
=
zeros
<
DType
>
({
int
(
N
),
int
(
K
)});
auto
overlaps_rw
=
overlaps
.
template
mutable_unchecked
<
2
>();
if
(
N
==
0
||
K
==
0
)
{
return
overlaps
;
}
for
(
int
k
=
0
;
k
<
K
;
++
k
)
{
for
(
int
n
=
0
;
n
<
N
;
++
n
)
{
if
(
standup_iou_r
(
n
,
k
)
<=
standup_thresh
)
continue
;
bg
::
append
(
poly
,
point_t
(
box_corners_r
(
n
,
0
,
0
),
box_corners_r
(
n
,
0
,
1
)));
bg
::
append
(
poly
,
point_t
(
box_corners_r
(
n
,
1
,
0
),
box_corners_r
(
n
,
1
,
1
)));
bg
::
append
(
poly
,
point_t
(
box_corners_r
(
n
,
2
,
0
),
box_corners_r
(
n
,
2
,
1
)));
bg
::
append
(
poly
,
point_t
(
box_corners_r
(
n
,
3
,
0
),
box_corners_r
(
n
,
3
,
1
)));
bg
::
append
(
poly
,
point_t
(
box_corners_r
(
n
,
0
,
0
),
box_corners_r
(
n
,
0
,
1
)));
bg
::
append
(
qpoly
,
point_t
(
qbox_corners_r
(
k
,
0
,
0
),
qbox_corners_r
(
k
,
0
,
1
)));
bg
::
append
(
qpoly
,
point_t
(
qbox_corners_r
(
k
,
1
,
0
),
qbox_corners_r
(
k
,
1
,
1
)));
bg
::
append
(
qpoly
,
point_t
(
qbox_corners_r
(
k
,
2
,
0
),
qbox_corners_r
(
k
,
2
,
1
)));
bg
::
append
(
qpoly
,
point_t
(
qbox_corners_r
(
k
,
3
,
0
),
qbox_corners_r
(
k
,
3
,
1
)));
bg
::
append
(
qpoly
,
point_t
(
qbox_corners_r
(
k
,
0
,
0
),
qbox_corners_r
(
k
,
0
,
1
)));
bg
::
intersection
(
poly
,
qpoly
,
poly_inter
);
if
(
!
poly_inter
.
empty
())
{
inter_area
=
bg
::
area
(
poly_inter
.
front
());
overlaps_rw
(
n
,
k
)
=
inter_area
;
}
poly
.
clear
();
qpoly
.
clear
();
poly_inter
.
clear
();
}
}
return
overlaps
;
}
}
// namespace spconv
}
// namespace spconv
#endif
#endif
\ No newline at end of file
spconv/utils/__init__.py
View file @
9cf5d747
...
@@ -16,7 +16,7 @@ import numpy as np
...
@@ -16,7 +16,7 @@ import numpy as np
from
spconv
import
spconv_utils
from
spconv
import
spconv_utils
from
spconv.spconv_utils
import
(
non_max_suppression
,
non_max_suppression_cpu
,
from
spconv.spconv_utils
import
(
non_max_suppression
,
non_max_suppression_cpu
,
points_to_voxel_3d_np
,
rbbox_iou
,
points_to_voxel_3d_np
,
rbbox_iou
,
rotate_non_max_suppression_cpu
)
rotate_non_max_suppression_cpu
,
rbbox_intersection
)
def
points_to_voxel
(
points
,
def
points_to_voxel
(
points
,
voxel_size
,
voxel_size
,
...
...
src/utils/all.cc
View file @
9cf5d747
...
@@ -41,6 +41,14 @@ PYBIND11_MODULE(spconv_utils, m)
...
@@ -41,6 +41,14 @@ PYBIND11_MODULE(spconv_utils, m)
py
::
return_value_policy
::
reference_internal
,
"rbbox iou"
,
py
::
return_value_policy
::
reference_internal
,
"rbbox iou"
,
"box_corners"
_a
=
1
,
"qbox_corners"
_a
=
2
,
"standup_iou"
_a
=
3
,
"box_corners"
_a
=
1
,
"qbox_corners"
_a
=
2
,
"standup_iou"
_a
=
3
,
"standup_thresh"
_a
=
4
);
"standup_thresh"
_a
=
4
);
m
.
def
(
"rbbox_intersection"
,
&
spconv
::
rbbox_intersection
<
double
>
,
py
::
return_value_policy
::
reference_internal
,
"rbbox iou"
,
"box_corners"
_a
=
1
,
"qbox_corners"
_a
=
2
,
"standup_iou"
_a
=
3
,
"standup_thresh"
_a
=
4
);
m
.
def
(
"rbbox_intersection"
,
&
spconv
::
rbbox_intersection
<
float
>
,
py
::
return_value_policy
::
reference_internal
,
"rbbox iou"
,
"box_corners"
_a
=
1
,
"qbox_corners"
_a
=
2
,
"standup_iou"
_a
=
3
,
"standup_thresh"
_a
=
4
);
m
.
def
(
"points_to_voxel_3d_np"
,
&
spconv
::
points_to_voxel_3d_np
<
float
,
3
>
,
m
.
def
(
"points_to_voxel_3d_np"
,
&
spconv
::
points_to_voxel_3d_np
<
float
,
3
>
,
"matrix tensor_square"
,
"points"
_a
=
1
,
"voxels"
_a
=
2
,
"coors"
_a
=
3
,
"matrix tensor_square"
,
"points"
_a
=
1
,
"voxels"
_a
=
2
,
"coors"
_a
=
3
,
"num_points_per_voxel"
_a
=
4
,
"coor_to_voxelidx"
_a
=
5
,
"num_points_per_voxel"
_a
=
4
,
"coor_to_voxelidx"
_a
=
5
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment