【发布时间】:2019-04-13 19:30:18
【问题描述】:
public BufferedImage detectAndDisplay(BufferedImage img, CascadeClassifier faceCascade) {
Mat frameGray = new Mat();
BufferedImage imgout = null;
Mat image = ImagePreProcessing.bufferedImageToMat(img);
// -- Detect faces
MatOfRect faces = new MatOfRect();
faceCascade.detectMultiScale(image, faces);
List<Rect> listOfFaces = faces.toList();
for (Rect face : listOfFaces) {
Point center = new Point(face.x + face.width / 2, face.y + face.height / 2);
Imgproc.ellipse(image, center, new Size(face.width / 2, face.height / 2), 0, 0, 360,
new Scalar(255, 0, 255), 3);
Mat faceROI = image.submat(face);
imgout = ImagePreProcessing.Mat2BufferedImage(faceROI);
System.out.println("OpenCV: " +center);
}
return imgout;
}
我有那个代码..但我不知道设置裁剪输出图像的代码在哪里。 我想要像原始版本一样带有圆形模板的图片..不要被裁剪 可以给我建议吗:)
输入:
输出:
【问题讨论】:
-
你的问题不清楚,你在问什么,最后你想得到什么结果?
-
感谢您的关注@BahramdunAdil。我不想裁剪图片。我希望图片保持其大小(size_input = size_output)
标签: java image opencv face-detection cascade-classifier