【问题标题】:How adjust tolerance level for OpenCV detection false positives?如何调整 OpenCV 检测误报的容忍度?
【发布时间】:2015-01-08 10:36:33
【问题描述】:

我正在使用 OpenCV 开发一个系统,该系统使用 haarCascades xml 文件检测对象。但是,有很多错误的检测。有没有办法减少错误检测?这是我的代码的一部分:

private void detecta(String arquivo)
{
CascadeClassifier bodyDetector = new CascadeClassifier(path+arquivo);
 MatOfRect faceDetections = new MatOfRect();
    bodyDetector.detectMultiScale(webcam_image, faceDetections);
       // bodyDetector.detectMultiScale(webcam_image, faceDetections);

    for (Rect rect : faceDetections.toArray()) {
      Core.rectangle(webcam_image, new Point(rect.x, rect.y), new Point(rect.x +         rect.width, rect.y + rect.height), new Scalar(0, 255, 0));// mat2Buf, mat2Buf);
    }

    if (faceDetections.toArray().length == 0) {

      toc.getLblSaida().setText("");

    } else {

      //java.awt.Toolkit.getDefaultToolkit().beep();  
      toc.getLblSaida().setText(+faceDetections.toArray().length + "objetos detectados");
  try {
      playSound();
  } catch (IOException ex) {
      Logger.getLogger(TestWebCam.class.getName()).log(Level.SEVERE, null, ex);
  }
    }

}

【问题讨论】:

    标签: java opencv video


    【解决方案1】:

    detectMultiScale 有几个重载可以让您执行此操作。

    即增加 minNeighbours [有效检测所需] 的值,设置 minSize 和 maxSize 可能会达到您想要的效果。

    【讨论】:

    • 感谢您的帮助!我试过你的提示。我做了如下: bodyDetector.detectMultiScale(webcam_image, faceDetections,1.1, 4, 0, new Size(20,20), new Size());但是,然而我有错误的检测......
    • 尝试增加 minNeighbours,直到你开始错过积极的一面
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-10-21
    • 1970-01-01
    • 2020-03-26
    • 2017-05-18
    • 1970-01-01
    相关资源
    最近更新 更多