Path: blob/master/DOTA_devkit/poly_nms_gpu/poly_nms.pyx
1611 views
import numpy as np1cimport numpy as np23assert sizeof(int) == sizeof(np.int32_t)45cdef extern from "poly_nms.hpp":6void _poly_nms(np.int32_t*, int*, np.float32_t*, int, int, float, int)78def poly_gpu_nms(np.ndarray[np.float32_t, ndim=2] dets, np.float thresh,9np.int32_t device_id=0):10cdef int boxes_num = dets.shape[0]11cdef int boxes_dim = dets.shape[1]12cdef int num_out13cdef np.ndarray[np.int32_t, ndim=1] \14keep = np.zeros(boxes_num, dtype=np.int32)15cdef np.ndarray[np.float32_t, ndim=1] \16scores = dets[:, 8]17cdef np.ndarray[np.int_t, ndim=1] \18order = scores.argsort()[::-1]19cdef np.ndarray[np.float32_t, ndim=2] \20sorted_dets = dets[order, :]21_poly_nms(&keep[0], &num_out, &sorted_dets[0, 0], boxes_num, boxes_dim, thresh, device_id)22keep = keep[:num_out]23return list(order[keep])242526