我正在开发一个 openCV 应用程序。通过一些代码,我能够检测正面。我想检测并记录用户微笑的次数。我的想法是在检测到面部后,我在其周围画一个矩形,此时我将称之为微笑检测。到目前为止,我的结果还不够成功。我正在发布我的人脸检测代码,任何人都可以给我任何指示如何从人脸检测中的 for 循环开始。谢谢。
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;
}
}
最佳答案
无论如何,你的选择很少:
关于java - 在 Java 中使用 openCV 检测面部微笑,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26016116/