赞
踩
nms_indices = cv.dnn.NMSBoxes(box, conf, confThreshold, nmsThreshold)
API文档:https://docs.opencv.org/master/d6/d0f/group__dnn.html#ga9d118d70a1659af729d01b10233213ee
void | cv::dnn::NMSBoxes (const std::vector< Rect > &bboxes, const std::vector< float > &scores, const float score_threshold, const float nms_threshold, std::vector< int > &indices, const float eta=1.f, const int top_k=0) |
Performs non maximum suppression given boxes and corresponding scores. More... | |
void | cv::dnn::NMSBoxes (const std::vector< Rect2d > &bboxes, const std::vector< float > &scores, const float score_threshold, const float nms_threshold, std::vector< int > &indices, const float eta=1.f, const int top_k=0) |
void | cv::dnn::NMSBoxes (const std::vector< RotatedRect > &bboxes, const std::vector< float > &scores, const float score_threshold, const float nms_threshold, std::vector< int > &indices, const float eta=1.f, const int top_k=0) |
支持 正框、旋转框和多边形
安装(需要cv2): pip install nms
使用:
indicies = nms.nms.nms_rboxes(rrects, scores)
By default, nms.nms.nms_boxes()
, nms.nms.nms_polygons()
and nms.nms.nms_rboxes()
use the Malisiiewicz et. al. NMS Algorithm. If you would prefer to use the OpenCV2 Fast algorithm or Felzenszwalb et. al. algorithm you can do so with the optional parameter nms_algorithm. For example:
indicies = nms.nms.nms_rboxes(rrects, scores, nms_algorithm=malisiewicz.nms)
nms.nms.nms_boxes()
, nms.nms.nms_polygons()
and nms.nms.nms_rboxes()
will also accept a list of key word arguments (**kwargs). The kwargs are passed to the NMS function to set values for the NMS threshold, confidence threshold, top_k and eta (eta is only applicable when using Fast).
For example, to set the NMS threshold to 0.5 (note that use of kwargs requires that nms_algorithm parameter be present):
indicies = nms.nms.nms_rboxes(rrects, scores, nms_algorithm=malisiewicz.nms, nms_threshold=0.5)
Please see the docs for nms.fast.nms()
, nms.malisiewicz.nms()
and nms.felzenszwalb.nms()
for additional information on kwargs
These are the NMS functions you are looking for.
nms.nms.
boxes
(rects, scores, nms_algorithm=<function nms>, **kwargs)[source]
Non Maxima Suppression for rectangles.
This function is provided for completeness as it replicates the functionality of cv2.dnn.NMSBoxes. This may be slightly faster as NMSBoxes uses the FAST comparison algorithm and by default this used Malisiewicz et al.
Parameters: |
|
---|---|
Returns: | a list of indicies of the best rects |
nms.nms.
polygons
(polys, scores, nms_algorithm=<function nms>, **kwargs)[source]
Non Maxima Suppression for polygons
Parameters: |
|
---|---|
Returns: | an array of indicies of the best polys |
nms.nms.
rboxes
(rrects, scores, nms_algorithm=<function nms>, **kwargs)[source]
Non Maxima Suppression for rotated rectangles
Parameters: | |
---|---|
Returns: | an array of indicies of the best rrects |
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。