Delete widerface_evaluate/box_overlaps.pyx
#7
by
hongywei
- opened
widerface_evaluate/box_overlaps.pyx
DELETED
@@ -1,55 +0,0 @@
|
|
1 |
-
# --------------------------------------------------------
|
2 |
-
# Fast R-CNN
|
3 |
-
# Copyright (c) 2015 Microsoft
|
4 |
-
# Licensed under The MIT License [see LICENSE for details]
|
5 |
-
# Written by Sergey Karayev
|
6 |
-
# --------------------------------------------------------
|
7 |
-
|
8 |
-
cimport cython
|
9 |
-
import numpy as np
|
10 |
-
cimport numpy as np
|
11 |
-
|
12 |
-
DTYPE = np.float64
|
13 |
-
ctypedef np.float_t DTYPE_t
|
14 |
-
|
15 |
-
def bbox_overlaps(
|
16 |
-
np.ndarray[DTYPE_t, ndim=2] boxes,
|
17 |
-
np.ndarray[DTYPE_t, ndim=2] query_boxes):
|
18 |
-
"""
|
19 |
-
Parameters
|
20 |
-
----------
|
21 |
-
boxes: (N, 4) ndarray of float
|
22 |
-
query_boxes: (K, 4) ndarray of float
|
23 |
-
Returns
|
24 |
-
-------
|
25 |
-
overlaps: (N, K) ndarray of overlap between boxes and query_boxes
|
26 |
-
"""
|
27 |
-
cdef unsigned int N = boxes.shape[0]
|
28 |
-
cdef unsigned int K = query_boxes.shape[0]
|
29 |
-
cdef np.ndarray[DTYPE_t, ndim=2] overlaps = np.zeros((N, K), dtype=DTYPE)
|
30 |
-
cdef DTYPE_t iw, ih, box_area
|
31 |
-
cdef DTYPE_t ua
|
32 |
-
cdef unsigned int k, n
|
33 |
-
for k in range(K):
|
34 |
-
box_area = (
|
35 |
-
(query_boxes[k, 2] - query_boxes[k, 0] + 1) *
|
36 |
-
(query_boxes[k, 3] - query_boxes[k, 1] + 1)
|
37 |
-
)
|
38 |
-
for n in range(N):
|
39 |
-
iw = (
|
40 |
-
min(boxes[n, 2], query_boxes[k, 2]) -
|
41 |
-
max(boxes[n, 0], query_boxes[k, 0]) + 1
|
42 |
-
)
|
43 |
-
if iw > 0:
|
44 |
-
ih = (
|
45 |
-
min(boxes[n, 3], query_boxes[k, 3]) -
|
46 |
-
max(boxes[n, 1], query_boxes[k, 1]) + 1
|
47 |
-
)
|
48 |
-
if ih > 0:
|
49 |
-
ua = float(
|
50 |
-
(boxes[n, 2] - boxes[n, 0] + 1) *
|
51 |
-
(boxes[n, 3] - boxes[n, 1] + 1) +
|
52 |
-
box_area - iw * ih
|
53 |
-
)
|
54 |
-
overlaps[n, k] = iw * ih / ua
|
55 |
-
return overlaps
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|