Skip to content

SelectriveSearchSegmentation

来自本人笔记: https://github.com/masterAllen/LearnOpenCV/blob/main/docs/SelectriveSearchSegmentation

方法在 ximgproc 中 Image sementation 这一小节,虽然归类在 segmentation 中,但其实是个目标检测方法,只是背后用到了图像分割。具体的论文发表在 ICJV 2013。

直接看代码即可:

gs = cv2.ximgproc.segmentation.createSelectiveSearchSegmentation()
gs.setBaseImage(src)

gs.switchToSelectiveSearchFast()
# gs.switchToSelectiveSearchQuality()
# gs.switchToSingleStrategy()

rects = gs.process()

show_frame = np.copy(src)
for idx, rect in enumerate(rects):
    if idx > 10:
        break
    x, y, w, h = rect
    cv2.rectangle(show_frame, (x, y), (x+w, y+h), (0, 255, 0), 1)

show_images([
    ('src', src),
    ('show_frame', show_frame)
])

Comments