3 from jsk_perception.srv
import NonMaximumSuppression
4 from jsk_perception.srv
import NonMaximumSuppressionResponse
5 from jsk_recognition_msgs.msg
import Rect
6 from jsk_recognition_msgs.msg
import RectArray
7 from jsk_topic_tools
import ConnectionBasedTransport
9 from std_msgs.msg
import Int64
16 super(self.__class__, self).
__init__()
17 self.
thre = rospy.get_param(
'~threshold', 0.0)
18 self.
pub_rects = self.advertise(
'~output', RectArray, queue_size=1)
19 self.
pub_count = self.advertise(
'~output/count', Int64, queue_size=1)
21 'non_maximum_suppression',
22 NonMaximumSuppression, self.
_req_cb)
25 self.
sub = rospy.Subscriber(
26 '~input', RectArray, self.
_msg_cb, queue_size=1)
34 rects_msg = RectArray()
35 rects_msg.header = msg.header
36 rects_msg.rects = rects
37 self.pub_rects.publish(rects_msg)
40 count_msg.data = count
41 self.pub_count.publish(count_msg)
45 req.rect, req.threshold)
46 return NonMaximumSuppressionResponse(rects, count)
52 if boxes.dtype.kind ==
"i":
53 boxes = boxes.astype(
"float")
59 area = (x2 - x1 + 1) * (y2 - y1 + 1)
65 xx1 = np.maximum(x1[i], x1[idxs[:last]])
66 yy1 = np.maximum(y1[i], y1[idxs[:last]])
67 xx2 = np.minimum(x2[i], x2[idxs[:last]])
68 yy2 = np.minimum(y2[i], y2[idxs[:last]])
69 w = np.maximum(0, xx2 - xx1 + 1)
70 h = np.maximum(0, yy2 - yy1 + 1)
71 overlap = (w * h) / area[idxs[:last]]
72 idxs = np.delete(idxs, np.concatenate(([last],
73 np.where(overlap > overlapThresh)[0])))
74 return boxes[pick].astype(
"int")
97 bbox.append(Rect(bx, by, bw, bh))
100 return bbox, len(pick)
103 if __name__ ==
"__main__":
104 rospy.init_node(
'non_maximum_suppression_server')
def non_max_suppression_fast(self, boxes, overlapThresh)
def non_max_suppression_equator(self, rect, threshold)
def non_max_suppression_handler(self, rects, threshold)