【发布时间】:2014-03-15 19:32:42
【问题描述】:
我正在尝试改进从相机捕获的面部检测,所以我认为如果在面部检测过程之前我从图像中删除背景会更好,
我使用BackgroundSubtractorMOG 和CascadeClassifier 和lbpcascade_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);
}
谢谢
【问题讨论】:
标签: opencv javacv face-detection background-subtraction