我正在尝试从相机捕获中改进人脸检测,所以我认为如果在人脸检测过程之前我从图像中删除背景会更好,我正在使用BackgroundSubtractorMOG
and CascadeClassifier
withlbpcascade_frontalface
进行人脸检测,
我的问题是:如何获取前景图像以将其用作人脸检测的输入?这就是我到目前为止所拥有的:
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);
}
谢谢