【发布时间】:2019-05-24 17:44:12
【问题描述】:
我是安卓新手。我正在使用 opencv 来检测人的面部和嘴巴。它没有正确检测嘴巴。你能帮我吗? 这是我的代码:
mJavaDetectorLip =
loadClassifier(R.raw.haarcascade_mcs_mouth,"haarcascade_mcs_mouth.xml",
cascadeDir);
......
Rect liparea = new Rect(new Point(20,20),new Point(mGray.width() - 20,
mGray.height() - 20 ));
lipArea(mJavaLip,liparea,100);
......
这是我的代码:
private Mat lipArea(CascadeClassifier clasificator, Rect area, int
size) {
Mat template = new Mat();
Mat mROI = mGray.submat(area);
MatOfRect mouths = new MatOfRect();
Point lips = new Point();
//isolate the eyes first
clasificator.detectMultiScale(mROI, mouths, 1.1, 2, Objdetect.CASCADE_FIND_BIGGEST_OBJECT
| Objdetect.CASCADE_SCALE_IMAGE, new Size(30, 30), new Size());
Rect[] mouthArray = mouths.toArray();
for (int i = 0; i < mouthArray.length;) {
Rect e = mouthArray[i];
e.x = area.x + e.x;
e.y = area.y + e.y;
Point center1 = new Point(e.x + mouthArray[i].width * 0.5,
e.y + mouthArray[i].height * 0.5);
int radius = (int) Math.round(mouthArray[i].width / 2);
Imgproc.circle(mRgba, center1, radius, new Scalar(255, 0, 0), 4, 8, 0);
new Scalar(0,255,0),1,8,0);
return template;
}
return template;
}
它不是停留在一个地方,而是在整个脸上移动。
【问题讨论】:
标签: java android opencv opencv3.0 face-detection