【发布时间】: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);
}
}
}
【问题讨论】: