我試圖改進相機捕捉中的人臉檢測,所以我認爲如果在人臉檢測過程之前我從圖像中刪除了背景, 我使用的是BackgroundSubtractorMOG
和CascadeClassifier
與lbpcascade_frontalface
面部檢測,使用openCv進行背景減法後的人臉檢測
我的問題是:我如何抓住前景圖像,以便使用它作爲面部檢測的輸入?這是我到目前爲止有:
while (true) {
capture.retrieve(image);
mog.apply(image, fgMaskMOG, training?LEARNING_RATE:0);
if (counter++ > LEARNING_LIMIT) {
training = false;
}
// I think something should be done HERE to 'apply' the foreground mask
// to the original image before passing it to the classifier..
MatOfRect faces = new MatOfRect();
classifier.detectMultiScale(image, faces);
// draw faces rect
for (Rect rect : faces.toArray()) {
Core.rectangle(image, new Point(rect.x, rect.y), new Point(rect.x + rect.width, rect.y + rect.height), new Scalar(255, 0, 0));
}
// show capture in JFrame
frame.update(image);
frameFg.update(fgMaskMOG);
Thread.sleep(1000/FPS);
}
感謝
優秀,昨晚我意識到我可以使用copyTo ...我也加入侵蝕,以避免噪音,謝謝 –