How to setting cropping size in CascadeCalssifier with Java
up vote
1
down vote
favorite
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;
}
that code I have..but I don't know where the code for setting crop output image.
I want to have the picture like original version with circle template..NOT to be crop
Can give me suggestion, please:)
input: 
output: 
java image opencv face-detection cascade-classifier
add a comment |
up vote
1
down vote
favorite
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;
}
that code I have..but I don't know where the code for setting crop output image.
I want to have the picture like original version with circle template..NOT to be crop
Can give me suggestion, please:)
input: 
output: 
java image opencv face-detection cascade-classifier
Your question is not clear, what are you asking, at the end what result do you want to get?
– Bahramdun Adil
2 days ago
Thank you for your attention @BahramdunAdil .I want NOT the picture to be crop. I want the picture still in its size (size_input = size_output)
– Winda Agusthia Netto
2 days ago
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
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;
}
that code I have..but I don't know where the code for setting crop output image.
I want to have the picture like original version with circle template..NOT to be crop
Can give me suggestion, please:)
input: 
output: 
java image opencv face-detection cascade-classifier
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;
}
that code I have..but I don't know where the code for setting crop output image.
I want to have the picture like original version with circle template..NOT to be crop
Can give me suggestion, please:)
input: 
output: 
java image opencv face-detection cascade-classifier
java image opencv face-detection cascade-classifier
edited 2 days ago
asked 2 days ago
Winda Agusthia Netto
155
155
Your question is not clear, what are you asking, at the end what result do you want to get?
– Bahramdun Adil
2 days ago
Thank you for your attention @BahramdunAdil .I want NOT the picture to be crop. I want the picture still in its size (size_input = size_output)
– Winda Agusthia Netto
2 days ago
add a comment |
Your question is not clear, what are you asking, at the end what result do you want to get?
– Bahramdun Adil
2 days ago
Thank you for your attention @BahramdunAdil .I want NOT the picture to be crop. I want the picture still in its size (size_input = size_output)
– Winda Agusthia Netto
2 days ago
Your question is not clear, what are you asking, at the end what result do you want to get?
– Bahramdun Adil
2 days ago
Your question is not clear, what are you asking, at the end what result do you want to get?
– Bahramdun Adil
2 days ago
Thank you for your attention @BahramdunAdil .I want NOT the picture to be crop. I want the picture still in its size (size_input = size_output)
– Winda Agusthia Netto
2 days ago
Thank you for your attention @BahramdunAdil .I want NOT the picture to be crop. I want the picture still in its size (size_input = size_output)
– Winda Agusthia Netto
2 days ago
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
accepted
In your code, you returned a cropped image of the original image, so if you want the original image, draw the circle and convert it to the BufferedImage and return.
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);
// dot not crop!!!
/*Mat faceROI = image.submat(face);
imgout = ImagePreProcessing.Mat2BufferedImage(faceROI);*/
System.out.println("OpenCV: " +center);
imgout = ImagePreProcessing.Mat2BufferedImage(image);
}
I got it!!! YES its work @BahramdunAdil thank you very much:)
– Winda Agusthia Netto
2 days ago
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
In your code, you returned a cropped image of the original image, so if you want the original image, draw the circle and convert it to the BufferedImage and return.
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);
// dot not crop!!!
/*Mat faceROI = image.submat(face);
imgout = ImagePreProcessing.Mat2BufferedImage(faceROI);*/
System.out.println("OpenCV: " +center);
imgout = ImagePreProcessing.Mat2BufferedImage(image);
}
I got it!!! YES its work @BahramdunAdil thank you very much:)
– Winda Agusthia Netto
2 days ago
add a comment |
up vote
0
down vote
accepted
In your code, you returned a cropped image of the original image, so if you want the original image, draw the circle and convert it to the BufferedImage and return.
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);
// dot not crop!!!
/*Mat faceROI = image.submat(face);
imgout = ImagePreProcessing.Mat2BufferedImage(faceROI);*/
System.out.println("OpenCV: " +center);
imgout = ImagePreProcessing.Mat2BufferedImage(image);
}
I got it!!! YES its work @BahramdunAdil thank you very much:)
– Winda Agusthia Netto
2 days ago
add a comment |
up vote
0
down vote
accepted
up vote
0
down vote
accepted
In your code, you returned a cropped image of the original image, so if you want the original image, draw the circle and convert it to the BufferedImage and return.
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);
// dot not crop!!!
/*Mat faceROI = image.submat(face);
imgout = ImagePreProcessing.Mat2BufferedImage(faceROI);*/
System.out.println("OpenCV: " +center);
imgout = ImagePreProcessing.Mat2BufferedImage(image);
}
In your code, you returned a cropped image of the original image, so if you want the original image, draw the circle and convert it to the BufferedImage and return.
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);
// dot not crop!!!
/*Mat faceROI = image.submat(face);
imgout = ImagePreProcessing.Mat2BufferedImage(faceROI);*/
System.out.println("OpenCV: " +center);
imgout = ImagePreProcessing.Mat2BufferedImage(image);
}
answered 2 days ago
Bahramdun Adil
3,23441744
3,23441744
I got it!!! YES its work @BahramdunAdil thank you very much:)
– Winda Agusthia Netto
2 days ago
add a comment |
I got it!!! YES its work @BahramdunAdil thank you very much:)
– Winda Agusthia Netto
2 days ago
I got it!!! YES its work @BahramdunAdil thank you very much:)
– Winda Agusthia Netto
2 days ago
I got it!!! YES its work @BahramdunAdil thank you very much:)
– Winda Agusthia Netto
2 days ago
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53239100%2fhow-to-setting-cropping-size-in-cascadecalssifier-with-java%23new-answer', 'question_page');
}
);
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Your question is not clear, what are you asking, at the end what result do you want to get?
– Bahramdun Adil
2 days ago
Thank you for your attention @BahramdunAdil .I want NOT the picture to be crop. I want the picture still in its size (size_input = size_output)
– Winda Agusthia Netto
2 days ago