我正在开发openCV应用程序。用一些代码,我能够检测前面。我想检测并保持用户微笑的次数。我的想法是在检测到脸部后,我正在画一个矩形,此时我会打电话给笑脸检测。到目前为止,我的结果不那么成功。我张贴我的代码进行人脸检测,任何人都可以给我任何指示如何从for循环开始脸部检测。谢谢。使用Java中的openCV检测脸部内的笑脸
public Mat detect(Mat inputframe) {
Mat mRgba = new Mat();
Mat mGrey = new Mat();
MatOfRect faces = new MatOfRect();
inputframe.copyTo(mRgba);
inputframe.copyTo(mGrey);
Imgproc.cvtColor(mRgba, mGrey, Imgproc.COLOR_BGR2GRAY);
Imgproc.equalizeHist(mGrey, mGrey);
face_cascade.detectMultiScale(mGrey, faces);
System.out.println(String.format("Detected %s face",
faces.toArray().length));
MatOfRect smileDetections = new MatOfRect();
face_cascade1.detectMultiScale(mGrey,smileDetections);
System.out.println(String.format("Detected %s smiles",smileDetections.toArray().length));
for (Rect rect : faces.toArray()) {
Point center = new Point(rect.x + rect.width * 0.5, rect.y
+ rect.height * 0.5);
Core.ellipse(mRgba, center, new Size(rect.width * 0.5,
rect.height * 0.5), 0, 0, 360, new Scalar(255, 0, 255), 4,
8, 0);
}
return mRgba;
}
}
你加载到'face_cascade1'的什么样的级联? – Micka 2014-09-24 13:59:35
我认为更好的解决方案是使用ASM模型来识别面部表情,就像一个微笑。像这样:http://www.youtube.com/watch?v=v8ipupeMwgo – dervish 2014-09-24 14:24:02
你还检查了opencv示例: /opencv-2.4.xx/samples/c/smiledetect.cpp? –
dervish
2014-09-24 14:28:51