【问题标题】:opencv selective search not returning region proposals (silent fails)opencv 选择性搜索不返回区域建议(静默失败)
【发布时间】:2020-10-20 20:13:03
【问题描述】:

我正在使用opencv contrib 进行选择性搜索。我正在尝试一些非常简单的方法,看看我是否能获得好的 rps。它只是运行,没有异常,但不生成矩形。

我有:

  • 重新安装 opencv 贡献模块
  • 检查其他 opencv 模型是否正常工作,(它们是!)
  • 同时运行多个图像

我在这个问题上纠结了一段时间,不知道该怎么办。

frame_cv = cv2.imread(fn)
h,w,_ = frame_cv.shape

#~let;s get out frame width to ~640xsomething, it's more manageable
if w > 600:
    ratio = 600.0/float(w)
    frame_cv = cv2.resize(frame_cv,(0,0),fx=ratio,fy=ratio)
ss = cv2.ximgproc.segmentation.createSelectiveSearchSegmentation()
ss.setBaseImage(frame_cv)
rects = ss.process()
print("[+] rects: ", len(rects))

【问题讨论】:

    标签: opencv image-processing deep-learning opencv3.0


    【解决方案1】:

    你忘了提到选择性搜索的类型,比如 switchToSelectiveSearchFast()。 这是示例-

    frame_cv = cv2.imread(fn)
    h,w,_ = frame_cv.shape
    
    #~let;s get out frame width to ~640xsomething, it's more manageable
    if w > 600:
        ratio = 600.0/float(w)
        frame_cv = cv2.resize(frame_cv,(0,0),fx=ratio,fy=ratio)
    ss = cv2.ximgproc.segmentation.createSelectiveSearchSegmentation()
    ss.setBaseImage(frame_cv)
    ss.switchToSelectiveSearchFast()
    rects = ss.process()
    print("[+] rects: ", len(rects))
    

    我希望这会奏效

    【讨论】:

      【解决方案2】:

      根据您的选择,您可以进行fastquality 搜索。

      快速方法在建议区域较少的情况下尽早完成工作。

      质量方法需要更多时间(约 4 次)来完成工作,但会提出更多区域

      设置基础镜像后

      image = cv2.imread(fn)
      ss = cv2.ximgproc.segmentation.createSelectiveSearchSegmentation()
      ss.setBaseImage(image)
      
      if method == "fast":
          ss.switchToSelectiveSearchFast()
      else:
          ss.switchToSelectiveSearchQuality()
      

      要查看方法之间的性能,您可以设置时间:

      start = time.time()
      rects = ss.process()
      end = time.time()
      

      最后,我们可以看到方法之间的准确性

      for i in range(0, len(rects), 100):
          output = image.copy()
      
          for (x, y, w, h) in rects[i:i + 100]:
              color = [random.randint(0, 255) for j in range(0, 3)]
              cv2.rectangle(output, (x, y), (x + w, y + h), color, 2)
      
          cv2.imshow("Output", output)
          key = cv2.waitKey(0) & 0xFF
      

      例如:

      快速方法耗时 1.3286 秒,提出 2068 个区域:

      质量方法耗时 4.2615 秒,提出 6356 个区域。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多